var o_navigator = navigator.userAgent.toLowerCase();
var isMacIE = (o_navigator.indexOf("msie 5")>-1&&o_navigator.indexOf("mac")>-1) ? 1 : 0;
var isPCIE = (o_navigator.indexOf("msie")>-1&&!isMacIE&&o_navigator.indexOf("opera")==-1) ? 1 : 0;
var isOpera = o_navigator.indexOf("opera")>-1 ? 1 : 0;
var isKHTML = o_navigator.indexOf("khtml")>-1 ? 1 : 0;
var isFF3 = (o_navigator.indexOf('firefox/3') != -1) ? 1 : 0;
var mArray	= new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var dArray 	= new Array("S","M","T","W","T","F","S");
var datesArray 		= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var today 			= new Date();			//todays date
var today_Day 				= today.getDay();		//current day of week 0-6
var today_Date				= today.getDate();		//current day 1-31
var today_Month				= today.getMonth();		//current month 0-11
var currentMonth_no_days 			= datesArray[today_Month];		//number of days in current month
var today_Year				= today.getFullYear();	//js method	not used here//current Year
var newT			= today_Date;					//cal selected date
var newM			= today_Month;					//cal selected month
var newY			= today_Year;					//cal selected year
var newDs			= currentMonth_no_days;					//days for selected Month
var newD			= today_Day;					//day of week
var numCalendars	= 2;					//number of calendars you want to create
var calDirection	= "vertical";			//put "horizontal" or "vertical"
var calopen 		= 0;					//boolean set state of iframe "0" closed "1" open;
var o_windowparent  = top;					//set parent frame
var o_input 		= 0;
var o_month = 0; var o_date = 0;
var o_iframecal = 0;
var o_from;var o_to;var v_from;var v_to;
var d_makefrom=0; var d_maketo=0;var s_lang="us";
var o_currentDate = false;
var i_firstMonth = today_Month;
var i_sfirstYear = today_Year; var i_sfirstMonth = today_Month;
var i_ofirstYear = today_Year; var i_ofirstMonth = today_Month;
var b_calinit = 0;
var o_row = null;
var i_numcal = 0;
var o_calbody = null; //where to write the calendar
var s_jscall = (isPCIE)? "parent." : "";
var s_closecal = "<div class='calClose'><a href='#' onclick='"+s_jscall+"closeCal();return false;'>close</a>Select a Date:</div>";
var b_date331 = 0;
var a_input = 0;
var o_parent;
var selected_textfield_type = "object"; //for text input or select list input
var textfield_value_array = null;
var drpdwn = false; //fix erica(apr 15)
var drpdwn2 = false;
var second = false;
if($('arrival') && $('arrival').value != '')
{
	arr = $('arrival').value.split('-');
}
if($('checkIn') && $('checkIn').value != '')
{ 
	arr = $('checkIn').value.split('-');
}
		
if($('arrival').value != '' || $('checkIn').value != '')
{ 

	openCal($('air_fromdate'),'air_fromdate','air_todate','calbox','departureDateContainer','us','vertical');		
	ty_changeMonths(arr[1]-1); 
	hideCalendar();
}

