/* * If the date is not set, make it the clients PC date! */ day_app = new Date().getDate(); month_app = new Date().getMonth(); year_app = new Date().getFullYear(); if(typeof(iMonth)=="undefined") iMonth = new Date().getMonth(); if(typeof(iYear)=="undefined") iYear = new Date().getFullYear(); if(typeof(iDay)=="undefined") iDay = new Date().getDate(); if(typeof(itype) == "undefined") itype = "strict" //loose->any date|strict->limit to maxDays if(typeof(imaxDays) == "undefined") imaxDays = 330 //counts only if itype=strict. Enable selection imaxDays from start date if(typeof(stDay) == "undefined") startDay = day_app; //enable selection from this date if(typeof(stMonth) == "undefined") startMonth = month_app; if(typeof(stYear) == "undefined") startYear = year_app; if(typeof(addZero) == "undefined") addZero = true; //true|false. Put 0 in front of days&months if <10 if(typeof(offX) == "undefined") offX = 10 // x distance from the mouse. if(typeof(offY) == "undefined") offY = -10 // y distance from the mouse. if(typeof(formatInputs) == "undefined") formatInputs = 1 // Gather the data from no. of inputs if(typeof(formatSplitter) == "undefined") formatSplitter = "/" // Character to add betwen day/month/year if(typeof(monthFormat) == "undefined") monthFormat = "mmm"; if(typeof(yearFormat) == "undefined") yearFormat = "yy"; if(typeof(folowMouse) == "undefined") folowMouse = true; if(typeof(formatType) == "undefined") formatType = "dd"+formatSplitter+monthFormat+formatSplitter+yearFormat; //Format data type if(typeof(callNotice) == "undefined") callNotice = "fallsilent()"; //call another function that a date has been selected. if (window.addEventListener) window.addEventListener("load", createBase, false) else if (window.attachEvent) window.attachEvent("onload", createBase) else if (document.getElementById) window.onload=createBase document.onmousemove = getMouseXY; var IE = document.all?true:false if (!IE) document.captureEvents(Event.MOUSEMOVE) var tempX = 0 var tempY = 0 function getMouseXY(e) { if (IE) { // grab the x-y pos.s if browser is IE tempX = event.clientX + document.body.scrollLeft tempY = event.clientY + document.body.scrollTop } else { // grab the x-y pos.s if browser is NS tempX = e.pageX tempY = e.pageY } if (tempX < 0){tempX = 0} if (tempY < 0){tempY = 0} return true } function getScrollXY() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [ scrOfX, scrOfY ]; } /* * Shortcut functions to ease the implementation. */ var d = document; function cel(obj){ return d.createElement(obj); } function sa(obj, atname, atprop){ return obj.setAttribute(atname, atprop); } function appendc(obj, elem){ return obj.appendChild(elem); } function cNode(obj, txt){ return obj.appendChild(d.createTextNode(txt)); } function getID(elem){ return d.getElementById(elem); } var DayCol = new Array("Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"); var MonthCol = new Array("Jan","Fév","Mar","Avr","Mai","Jun","Jul","Aoû","Sep","Oct","Nov", "Déc") function getDaysInMonth(mnt, yr) { var DaysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (mnt == 1) DaysInMonth[1] = ((yr % 400 == 0) || ((yr % 4 == 0) && (yr % 100 !=0))) ? 29 : 28; return DaysInMonth[mnt]; } /* * Base class for the widget */ var cw = { currMonth: iMonth, currYear: iYear, currDay: iDay, selMonth: iMonth, selYear: iYear, selDay: iDay, config: itype, maxDays: imaxDays, stMonth : startMonth, stYear : startYear, stDay : startDay, endMonth : 11, endYear : iYear, endDay : 31, addZ: addZero, setMarks: function() { if(this.config=='strict') { this.stDay = iDay; this.stMonth = iMonth; this.stYear = iYear; this.getEnd(); } }, getConfMonths: function() { if(this.config=='strict') cw.setMarks(); mthCol = cel("ul"); mthCol.id = "months"; k=0; for(i=0;i<12; i++) { mth = cel("li"); if(cw.isValidMonth(i)) { mth.className = "months"; if(cw.isCurrentMonth(i)) mth.className = "currMonth"; mtha = cel("a"); mtha.href = "javascript:modMonth("+this.selYear+"," + i + ")"; mtha.innerHTML = MonthCol[i]; appendc(mth, mtha); } else { mth.className = "monthDisabled"; mth.innerHTML = MonthCol[i]; } appendc(mthCol, mth) } cw.setBrowseYears(); return mthCol ; }, getConfDays: function() { dayCol = cel("ul"); dayCol.id = "days"; for(i=0;i<7;i++) { dayCell = cel("li"); dayCell.className = "headDay"; dayCell.innerHTML = DayCol[i]; appendc(dayCol, dayCell); } var iFirstDay = new Date(this.selYear, this.selMonth, 1).getDay(); iFirstDay-- if(iFirstDay<0){iFirstDay=6} for(i=0;i11) { tmpM -=12 tmpY++; } this.endMonth = tmpM-1; this.endDay = 31; this.endYear = tmpY; }, isValidDate: function(tDay) { if(this.config == "loose") return true; if(this.selYear==this.stYear) { if(this.selMonththis.endMonth) return false; if(this.selMonth==this.endMonth && tDay>this.endDay) return false; } if(this.selYear == this.endYear && this.selYear==this.stYear){ if(this.selMonth> this.endMonth || this.selMonththis.endYear) return false; return true; }, isWeekend: function(tDay) { sun = new Date(this.selYear, this.selMonth, tDay).getDay(); if(sun==6||sun==0) return true; return false; }, isCurrentDay: function(tDay) { if(this.selDay == tDay) return true; return false; }, setBrowseYears: function() { brsY = cel('li'); brsY.className = "yearBrowse"; if(this.selYear <= this.stYear && this.config == "strict") { backB = cel('span'); backB.innerHTML = ""; } else { backB= cel('a'); backB.href = "javascript: modYear(-1)"; backB.innerHTML = "«"; } yText = cel("b"); yText.innerHTML = cw.selYear; if(this.selYear >= this.endYear && this.config == "strict"){ fwdB = cel('span'); fwdB.innerHTML = ""; } else { fwdB = cel('a'); fwdB.href= "javascript: modYear(1)"; fwdB.innerHTML = "»"; } appendc(brsY, backB); appendc(brsY, yText); appendc(brsY, fwdB); appendc(mthCol, brsY); }, isValidMonth: function(m) { if(this.config == "loose") return true; else { if(this.selYear< this.stYear) return false; if(this.selYear==this.stYear && mthis.endYear) return false; if(this.selYear==this.endYear && m>this.endMonth) return false; } return true; }, isCurrentMonth: function(i) { if(i==this.selMonth) return true return false; } } cw.setMarks(); function createBase() { var el = cel('div'); el.id="calendar"; el.style.display="none"; if(typeof(elToAppend) == "undefined") tDocument = document.getElementsByTagName('body').item(0); else { var tt = elToAppend; tDocument = document.getElementById(tt); } appendc(tDocument, el); } function createCalendarElements() { var el = 'calendar'; var calCon = cel('div'); calCon.id = "elements"; while(document.getElementById(el).firstChild) document.getElementById(el).removeChild(document.getElementById(el).firstChild); appendc(document.getElementById(el), calCon); mthCol = cw.getConfMonths(); appendc(calCon, mthCol); dayStruct = cw.getConfDays(); appendc(calCon, dayStruct); closeBtn = cel('div'); closeBtn.id = "closeBtn"; closeBtna = cel('a'); closeBtna.href = "javascript: closeCalendar()"; closeBtna.innerHTML = "Fermer"; appendc(closeBtn, closeBtna); appendc(document.getElementById(el), closeBtn); } function modMonth(newY, newM) { cw.selYear = newY; cw.selMonth = newM; createCalendarElements(); } function newDay(newD) { cw.selDay = newD; createCalendarElements(); } function modYear(way) { cw.selMonth=11 if(way>0) cw.selMonth=0; cw.selYear += way; createCalendarElements(); } var datas; var elem1; var elem2; var elem3; var mA=0; var yA=0; var mm = new Array('mm', 'mmm'); var yy = new Array('yy', 'yyyy'); function fPopCalendar(param1, param2, param3) { tmpString = new String(); if(formatInputs==1) { elem1 = param1; tmpString = document.getElementById(elem1).value; } if(formatInputs==2) { elem1 = param1; elem2 = param2; tmpString = document.getElementById(elem1).value + formatSplitter + document.getElementById(elem2).value; } if(formatInputs==3) { elem1 = param1; elem2 = param2; elem3 = param3; tmpString = document.getElementById(elem1).value + formatSplitter + document.getElementById(elem2).value+ formatSplitter + document.getElementById(elem3).value; } datas = tmpString.split(formatSplitter); tmpo = formatType.split(formatSplitter); dC="";tC=""; if(datas.length == tmpo.length) { for(i=0;i