// JavaScript Document

g_l=[];g_l.MONTHS=["Enero","Febrefo","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
g_l.DAYS_3=["Dom","Lun","Mar","Mie","Jue","Vie","Sab"];
g_l.MONTH_FWD="Avanzar mes";
g_l.MONTH_BCK="Retroceder mes";
g_l.YEAR_FWD="Avanzar aņo";
g_l.YEAR_BCK="Retrocecer aņo";
g_l.CLOSE="Cerrar calendario";
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=g_currentDateObject.dateObject.getDate();
g_currentDateObject.month=g_currentDateObject.dateObject.getMonth()+1;
g_currentDateObject.year=g_currentDateObject.dateObject.getFullYear();
var origen;
var destino;
var indTrayecto = 0;

JsgetElem=function(a){return document.getElementById(a)};

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(a){
	
	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(a);
	this.makeCalendar()
};

JsDatePick.getCalInstanceById=function(a){return g_arrayOfUsedJsDatePickCals[parseInt(a,10)]};

JsDatePick.getInternetExplorerVersion=function(){
	var c=-1,a,b;
	if(navigator.appName=="Microsoft Internet Explorer"){
		a=navigator.userAgent;b=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");
		if(b.exec(a)!=null){c=parseFloat(RegExp.$1)
	}return c}
};

JsDatePick.prototype.setC=function(a,b){
	if(this.isie&&this.iever>7){a.setAttribute("class",b)}
	else{a.className=b}
};

JsDatePick.prototype.getUnUsedGlobalNumber=function(){
	var a=Math.floor(Math.random()*1000);
	while(!this.isUnique_GlobalNumber(a)){
		a=Math.floor(Math.random()*1000)
	}
	return a
};

JsDatePick.prototype.isUnique_GlobalNumber=function(b){
	var a;
	for(a=0;a<g_arrayOfUsedJsDatePickCalsGlobalNumbers.length;a++){
		if(g_arrayOfUsedJsDatePickCalsGlobalNumbers[a]==b){return false}
	}
	return true
};

JsDatePick.prototype.addOnSelectedDelegate=function(a){
	if(typeof(a)=="function"){this.addonSelectedDelegate=a}
	return false
};

JsDatePick.prototype.setOnSelectedDelegate=function(a){
	if(typeof(a)=="function"){this.onSelectedDelegate=a;return true}
	return false
};

JsDatePick.prototype.executeOnSelectedDelegateIfExists=function(){
	if(typeof(this.onSelectedDelegate)=="function"){this.onSelectedDelegate()}
	if(typeof(this.addonSelectedDelegate)=="function"){this.addonSelectedDelegate()}
};

JsDatePick.prototype.setRepopulationDelegate=function(a){
	if(typeof(a)=="function"){this.repopulationDelegate=a;return true}
	return false
};

JsDatePick.prototype.setConfiguration=function(a){
	
	this.oConfiguration.isStripped=(a.isStripped!=null)?a.isStripped:false;
	this.oConfiguration.useMode=(a.useMode!=null)?a.useMode:1;
	this.oConfiguration.selectedDate=(a.selectedDate!=null)?a.selectedDate:null;
	this.oConfiguration.target=(a.target!=null)?a.target:null;
	this.oConfiguration.yearsRange=(a.yearsRange!=null)?a.yearsRange:[1971,2100];
	this.oConfiguration.limitToToday=(a.limitToToday!=null)?a.limitToToday:false;
	this.oConfiguration.limitToDays=(a.limitToDays!=null)?a.limitToDays:false;
	this.oConfiguration.limitDaysArr = (a.limitDaysArr!=null)?a.limitDaysArr:[[1,3,6],[1,3,4,5,6],[1,2]];
	this.oConfiguration.field=(a.field!=null)?a.field:false;
	this.oConfiguration.cellColorScheme=(a.cellColorScheme!=null)?a.cellColorScheme:"ocean_blue";
	this.oConfiguration.dateFormat=(a.dateFormat!=null)?a.dateFormat:"%m-%d-%Y";
	this.oConfiguration.imgPath=(g_jsDatePickImagePath.length!=null)?g_jsDatePickImagePath:"img/";
	this.oConfiguration.weekStartDay=(a.weekStartDay!=null)?a.weekStartDay:1;
	this.selectedDayObject={};
	this.flag_DayMarkedBeforeRepopulation=false;
	this.flag_aDayWasSelected=false;
	this.lastMarkedDayObject=null;
	if(!this.oConfiguration.selectedDate){
		this.currentYear=this.oCurrentDay.year;
		this.currentMonth=this.oCurrentDay.month;
		this.currentDay=this.oCurrentDay.day
	}
};

JsDatePick.prototype.resizeCalendar=function(){
	/*origen = document.getElementById('fromAirport').options[document.getElementById('fromAirport').options.selectedIndex].value;
	destino = document.getElementById('toAirport').options[document.getElementById('toAirport').options.selectedIndex].value
	alert(origen+' '+destino);
	if((origen == 'CUN' && destino == 'MAD') ||  (origen == 'MAD' && destino == 'CUN')){indTrayecto = 0}
	else if((origen == 'MAD' && destino == 'PUJ')){indTrayecto = 1}
	else{indTrayecto = 2}
	alert('indTrayecto = '+indTrayecto);*/
	this.leftWallStrechedElement.style.height="0px";
	this.rightWallStrechedElement.style.height="0px";
	var a=this.JsDatePickBox.offsetHeight,b=a-16;
	if(b<0){return}
	this.leftWallStrechedElement.style.height=b+"px";
	this.rightWallStrechedElement.style.height=b+"px";
	return true
};

JsDatePick.prototype.closeCalendar=function(){
	this.JsDatePickBox.style.display="none";
	document.onclick=function(){}
};

JsDatePick.prototype.populateFieldWithSelectedDate=function(){
	
	JsgetElem(this.oConfiguration.target).value=this.getSelectedDayFormatted();
	if(this.lastPickedDateObject){delete (this.lastPickedDateObject)}
	this.lastPickedDateObject={};
	this.lastPickedDateObject.day=this.selectedDayObject.day;
	this.lastPickedDateObject.month=this.selectedDayObject.month;
	this.lastPickedDateObject.year=this.selectedDayObject.year;
	this.closeCalendar()
	if(this.oConfiguration.target == 'inputField'){idDia = 'outboundDay'; idMes = 'outboundMonth'; idAnio = 'outboundYear'}
	else if(this.oConfiguration.target == 'inputField2'){idDia = 'inboundDay'; idMes = 'inboundMonth'; idAnio = 'inboundYear'}
	document.getElementById(idDia).options.selectedIndex = this.lastPickedDateObject.day-1;
	document.getElementById(idMes).options.selectedIndex = this.lastPickedDateObject.month-1;
	for(j=0;j<document.getElementById(idAnio).options.length;j++){
		if(document.getElementById(idAnio).options[j].value == this.lastPickedDateObject.year){
			document.getElementById(idAnio).options.selectedIndex = j;
		}
	}
	cargaCombos();
};

JsDatePick.prototype.makeCalendar=function(){
	var j=document,e,a,b,k,g,h,f,o,i,m,n,l,c;
	e=j.createElement("div");
	a=j.createElement("div");
	b=j.createElement("div");
	this.setC(e,"JsDatePickBox");
	this.setC(a,"clearfix");
	this.setC(b,"jsDatePickCloseButton");
	b.setAttribute("globalNumber",this.globalNumber);
	b.onmouseover=function(){
		var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));
		d.setTooltipText(g_l.CLOSE);
		d.setC(this,"jsDatePickCloseButtonOver")
	};
	b.onmouseout=function(){
		var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));
		d.setTooltipText("");
		d.setC(this,"jsDatePickCloseButton")
	};
	b.onmousedown=function(){
		var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));
		d.setTooltipText(g_l.CLOSE);
		d.setC(this,"jsDatePickCloseButtonDown")};
		b.onmouseup=function(){
			var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));
			d.setTooltipText("");
			d.setC(this,"jsDatePickCloseButton");
			d.closeCalendar()
		};
		this.JsDatePickBox=e;
		k=j.createElement("div");
		g=j.createElement("div");
		h=j.createElement("div");
		f=j.createElement("div");
		this.setC(h,"topWall");
		this.setC(f,"bottomWall");
		if(this.isie&&this.iever==6){f.style.bottom="-2px"}
		o=j.createElement("div");
		i=j.createElement("div");
		m=j.createElement("div");
		this.setC(o,"leftTopCorner");
		this.setC(i,"leftBottomCorner");
		this.setC(m,"leftWall");
		this.leftWallStrechedElement=m;
		this.leftWall=k;
		this.rightWall=g;
		k.appendChild(o);
		k.appendChild(m);
		k.appendChild(i);
		o=j.createElement("div");
		i=j.createElement("div");
		m=j.createElement("div");
		this.setC(o,"rightTopCorner");
		this.setC(i,"rightBottomCorner");
		this.setC(m,"rightWall");
		this.rightWallStrechedElement=m;
		g.appendChild(o);
		g.appendChild(m);
		g.appendChild(i);
		if(this.oConfiguration.isStripped){
			this.setC(k,"hiddenBoxLeftWall");
			this.setC(g,"hiddenBoxRightWall")
		}
		else{
			this.setC(k,"boxLeftWall");
			this.setC(g,"boxRightWall")
		}
		e.appendChild(k);
		e.appendChild(this.getDOMCalendarStripped());
		e.appendChild(g);e.appendChild(a);
		if(!this.oConfiguration.isStripped){
			e.appendChild(b);
			e.appendChild(h);
			e.appendChild(f)
		}
		if(this.oConfiguration.useMode==2){
				if(this.oConfiguration.target!=false){
						if(typeof(JsgetElem(this.oConfiguration.target))!=null){
								n=JsgetElem(this.oConfiguration.target);
								l=document.createElement("span");
								n.parentNode.replaceChild(l,n);
								l.appendChild(n);
								n.setAttribute("globalNumber",this.globalNumber);
								n.onclick=function(){
									JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")).showCalendar()
								};
								n.onfocus=function(){
									JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")).showCalendar()
								};
								l.style.position="relative";
								l.style.zIndex = "999";
							//	this.initialZIndex++;
								e.style.zIndex="999";
								e.style.position="absolute";
								e.style.top="18px";
								e.style.left="0px";
								e.style.display="none";
								l.appendChild(e);
								c=new Function("g_arrayOfUsedJsDatePickCals["+this.globalNumber+"].populateFieldWithSelectedDate();");
								this.setOnSelectedDelegate(c)
							}
							else{alert(g_l.ERROR_3)}
						}
					}
				else{
						if(this.oConfiguration.target!=null){
								JsgetElem(this.oConfiguration.target).appendChild(e);
								JsgetElem(this.oConfiguration.target).style.position="relative";
								e.style.position="absolute";
								e.style.top="0px";
								e.style.left="0px";
								this.resizeCalendar();
								this.executePopulationDelegateIfExists()
							}
							else{alert(g_l.ERROR_4)}
						}
					};
					JsDatePick.prototype.determineFieldDate=function(){
						
						/*origen = document.getElementById('fromAirport').options[document.getElementById('fromAirport').options.selectedIndex].value;
						destino = document.getElementById('toAirport').options[document.getElementById('toAirport').options.selectedIndex].value;*/
						/*if((origen == 'CUN' && destino == 'MAD') ||  (origen == 'MAD' && destino == 'CUN')){indTrayecto = 0}
						else if((origen == 'MAD' && destino == 'PUJ')){indTrayecto = 1}
						else{indTrayecto = 2}*/
						/*if((origen == 'CUN' && destino == 'MAD') ||  (origen == 'MAD' && destino == 'CUN')){indTrayecto = 0}
						else if((origen == 'MAD' && destino == 'PUJ') || (origen == 'PUJ' && destino == 'MAD')){indTrayecto = 1}
						else if((origen == 'MAD' && destino == 'SDQ') || (origen == 'SDQ' && destino == 'MAD')){indTrayecto = 2;}
						else{indTrayecto = 3}*/
						var b,c,e,g,l,d,a,h,k,f=false,j=false;
						if(this.lastPickedDateObject){
							this.setSelectedDay({year:parseInt(this.lastPickedDateObject.year),month:parseInt(this.lastPickedDateObject.month,10),day:parseInt(this.lastPickedDateObject.day,10)})}else{b=JsgetElem(this.oConfiguration.target);if(b.value.trim().length==0){this.unsetSelection();if(typeof(this.oConfiguration.selectedDate)=="object"&&this.oConfiguration.selectedDate){this.setSelectedDay({year:parseInt(this.oConfiguration.selectedDate.year),month:parseInt(this.oConfiguration.selectedDate.month,10),day:parseInt(this.oConfiguration.selectedDate.day,10)})}}else{if(b.value.trim().length>5){c=this.senseDivider(this.oConfiguration.dateFormat);e=this.oConfiguration.dateFormat;g=b.value.trim().split(c);l=e.trim().split(c);d=a=h=k=0;for(d=0;d<l.length;d++){switch(l[d]){case"%d":case"%j":a=d;break;case"%m":case"%n":k=d;break;case"%M":k=d;f=true;break;case"%F":k=d;j=true;break;case"%Y":case"%y":h=d}}if(f){for(d=0;d<12;d++){if(g_l.MONTHS[d].substr(0,3).toUpperCase()==g[k].toUpperCase()){k=d+1;break}}}else{if(j){for(d=0;d<12;d++){if(g_l.MONTHS[d].toLowerCase()==g[k].toLowerCase()){k=d+1;break}}}else{k=parseInt(g[k],10)}}this.setSelectedDay({year:parseInt(g[h],10),month:k,day:parseInt(g[a],10)})}else{this.unsetSelection();return}}}};JsDatePick.prototype.senseDivider=function(a){return a.replace("%d","").replace("%j","").replace("%m","").replace("%M","").replace("%n","").replace("%F","").replace("%Y","").replace("%y","").substr(0,1)};JsDatePick.prototype.showCalendar=function(){if(this.JsDatePickBox.style.display=="none"){this.determineFieldDate();this.JsDatePickBox.style.display="block";this.resizeCalendar();this.executePopulationDelegateIfExists();this.JsDatePickBox.onmouseover=function(){document.onclick=function(){}};this.JsDatePickBox.setAttribute("globalCalNumber",this.globalNumber);
							
							this.JsDatePickBox.onmouseout=function(){document.onclick=new Function("g_arrayOfUsedJsDatePickCals["+this.getAttribute("globalCalNumber")+"].closeCalendar();")}}else{return}};JsDatePick.prototype.isAvailable=function(c,a,b){if(c>this.oCurrentDay.year){return false}if(a>this.oCurrentDay.month&&c==this.oCurrentDay.year){return false}if(b>this.oCurrentDay.day&&a==this.oCurrentDay.month&&c==this.oCurrentDay.year){return false}return true};JsDatePick.prototype.getDOMCalendarStripped=function(){var h=document,e,i,b,a,f,c,g;e=h.createElement("div");if(this.oConfiguration.isStripped){this.setC(e,"boxMainStripped")}else{this.setC(e,"boxMain")}this.boxMain=e;i=h.createElement("div");b=h.createElement("div");a=h.createElement("div");f=h.createElement("div");c=h.createElement("div");g=h.createElement("div");this.setC(b,"clearfix");this.setC(g,"clearfix");this.setC(i,"boxMainInner");this.setC(a,"boxMainCellsContainer");this.setC(f,"tooltip");this.setC(c,"weekDaysRow");this.tooltip=f;e.appendChild(i);this.controlsBar=this.getDOMControlBar();this.makeDOMWeekDays(c);i.appendChild(this.controlsBar);i.appendChild(b);i.appendChild(f);i.appendChild(c);i.appendChild(a);i.appendChild(g);this.boxMainCellsContainer=a;this.populateMainBox(a);return e};JsDatePick.prototype.makeDOMWeekDays=function(a){var c=0,g=document,f=g_l.DAYS_3,e,b;for(c=this.oConfiguration.weekStartDay;c<7;c++){b=g.createElement("div");e=g.createTextNode(f[c]);this.setC(b,"weekDay");b.appendChild(e);a.appendChild(b)}if(this.oConfiguration.weekStartDay>0){for(c=0;c<this.oConfiguration.weekStartDay;c++){b=g.createElement("div");e=g.createTextNode(f[c]);this.setC(b,"weekDay");b.appendChild(e);a.appendChild(b)}}b.style.marginRight="0px"};JsDatePick.prototype.repopulateMainBox=function(){while(this.boxMainCellsContainer.firstChild){this.boxMainCellsContainer.removeChild(this.boxMainCellsContainer.firstChild)}this.populateMainBox(this.boxMainCellsContainer);this.resizeCalendar();this.executePopulationDelegateIfExists()};JsDatePick.prototype.executePopulationDelegateIfExists=function(){if(typeof(this.repopulationDelegate)=="function"){this.repopulationDelegate()}};JsDatePick.prototype.populateMainBox=function(h){var f=document,g,l,c=1,k=false,n=this.currentMonth-1,j,a,m,e,b;j=new Date(this.currentYear,n,1,1,0,0);a=j.getTime();this.flag_DayMarkedBeforeRepopulation=false;this.setControlBarText(this.monthsTextualRepresentation[n]+", "+this.currentYear);m=parseInt(j.getDay())-this.oConfiguration.weekStartDay;if(m<0){m=m+7}e=0;for(e=0;e<m;e++){g=f.createElement("div");this.setC(g,"skipDay");h.appendChild(g);if(c==7){c=1}else{c++}}while(j.getMonth()==n){k=false;g=f.createElement("div");if(this.lastPostedDay){if(this.lastPostedDay==j.getDate()){l=parseInt(this.lastPostedDay,10)+1}else{l=f.createTextNode(j.getDate())}}else{l=f.createTextNode(j.getDate())}g.appendChild(l);h.appendChild(g);g.setAttribute("globalNumber",this.globalNumber);if(c==7){if(g_jsDatePickDirectionality=="ltr"){g.style.marginRight="0px"}else{g.style.marginLeft="0px"}}if(this.isToday(j)){g.setAttribute("isToday",1)}
							
							if(this.oConfiguration.limitToToday){
								if(!this.isAvailable(this.currentYear,this.currentMonth,parseInt(j.getDate()))){
									k=true;
									g.setAttribute("isJsDatePickDisabled",1)
								}
								
							}
							
							if(this.oConfiguration.limitToDays){
								
								var dane = new Date(this.currentYear,this.currentMonth,parseInt(j.getDate()));
								var danArr;
								var damDArr;
								var danMArr;
								var danMArr;
								
								damDArr = j.getDate();
								danArr = j.getDay();
								danMArr = j.getMonth();
								danYArr = j.getFullYear();
								
								/*if((origen == 'CUN' && destino == 'MAD') ||  (origen == 'MAD' && destino == 'CUN')){indTrayecto = 0}
								else if((origen == 'MAD' && destino == 'PUJ') || (origen == 'PUJ' && destino == 'MAD')){
									indTrayecto = 1
									if(danYArr == 2011 && danMArr<10){this.oConfiguration.limitDaysArr[indTrayecto] = [0,1,3,4,5,6]; }
									else if ((danYArr == 2011 && danMArr>9) || (danYArr == 2012 && danMArr<3 && damDArr<20)){this.oConfiguration.limitDaysArr[indTrayecto] = [0,2,3,4,5,6];}
									else if (danYArr == 2012 && danMArr>1 && damDArr>21){this.oConfiguration.limitDaysArr[indTrayecto] = [0,1,3,4,5,6];}									
								}
								else if((origen == 'MAD' && destino == 'SDQ') || (origen == 'SDQ' && destino == 'MAD')){indTrayecto = 2;}
								else{indTrayecto = 3}*/
								for(z=0;z<orgArr.length;z++){				
									if((aeropuertoOrigenSel == orgArr[z][0] && aeropuertoDestinoSel == orgArr[z][1]) ||  (aeropuertoOrigenSel == orgArr[z][1] && aeropuertoDestinoSel == orgArr[z][0])){trayecto = z}
								}
								
								if(exceptionsRng[trayecto].length>0){
									for(u=0;u<exceptionsRng[trayecto].length;u++){
										var exRng = exceptionsRng[trayecto][u].split('/');
										var exRnganio = exRng[2];
										var exRngmes = exRng[1];
										var exRngDia = exRng[0]-1;
										var exceptRngDate = new Date(exRnganio,exRngmes,exRngDia);
										//alert('exceptRngDate = '+exceptRngDate);
										if(dane<exceptRngDate){trayectoExc = u;break}
									}
								}
								
								else{trayectoExc = 0}
								//alert('excetpionsNeg = '+excetpionsNeg[indTrayecto]);
								
								//alert('danArr = '+danArr);
								//alert('danMArr = '+danMArr);
								//alert(this.oConfiguration.limitDaysArr);
								for(u=0;u<this.oConfiguration.limitDaysArr[trayecto][trayectoExc].length;u++){
									if(this.oConfiguration.limitDaysArr[trayecto][trayectoExc][u] == danArr){
										k=true;
										g.setAttribute("isJsDatePickDisabled",1);										
									}
								}
								
								for(u = 0; u<excetpionsNeg[trayecto].length;u++){
									exNeg = excetpionsNeg[trayecto][u].split('/');
									var exNeganio = exNeg[2];
									var exNegmes = exNeg[1]-1;
									var exNegDia = exNeg[0];
									exNegData = new Date(exNeganio,exNegmes,exNegDia)
									if(exNeganio == danYArr && exNegmes == danMArr && exNegDia == damDArr){k=true;g.setAttribute("isJsDatePickDisabled",1);}
								}
								
								for(u = 0; u<excetpionsPos[trayecto].length;u++){
									exNeg = excetpionsPos[trayecto][u].split('/');
									var exPosanio = exNeg[2];
									var exPosmes = exNeg[1]-1;
									var exPosDia = exNeg[0];
									exPosData = new Date(exPosanio,exPosmes,exPosDia)
									if(exPosanio == danYArr && exPosmes == danMArr && exPosDia == damDArr){k=false;g.setAttribute("isJsDatePickDisabled",1);}
								}
								
								/*if(j.getDay() == 1 || j.getDay() == 3 || j.getDay() == 6){
										k=true;
										g.setAttribute("isJsDatePickDisabled",1)
								}*/
							}
							
							g.onmouseover=function(){var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")),i;i=d.getCurrentColorScheme();if(parseInt(this.getAttribute("isSelected"))==1){return}if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}if(parseInt(this.getAttribute("isToday"))==1){d.setC(this,"dayOverToday");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayOver.gif) left top no-repeat"}else{d.setC(this,"dayOver");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayOver.gif) left top no-repeat"}};g.onmouseout=function(){var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")),i;i=d.getCurrentColorScheme();if(parseInt(this.getAttribute("isSelected"))==1){return}if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}if(parseInt(this.getAttribute("isToday"))==1){d.setC(this,"dayNormalToday");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayNormal.gif) left top no-repeat"}else{d.setC(this,"dayNormal");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayNormal.gif) left top no-repeat"}};g.onmousedown=function(){var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")),i;i=d.getCurrentColorScheme();if(parseInt(this.getAttribute("isSelected"))==1){return}if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}if(parseInt(this.getAttribute("isToday"))==1){d.setC(this,"dayDownToday");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayDown.gif) left top no-repeat"}else{d.setC(this,"dayDown");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayDown.gif) left top no-repeat"}};g.onmouseup=function(){var d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber")),i;i=d.getCurrentColorScheme();if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}if(parseInt(this.getAttribute("isToday"))==1){d.setC(this,"dayNormalToday");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayNormal.gif) left top no-repeat"}else{d.setC(this,"dayNormal");this.style.background="url("+d.oConfiguration.imgPath+i+"_dayNormal.gif) left top no-repeat"}d.setDaySelection(this);d.executeOnSelectedDelegateIfExists()};if(this.isSelectedDay(j.getDate())){g.setAttribute("isSelected",1);this.flag_DayMarkedBeforeRepopulation=true;this.lastMarkedDayObject=g;if(parseInt(g.getAttribute("isToday"))==1){this.setC(g,"dayDownToday");g.style.background="url("+this.oConfiguration.imgPath+this.oConfiguration.cellColorScheme+"_dayDown.gif) left top no-repeat"}else{this.setC(g,"dayDown");g.style.background="url("+this.oConfiguration.imgPath+this.oConfiguration.cellColorScheme+"_dayDown.gif) left top no-repeat"}}else{b=this.getCurrentColorScheme();if(parseInt(g.getAttribute("isToday"))==1){if(k){this.setC(g,"dayDisabled");g.style.background="url("+this.oConfiguration.imgPath+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat"}else{this.setC(g,"dayNormalToday");g.style.background="url("+this.oConfiguration.imgPath+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat"}}else{if(k){this.setC(g,"dayDisabled");g.style.background="url("+this.oConfiguration.imgPath+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat"}else{this.setC(g,"dayNormal");g.style.background="url("+this.oConfiguration.imgPath+this.oConfiguration.cellColorScheme+"_dayNormal.gif) left top no-repeat"}}}if(c==7){c=1}else{c++}a+=86400000;j.setTime(a)}this.lastPostedDay=null;return h};JsDatePick.prototype.unsetSelection=function(){this.flag_aDayWasSelected=false;this.selectedDayObject={};this.repopulateMainBox()};JsDatePick.prototype.setSelectedDay=function(a){this.flag_aDayWasSelected=true;this.selectedDayObject.day=parseInt(a.day,10);this.selectedDayObject.month=parseInt(a.month,10);this.selectedDayObject.year=parseInt(a.year);this.currentMonth=a.month;this.currentYear=a.year;this.repopulateMainBox()};JsDatePick.prototype.isSelectedDay=function(a){if(this.flag_aDayWasSelected){if(parseInt(a)==this.selectedDayObject.day&&this.currentMonth==this.selectedDayObject.month&&this.currentYear==this.selectedDayObject.year){return true}else{return false}}return false};JsDatePick.prototype.getSelectedDay=function(){if(this.flag_aDayWasSelected){return this.selectedDayObject}else{return false}};JsDatePick.prototype.getSelectedDayFormatted=function(){if(this.flag_aDayWasSelected){var a=this.oConfiguration.dateFormat;a=a.replace("%d",this.selectedDayObject.day.toString().strpad());a=a.replace("%j",this.selectedDayObject.day);a=a.replace("%m",this.selectedDayObject.month.toString().strpad());a=a.replace("%M",g_l.MONTHS[this.selectedDayObject.month-1].substr(0,3).toUpperCase());a=a.replace("%n",this.selectedDayObject.month);a=a.replace("%F",g_l.MONTHS[this.selectedDayObject.month-1]);a=a.replace("%Y",this.selectedDayObject.year);a=a.replace("%y",this.selectedDayObject.year.toString().substr(2,2));return a}else{return false}};JsDatePick.prototype.setDaySelection=function(a){var b=this.getCurrentColorScheme();if(this.flag_DayMarkedBeforeRepopulation){this.lastMarkedDayObject.setAttribute("isSelected",0);if(parseInt(this.lastMarkedDayObject.getAttribute("isToday"))==1){this.setC(this.lastMarkedDayObject,"dayNormalToday");this.lastMarkedDayObject.style.background="url("+this.oConfiguration.imgPath+b+"_dayNormal.gif) left top no-repeat"}else{this.setC(this.lastMarkedDayObject,"dayNormal");this.lastMarkedDayObject.style.background="url("+this.oConfiguration.imgPath+b+"_dayNormal.gif) left top no-repeat"}}this.flag_aDayWasSelected=true;this.selectedDayObject.year=this.currentYear;this.selectedDayObject.month=this.currentMonth;this.selectedDayObject.day=parseInt(a.innerHTML);this.flag_DayMarkedBeforeRepopulation=true;this.lastMarkedDayObject=a;a.setAttribute("isSelected",1);if(parseInt(a.getAttribute("isToday"))==1){this.setC(a,"dayDownToday");a.style.background="url("+this.oConfiguration.imgPath+b+"_dayDown.gif) left top no-repeat"}else{this.setC(a,"dayDown");a.style.background="url("+this.oConfiguration.imgPath+b+"_dayDown.gif) left top no-repeat"}};JsDatePick.prototype.isToday=function(a){var b=this.oCurrentDay.month-1;if(a.getDate()==this.oCurrentDay.day&&a.getMonth()==b&&a.getFullYear()==this.oCurrentDay.year){return true}return false};JsDatePick.prototype.setControlBarText=function(a){var b=document.createTextNode(a);while(this.controlsBarTextCell.firstChild){this.controlsBarTextCell.removeChild(this.controlsBarTextCell.firstChild)}this.controlsBarTextCell.appendChild(b)};JsDatePick.prototype.setTooltipText=function(a){while(this.tooltip.firstChild){this.tooltip.removeChild(this.tooltip.firstChild)}var b=document.createTextNode(a);this.tooltip.appendChild(b)};JsDatePick.prototype.moveForwardOneYear=function(){var a=this.currentYear+1;if(a<parseInt(this.oConfiguration.yearsRange[1])){this.currentYear++;this.repopulateMainBox();return true}else{return false}};JsDatePick.prototype.moveBackOneYear=function(){var a=this.currentYear-1;if(a>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 h=document,c,f,g,b,a,e;c=h.createElement("div");f=h.createElement("div");g=h.createElement("div");b=h.createElement("div");a=h.createElement("div");e=h.createElement("div");this.setC(c,"controlsBar");this.setC(f,"monthForwardButton");this.setC(g,"monthBackwardButton");this.setC(b,"yearForwardButton");this.setC(a,"yearBackwardButton");this.setC(e,"controlsBarText");c.setAttribute("globalNumber",this.globalNumber);f.setAttribute("globalNumber",this.globalNumber);g.setAttribute("globalNumber",this.globalNumber);a.setAttribute("globalNumber",this.globalNumber);b.setAttribute("globalNumber",this.globalNumber);this.controlsBarTextCell=e;c.appendChild(f);c.appendChild(g);c.appendChild(b);c.appendChild(a);c.appendChild(e);f.onmouseover=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}d=this.parentNode;while(d.className!="controlsBar"){d=d.parentNode}i=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));i.setTooltipText(g_l.MONTH_FWD);i.setC(this,"monthForwardButtonOver")};f.onmouseout=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText("");d.setC(this,"monthForwardButton")};f.onmousedown=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}d=this.parentNode;while(d.className!="controlsBar"){d=d.parentNode}i=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));i.setTooltipText(g_l.MONTH_FWD);i.setC(this,"monthForwardButtonDown")};f.onmouseup=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.MONTH_FWD);d.setC(this,"monthForwardButton");d.moveForwardOneMonth()};g.onmouseover=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.MONTH_BCK);d.setC(this,"monthBackwardButtonOver")};g.onmouseout=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText("");d.setC(this,"monthBackwardButton")};g.onmousedown=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.MONTH_BCK);d.setC(this,"monthBackwardButtonDown")};g.onmouseup=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.MONTH_BCK);d.setC(this,"monthBackwardButton");d.moveBackOneMonth()};b.onmouseover=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.YEAR_FWD);d.setC(this,"yearForwardButtonOver")};b.onmouseout=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText("");d.setC(this,"yearForwardButton")};b.onmousedown=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.YEAR_FWD);d.setC(this,"yearForwardButtonDown")};b.onmouseup=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.YEAR_FWD);d.setC(this,"yearForwardButton");d.moveForwardOneYear()};a.onmouseover=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.YEAR_BCK);d.setC(this,"yearBackwardButtonOver")};a.onmouseout=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText("");d.setC(this,"yearBackwardButton")};a.onmousedown=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.YEAR_BCK);d.setC(this,"yearBackwardButtonDown")};a.onmouseup=function(){var i,d;if(parseInt(this.getAttribute("isJsDatePickDisabled"))==1){return}i=this.parentNode;while(i.className!="controlsBar"){i=i.parentNode}d=JsDatePick.getCalInstanceById(this.getAttribute("globalNumber"));d.setTooltipText(g_l.YEAR_BCK);d.setC(this,"yearBackwardButton");d.moveBackOneYear()};return c};
							// JavaScript Document