function findFirstDay(){
	
	firstDay = new Date();
	firstDay.setDate(1);
	firstDay.setMonth(newM);
	firstDay.setFullYear(newY);	
	return firstDay.getDay();
}
function check331(d_date){
	i_date331 = Math.floor((d_date-today)/86400000);
	b_check331 = (i_date331>355) ? 1 : 0;
	return b_check331;
}
function vm_setupCal(){
	i_numcal = 0;
	vm_makeCal(today_Month);
}
function preventClose(evt){
	if(isKHTML||isOpera)evt.stopPropagation();
}
function ty_makeDate(which, whichMonth){
	d_makedate = new Date(newY,newM,which);
	b_date331 = check331(d_makedate);

	//if((today_Date>which && today_Month == newM && today_Year == newY)||b_date331){
	if((today_Date>which && today_Month == newM && today_Year == newY)||b_date331){
	
		s_makeDate = "<td class='calDateOff'>";
		s_makeDate+= which;
	}else if((v_from.date!=-1)&&(o_input=="returnDateMonth|returnDateDay")&&((v_from.year > newY)||( v_from.month >whichMonth && v_from.year == newY)||(v_from.date>which && v_from.month >= whichMonth && v_from.year >= newY)))
	{
		s_makeDate = "<td class='calDateOff'>";
		s_makeDate+= which;
	}else if((v_to.date!=-1)&&(o_input=="departureDateMonth|departureDateDay")&&((v_to.year < newY)||( v_to.month <whichMonth && v_to.year == newY)||(v_to.date<which && v_to.month <= whichMonth && v_to.year <= newY)))
	{
		s_makeDate = "<td class='calDateOff'>";
		s_makeDate+= which;
	}
	
	else{
		if(d_makefrom||d_maketo){
			s_makeDate = ((d_makedate.toString()==d_makefrom.toString())||(d_makedate.toString()==d_maketo.toString())) ? "<td class='calDateSel'>" : (d_makedate>d_makefrom&&d_makedate<d_maketo&&d_makefrom) ? "<td class='calDateRng'>" : "<td class='calDate'>";
		}else{
			s_makeDate = "<td class='calDate'>";
		}
				s_makeDate+= "<a href='#' onclick='"+s_jscall+"ty_setDate("+newM+","+which+",this.parentNode,"+newY+");return false;' class='calDateA'>";
		s_makeDate+= which;
		s_makeDate+="</a>";
	}
	s_makeDate+="</td>\n";
	return s_makeDate;
}
function ty_maketr(what){
	s_tr = "<tr>\n";
	s_tr+= what;
	s_tr+= "</tr>\n";
	return s_tr;
}
function ty_changeMonths(which){
	i_numcal = 0;
	o_calbody.innerHTML ="";
	if(which < 0){
		which=11;
		newY--;
	}
	vm_makeCal(which);
}
function vm_makeCal(whichMonth){
//window.alert("  "+o_input.id+" A "+selected_textfield.id+ "  "+ "air_todate".equals(selected_textfield.id));
	b_calinit = 1;
	o_cal= "";
	o_caltr="";o_caltd="";
	newM = whichMonth;
	if(newM < today_Month) newY = today_Year+1;
	
	//chk
		var cIn = $('checkIn').value.split("-")
		var cOut = $('checkOut').value.split("-")
		
		if(cIn[1] != cOut[1])
		{
			newY = cIn[0];
		}
	//end chk
	
	if (newM>=12){
		newM=whichMonth-12;
		newY++;
	}
	if(i_numcal==0){
		i_firstMonth = newM
		switch(selected_textfield_type){
			case "object":
				i_ofirstMonth  = newM;
				i_ofirstYear = newY;
			break;
			default:
				i_sfirstMonth  = newM;
				i_sfirstYear = newY;
		}
	}
	newDs = datesArray[newM];
	isLeap 	= (newY % 4 == 0 && (newY % 100 !=0 || newY % 400 ==0 )) ? 1:0
	if (newM==1) newDs=newDs+isLeap;
	newD = findFirstDay();
	countDay = newD; 

	if(newY.length > 4)
	{
		newY = newY.truncate(4,'');
	}
	s_calclass = (calDirection=="vertical")? "calTableV" : "calTableH";
	o_cal+="<table month='"+newM+"' year='"+newY+"' cellpadding='0' cellspacing='0' border='0' class='"+s_calclass+"'>\n";
	o_caltr+= "<tr class='calRowHighlight'>\n";
	o_caltd+= "<td colspan='7' class='calLabel'>";
	o_caltd+= mArray[newM]+"&nbsp;"+newY;
	o_caltd+= "</td>";
	o_caltr+=o_caltd;
	o_caltr+="</tr>\n";
	o_cal+=o_caltr;
	o_caltd = "";
	for(i=0;i < dArray.length;i++){
		o_caltd+="<td class='calDayName'>";
		o_caltd+=dArray[i];
		o_caltd+="</td>\n";
	}
	o_caltr = ty_maketr(o_caltd);
	o_cal+=o_caltr;
	o_caltd = "";
	i_calRows = 0;

	for (d=1;d<=newDs;d++){
		if(d==1)for(bd=0;bd < newD;bd++)o_caltd += "<td class='calDate'>&nbsp;</td>\n";
		o_caltd += ty_makeDate(d, whichMonth);
		countDay++;
		if(countDay==7){
			countDay=0;
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;
			o_caltd = "";
			i_calRows++
		}
		if(d==newDs && countDay!=0){
			for (bd=countDay;bd < 7;bd++) o_caltd += "<td class='calDate'>&nbsp;</td>\n";
			o_caltr = ty_maketr(o_caltd);
			o_cal+=o_caltr;			
			o_caltd ="";
			i_calRows++
		}
	}
	if(i_calRows < 6){
		o_caltd = "";
		for(bd=0;bd < 7;bd++) o_caltd += "<td class='calDate'>&nbsp;</td>\n";
		o_caltr = ty_maketr(o_caltd);
		o_cal+= o_caltr;
	}
	o_cal+="</table>";
	o_calbody.innerHTML += (i_numcal==0) ? (newM==today_Month&&newY==today_Year) ? s_closecal+"<span class='calNavA'>&nbsp;</span>" : s_closecal+"<a href='#' onclick='"+s_jscall+"ty_changeMonths("+i_firstMonth+"-1);"+s_jscall+"preventClose(event);return false' class='calNavA'>Previous Month</a>" : "";
	o_calbody.innerHTML += o_cal;
	i_numcal++;
	if(i_numcal==numCalendars&&!(newM==today_Month-1)&&!b_date331)o_calbody.innerHTML+= "<a href='#' onclick='"+s_jscall+"ty_changeMonths("+i_firstMonth+"+1);"+s_jscall+"preventClose(event);return false;' class='calNavA'>Next Month</a>"
	if(i_numcal < numCalendars)vm_makeCal(newM+1);
	else if (i_firstMonth > newM){
		newY--;
	}
}
function indexMonth(whatMonth)
{ 
	var idx;
			var ctr = 1;
			for(i=today_Month; i<12; i++)
			{
				if(whatMonth == i)
				{
					index = ctr;					
				}
				ctr++		
			}
			if(today_Month > 0)
			{
				uLimit = 12-ctr;
				
				for(i=0; i<=uLimit; i++)
				{
					if(whatMonth == i)
					{
						index = ctr;
					}
					ctr++;
				}
			}
			return index;
}
function ty_setDate(whatMonth,whatDate,whatTD,whatYear){

	o_currentDate = whatTD;
	o_currentDate.className = "calDateSel";

	if(typeof(o_input)=="object"){		
		o_input.value = whatDate + "-" + (whatMonth+1) + "-" + whatYear ;		
		
		if(second == true)
		{ 
			//second box
				//arrival (yyyy-mm-dd)		
				arr = $('air_fromdate2').value.split("-");
				arr_orig = arr[2]+'-'+arr[1]+'-'+arr[0];
				//arrival (dd-mm-yyyy)
				arr_new = $('air_fromdate2').value;
				
				//departure (yyyy-mm-dd)
				dep = $('air_todate2').value.split("-");
				dep_orig = dep[2]+'-'+dep[1]+'-'+dep[0];		
				//departure (dd-mm-yyyy)
				dep_new = $('air_todate2').value;		
				//departure (+1)	
				var night = $('selNights').value; 
				dp = new Date(arr[2],(arr[1]-1),(arr[0]*1)+(night*1));
				depDt = dp.getDate() + "-"+((dp.getMonth()*1)+1) + "-" + dp.getFullYear();			
				depDt_orig = dp.getFullYear() + "-"+((dp.getMonth()*1)+1) + "-" + dp.getDate();							
				
			
				
			//end second box
			$('arrival').value = arr_orig;
			$('checkIn').value = arr_orig;			
			
			if(o_input.id == 'air_fromdate2')
			{
				$('checkOut').value = depDt_orig;
				$('departure').value = depDt_orig;
				$('air_todate2').value = depDt;
			}
			else
			{			
				$('checkOut').value = dep_orig;
				$('departure').value = dep_orig;
				
				//for nights
				var one_day=1000*60*60*24

				aval = $('air_fromdate2').value.split("-");
				aval = new Date(aval[2],(aval[1]-1),aval[0]);
				
				dval = $('air_todate2').value.split("-");
				dval = new Date(dval[2],(dval[1]-1),dval[0]);
				
				difference = (dval-aval)/one_day;
				
				$('selNights').selectedIndex = difference-1;

			}
		}
		else
		{			
			//first box
				//arrival (yyyy-mm-dd)		
				arr = $('air_fromdate').value.split("-");
				arr_orig = arr[2]+'-'+arr[1]+'-'+arr[0];
				//arrival (dd-mm-yyyy)
				arr_new = $('air_fromdate').value;
				
				//departure (yyyy-mm-dd)
				dep = $('air_todate').value.split("-");
				dep_orig = dep[2]+'-'+dep[1]+'-'+dep[0];		
				//departure (dd-mm-yyyy)
				dep_new = $('air_todate').value;		
				//departure (+1)	
				dp = new Date(arr[2],(arr[1]-1),(arr[0]*1)+1); 
				depDt = dp.getDate() + "-"+((dp.getMonth()*1)+1) + "-" + dp.getFullYear();			
				depDt_orig = dp.getFullYear() + "-"+((dp.getMonth()*1)+1) + "-" + dp.getDate();		
			//end first box

			$('arrival').value = arr_orig;
			$('checkIn').value = arr_orig;				
			
			if(o_input.id == 'air_fromdate')
			{		
				$('checkOut').value = depDt_orig;
				$('departure').value = depDt_orig;
				$('air_todate').value = depDt;
			}
			else
			{	
				$('checkOut').value = dep_orig;
				$('departure').value = dep_orig;
			}
		}

	}else{	


		//fix for the indexing of months (erica apr. 15)			
			whatMonth = indexMonth(whatMonth);
		//end fix

		document.getElementById(textfield_value_array[0]).selectedIndex = whatMonth;//fix (erica apr. 15)		
		
		//document.getElementById(textfield_value_array[1]).selectedIndex = whatDate-1;
		act = o_input.split('|');
		
		if(act[0] == 'checkInMY') 
		{			
			if(drpdwn == true)
			{
				document.getElementById(textfield_value_array[1]).selectedIndex = whatDate-1;
			}
			else
			{
				document.getElementById(textfield_value_array[1]).selectedIndex = whatDate;
			}
		}
		else
		{
			if(drpdwn2 == true)
			{
				document.getElementById(textfield_value_array[1]).selectedIndex = whatDate-1;
			}
			else
			{
				document.getElementById(textfield_value_array[1]).selectedIndex = whatDate;
			}
		}
	


		$('arrival').value = $('checkInMY').value+'-'+$('checkInDay').value;
		$('departure').value = $('checkOutMY').value+'-'+$('checkOutDay').value;
		
		$('checkIn').value = $('checkInMY').value+'-'+$('checkInDay').value;
		$('checkOut').value = $('checkOutMY').value+'-'+$('checkOutDay').value;	
		
		
		//adjDate(document.getElementById(textfield_value_array[0]).form);
	}
	
	closeCal();
}
function changeNight(nights, arrival, departure)
{
	if($(arrival).value != 'dd-mm-yyyy')
	{
		var arr = $(arrival).value.split("-");	
		dp = new Date(arr[2],(arr[1]-1),(arr[0]*1)+(nights*1)); 
		nextMonth_format = dp.getDate() + "-"+((dp.getMonth()*1)+1) + "-" + dp.getFullYear();	
		nextMonth =  dp.getFullYear() + "-"+((dp.getMonth()*1)+1) + "-" + dp.getDate();	
		thisMonth = arr[2] + "-"+ (arr[1]*1) + "-" + arr[0];	
		
		$(departure).value = nextMonth_format;

		$('checkOut').value = nextMonth;
		$('departure').value = nextMonth;
		$('checkIn').value = thisMonth;
		
		//format
		a = $(arrival).value.split("-");
		if(a[1].length == 1)
		{
			$(arrival).value = a[0]+'-0'+a[1]+'-'+a[2]
		}
		d = $(departure).value.split("-");
		if(d[1].length == 1)
		{
			$(departure).value = d[0]+'-0'+d[1]+'-'+d[2]
		}

		
	}
}
function changeCal()
{
	whatDate = $('checkInDay').value;
	my = $('checkInMY').value.split("-");
	whatMonth = my[1];
	whatYear = my[2];

	today_Year	= whatYear; 
	newY	= whatYear; 
	i_sfirstYear = whatYear;	
	
	openCal('checkInMY|checkInDay','checkInMY|checkInDay','checkOutMY|checkOutDay','calbox','departureDateContainer','us','vertical')

	hideCalendar();
	
	ty_changeMonths(whatMonth-1);
	ty_changeMonths(whatMonth-1);
	
	drpdwn = true;

}
function changeCal2()
{	
	drpdwn2 = true;

}
function hideCalendar(){
	o_caldiv.style.display = "none"
	if(o_parent) o_parent.className = "cbrow"
}
function splitDate(s_input, s_mode){
	this.delimitor = (s_input.indexOf("/")>-1) ? "/" : (s_input.indexOf(".")>-1) ? "." : (s_input.indexOf("-")>-1) ? "-" : (s_input.indexOf(",")>-1) ? "," : "/";
	a_input = s_input.split(this.delimitor);
	this.date = -1;this.month = -1;this.year = -1;
	if(a_input.length==3&&!isNaN(a_input[0])&&!isNaN(a_input[1])&&!isNaN(a_input[2])){
		this.month = (s_mode=="us") ? parseInt(a_input[0],10)-1 : parseInt(a_input[1],10)-1;
		this.date = (s_mode=="us") ? parseInt(a_input[1],10) : parseInt(a_input[0],10);
		this.year = a_input[2];
		if(this.month>11||this.month<0)this.month=-1;
		if(this.date>31||this.month<0)this.date=-1;
		i_yrlength = this.year.toString().length;
		if(i_yrlength==2)this.year = "20"+this.year;//fix this in the next 96 years...
		if(i_yrlength<1||i_yrlength==3||this.year<today_Year)this.year=-1;
	}
}
var o_caldiv=0;var calopen=0;
var t_calcloser = null;
function buildDate(s_monthdate){ 
	a_monthdate = s_monthdate.split("|");
	
	bd_oMonth = document.getElementById(a_monthdate[0]); 
	bd_oDate = document.getElementById(a_monthdate[1]);
	
	//fix by erica (apr. 15)
	bd_oMonth = ''; 
	bd_oDate = '';
	//end fix by erica
	
	i_month = bd_oMonth.selectedIndex+1; 
	i_date = bd_oDate.selectedIndex+1;
	s_date = "";

	s_date = i_month+"/"+i_date+"/"; 
	s_date+= (i_month-1 < today_Month) ? today_Year+1 : today_Year;
	return s_date;
}
var s_lastinputtype = null;
function makeCalendar(selected_textfield,start_textfield,end_textfield,s_mode){
	
	o_input = selected_textfield;
	if(isPCIE){
		document.getElementById("calbox").innerHTML="<iframe id=\"calframe\" src=\"javascript:'calendar'\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" frameborder=\"0\"></iframe>"
		s_iecalcss = "<link rel='STYLESHEET' type='text/css' href='"+document.getElementById("calendarcss").href+"' />";
		o_califrame = document.getElementById("calframe")
		calframe.document.open();
		calframe.document.write("<html><head>"+s_iecalcss+"</head><body id='calbox' class='calendar'></body></html>");
		calframe.document.close();

		
	} 
	i_numcal = 0;
	if(isPCIE)document.getElementById("calframe").className="calframe";
	o_calbody = (isPCIE) ? calframe.document.getElementById("calbox") : document.getElementById("calbox");
	o_calbody.innerHTML="";
	o_udate = (typeof(o_input)=="object") ? new splitDate(o_input.value,'us') : new splitDate(buildDate(o_input),'us') ;
	a_from = start_textfield.split("|");
	v_from = (a_from.length==1) ? new splitDate(document.getElementById(start_textfield).value,s_mode) : new splitDate(buildDate(start_textfield),s_mode);
	
	a_to = end_textfield.split("|");
	v_to = (a_to.length==2) ? new splitDate(buildDate(end_textfield),s_mode) : (document.getElementById(end_textfield)) ? new splitDate(document.getElementById(end_textfield).value,s_mode) : new splitDate("",s_mode);
	d_makefrom = (v_from.month!=-1) ? new Date(v_from.year,v_from.month,v_from.date) : 0;
	d_maketo = (v_to.month!=-1) ? new Date(v_to.year,v_to.month,v_to.date) : 0;
	
switch(b_calinit){
case 0:
	if(o_udate.month!=-1&&o_udate.year!=-1&&o_udate.date!=-1){
		newY=o_udate.year; 
		newM=o_udate.month;
		newD=o_udate.date;
		//fix
		if($('arrival').value != '' || $('checkIn').value != '')
		{
			st = $('checkIn').value;
			if($('arrival').value != '')
			{
				st = $('arrival').value;
			}
			st = st.split('-');
			o_udate.month = st[1];			
		}
		//end fix
		
		vm_makeCal(o_udate.month*1);	
	}else if(o_udate!=document.getElementById(start_textfield)&&d_makefrom){
		newY=v_from.year;
		newM=v_from.month;
		newD=v_from.date;
		vm_makeCal(v_from.month);	
	}else if(o_udate!=document.getElementById(end_textfield)&&d_maketo){
		newY=v_to.year;
		newM=v_to.month;
		newD=v_to.date;
		vm_makeCal(v_to.month);	
	}else{
		newY=today_Year;newM=today_Month;newD=today_Day;
		vm_makeCal(today_Month);	
	}
break;
default:
		switch(selected_textfield_type){
			case "object":
				newM = i_ofirstMonth;
				newY = i_ofirstYear; 
			break;
			default:
				newM = i_sfirstMonth;
				newY = i_sfirstYear; 
		}
		vm_makeCal(newM); 
	}
	s_lastinputtype = typeof(o_input); 
}

