/*
changes:
2005-01-20 - in GoToSite function - changed the redirection by using 'window.location'
2005-01-23 - changed the way onreadystatechange is initialized (it should work now on Firefox too)
2005-01-24 - added functions _SetDates_, _SincronizeDDL_ for sincronizing the dates comboboxes
2005-01-26 - added SetTodayInCruises function
*/
window.onload = function()
{
	//if we are not using IE browser
	if(typeof(document.readyState) == "undefined")
	{
		try { InitSpeedBookContent(); } catch( e ) {}
	}
	else if(document.readyState == 'complete')
	{
		try { InitSpeedBookContent(); } catch( e ) {}

	}
}

function _SetDates_(sIdCheckIn, sIdCheckOut)
{
	var CheckInMonth = sIdCheckIn + "_ddlMonth";
	var CheckInDay = sIdCheckIn + "_ddlDay";
	var CheckOutMonth = sIdCheckOut + "_ddlMonth";
	var CheckOutDay = sIdCheckOut + "_ddlDay";
	
	_SincronizeDDL_(CheckInMonth, CheckOutMonth, 0);
	CheckDateValue('sp_Hotels_dpCheckIn', true);
	CheckDateValue('sp_Hotels_dpCheckOut', true);
	_SincronizeDDL_(CheckInDay, CheckOutDay, 1);
}

function _SincronizeDDL_(CheckIn, CheckOut, advance)
{
	try
	{
		var ddlCheckIn = document.getElementById(CheckIn);
		var ddlCheckOut = document.getElementById(CheckOut);
		if (ddlCheckIn.selectedIndex != ddlCheckIn.length-1)
			ddlCheckOut.selectedIndex = ddlCheckIn.selectedIndex + advance;
		else
		{
			if (advance == 0)
				ddlCheckOut.selectedIndex = 1;
			else
				ddlCheckOut.selectedIndex = 1;
        }
	}catch (e){alert("Eroare: "+e);}
}
  
function InitSpeedBookContent()
{
	try{
	InitCarLocation('sp_Cars_ftlDropOffLocationDest_txtLocation');
	} catch( e ) {}

  /* set Hotel Days */
	//debugger;
	SetToday( "sp_Hotels_dpCheckIn", 0 );
	SetToday( "sp_Hotels_dpCheckOut", 1 );

	/*set Flight Days */
	SetToday( "sp_Flights_fdDestination_fdDest1_dpDeparting", 0 );
	SetToday( "sp_Flights_dpReturning", 1 );
	
	/* set Car Days */
	SetToday( "sp_Cars_dpPickUp", 0 );
	SetToday( "sp_Cars_dpDropOff", 2 );

	/* set Package Days */
	SetToday( "sp_Packages_fdDestination_fdDest1_dpDeparting", 0 );
	SetToday( "sp_Packages_dpReturning", 1 );	
	
	SetTodayInCruises();
}


CrossDomainChanel = function(chanelID,request,callBack)
{
	var CDChanel=document.createElement("script");
	CDChanel.type="text/javascript";
	CDChanel.language="javascript";
	CDChanel.id=chanelID;
	CDChanel.src=request;
			
	if(navigator.userAgent.indexOf("IE")>=0)
	{
		CDChanel.onreadystatechange=function()
		{
			if(CDChanel&&("loaded"==CDChanel.readyState||"complete"==CDChanel.readyState))
			{
				CDChanel.onreadystatechange=null;
				EndInvoke(CDChanel,callBack);
			}
		};
	}
	else
	{
		CDChanel.onload=function(){CDChanel.onload=null;EndInvoke(CDChanel,callBack)};
	}

	document.getElementsByTagName("head")[0].appendChild(CDChanel);
	
	function EndInvoke(CDChanel,callBack)
	{
		callBack()
		document.getElementsByTagName("head")[0].removeChild(CDChanel);
	}
}

function addLoadEvent(func, func_first) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
		window.onload = func;
	} 
	else 
	{
		window.onload = 
			function() 
			{
				if (func_first == "true")
				{
					func();
					oldonload();
				}
				else
				{
					oldonload();
					func();
				}	
			}
	}
}

