	/*
	*****************************************************************************************************
	Author : 
	Source : 
	Date : 
	*****************************************************************************************************
	*/
function currencyWindow(popurl)
	{
	currWindow = window.open(popurl, 'CurrencyConverter', 'width=460,height=380');
	currWindow.focus;
	}

function changeForm(id)
{ 
	var f; 
	f=document.search;
	//alert(id);
	 if(id == 2)
	 {
		hotelbox.style.display='none';
		airbox.style.display='block';
		lastmindealsbox.style.display='none';
		carbox.style.display='none';
		hotelairbox.style.display='none';
		clickstay('id2');
	 }
	 else if(id == 3)
	 {
		hotelbox.style.display='none';
		airbox.style.display='none';
		lastmindealsbox.style.display='block';
		carbox.style.display='none';
		hotelairbox.style.display='none';
		clickstay('id5');

	 }
	 else if(id == 4)
	 {
		 hotelbox.style.display='none'; 
		 airbox.style.display='none';
		 lastmindealsbox.style.display='none';
		 carbox.style.display='block';
		 hotelairbox.style.display='none';
		 clickstay('id4');
		 //alert(document.hotsrchbox.dod_dd.selectedIndex);
		 document.CarSearch.pudate_mo.options.selectedIndex = document.hotsrchbox.doa_mm.options.selectedIndex;
		 document.CarSearch.pudate_dy.options.selectedIndex = document.hotsrchbox.doa_dd.options.selectedIndex;
		 document.CarSearch.dodate_mo.options.selectedIndex = document.hotsrchbox.dod_mm.options.selectedIndex;
		 document.CarSearch.dodate_dy.options.selectedIndex = document.hotsrchbox.dod_dd.options.selectedIndex;
	 }
	 else if(id == 6)
	 {
		 hotelbox.style.display='none'; 
		 airbox.style.display='none';
		 lastmindealsbox.style.display='none';
		 carbox.style.display='none';
		 hotelairbox.style.display='block';
		 clickstay('id3');
	 }
	 else 
	 {
		hotelbox.style.display='block';
		airbox.style.display='none';
		lastmindealsbox.style.display='none';
		carbox.style.display='none';
		hotelairbox.style.display='none';
		clickstay('id1');
	 }
}

function IsLeapYear(yrStr)
{
 var leapYear = false;
 var year = parseInt(yrStr, 10);
 if (year%4 == 0) 
  { 
	leapYear = true;
	if (year%100 == 0)
	 {
	  leapYear = false;
	  if (year%400 == 0)
	   {
	    leapYear = true;
		}
	  }
   }
  return leapYear;
 }


function getDaysInMonth(mthIdx, yrStr) 
{
 var maxDays = 31;
 if (mthIdx == 1)
	{
	 if (IsLeapYear(yrStr))
	   { 
	    maxDays = 29;
	   }
	 else
		{
		  maxDays = 28;
		}
     }
 if (mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10)
	{
	 maxDays = 30;
	 }
 return maxDays;
}

