<!--
function objToString(o){s='';for(aProp in o){s += aProp + "\t";}return s;}
var cal_only=0;
var is_nav=0;
var Events = Array();

function set_day(day){
	if(cal_only==1){
		mt = document.getElementById('month');
		yr = document.getElementById('year');
		deptCond = window.opener.document.getElementById('deptDateCondensed');
		deptCond.value = yr.value + '/' + mt.value + '/' + day;
		window.close();
	}else if(is_nav!=1){
		clearTravelContent();
	}else{ // is_nav must equal one
		document.getElementById('mini_cal').submit();
	}
	return true;
}
function set_year(){populateCalEvents(0,1);}
function get_mycalFilter(){try{var MapKey = document.getElementById('mycal_filter').value;}catch(e){var MapKey = 'Events';}return MapKey;}
function populateCalEvents(dir,update_only){
	var y=document.getElementById('year');var m=document.getElementById('month');var mth=m.options[m.selectedIndex].value;var yr=y.options[y.selectedIndex].value;var MapKey = get_mycalFilter();
	if(!update_only){if(dir){mth++;if(mth>12){mth=1;yr++;}}else{mth--;if(mth==0){mth=12;yr--;}}}
	pm=mth;if(mth<10){mth="0"+mth;}ind = yr + "" + mth;p=-1;
	if(is_nav==1){for(x=0;x< Events[MapKey].length;x++){if(Events[MapKey][x][0]==ind){p=x;break;}}eveArr=(p!=-1)? Events[MapKey][p][1]: [];write_month(yr,mth,0,eveArr);}
	for(x=0;x < m.options.length;x++){if(m.options[x].value == pm){m.selectedIndex=x;}}
	for(x=0;x < y.options.length;x++){if(y.options[x].value == yr){y.selectedIndex=x;}}	
	if(is_nav!=1){set_month(1);}
}

function populateDest(pcfl,is_onload){
	if(is_onload){return;}
	if(default_dest!=''){populateDur(pcfl);return;}
	if(document.getElementById){
		var is_header = false;
		lF=document.getElementById('leavingFrom');
		gT=document.getElementById('goingTo');
		gI = gT.selectedIndex;
		fC=(default_dept=='')?[lF.options[lF.selectedIndex].value]:default_dept.split('|');
		oGT=gT.options[gT.selectedIndex].value;
		//alert('Original GoingTo'+oGT);
		gT.options.length=0;
		ns=0;
		gT.options[0]=new Option('Please Select...','');
		if(fC==0){return;}
		optionCache=new Array();
		var ax=0;
		var lx = fC.length;
		var piv;
		var sm = SortDest[pcfl][sortMethod];
		for(w=0;w < lx;w++){
			piv = Dept[pcfl][fC[w]];
			if(piv){
				var lxb = piv.length;
				for(x=1;x <= lxb;x++){
					var lxc = sm.length;
					for(z=0;z < lxc;z++){
						if(piv[x-1][0] == sm[z]){
							optionCache[[piv[x-1][0]]]=piv[x-1][1];
						}
					}
				}
			}
		}
		y=1;
		lI = 'NA';
		pad = (sortMethod > 0)? ' - ': '';
		var lx = sm.length;
		var piv2,piv3;
		for(x=0;x <= lx;x++){
			for(z in optionCache){
				if(typeof(optionCache[z]) != 'function' && z == sm[x]){
					if(sortMethod > 0){
						piv3 = Dind[z][sortMethod];						
						if(piv3 != lI){
							piv2 = Cj[sortMethod][piv3];
							gT.options[y]=new Option(Ci[sortMethod][piv3],'*|'+piv2);
							lI = piv3;
							y++;
							if(piv2.length == 3){
								continue;
							}
						}
					}
					gT.options[y]=new Option(pad +optionCache[z],z);
					if(z==oGT){
						ns=y;
					}							
					y++;
				}
			}
		}
		if(ns){
			gT.selectedIndex=ns;
		}
	}
	try{
		set_month();
	}catch(e){
				
	}							
}
					
					
function populateDur(pcfl){
	populateCalendar();
	if((pcfl!='pc' || incl=='on') && expfldur==0){return;}

	lF=document.getElementById('leavingFrom');
	fC=(default_dept=='')?[lF.options[lF.selectedIndex].value]:default_dept.split('|');
	if(fC==0){return;}
	if(default_dest!=''){
		oGT = default_dest;
	}else{	
		gT=document.getElementById('goingTo');
		oGT=gT.options[gT.selectedIndex].value;
	}
	if(oGT.substr(0,2) == '*|'){
		oGT = oGT.substr(2);
	}
	oGT=oGT.split('|');

	if(pcfl=='pc'){
		dU=document.getElementById('duration');
		odU=dU.options[dU.selectedIndex].value;
		dU.options.length = 0;
		dU.options[0]=new Option('Any Length...','all');
		P=['All Inclusive','Semi Inclusive','Breakfast','No Meals','2 Meals Per Day','3 Meals Per Day'];
		P2=['p3','p22','p11','p1','p2','p21'];
		pC=document.getElementById('package_code');
		opC=pC.options[pC.selectedIndex].value;
		pC.options.length = 0;
		pC.options[0]=new Option('All Packages...','any');
	}else{
		dU=document.getElementById('flight_return');
		odU=dU.options[dU.selectedIndex].value;
		dU.options.length = 0;
		dU.options[0]=new Option('Round Trip and One Way','return');
		dU.options[1]=new Option('One Way Only','oneway');
	}
	ns=0;nt=0;
	dUOptionsUsed = [];
	pCOptionsUsed = [];
	var piv;
	for(q in oGT){
		for(z=0;z < fC.length;z++){
			for(x=1;x <= Dept[pcfl][fC[z]].length;x++){
				piv = Dept[pcfl][fC[z]][x-1];
				if(piv[0]==oGT[q]){
					for(y=0;y < piv[2].length;y++){
						if(piv[2][y] in dUOptionsUsed){continue;}
						dU.options[dU.options.length]=new Option(piv[2][y]+' Days',piv[2][y]);
						dUOptionsUsed[piv[2][y]]=1;
						if(piv[2][y]==odU){
							ns=y+1;
						}
					}
					if(pcfl=='pc'){
						var num;
						var pl = piv[3].length;
						for(y=0;y < pl;y++){
							num = piv[3][y];
							if(P2[num] in pCOptionsUsed || typeof(num) == 'undefined'){continue;}
							pC.options[pC.options.length]=new Option(P[num],P2[num]);
							pCOptionsUsed[P2[num]]=1;
							if(P2[num]==opC){
								nt=pC.options.length;
							}
						}
					}
				}
			}
		}
	}
	if(ns){dU.selectedIndex=ns;}
	if(nt && pcfl == 'pc'){pC.selectedIndex=nt;}
}