function GetStaticPage( pagename, searchBoxPlaceHolder )
{
	try
	{
		var test = new CrossDomainChanel('chanel2' , pagename ,RenderData);
	}
	catch( e ) {}

	function RenderData()
	{
	    document.getElementById(searchBoxPlaceHolder).innerHTML = GetAllData();

	    window.setTimeout(function() {
	        InitDates();
	    }, 1);
	}
}
var iniDatesChecked = 1;
function InitDates() {
    try {
        var today = new Date();
        document.getElementById('sp_Hotels_dpCheckIn_ddlMonth').value = today.getMonth() + 1;
        document.getElementById('sp_Hotels_dpCheckIn_ddlDay').selectedIndex = today.getDate();
        _SetDates_("sp_Hotels_dpCheckIn", "sp_Hotels_dpCheckOut");
    }
    catch (ex) {
        if (iniDatesChecked < 50) {
            iniDatesChecked++;
            window.setTimeout(function() {
                InitDates();
            }, 100);
        }
    }
}
function GetStaticPageAndSpill( pagename, ob )
{
/************ define the xmlhttp object *****************/
	var __lmt_xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  __lmt_xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    __lmt_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   __lmt_xmlhttp=false
	  }
	 }
	@else
	 __lmt_xmlhttp=false
	@end @*/
	if (!__lmt_xmlhttp && typeof XMLHttpRequest!='undefined') 
	{
 		try 
 		{
  			__lmt_xmlhttp = new XMLHttpRequest();
 		} 
 		catch (e) 
		{
	  		__lmt_xmlhttp=false
	 	}
	}
	
/*********** now can work,  *****************************/
	if (__lmt_xmlhttp) 
	{
		__lmt_xmlhttp.open("GET", pagename, false);
    __lmt_xmlhttp.send(null)
      document.write(__lmt_xmlhttp.responseText);
	}
}

function GoToSite( baseurl, queryString )
{
	var aunID = "__lmt_aun";
	var apassID = "__lmt_apass";
	var qString;
	
	//alert( "in GoToSite" );
	
	qString = queryString;
	//alert( qString);
	var aun = document.getElementById( aunID );
	var apass = document.getElementById( apassID );
	//if( null!=aun && null!=apass && aun.value!="" && apass.value!="" )
		//qString += "&aun=" + aun.value + "&apas=" + apass.value;
		
	var completeurl=baseurl + "/" + qString;
	if(linkBuilderMode)
	{
		var aElement = document.getElementById('link')
		if(aElement==null)
		{
			aElement = document.createElement('div');
			aElement.id='link';
		}
		aElement.innerHTML= completeurl;
	    document.body.appendChild(aElement);
	}
	else 
	{
	    window.location= completeurl;
	}
}
/*********** Hotel Search methods ****************************/