function adjustDate(mthIdx, Dt, initDate)
{
var value = 0;

var today = new Date();
var theYear = parseInt(today.getYear(),10);

if (mthIdx < today.getMonth()) {
	theYear = (parseInt(today.getYear(),10) + 1);
}

if (theYear < 100) {
	theYear = "19" + theYear;
	}
else {
	if ((theYear - 100) < 10) {
		theYear = "0" + (theYear - 100);
		}
	else 
		{
		theYear = (theYear - 100) + "";
		}
	theYear = "20" + theYear
}

var numDays = getDaysInMonth(mthIdx, theYear);

 
// checks whether to initialize date or not.
if (initDate == 1) 
	{
	  if ((numDays - Dt)==7)
		{

		//checks if month is December
		if (mthIdx==11) {
			document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx;
			document.hotsrchbox.dod_mm.options.selectedIndex = 0;
			document.hotsrchbox.dod_yy.options.selectedIndex =+1;

			document.CarSearch.pudate_mo.options.selectedIndex = mthIdx;
			document.CarSearch.dodate_mo.options.selectedIndex = 0;
		} else {
			document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx;
			document.hotsrchbox.dod_mm.options.selectedIndex = mthIdx+1;

			document.CarSearch.pudate_mo.options.selectedIndex = mthIdx;
			document.CarSearch.dodate_mo.options.selectedIndex = mthIdx+1;
		}

		//hotel search box
	    document.hotsrchbox.doa_dd.options.selectedIndex = numDays - 1;
	    document.hotsrchbox.dod_dd.options.selectedIndex =  7 - (numDays - Dt);

		//car search box
		document.CarSearch.pudate_dy.options.selectedIndex = numDays - 1;
		document.CarSearch.dodate_dy.options.selectedIndex = 7 - (numDays - Dt);

		}
		else if ((numDays-Dt)<7)
				{

				if (mthIdx==11) {
					document.hotsrchbox.doa_mm.options.selectedIndex = 0;
					document.hotsrchbox.dod_mm.options.selectedIndex = 
					document.hotsrchbox.doa_mm.options.selectedIndex;
					document.hotsrchbox.doa_yy.options.selectedIndex =+1;
					document.hotsrchbox.dod_yy.options.selectedIndex =+1;

					document.CarSearch.pudate_mo.options.selectedIndex = 0;
					document.CarSearch.dodate_mo.options.selectedIndex = 
					document.CarSearch.pudate_mo.options.selectedIndex;
				} else {
					document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx + 1;
					document.hotsrchbox.dod_mm.options.selectedIndex = document.hotsrchbox.doa_mm.options.selectedIndex;	

					document.CarSearch.pudate_mo.options.selectedIndex = mthIdx + 1;
					document.CarSearch.dodate_mo.options.selectedIndex = document.CarSearch.pudate_mo.options.selectedIndex;
				}					

				//hotel search box
				document.hotsrchbox.doa_dd.options.selectedIndex = 6 - (numDays - Dt);
				document.hotsrchbox.dod_dd.options.selectedIndex = 7 - (numDays - Dt);	

				//car search box
				document.CarSearch.pudate_dy.options.selectedIndex = 6 - (numDays - Dt);
				document.CarSearch.dodate_dy.options.selectedIndex = 7 - (numDays - Dt);

				}
		else
			{ 
			//hotel search box
			document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx;
			document.hotsrchbox.doa_dd.options.selectedIndex = (Dt - 1) + 7;
			document.hotsrchbox.dod_mm.options.selectedIndex = document.hotsrchbox.doa_mm.options.selectedIndex;
			document.hotsrchbox.dod_dd.options.selectedIndex = (Dt - 1) + 8;

			//car search box
			document.CarSearch.pudate_mo.options.selectedIndex = mthIdx;
			document.CarSearch.pudate_dy.options.selectedIndex = (Dt - 1) + 7;
			document.CarSearch.dodate_mo.options.selectedIndex = document.CarSearch.pudate_mo.options.selectedIndex;
			document.CarSearch.dodate_dy.options.selectedIndex = (Dt - 1) + 8;
			}
		}
else
	{		
	if (mthIdx == 1)
		{
		if (Dt.options.selectedIndex + 1 < numDays) 
			{
			return 0;
			}
		else
			{
			Dt.options.selectedIndex=numDays - 1;
			if (numDays == 29)
				{
				return 99;
				}
			else
				{
				return 1;
				}
			}
		}
	 if (Dt.options.selectedIndex + 1 < numDays)
		{
		value = 0;
		}
	 else
		{
		if (Dt.options.selectedIndex + 1 > numDays)
			{
			Dt.options.selectedIndex--;
			value = 3;
			}
		else
			{
			value = 2;
			}
		}
	 return value;
	}
}


function amadChange(inM, inD, outM, outD)
{
 var res = adjustDate(inM.options.selectedIndex, inD, 0);
 if (res != 0 )
	{
		outD.options.selectedIndex = 0;
		if (outM.options.selectedIndex == 11) {
			outM.options.selectedIndex = 0;
			}
		else {
			outM.options.selectedIndex = inM.options.selectedIndex + 1;
			}
		}
 else
	{
	outM.options.selectedIndex = inM.options.selectedIndex;
	outD.options.selectedIndex = inD.options.selectedIndex + 1;
	}
return;
}

function initDate()
{
	var today = new Date();
	var currMth = today.getMonth();
	var currDate = today.getDate();

	var mth = document.hotsrchbox.doa_dd.options.selectedIndex = currMth;
	var Dt = document.hotsrchbox.doa_dd.options.selectedIndex = currDate;
	adjustDate(mth, Dt, 1);
}
	
function waitBox()
{
  var popup = window.open('http://reservations.hotelsandmore.com/wait.html','wait','height=125 ,width=330,left=330,top=330');
}

function showCal(url)
	{
	calWindow = window.open(url, 'Calendar', 'scrollbars=YES, width=550,height=225');
	calWindow.focus;
	}

function disclaimerWin(tnc)
	{
	tncWindow = window.open(tnc, 'TermsAndConditions', 'width=325,height=500');
	tncWindow.focus;
	}

function airportCodes(url)
	{
	arptWindow = window.open(url, 'AirportCodes', 'width=450,height=350');
	arptWindow.focus;
	}

var anyopen = "id1";
function clickstay(tdid) {
	document.all[anyopen].className = "tabOff";
	document.all[tdid].className = "tabOn";
	anyopen=tdid;
	}