function openCal(selected_textfield,start_textfield,end_textfield,s_cal,s_parent,s_mode,s_caldir){ 

	if(o_parent) o_parent.className = "cbrow";//(selected_textfield_type=="object") ? "cbcalrow" : "cbrow"; 	
	clearTimeout(t_calcloser);
	selected_textfield_type = typeof(selected_textfield);
	textfield_value_array = null; 
	if(selected_textfield_type!="object") textfield_value_array = selected_textfield.split("|");
	calopen = 0; 
	o_caldiv = document.getElementById(s_cal);
	o_caldiv.style.display = "block";
	o_caldiv.className = "calboxon"; 
	makeCalendar(selected_textfield,start_textfield,end_textfield,s_mode)
	//get objects
	o_inputright = (selected_textfield_type!="object") ?  document.getElementById(textfield_value_array[1]) : selected_textfield;
	o_parent = document.getElementById(s_parent);
	o_cal = document.getElementById(s_cal);
	o_parent.className+=" cbrowon";
	i_calx = parseInt(o_inputright.offsetLeft)+parseInt(o_inputright.offsetWidth)+parseInt(o_inputright.offsetWidth)+parseInt(o_inputright.offsetWidth);
	i_caly = parseInt(o_parent.offsetTop)+(parseInt(o_parent.offsetHeight)/2)-(parseInt(o_cal.offsetHeight)/2);
	o_cal.style.top = (i_caly>0) ? i_caly+"px" : "0px";
	o_cal.style.left = i_calx+"px";
	setTimeout("calopen = 1",500);
	if(start_textfield == 'air_fromdate2' || start_textfield == 'air_todate2')
	{ 		
		pos = findPos($(o_input.id));
		$('calbox').style.top = (pos[1]-160)+"px";
		$('calbox').style.left = (pos[0]+150)+"px";
		second = true;


	}
	else
	{
		pos = findPos($('air_fromdate'));
		$('calbox').style.top = (pos[1]-90)+"px";
		$('calbox').style.left = (pos[0]+170)+"px";
		second = false;
	}
}
function closeCal(){
	if(o_caldiv&&calopen)t_calcloser = setTimeout("hideCalendar()",500);
	calopen=0;
}
if(isFF3 == 0){
	window.onclick=closeCal;
	window.document.onclick=closeCal;
}

		
	$('air_todate2').value = $('air_todate').value
	$('air_fromdate2').value = $('air_fromdate').value
	$('Adults2').value = $('Adults').value;
	
	//for nights
	
	if(document.getElementById('air_fromdate2') != null)
	{
		if($('air_fromdate2').value != 'dd-mm-yyyy' && $('air_fromdate2').value != '')
		{ 
			var one_day=1000*60*60*24
		
			aval = $('air_fromdate2').value.split("-");
			aval = new Date(aval[2],(aval[1]-1),aval[0]);
						
			dval = $('air_todate2').value.split("-");
			dval = new Date(dval[2],(dval[1]-1),dval[0]);
				
			difference = (dval-aval)/one_day;
						
			$('selNights').selectedIndex = difference-1;
		}
	}
	if(document.getElementById('secondaryDate'))
	{ 
		sideHeight = $('divSCContentBody').offsetHeight
		topHeight = 188
		midHeight = ($('overviewContent').offsetHeight)+290+topHeight+($('divMCContentHeader').offsetHeight);

		mar = sideHeight + topHeight;

			if(navigator.appName == "Microsoft Internet Explorer")
			{
				mar = (mar - midHeight)-10;
			}
			else
			{
				mar = (mar - midHeight)-30;

			}
            mar = Math.abs(mar);/* FIX!! */
			$('secondaryDate').style.margin = mar+"px 0 -15px 0";			
			
		
		//for mac safari		

		arr1=strstr(navigator.appVersion,"3.2.1 Safari")
		arr2=strstr(navigator.appVersion,") Safari")
		arr3=strstr(navigator.appVersion,"4.0 Safari")
		
		
		if( (navigator.platform == "MacPPC" || navigator.platform == "MacIntel") )
		{
			$('secondaryDate').style.cssText = "margin:"+(mar+10)+"px 0 -15px 0 !important;";			
			if(arr2 != false)
			{
				$('secondaryDate').style.cssText = "margin:"+(mar+70)+"px 0 -15px 0 !important;";			
			}
			if(strstr(navigator.appVersion,"Firefox") != false)
			{
				$('secondaryDate').style.cssText = "margin:"+(mar+120)+"px 0 -15px 0 !important;";			
			}
		}
		
		//for IE 6
		if(o_navigator.indexOf("msie 6.0") > 0)
		{
			ycoord = findPos($('addLinks')) ;
			ycoord = ycoord[1] + $('addLinks').offsetHeight; 
			ycoord = midHeight
			
			if(sideHeight > 530)
			{
				neg = 120;
			}
			else
			{
				neg = 160;
			}
			$('secondaryDate').style.cssText = "top:"+(ycoord-neg)+"px !important; ";
			
			$('divFooter').style.display = "none";
			$('divFooterDrape').style.display = "none";
		}		
	}
	function strstr( haystack, needle, bool ) {
 
		var pos = 0;
	 
		haystack += '';
		pos = haystack.indexOf( needle );
		if( pos == -1 ){
			return false;
		} else{
			if( bool ){
				return haystack.substr( 0, pos );
			} else{
				return haystack.slice( pos );
			}
		}
	}