function PerformSearchHotel( baseurl, affiliate )
{
	var checkInMonth, checkInDay, checkOutMonth, checkOutDay;
	var rooms;
	var r1a, r2a, r3a, r1c, r2c, r3c, r1ca, r1ca1, r2ca, r2ca1, r3ca, r3ca1;
	var hotelName, brand, stars;
	var destination;
	
	
	/**** temporary variables to hold controls ID's ****/
	
	var checkInMonthID = "sp_Hotels_dpCheckIn_ddlMonth";
	var checkInDayID = "sp_Hotels_dpCheckIn_ddlDay";
	var checkOutMonthID = "sp_Hotels_dpCheckOut_ddlMonth";
	var checkOutDayID = "sp_Hotels_dpCheckOut_ddlDay";
	var roomID = "sp_Hotels_ddlRooms";
	var r1aID="sp_Hotels_Room1_ddlAdult";
	var r2aID="sp_Hotels_Room2_ddlAdult";
	var r3aID="sp_Hotels_Room3_ddlAdult";
	var r1cID="sp_Hotels_Room1_ddlChildren";

	var r2cID="sp_Hotels_Room2_ddlChildren";	
	var r3cID="sp_Hotels_Room3_ddlChildren";
	var r1caID="sp_Hotels_Room1_rpChildAge__ctl0_txtChildrenAge";
	var r1ca1ID="sp_Hotels_Room1_rpChildAge__ctl1_txtChildrenAge";
	var r2caID="sp_Hotels_Room2_rpChildAge__ctl0_txtChildrenAge";
	var r2ca1ID="sp_Hotels_Room2_rpChildAge__ctl1_txtChildrenAge";
	var r3caID="sp_Hotels_Room3_rpChildAge__ctl0_txtChildrenAge";
	var r3ca1ID="sp_Hotels_Room3_rpChildAge__ctl1_txtChildrenAge";
	var hotelNameID="sp_Hotels_txtHotelName";
	var starsID="sp_Hotels_ddlCategories";
	var brandID="sp_Hotels_ddlChains";
  var destinationID="";
  var ageString = "";
  var tempage = "";

  /* ADDED BY JASON TO GET DESTINATION FIELD */
  var destinationID="sp_Hotels_hdDestinations__ctl0_txtLocation";
	var destination = document.getElementById( destinationID ).value
  if ("Enter City Name Here" == destination || "" == destination) { destination = "NYC"; }
  /* END ADDED BY JASON TO GET DESTINATION FIELD */

	/********** END of teporary variables **************/
	
	//var ciMonth = document.getElementById( checkInMonthID );
	checkInMonth = document.getElementById( checkInMonthID ).selectedIndex;
	checkInDay = document.getElementById( checkInDayID ).selectedIndex;
	checkOutMonth = document.getElementById( checkOutMonthID ).selectedIndex;
	checkOutDay = document.getElementById( checkOutDayID ).selectedIndex;
  rooms = document.getElementById( roomID ).selectedIndex + 1;
	
	/** adults **/
	if( document.getElementById( r2aID ).style.display != "none" )
		r2a = document.getElementById( r2aID ).selectedIndex + 1;
	if( document.getElementById( r3aID ).style.display != "none" )
		r3a = document.getElementById( r3aID ).selectedIndex + 1;

	/** room 1 guests **/
	r1a = document.getElementById( r1aID ).selectedIndex + 1;
	r1c = document.getElementById( r1cID ).selectedIndex;
	
  // JMC NOTES //
  // Assigns r1ca & r1ca1 values if they have are visible on the form.
  // If they are not on the form
  r1ca = document.getElementById( r1caID ).value;
  r1ca1 = document.getElementById( r1ca1ID ).value;

  //alert (r1ca + " : " + r1ca1);
  
  // JMC NOTES //
  // NUMBER OF ADULTS & CHILDREN ADDED TO STRING
  ageString += r1a != "" ? "&r1a=" + r1a : "";
  ageString += r1c != 0 ? "&r1c=" + r1c + "&r1ca=" : "";
  
  // JMC NOTES //
  // if r1ca & r1ca1 contain values, then form values are added
  // else default ages are added since the user selected the number
  // of children correctly.
  switch (r1c) {
  case 1:
    tempage += r1ca != "" ? r1ca : "11"; break;
  case 2:
    tempage += r1ca != "" ? r1ca : "11";
    tempage += r1ca1 != "" ? "," + r1ca1 : ",11"; break;
  default: 
    tempage = ""; break;
  }

  ageString += tempage;
  tempage = "";

	/** room 1 guests **/
	if( rooms > 1 )
	{
		r2a = document.getElementById( r2aID ).selectedIndex + 1;
		r2c = document.getElementById( r2cID ).selectedIndex;
		r2ca = document.getElementById( r2caID ).value;
    r2ca1 = document.getElementById( r2ca1ID ).value;

    //alert (r2ca + " : " + r2ca1);
  
    // JMC NOTES //
    // NUMBER OF ADULTS & CHILDREN ADDED TO STRING
    ageString += r2a != "" ? "&r2a=" + r2a : "";
    ageString += r2c != 0 ? "&r2c=" + r2c + "&r2ca=" : "";
    
    // JMC NOTES //
    // if r2ca & r2ca1 contain values, then form values are added
    // else default ages are added since the user selected the number
    // of children correctly.
    switch (r2c) {
    case 1:
      tempage += r2ca != "" ? r2ca : "12"; break;
    case 2:
      tempage += r2ca != "" ? r2ca : "12";
      tempage += r2ca1 != "" ? "," + r2ca1 : ",13"; break;
    default: 
      tempage = ""; break;
    }

    ageString += tempage;
    tempage = "";
	}
	if( rooms > 2 )
	{
		r3a = document.getElementById( r3aID ).selectedIndex + 1;
		r3c = document.getElementById( r3cID ).selectedIndex;
		r3ca = document.getElementById( r3caID ).value;
		r3ca1 = document.getElementById( r3ca1ID ).value;
    
    //alert (r3ca + " : " + r3ca1);

    // JMC NOTES //
    // NUMBER OF ADULTS & CHILDREN ADDED TO STRING
    ageString += r3a != "" ? "&r2a=" + r3a : "";
    ageString += r3c != 0 ? "&r2c=" + r3c + "&r2ca=" : "";
    
    // JMC NOTES //
    // if r3ca & r3ca1 contain values, then form values are added
    // else default ages are added since the user selected the number
    // of children correctly.
    switch (r3c) {
    case 1:
      tempage += r3ca != "" ? r3ca : "12"; break;
    case 2:
      tempage += r3ca != "" ? r3ca : "12";
      tempage += r3ca1 != "" ? "," + r3ca1 : ",13"; break;
    default: 
      tempage = ""; break;
    }

    ageString += tempage;
    tempage = "";
	}

	if( null != document.getElementById( hotelNameID ) )
		hotelName = document.getElementById( hotelNameID ).value;
	
	if( null != document.getElementById( brandID ) )
		brand = document.getElementById( brandID ).value;
		
	if( null != document.getElementById( starsID ) )
		stars = document.getElementById( starsID ).value;
	
	var qString = "?st=2" + "&cin=" + BuildDateString( checkInMonth, checkInDay ) + "&cout=" + BuildDateString( checkOutMonth, checkOutDay );
	qString += "&mod=2&dst=" + destination + ageString; //!!!!!!!!!!!!!mod=2  and remove &afID=55!!!


  qString += hotelName != null && hotelName != "" ? "&hn=" + hotelName : "";
	qString += brand != null && brand != "" ? "&brnd=" + brand : "";
	qString += stars != null && stars != 0 ? "&str=" + stars : "";
	
	//qString += "&hid=7647"; !!!!!!!!!!!!!Remove!!!
	//qString += "&prv=localTgsProvider"; !!!!!!!!!!!!!Remove!!!

	 //alert( qString );
	//location.replace( baseurl + "/" + qString );
	GoToSite( baseurl, qString );
}