function populateCalendar(){try{set_month();}catch(e){}}

function set_month(update_only){
	if(cal_only==1 || is_nav==1){m=document.getElementById('mini_cal');m.submit();return true;}
	var m=document.getElementById('month');
	var year=document.getElementById('year');
	var mth = m.value;
	if(mth.length==1){mth="0"+mth;}
	var yr=year.value;
	var highlight = [];
	var dept=(default_dept=='')?[document.getElementById('leavingFrom').value]:default_dept.split('|');
	var dest=document.getElementById('goingTo');
	DEST=(dest==null)? default_dest.split("|") : dest.value.split("|");
	s_i= yr+""+mth;
	var f = -1;
	var cL=0;
	var cR=0;
	var piv,pl,pm;
	for(d in DEST){
		for(w=0;w < dept.length;w++){
			piv = Dept[pcfl][dept[w]];
			pl = piv.length;
			for(x=0;x < pl;x++){
				if(piv[x][0] == DEST[d]){
					pm = piv[x][4][0].length;
					for(y=0;y < pm;y++){
						if(piv[x][4][0][y] == s_i){
							for(z in piv[x][4][1][y]){						
								highlight.push(piv[x][4][1][y][z]);
							}
							break;
						}
					}
					if(cL && cL > piv[x][4][2][0] || !cL){cL=piv[x][4][2][0];}
					if(cR && cR < piv[x][4][2][1] || !cR){cR=piv[x][4][2][1];}
					break;
				}
			}
		}
	}

	aR=document.getElementById('nav-month-right');
	aL=document.getElementById('nav-month-left');
	if(dest==null){
		defflag = 1;
	}else{
		defflag=dest.value;
	}
	aL.style.display=(cL >= s_i || defflag == 0)?'none':'inline';
	aR.style.display=(cR <= s_i || defflag == 0)?'none':'inline';
	m.value = parseFloat(mth);
	year.value = yr;

	write_month(yr,mth,'POST',highlight);
	return true;
}


Array.prototype.find = function (s){for(var i=0;i<this.length;i++)if(this[i] == s) return true; return false;}
function isLeap(year){
 if ((year%400==0)||((year%4==0)&&(year%100!=0))) {return true;}
 else {return false;}
}


function write_month(yr,mth,mode,highlight){
	var myDate = new Date();
	myDate.setFullYear(yr,mth-1,1);
	var theFirst = myDate.getDay();
	ML=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	dayMax = ((mth-1)==1 && isLeap(yr))? ML[mth-1]+1: ML[mth-1];
	//alert(dayMax);
	// 7 == Saturday
	// wipe the grid clean
	day=0;
	for(z=1;z<43;z++){
		c=document.getElementById('cal-'+z);
		c.className = "empty_day_cell";
		c.innerHTML = '';
		if(z > theFirst && day < dayMax){
			day++;
			c.className = "day_cell";
			c.innerHTML = day
			if(highlight.find(day)){
				c.className = "travel_cell";
				c.innerHTML = "<input class='day_cell_input' type='submit' name='day' onclick='set_day("+day+");' value='"+day+"' />";
			}
		}	
	}
}

function get_mini_cal(){
	if(document.getElementById){
		dept = document.getElementById('leavingFrom');
		if(default_dest!=''){
			destination = default_dest;
		}else{
			dest = document.getElementById('goingTo');
			destination = dest.value;
		}
		pack = (pcfl=='pc')? document.getElementById('package_code'): document.getElementById('flight_return');
		if(!(dept.value  == '' || dept.value == 0) && !(destination == '' || destination == 0)){
			DeptDest = '&dept='+dept.value+'&dest='+destination+'&pcfl='+pcfl+'&pack='+pack.value;
		}else{
			DeptDest = '&dept=all&dest=all';
		}
	}
	window.open('index.php?page=mini_calendar'+DeptDest,'mini_cal', 'toolbar=no,width=250,height=200');
}


//-->




