g_l = []; /* g_l["MONTHS"] = ["January","February","March","April","May","June","July","August","September","October","November","December"]; g_l["DAYS_3"] = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; g_l.MONTHS=["Հունվար","Փետրվար","Մարտ","Ապրիլ","Մայիս","Հունիս","Հուլիս","Օգոստոս","Սեպտեմբեր","Հոկտեմբեր","Նոյեմբեր","Դեկտեմբեր"];*/ g_l["MONTHS"] = ["January","February","March","April","May","June","July","August","September","October","November","December"]; g_l.DAYS_3=["Կիր","Երկ","Երք","Չրք","Հնգ","Ուրբ","Շբթ"]; g_l["MONTH_FWD"] = "Move a month forward"; g_l["MONTH_BCK"] = "Move a month backward"; g_l["YEAR_FWD"] = "Move a year forward"; g_l["YEAR_BCK"] = "Move a year backward"; g_l["CLOSE"] = "Close the calendar"; g_l["ERROR_2"] = g_l["ERROR_1"] = "Date object invalid!"; g_l["ERROR_4"] = g_l["ERROR_3"] = "Target invalid"; g_jsDatePickImagePath = "img/"; g_jsDatePickDirectionality = "ltr"; g_arrayOfUsedJsDatePickCalsGlobalNumbers = []; g_arrayOfUsedJsDatePickCals = []; g_currentDateObject = {}; g_currentDateObject.dateObject = new Date(); g_currentDateObject.day=18; g_currentDateObject.month=11; g_currentDateObject.year=2017; JsgetElem = function(id){ return document.getElementById(id); }; String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); }; String.prototype.ltrim = function() { return this.replace(/^\s+/,""); }; String.prototype.rtrim = function() { return this.replace(/\s+$/,""); }; String.prototype.strpad=function(){ return (!isNaN(this) && this.toString().length==1)?"0"+this:this; }; JsDatePick = function(configurationObject){ if (document.all){ this.isie = true; this.iever = JsDatePick.getInternetExplorerVersion(); } else { this.isie = false; } this.oConfiguration = {}; this.oCurrentDay = g_currentDateObject; this.monthsTextualRepresentation = g_l["MONTHS"]; this.lastPostedDay = null; this.initialZIndex = 2; this.globalNumber = this.getUnUsedGlobalNumber(); g_arrayOfUsedJsDatePickCals[this.globalNumber] = this; this.setConfiguration(configurationObject); this.makeCalendar(); }; JsDatePick.getCalInstanceById=function(id){ return g_arrayOfUsedJsDatePickCals[parseInt(id,10)]; }; JsDatePick.getInternetExplorerVersion=function(){ var rv = -1, ua, re; if (navigator.appName == 'Microsoft Internet Explorer'){ ua = navigator.userAgent; re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null){ rv = parseFloat( RegExp.$1 ); } return rv; } }; JsDatePick.prototype.setC = function(obj, aClassName){ if (this.isie && this.iever > 7){ obj.setAttribute("class", aClassName); } else { obj.className = aClassName; } }; JsDatePick.prototype.getUnUsedGlobalNumber = function(){ var aNum = Math.floor(Math.random()*1000); while ( ! this.isUnique_GlobalNumber(aNum) ){ aNum = Math.floor(Math.random()*1000); } return aNum; }; JsDatePick.prototype.isUnique_GlobalNumber = function(aNum){ var i; for (i=0; i 7){ divider = this.senseDivider(this.oConfiguration.dateFormat); dateMold = this.oConfiguration.dateFormat; array = aField.value.trim().split(divider); array2 = dateMold.trim().split(divider); i=dI=yI=mI=0; for (i=0; i this.oCurrentDay.year){ return false; } if (m > this.oCurrentDay.month && y == this.oCurrentDay.year){ return false; } if (d > this.oCurrentDay.day && m == this.oCurrentDay.month && y == this.oCurrentDay.year ){ return false; } return true; }; JsDatePick.prototype.getDOMCalendarStripped = function(){ var d = document,boxMain,boxMainInner,clearfix,boxMainCellsContainer,tooltip,weekDaysRow,clearfix2; boxMain = d.createElement("div"); if (this.oConfiguration.isStripped){ this.setC(boxMain, "boxMainStripped"); } else { this.setC(boxMain, "boxMain"); } this.boxMain = boxMain; boxMainInner = d.createElement("div"); clearfix = d.createElement("div"); boxMainCellsContainer = d.createElement("div"); tooltip = d.createElement("div"); weekDaysRow = d.createElement("div"); clearfix2 = d.createElement("div"); this.setC(clearfix, "clearfix"); this.setC(clearfix2, "clearfix"); this.setC(boxMainInner, "boxMainInner"); this.setC(boxMainCellsContainer, "boxMainCellsContainer"); this.setC(tooltip, "tooltip"); this.setC(weekDaysRow, "weekDaysRow"); this.tooltip = tooltip; boxMain.appendChild(boxMainInner); this.controlsBar = this.getDOMControlBar(); this.makeDOMWeekDays(weekDaysRow); boxMainInner.appendChild(this.controlsBar); boxMainInner.appendChild(clearfix); boxMainInner.appendChild(tooltip); boxMainInner.appendChild(weekDaysRow); boxMainInner.appendChild(boxMainCellsContainer); boxMainInner.appendChild(clearfix2); this.boxMainCellsContainer = boxMainCellsContainer; this.populateMainBox(boxMainCellsContainer); return boxMain; }; JsDatePick.prototype.makeDOMWeekDays = function(aWeekDaysRow){ var i=0,d = document,weekDaysArray = g_l["DAYS_3"],textNode,weekDay; for (i=this.oConfiguration.weekStartDay; i<7; i++){ weekDay = d.createElement("div"); textNode = d.createTextNode(weekDaysArray[i]); this.setC(weekDay, "weekDay"); weekDay.appendChild(textNode); aWeekDaysRow.appendChild(weekDay); } if (this.oConfiguration.weekStartDay > 0){ for (i=0; i parseInt(this.oConfiguration.yearsRange[0])){ this.currentYear--; this.repopulateMainBox(); return true; } else { return false; } }; JsDatePick.prototype.moveForwardOneMonth = function(){ if (this.currentMonth < 12){ this.currentMonth++; } else { if (this.moveForwardOneYear()){ this.currentMonth = 1; } else { this.currentMonth = 12; } } this.repopulateMainBox(); }; JsDatePick.prototype.moveBackOneMonth = function(){ if (this.currentMonth > 1){ this.currentMonth--; } else { if (this.moveBackOneYear()){ this.currentMonth = 12; } else { this.currentMonth = 1; } } this.repopulateMainBox(); }; JsDatePick.prototype.getCurrentColorScheme = function(){ return this.oConfiguration.cellColorScheme; }; JsDatePick.prototype.getDOMControlBar = function(){ var d = document, controlsBar,monthForwardButton,monthBackwardButton,yearForwardButton,yearBackwardButton,controlsBarText; controlsBar = d.createElement("div"); monthForwardButton = d.createElement("div"); monthBackwardButton = d.createElement("div"); yearForwardButton = d.createElement("div"); yearBackwardButton = d.createElement("div"); controlsBarText = d.createElement("div"); this.setC(controlsBar, "controlsBar"); this.setC(monthForwardButton, "monthForwardButton"); this.setC(monthBackwardButton, "monthBackwardButton"); this.setC(yearForwardButton, "yearForwardButton"); this.setC(yearBackwardButton, "yearBackwardButton"); this.setC(controlsBarText, "controlsBarText"); controlsBar.setAttribute("globalNumber",this.globalNumber); monthForwardButton.setAttribute("globalNumber",this.globalNumber); monthBackwardButton.setAttribute("globalNumber",this.globalNumber); yearBackwardButton.setAttribute("globalNumber",this.globalNumber); yearForwardButton.setAttribute("globalNumber",this.globalNumber); this.controlsBarTextCell = controlsBarText; controlsBar.appendChild(monthForwardButton); controlsBar.appendChild(monthBackwardButton); controlsBar.appendChild(yearForwardButton); controlsBar.appendChild(yearBackwardButton); controlsBar.appendChild(controlsBarText); monthForwardButton.onmouseover = function(){ var gRef,parentElement; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["MONTH_FWD"]); gRef.setC(this, "monthForwardButtonOver"); }; monthForwardButton.onmouseout = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(''); gRef.setC(this, "monthForwardButton"); }; monthForwardButton.onmousedown = function(){ var gRef,parentElement; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["MONTH_FWD"]); gRef.setC(this, "monthForwardButtonDown"); }; monthForwardButton.onmouseup = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["MONTH_FWD"]); gRef.setC(this, "monthForwardButton"); gRef.moveForwardOneMonth(); }; monthBackwardButton.onmouseover = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["MONTH_BCK"]); gRef.setC(this, "monthBackwardButtonOver"); }; monthBackwardButton.onmouseout = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(''); gRef.setC(this, "monthBackwardButton"); }; monthBackwardButton.onmousedown = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["MONTH_BCK"]); gRef.setC(this, "monthBackwardButtonDown"); }; monthBackwardButton.onmouseup = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["MONTH_BCK"]); gRef.setC(this, "monthBackwardButton"); gRef.moveBackOneMonth(); }; yearForwardButton.onmouseover = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["YEAR_FWD"]); gRef.setC(this, "yearForwardButtonOver"); }; yearForwardButton.onmouseout = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(''); gRef.setC(this, "yearForwardButton"); }; yearForwardButton.onmousedown = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["YEAR_FWD"]); gRef.setC(this, "yearForwardButtonDown"); }; yearForwardButton.onmouseup = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["YEAR_FWD"]); gRef.setC(this, "yearForwardButton"); gRef.moveForwardOneYear(); }; yearBackwardButton.onmouseover = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["YEAR_BCK"]); gRef.setC(this, "yearBackwardButtonOver"); }; yearBackwardButton.onmouseout = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(''); gRef.setC(this, "yearBackwardButton"); }; yearBackwardButton.onmousedown = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["YEAR_BCK"]); gRef.setC(this, "yearBackwardButtonDown"); }; yearBackwardButton.onmouseup = function(){ var parentElement,gRef; if (parseInt(this.getAttribute("isJsDatePickDisabled")) == 1){ return; } parentElement = this.parentNode; while (parentElement.className != "controlsBar"){ parentElement = parentElement.parentNode; } gRef = JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")); gRef.setTooltipText(g_l["YEAR_BCK"]); gRef.setC(this, "yearBackwardButton"); gRef.moveBackOneYear(); }; return controlsBar; };