/******************* End Search Hotel *********************************/




/****************** Search Flight Methods *****************************/

function PerformSearchFlight(  baseurl, affiliate )
{
	var checkInMonthID = "sp_Flights_fdDestination_fdDest1_dpDeparting_ddlMonth";
	var checkInDayID = "sp_Flights_fdDestination_fdDest1_dpDeparting_ddlDay";
	var checkOutMonthID = "sp_Flights_dpReturning_ddlMonth";
	var checkOutDayID = "sp_Flights_dpReturning_ddlDay";
	var fromID = "sp_Flights_fdDestination_fdDest1_ftlDeparting_ftlDeparting_txtLocation";
	var toID = "sp_Flights_fdDestination_fdDest1_ftlArriving_ftlArriving_txtLocation";
	var adultID = "sp_Flights_ucPassAge_ddlAdult";
	var childID = "sp_Flights_ucPassAge_ddlChildren";
	var seniorID = "sp_Flights_ucPassAge_ddlSenior";
	var infantID = "sp_Flights_ucPassAge_ddlInfant";
	
	var caID = "sp:Flights:ucPassAge:rpChildAge";
	var saID = "sp:Flights:ucPassAge:rpSeniorAge";
	
	var checkInMonth, checkInDay, checkOutMonth, checkOutDay;
	var from, to;
	var adult, child, senior, infant;
	
	checkInMonth = document.getElementById( checkInMonthID ).selectedIndex;
	checkInDay = document.getElementById( checkInDayID ).selectedIndex + 1;
	if( null !=  document.getElementById( checkOutMonthID ) )
		checkOutMonth = document.getElementById( checkOutMonthID ).selectedIndex;
	if( null !=  document.getElementById( checkOutDayID ) )
		checkOutDay = document.getElementById( checkOutDayID ).selectedIndex + 1;
	
	from = document.getElementById( fromID ).value;
	to = document.getElementById( toID ).value;

  if ("" == from || "Enter City or Airport Code" == from) { from = "YTO"; }
  if ("" == to || "Enter City or Airport Code" == to) { to = "Orlando" }
	
	adult = document.getElementById( adultID ).selectedIndex;
  child = document.getElementById( childID ).selectedIndex;
  senior = document.getElementById( seniorID ).selectedIndex;
  infant = document.getElementById( infantID ).selectedIndex;
	
	ca = document.getElementsByName( caID );
	sa = document.getElementsByName( saID );
	
	var qString	= "?st=1&mod=1" + "&afId=" + affiliate + "&frm=" + from + "&afto=" + to;
	qString += "&dep=" + BuildDateString( checkInMonth, checkInDay );
	qString += null != checkOutMonth ? "&ret=" + BuildDateString( checkOutMonth, checkOutDay ) : "";
	qString += "&adt=" + adult;

	if( null!=child && child>0 )
	{
		var caCol = "";
		if( null != ca )
		{
			for(var i=0; i<child; i++)
			{
				caCol += ca[i].value != "" ? ca[i].value : "11";
				caCol += i != child-1 ? "," : "";
			}
		}
		qString += "&cnn=" + child;
		qString += caCol != "" ? "&ca=" + caCol : "";
	}

	if( null!=senior && senior>0)
	{
		var saCol = "";
		if( null != sa )
		{
			for(var i=0; i<senior; i++)
			{
				saCol += sa[i].value != "" ? sa[i].value : "65";
				saCol += i != senior-1 ? "," : "";
			}
		}
		qString += "&snn=" + senior;
		qString += saCol != "" ? "&sa=" + saCol : "";
	}

	qString += null!=infant && infant>0 ? "&inf=" + infant : "";	
	 //alert( qString );
	//location.replace( baseurl + "/" + qString );
	GoToSite( baseurl, qString );
}

