// JavaScript Document



<!--



function selectDate()

{

  var now = new Date();

  var mth = now.getMonth();

  var dd = now.getDate();



  if (mth < 10)

   {

     mth == 0 + mth;

    }

  if (dd < 10)

   {

     dd == 0 + dd;

   }

  if (dd >= 30)

   {

    document.frmARNQuickSearch.selMonth_A.selectedIndex = mth;

    document.frmARNQuickSearch.selDay_A.selectedIndex = dd - 1;

    document.frmARNQuickSearch.selDay_D.selectedIndex = dd - dd;

    document.frmARNQuickSearch.selMonth_D.selectedIndex = mth + 1;

   //alert(mth + 1);

   }

  else

   {

  	document.frmARNQuickSearch.selMonth_A.selectedIndex = mth;

  	document.frmARNQuickSearch.selDay_A.selectedIndex = dd;

  	document.frmARNQuickSearch.selMonth_D.selectedIndex = mth;

  	document.frmARNQuickSearch.selDay_D.selectedIndex = dd + 1;

  }



  document.frmARNQuickSearch.city.focus();



 }



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 < 1000)//IE check

{

	if (theYear < 100) {

		theYear = "19" + theYear;

		}

	else {

		if ((theYear - 100) < 10) {

			theYear = "0" + (theYear - 100);

			}

		else 

			{

			theYear = (theYear - 100) + "";

			}

		theYear = "20" + theYear

	}

}

document.frmARNQuickSearch.doa_year.value = theYear ;

document.frmARNQuickSearch.dod_year.value = theYear ;

//Set the year





var numDays = getDaysInMonth(mthIdx, theYear);



 

// checks whether to initialize date or not.

if (initDate == 1) 

	{

	  // only goes here if seven days left in the month.

	  if ((numDays-Dt)==7)

		{

		//hotel search box

		//alert("line 116 " + numDays + " " + Dt);

		if (mthIdx==11)

		{

			document.frmARNQuickSearch.selMonth_A.options.selectedIndex = mthIdx;

			document.frmARNQuickSearch.selMonth_D.options.selectedIndex = 0;

		} else {

			document.frmARNQuickSearch.selMonth_A.options.selectedIndex = mthIdx;

			document.frmARNQuickSearch.selMonth_D.options.selectedIndex = mthIdx+1;

		}



	    document.frmARNQuickSearch.selDay_A.options.selectedIndex = numDays - 1;

	    document.frmARNQuickSearch.selDay_D.options.selectedIndex =  7 - (numDays - Dt);

		}

		else if ((numDays-Dt)<7)

				{

				//hotel search box

				//alert("line 125 " + numDays + " " + Dt);

				if (mthIdx==11)

				{

					document.frmARNQuickSearch.selMonth_A.options.selectedIndex = 0;

					document.frmARNQuickSearch.selMonth_D.options.selectedIndex = document.frmARNQuickSearch.selMonth_A.options.selectedIndex;

				} else {

					document.frmARNQuickSearch.selMonth_A.options.selectedIndex = mthIdx+1;

					document.frmARNQuickSearch.selMonth_D.options.selectedIndex = document.frmARNQuickSearch.selMonth_A.options.selectedIndex;

				}

			

				document.frmARNQuickSearch.selDay_A.options.selectedIndex = 6 - (numDays - Dt);

				document.frmARNQuickSearch.selDay_D.options.selectedIndex = 7 - (numDays - Dt);	

				}

		else

			{ 

			//hotel search box -- goes here if dates are in the same month.

			//alert("line 134 " + numDays + " " + Dt);

			document.frmARNQuickSearch.selMonth_A.options.selectedIndex = mthIdx;

			document.frmARNQuickSearch.selDay_A.options.selectedIndex = (Dt - 1) + 7;

			document.frmARNQuickSearch.selMonth_D.options.selectedIndex = document.frmARNQuickSearch.selMonth_A.options.selectedIndex;

			document.frmARNQuickSearch.selDay_D.options.selectedIndex = (Dt - 1) + 8;

			}



		//document.frmARNQuickSearch.city.focus();



		}

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, inY, outY)

{

//@Desc - need to set the year based what the user has selected.

  var jnow = new Date();

  var jmth = jnow.getMonth();

  var jdate = jnow.getDate();

  var inY = "2005" ;

  var outY = "2005"; 

  if (inM.options.selectedIndex <= jmth)

	{

		if (inD.options[inD.options.selectedIndex].value < jdate)

		{

			inY = jnow.getFullYear() + 1 ;

			outY = jnow.getFullYear() + 1 ;

			

			

		}

		else

		{

			inY = jnow.getFullYear() ;

			outY = jnow.getFullYear() ;	

			

		}

	}else

	{

			inY = jnow.getFullYear() ;

			outY = jnow.getFullYear();

			

	}

	document.frmARNQuickSearch.doa_year.value = inY;

	document.frmARNQuickSearch.dod_year.value = outY;

	

 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.frmARNQuickSearch.selDay_A.options.selectedIndex = currMth;

	var Dt = document.frmARNQuickSearch.selDay_A.options.selectedIndex = currDate;

	adjustDate(mth, Dt, 1);

}





function currYear()

{ 

	var today = new Date();

	currYear = today.getFullYear();

	document.write(currYear);

}



//-->