/*************** End Flight Search ******************/



/*************** Search Car Methods *****************/

function PerformSearchCar(  baseurl, affiliate )
{
	var checkInMonthID = "sp_Cars_dpPickUp_ddlMonth";
	var checkInDayID = "sp_Cars_dpPickUp_ddlDay";
	var checkInTimeID = "sp_Cars_dpPickUp_ddlTime";
	var checkOutMonthID = "sp_Cars_dpDropOff_ddlMonth";
	var checkOutDayID = "sp_Cars_dpDropOff_ddlDay";
	var checkOutTimeID = "sp_Cars_dpDropOff_ddlTime";
	var puAirportID = "sp_Cars_rbPickUpLocationAirport";
	//var puCityID = "sp_Cars_rbPickUpLocationCity";
	var puSameAsID = "sp_Cars_rbDropOffLocationSameAsPickup";
	var fromID = "sp_Cars_ftlPickupLocationDest_txtLocation";
	var toID = "sp_Cars_ftlDropOffLocationDest_txtLocation";
	
	
	var checkInMonth ,checkInDay ,checkInTime ,checkOutMonth ,checkOutDay ,checkOutTime;
	var puType;
	var puAirport;
	var from, to
	
	from = document.getElementById( fromID ).value;
	to = document.getElementById( toID ).value;

  if ("" == from || "Enter Airport Code" == from) { from = "JFK"; }
  if ("" == to || "Enter Airport Code" == to) { to = "JFK"; }

	var puTypeObject = document.getElementById( puAirportID );

	if( null!=puTypeObject && puTypeObject.checked )
	{
		puType = "A";
		var sameAs = document.getElementById( puSameAsID );
		if( null==sameAs || sameAs.style.display == "none" || !sameAs.checked )
		to = document.getElementById( toID ).value;			
	}
	else
		puType = "C";
		
	//dates
	var ciTimeObj, coTimeObj;
	ciTimeObj = document.getElementById( checkInTimeID );
	coTimeObj = document.getElementById( checkOutTimeID )
	checkInMonth = document.getElementById( checkInMonthID ).selectedIndex;
	checkInDay = document.getElementById( checkInDayID ).selectedIndex + 1;
	checkInTime = ciTimeObj.options[ ciTimeObj.selectedIndex ].value
	checkOutMonth = document.getElementById( checkOutMonthID ).selectedIndex;
	checkOutDay = document.getElementById( checkOutDayID ).selectedIndex + 1;
	checkOutTime = coTimeObj.options[ coTimeObj.selectedIndex ].value
	
	var qString	= "?st=3&mod=1" + "&afId=" + affiliate + "&frm=" + from + "&afto=" + to;
	qString += "&ltype=" + puType; // JMC OLD // qString += "&ltype=A" 
	qString += "&dep=" + BuildDateString( checkInMonth, checkInDay );
	qString += "&dept=" + checkInTime + ":00";
	qString += "&ret=" + BuildDateString( checkOutMonth, checkOutDay );
	qString += "&rett=" + checkOutTime + ":00";
		
	// alert( qString );
	//location.replace( baseurl + "/" + qString );
	GoToSite( baseurl, qString );
}


/****************** End Car Search *******************/



/****************** Cruise Search Methods *******************/

function PerformSearchCruise(  baseurl, affiliate )
{
	var destinationID = "sp_spanModuleCruise_ddlDestinations";
	var departID = "sp_spanModuleCruise_ddlDepartMonth";
	var lengthID = "sp_spanModuleCruise_ddlLength";
	var adultID = "sp_spanModuleCruise_ddlAdults";
	var childID = "sp_spanModuleCruise_ddlChildren";
	
	var destination, depart ,length ,adult ,child;
	
	destination = document.getElementById( destinationID ).options[ document.getElementById( destinationID ).selectedIndex ].value;
	depart = document.getElementById( departID ).options[ document.getElementById( departID ).selectedIndex ].value;
	length = document.getElementById( lengthID ).options[ document.getElementById( lengthID ).selectedIndex ].value;
	adult = document.getElementById( adultID ).options[ document.getElementById( adultID ).selectedIndex ].value;
	child = document.getElementById( childID ).options[ document.getElementById( childID ).selectedIndex ].value;
	
	var qString	= "?st=4&mod=1" + "&afId=" + affiliate;
	qString += "&dst=" + destination;
	qString += "&dep=" + depart;
	qString += "&len=" + length;
	qString += "&adt=" + adult;
	qString += "&cnn=" + child;
	
	// alert( qString );
	//location.replace( baseurl + "/" + qString );
	GoToSite( baseurl, qString );
		
}

/****************** End Cruise Search *******************/


/****************** Package Search Methods *******************/

function PerformSearchPackage( baseurl, affiliate )
{
	var checkInMonthID = "sp_Packages_fdDestination_fdDest1_dpDeparting_ddlMonth";
	var checkInDayID = "sp_Packages_fdDestination_fdDest1_dpDeparting_ddlDay";
	var checkOutMonthID = "sp_Packages_dpReturning_ddlMonth";
	var checkOutDayID = "sp_Packages_dpReturning_ddlDay";
	
	var fromID = "sp_Packages_fdDestination_fdDest1_ftlDeparting_ftlDeparting_txtLocation";
	var toID = "sp_Packages_fdDestination_fdDest1_ftlArriving_ftlArriving_txtLocation";
	
	var roomID = "sp_Packages_FHddlRooms"
	
	var roomPrefix = "sp_Packages_FHRoom";
	var adultID = "_ddlAdult";
	var childID = "_ddlChildren";
	var seniorID = "_ddlSenior";
	var infantID = "_ddlInfant";
	
	var caPrefix = "_rpChildAge__ctl";
	var caID = "_txtChildrenAge";
	var saPrefix = "_rpSeniorAge__ctl";
	var saID = "_txtSeniorAge";
	
	var checkInMonth, checkInDay, checkOutMonth, checkOutDay;
	var from ,to, room;
	var adult ,child ,senior, infant, ca, sa;
			
	var roomArray = new Array();
	room = eval(document.getElementById( roomID ).options[ document.getElementById( roomID ).selectedIndex ].value);
	var roomsString = "";
	
	for(i = 0; i < room; i++)
	{
		adult = document.getElementById( roomPrefix + (i+1) + adultID ).selectedIndex;
		child = document.getElementById( roomPrefix + (i+1) + childID ).selectedIndex;
		senior = document.getElementById( roomPrefix + (i+1) + seniorID ).selectedIndex;
		infant = document.getElementById( roomPrefix + (i+1) + infantID ).selectedIndex;
		
		roomsString += null!=adult && adult>0 ? "&r" + (i+1) + "a=" + adult : "";
		roomsString += null!=child && child>0 ? "&r" + (i+1) + "c=" + child : ""; 
		roomsString += null!=senior && senior>0 ? "&r" + (i+1) + "s=" + senior : ""; 
		roomsString += null!=infant && infant>0 ? "&r" + (i+1) + "i=" + infant : "";
/*
    // ADDED TO REPLACE COMMENT OUT ABOVE by Jason
    var caCol=""
    var saCol=""

    for (var i=0; i<child; i++) { 
      caCol += "11"; caCol += i != child-1 ? "," : "";
    }
    roomsString += "" != caCol ? "&r1ca=" + caCol : "";
    for (var i=0; i<senior; i++) { 
      saCol += "65"; saCol += i != senior-1 ? "," : "";
    }
    roomsString += "" != saCol ? "&r1sa=" + saCol : "";
	// END ADDED TO REPLACE COMMENT OUT ABOVE by Jason
	*/	
		/* Commented Out by Jason (Fields Not Used on Form)*/
		if( null!=child && child>0 )
		{ 
			roomsString+= "&r" + (i+1) + "ca=";
			for(j=0; j<child; j++)
			{
				roomsString += document.getElementById( roomPrefix + (i+1) + caPrefix + j + caID ).value != "" ? document.getElementById( roomPrefix + (i+1) + caPrefix + j + caID ).value : "12";
				roomsString += j!=(child-1) ? "," : "";
			}
		}
		
		if( null!=senior && senior>0 )
		{ 
			roomsString+= "&r" + (i+1) + "sa=";
			for(j=0; j<senior; j++)
			{
				roomsString += document.getElementById( roomPrefix + (i+1) + saPrefix + j + saID ).value != "" ? document.getElementById( roomPrefix + (i+1) + saPrefix + j + saID ).value : "66";
				roomsString += j!=(senior-1) ? "," : "";
			}
		}
		/* END Commented Out by Jason (Fields Not Used on Form) */
	}
	
	checkInMonth = document.getElementById( checkInMonthID ).selectedIndex;
	checkInDay = document.getElementById( checkInDayID ).selectedIndex + 1;
	if( null !=  document.getElementById( checkOutMonthID ) )
		checkOutMonth = document.getElementById( checkOutMonthID ).selectedIndex;
	if( null !=  document.getElementById( checkOutDayID ) )
		checkOutDay = document.getElementById( checkOutDayID ).selectedIndex + 1;
	
	from = document.getElementById( fromID ).value;
	to = document.getElementById( toID ).value;

  if ("" == from || "Enter City or Airport Code" == from) { from = "YTO"; }
  if ("" == to || "Enter City or Airport Code" == to) { to = "New York"; }
	
	var qString	= "?st=5&mod=1" + "&afId=" + affiliate + "&frm=" + from + "&afto=" + to;
	qString += "&dep=" + BuildDateString( checkInMonth, checkInDay );
	qString += null != checkOutMonth ? "&ret=" + BuildDateString( checkOutMonth, checkOutDay ) : "";
	qString += roomsString;
	
	// alert( qString );
	//location.replace( baseurl + "/" + qString );
	GoToSite( baseurl, qString );
}

/*************** End Package Search Methods ****************/

function GetMonthDayYear( month, day )
{
	var d = new Date();
	if( month < d.getMonth() )
	    return d.getFullYear() + 1;
	else if( month == d.getMonth() )
	{
		if( day < d.getDate() )
		    return d.getFullYear() + 1;
	}

	return d.getFullYear();
}

function SetToday( ddlsPrefix , addDays )
{
	var today =  new Date(new Date().setHours( 0,0,0,0 ) );

	if( addDays != null  )
		today.setDate( today.getDate() + addDays );
	
	var objDdlMonth = document.getElementById( ddlsPrefix + "_ddlMonth" );
	var objDdlDay = document.getElementById( ddlsPrefix + "_ddlDay" );
	
	
	objDdlDay.selectedIndex = today.getDate();
	objDdlMonth.selectedIndex  = today.getMonth() + 1; // JMC // objDdlMonth.selectedIndex = today.getMonth() + 1;
	
	SyncDayByMonth( objDdlDay , today );
}

function SetTodayInCruises(){
	var oCruiseComboDate = document.getElementById("sp_spanModuleCruise_ddlDepartMonth");
	if(oCruiseComboDate==null)return;
	var today = new Date(new Date().setHours(0,0,0,0));
	var i;
	var m = today.getMonth()+1;
	if(m<10)m = "0" + m ;
	var formattedToday = m+"/"+today.getFullYear();
	for(i=0;i<oCruiseComboDate.length;i++)
		if(oCruiseComboDate[i].value==formattedToday){
			oCruiseComboDate.selectedIndex=i;
			return;
		}
}

function BuildDateString( month, day )
{
	return month + "/" + day + "/" + GetMonthDayYear( month, day );
}
