//code removed from page via inroads standards,
//code based from wctravel.com
YAHOO.namespace("example.calendar");
function changeAll() {change('tab_1','norm_tab');change('tab_2','norm_tab');change('tab_3','norm_tab');change('tab_4','norm_tab');change('tab_5','norm_tab');change('tab_6','norm_tab');}
  
// hide and show id's
function hideAll() {hide('hotel_frame');hide('air_frame');hide('airHotel_frame');hide('car_frame');hide('lmd_frame');/*hide('attractions_frame');*/}
	
// toggle search boxes and higlights tabs
function flip(idLayer){
	hideAll();
	/*if (idLayer=='1' || idLayer=='hotel' ){ searchType = "hotel";show('hotel_frame');changeAll();change('tab_1','active_tab');}
	if (idLayer=='2' || idLayer=='air'){ searchType = "air";show('air_frame');changeAll();change('tab_2','active_tab');}
	if (idLayer=='3' || idLayer=='customtrip'){searchType = "airHotel";show('airHotel_frame');changeAll();change('tab_3','active_tab');}
	if (idLayer=='4' || idLayer=='car'){searchType = "car";show('car_frame');changeAll();change('tab_4','active_tab');}
	if (idLayer=='5' || idLayer=='lmd'){searchType = "lmd";show('lmd_frame');changeAll();change('tab_5','active_tab');}
	if (idLayer=='6' || idLayer=='activities'){searchType = "attractions";show('attractions_frame');changeAll();change('tab_6','active_tab');}*/
	//rewrite:
	show(idLayer+"_frame");
	searchType=idLayer;
}

// to redirect to 4hr car advanced search page
function go() {
	var destination = document.CarSearch.puwhere.value;
	var re = new RegExp('CarRequest');
	var m = re.exec(destination);
	if (m != null){
		//location.target = "_top";
		top.location.href = destination;
	}else{
		return false;
	}
}

var searchType= "hotel";
var hotelDoaCal;
var hotelDodCal;
var htlCalArray = new Array(); // store calendar objects for use to show calendar.

function hotelInitCal(){
	hotelDoaCal = new WCT.calendar("hotelDoa","hotelCal1Container","hotelCalendarBoxArrive",document.getElementById("HotelSearch").chk_in,"DOA");            
	hotelDodCal = new WCT.calendar("hotelDod","hotelCal2Container","hotelCalendarBoxDepart",document.getElementById("HotelSearch").chk_out,"doD");
	hotelDoaCal.addLinkedCal(hotelDodCal);
	hotelDodCal.addLinkedCal(hotelDoaCal);     

	htlCalArray.push(hotelDoaCal);
	htlCalArray.push(hotelDodCal);
}

function htlSplitDate(){
	hotelDoaCal.returnSelectedDate("doa_yy","doa_mm","doa_dd");
	hotelDodCal.returnSelectedDate("dod_yy","dod_mm","dod_dd");
}

function getCT_XStyle(){
	var bkImg = null;
	var x=document.getElementById('ad_link');
	try
	{
		if (window.getComputedStyle  ){
			var cStyle = window.getComputedStyle(x, "");
			bkImg = cStyle.getPropertyValue("background-image");
		}else{
			bkImg = x.currentStyle.backgroundImage;
		}     

		if(bkImg.match("save220.gif")){
			document.getElementById("ct_info_link").style.display = 'block';
		}
	}catch(e){}
}


window.onload = function myonload(){
	loadTripForm();
	loadWeather(10028,'weatherContainer');
	getCT_XStyle();
	
	document.getElementById('searchType_home').checked=true;

	//for hotel

	//initPopUp();??!
	//initPopUp();
	//air


}
//var declaration en-mass
//hotel
var validateError = new Object();
//for air
var airDoaCal;
var airDodCal;
var airCalArray = new Array(); // store calendar objects for use to show calendar.
//
var validateError = new Object();
//airhotel
var customtripDoaCal;
var customtripDodCal;
var ctCalArray = new Array(); // store calendar objects for use to show calendar.
var validateError = new Object();
//car
var carDoaCal;
var carDodCal;
var carCalArray = new Array(); // store calendar objects for use to show calendar.

loadErrorTranslation(validateError);

function  toggleTime(dateType)
{
	if (dateType == 'exact'){hide('departDateFlexibility');hide('returnDateFlexibility');showInline('dateLeavingTime');showInline('dateReturningTime');}
	if (dateType == 'plusMinus'){showInline('departDateFlexibility');showInline('returnDateFlexibility');hide('dateLeavingTime');hide('dateReturningTime');}
}
function hide(idLayer) { 
//	alert(idLayer);
//	alert(document.getElementById(idLayer));
//	try {
		if(typeof(idLayer) != "object")
		{
	//		try
			{
				document.getElementById(idLayer).style.display='none'; 
			}
		//	catch(error){}
		}
		else
		{	
			idLayer.style.display='none'; 
		}
//	}
//	catch(e){};
}
function runAdvancedAirOptClose(){
	hide('popupMask');
	hide('alertPref');
	hide('popupContainer');
	resetAdvanceOption();
	hidePopWin(false);
}
function runAdvancedAirOptSave(){
		hide('popupMask');
		hide('popupContainer');
		showInline('alertPref');
		hidePopWin(false);
}
// used to hide and show elements. 
function show(idLayer) {
	try{
		if(typeof(idLayer) != "object")
			document.getElementById(idLayer).style.display='';  
		else
			idLayer.style.display='';  
	}
	catch(e){};
}

function runChangeAirSearchType(){
	var selct=document.getElementById('flightType');
	switch(selct.options[selct.selectedIndex].value){
		case 'roundtrip':
			changeAirSearchType('rt','AirSearch');
			break;
		case 'oneway':
			changeAirSearchType('ow','AirSearch');
			break;
		case	'multicity':
			changeAirSearchType('mc','AirSearch');
			break;
	}
}

function changeAirSearchType(searchType,form)
{
	var form = document.getElementById(form);
	if(searchType == "rt")  // round trip type
	{
		hide('multiCityForm');
		hide('multi_city_add');		
		show('round_way');
		show('search_options1')
		show("chk_out_lbl");
		show("chk_out");
		show(form.dateReturningTime);
		form.flightType[0].checked = true;
	}
	else if(searchType == "mc")  // multiple destinations
	{
		hide('round_way');
		show('multiCityForm');
		show('multi_city_add');
		form.dateTypeSelect[0].checked = true;
		form.flightType[2].checked = true;	
	}
	else	// one way
	{
		hide('multiCityForm');
		hide('multi_city_add');
		show('round_way');
		hide('search_options1');
		hide("chk_out_lbl");
		hide("chk_out");
		hide(form.dateReturningTime);
		hide(form.returnDateFlexibility);		
		form.dateTypeSelect[0].checked = true;
		form.flightType[1].checked = true;		
	}		
	clearSearchForm(searchType,form);
}


function runChangeAirDateType(){
	var selct=document.getElementById('dateTypeSelect');
	switch(selct.options[selct.selectedIndex].value){
		case 'exactDates':
			toggleTime('exact');
			break;
		case 'plusMinusDate':
			toggleTime('plusMinus');
			break;
	}
}

function airInitCal(){
	airDoaCal = new WCT.calendar("airDoa","airCal1Container","airCalendarBoxArrive",document.forms["AirSearch"].chk_in21,"DOA");
	airDodCal = new WCT.calendar("airDod","airCal2Container","airCalendarBoxDepart",document.forms["AirSearch"].chk_out21,"doD");
	airDoaCal.addLinkedCal(airDodCal);
	airDodCal.addLinkedCal(airDoaCal);
	airCalArray.push(airDoaCal);
	airCalArray.push(airDodCal);
}

multiCalArray = new Array();

function showMultiCal (el,index){
	if (typeof(index) == 'number' && typeof(multiCalArray[index]) != 'object'){
		multiCalArray[index] = new WCT.calendar("mairDoa"+index,"airCal1MultiContainer"+index,"airCalendarBoxMultiArrive"+index,el,"DOA"); 
	}
	multiCalArray[index].showCalendar(multiCalArray,el);
}

function resetAdvanceOption(){
	document.forms['AirSearch'].airlineSearchPref.options[0].selected=true;
	document.forms['AirSearch'].maxConnections.checked=false;
	document.forms['AirSearch'].classOfService.options[0].selected=true;
	document.forms['AirSearch'].fareType.options[0].selected=true;
}

var customtripDoaCal;
var customtripDodCal;
var ctCalArray = new Array(); // store calendar objects for use to show calendar.

function ctInitCal(){
	customtripDoaCal = new WCT.calendar("customtripDoa","ctCal1Container","ctCalendarBoxArrive",document.forms["airHotelSearch"].chk_in3,"DOA");          
	customtripDodCal = new WCT.calendar("customtripDod","ctCal2Container","ctCalendarBoxDepart",document.forms["airHotelSearch"].chk_out3,"doD");
	customtripDoaCal.addLinkedCal(customtripDodCal);
	customtripDodCal.addLinkedCal(customtripDoaCal);   

	ctCalArray.push(customtripDoaCal);
	ctCalArray.push(customtripDodCal);
}

function ctSplitDate(){
	customtripDoaCal.returnSelectedDate("","dateLeavingMonth","dateLeavingDay");
	customtripDodCal.returnSelectedDate("","dateReturningMonth","dateReturningDay");
}

var starts = new Array();
var ends   = new Object();
var nnw = 0;

starts[0] = { t: 1249102800, v: 'Saturday, August 01, 2009', e: [1249275600,1249362000,1249448400] };
ends[0] = new Array();
ends[0][0] = {t: '1249275600', v: 'Monday, August 03, 2009'};
ends[0][1] = {t: '1249362000', v: 'Tuesday, August 04, 2009'};
ends[0][2] = {t: '1249448400', v: 'Wednesday, August 05, 2009'};

starts[1] = { t: 1249189200, v: 'Sunday, August 02, 2009', e: [1249362000,1249448400,1249534800,1249621200,1249707600,1249794000] };
ends[1] = new Array();
ends[1][0] = {t: '1249362000', v: 'Tuesday, August 04, 2009'};
ends[1][1] = {t: '1249448400', v: 'Wednesday, August 05, 2009'};
ends[1][2] = {t: '1249534800', v: 'Thursday, August 06, 2009'};
ends[1][3] = {t: '1249621200', v: 'Friday, August 07, 2009'};
ends[1][4] = {t: '1249707600', v: 'Saturday, August 08, 2009'};
ends[1][5] = {t: '1249794000', v: 'Sunday, August 09, 2009'};

starts[2] = { t: 1249275600, v: 'Monday, August 03, 2009', e: [1249448400,1249534800,1249621200,1249707600,1249794000,1249880400] };
ends[2] = new Array();
ends[2][0] = {t: '1249448400', v: 'Wednesday, August 05, 2009'};
ends[2][1] = {t: '1249534800', v: 'Thursday, August 06, 2009'};
ends[2][2] = {t: '1249621200', v: 'Friday, August 07, 2009'};
ends[2][3] = {t: '1249707600', v: 'Saturday, August 08, 2009'};
ends[2][4] = {t: '1249794000', v: 'Sunday, August 09, 2009'};
ends[2][5] = {t: '1249880400', v: 'Monday, August 10, 2009'};

starts[3] = { t: 1249362000, v: 'Tuesday, August 04, 2009', e: [1249534800,1249621200,1249707600,1249794000,1249880400,1249966800] };
ends[3] = new Array();
ends[3][0] = {t: '1249534800', v: 'Thursday, August 06, 2009'};
ends[3][1] = {t: '1249621200', v: 'Friday, August 07, 2009'};
ends[3][2] = {t: '1249707600', v: 'Saturday, August 08, 2009'};
ends[3][3] = {t: '1249794000', v: 'Sunday, August 09, 2009'};
ends[3][4] = {t: '1249880400', v: 'Monday, August 10, 2009'};
ends[3][5] = {t: '1249966800', v: 'Tuesday, August 11, 2009'};

starts[4] = { t: 1249448400, v: 'Wednesday, August 05, 2009', e: [1249621200,1249707600,1249794000,1249880400,1249966800,1250053200] };
ends[4] = new Array();
ends[4][0] = {t: '1249621200', v: 'Friday, August 07, 2009'};
ends[4][1] = {t: '1249707600', v: 'Saturday, August 08, 2009'};
ends[4][2] = {t: '1249794000', v: 'Sunday, August 09, 2009'};
ends[4][3] = {t: '1249880400', v: 'Monday, August 10, 2009'};
ends[4][4] = {t: '1249966800', v: 'Tuesday, August 11, 2009'};
ends[4][5] = {t: '1250053200', v: 'Wednesday, August 12, 2009'};

starts[5] = { t: 1249534800, v: 'Thursday, August 06, 2009', e: [1249707600,1249794000,1249880400,1249966800,1250053200] };
ends[5] = new Array();
ends[5][0] = {t: '1249707600', v: 'Saturday, August 08, 2009'};
ends[5][1] = {t: '1249794000', v: 'Sunday, August 09, 2009'};
ends[5][2] = {t: '1249880400', v: 'Monday, August 10, 2009'};
ends[5][3] = {t: '1249966800', v: 'Tuesday, August 11, 2009'};
ends[5][4] = {t: '1250053200', v: 'Wednesday, August 12, 2009'};

starts[6] = { t: 1249621200, v: 'Friday, August 07, 2009', e: [1249794000,1249880400,1249966800,1250053200] };
ends[6] = new Array();
ends[6][0] = {t: '1249794000', v: 'Sunday, August 09, 2009'};
ends[6][1] = {t: '1249880400', v: 'Monday, August 10, 2009'};
ends[6][2] = {t: '1249966800', v: 'Tuesday, August 11, 2009'};
ends[6][3] = {t: '1250053200', v: 'Wednesday, August 12, 2009'};

starts[7] = { t: 1249707600, v: 'Saturday, August 08, 2009', e: [1249880400,1249966800,1250053200] };
ends[7] = new Array();
ends[7][0] = {t: '1249880400', v: 'Monday, August 10, 2009'};
ends[7][1] = {t: '1249966800', v: 'Tuesday, August 11, 2009'};
ends[7][2] = {t: '1250053200', v: 'Wednesday, August 12, 2009'};

starts[8] = { t: 1249794000, v: 'Sunday, August 09, 2009', e: [1249966800,1250053200,1250139600,1250226000,1250312400,1250398800] };
ends[8] = new Array();
ends[8][0] = {t: '1249966800', v: 'Tuesday, August 11, 2009'};
ends[8][1] = {t: '1250053200', v: 'Wednesday, August 12, 2009'};
ends[8][2] = {t: '1250139600', v: 'Thursday, August 13, 2009'};
ends[8][3] = {t: '1250226000', v: 'Friday, August 14, 2009'};
ends[8][4] = {t: '1250312400', v: 'Saturday, August 15, 2009'};
ends[8][5] = {t: '1250398800', v: 'Sunday, August 16, 2009'};

starts[9] = { t: 1249880400, v: 'Monday, August 10, 2009', e: [1250053200,1250139600,1250226000,1250312400,1250398800,1250485200] };
ends[9] = new Array();
ends[9][0] = {t: '1250053200', v: 'Wednesday, August 12, 2009'};
ends[9][1] = {t: '1250139600', v: 'Thursday, August 13, 2009'};
ends[9][2] = {t: '1250226000', v: 'Friday, August 14, 2009'};
ends[9][3] = {t: '1250312400', v: 'Saturday, August 15, 2009'};
ends[9][4] = {t: '1250398800', v: 'Sunday, August 16, 2009'};
ends[9][5] = {t: '1250485200', v: 'Monday, August 17, 2009'};


function init_date_originations() {
	var orig = document.date.in_origination_key;
	var i = 0;
	for (o in originations) {
		orig.options[i] = new Option(originations[o], o);
		i++;
	}
	var idx = 0;
	i = 0;
	for (k in originations) {
		if (k == 371)
		break;
		i++;
	}
	orig.selectedIndex = i;
}

function initform(form) {
	init_date_originations();
	var ds = document.date.in_start_date;
	var de = document.date.in_end_date;

	ds.options[0] = new Option('This weekend', '1249102800,');
	de.options[0] = new Option('This weekend', '1249189200,1249275600,1249362000,1249448400');

	if (!nnw)
		ds.options[1] = new Option('Next Weekend', '1249707600,');

	var i = (nnw) ? 1 : 2;
	for (var j = 0; j < starts.length; i++, j++) {                
		ds.options[i] = new Option(starts[j].v, starts[j].t);
	}
	de.selectedIndex = 0;
}

function changeend(start_idx){
	var ds = document.date.in_start_date;
	var de = document.date.in_end_date;
	de.options.length = 0;
	if (start_idx == 0) {
		de.options[0] = new Option('This weekend', '1249189200,1249275600,1249362000,1249448400');
	}
	else if (start_idx == 1 && !nnw) {
		de.options[0] = new Option('Next Weekend', '1250312400,1250398800,1250485200,1250571600,1250658000');
	}
	else {
		var e = (nnw) ? start_idx - 1 : start_idx - 2;
		for (var i = 0; i < ends[e].length; i++) {
			de.options[i] = new Option(ends[e][i].v, ends[e][i].t);
		}
	}
	de.selectedIndex = 0;
}

function showDates(){
	hide('lmd_dest');
	showInline('lmd_dates');
}

function showDest(){
	hide('lmd_dates');
	showInline('lmd_dest');
}
function carInitCal(){       
	carDoaCal = new WCT.calendar("carDoa","carCal1Container","carCalendarBoxArrive",document.forms["CarSearch"].chk_in_pudate,"DOA");            
	carDodCal = new WCT.calendar("carDod","carCal2Container","carCalendarBoxDepart",document.forms["CarSearch"].chk_out_pudate,"doD");
	carDoaCal.addLinkedCal(carDodCal);
	carDodCal.addLinkedCal(carDoaCal);     

	carCalArray.push(carDoaCal);
	carCalArray.push(carDodCal);
}

function carSplitDate(){
	carDoaCal.returnSelectedDate("","pudate_mo","pudate_dy");
	carDodCal.returnSelectedDate("","dodate_mo","dodate_dy");
}
function displayages(childobj,idnum){	
	var	minorsAge = YAHOO.util.Dom.getElementsByClassName("minorsAge","select",searchType+"_frame");
	var childAgeContainer = getChildrenBox();
	
	if (childobj.options[0].selected){hide(childAgeContainer); hide(minorsAge[0]); hide(minorsAge[1]); hide(minorsAge[2]); hide(minorsAge[3]);}
	if (childobj.options[1].selected){show('children_box_spacer'+idnum);show(childAgeContainer); showInline(minorsAge[0]); hide(minorsAge[1]); hide(minorsAge[2]); hide(minorsAge[3]);}
	if (childobj.options[2].selected){show('children_box_spacer'+idnum);show(childAgeContainer); showInline(minorsAge[0]); showInline(minorsAge[1]); hide(minorsAge[2]); hide(minorsAge[3]);}
	if (childobj.options[3].selected){show('children_box_spacer'+idnum);show(childAgeContainer); showInline(minorsAge[0]); showInline(minorsAge[1]); showInline(minorsAge[2]); hide(minorsAge[3]);}
	if (childobj.options[4].selected){show('children_box_spacer'+idnum);show(childAgeContainer); showInline(minorsAge[0]); showInline(minorsAge[1]); showInline(minorsAge[2]); showInline(minorsAge[3]);}
}
function showMoreAirOptions(){
		docwidth=get_document_window_width();
		docheight=get_document_window_height();
		
		var div=document.getElementById('popupContainer');
		div.style.display="";
		width=div.style.width.substr(0,div.style.width.indexOf('p'));
		div.style.width=convert_width(width,docwidth)+"px";
		div.style.left=calculate_left(width,docwidth)+"px";
		div.style.top=0+"px";
		
		
		var div2=document.getElementById('popupMask');
		div2.style.display="";
		div2.style.width=convert_width("100%",docwidth)+"px";
		div2.style.height=convert_height("100%",docheight)+"px";
		div2.style.left=calculate_left(div.style.width,docwidth)+"px";
		div2.style.top=calculate_top(div.style.height,docheight)+"px";
		
		
		
}
function fillTimeOptions(selectid){
	selected=document.getElementById(selectid);
	var times=new Array("12:00am","1:00am","2:00am","3:00am","4:00am","5:00am","6:00am","7:00am","8:00am","9:00am","10:00am","11:00am",
	"12:00pm","1:00pm","2:00pm","3:00pm","4:00pm","5:00pm","6:00pm","7:00pm","8:00pm","9:00pm","10:00pm","11:00pm",
	"Morning","Noon","Evening"," ")
	for(var i=0;i<times.length;i++){
		var y=document.createElement('option');
		y.value=times[i];
		if(times[i]!=" "){
			y.text=times[i];
		}else{
			y.text="Anytime";
			y.selected=true;
		}
		selected.add(y,null);
	}
}
function tripPackage(){
	window.location.href="trips/InitialSearch.do?Service=TPN&&affiliateId=10017646&subAffiliateId=none&aspHeader=customtrip&aspFooter=customtrip";
}

function wct_lmd_in_origination_key() {
  if ( ! _wct_lmd_in_origination_key ) {
    if ( document.dest != null ) {
      // Try getting it from the Select widget?
      var orig = document.dest.in_origination_key;
      if ( orig.selectedIndex >= 0 ) {
        _wct_lmd_in_origination_key = orig.options[orig.selectedIndex].value;
      }
    }
  }

  if ( ! _wct_lmd_in_origination_key ) {
    // Try getting it from the document URL?
    _wct_lmd_in_origination_key = document.location.href.match(/[?;&]in_origination_key=(\d+)/);
    _wct_lmd_in_origination_key = _wct_lmd_in_origination_key != null 
      ? _wct_lmd_in_origination_key[1] : 371; // "371" is magic for NYC.
  }

  return _wct_lmd_in_origination_key;
}

//checks all of the search boxes for errors and displayes warnings
/*function checkForm(FormName, type) {

var childrenBox = getChildrenBox();
var form = document.getElementById(FormName);


var searchForm = form;
if( type=='hotel' || type=='saverate' || type=='attractions'){ 
	var cityVal =  form.city.value;
	if(type!='attractions')
	{
		var child 	=  form.num_children.selectedIndex;
	}
}
if(type=='airHotel' || type=='air'){ 
	var leavingFromVal;
	var goingToVal;

	if(type=='air')
	{
		leavingFromVal =  form.leavingFrom.value
		goingToVal =  form.goingTo.value
	}
	else
	{
		leavingFromVal =  form.leavingFrom.value
		goingToVal =  form.goingTo.value		
	}
	var child 	=  form.num_children.selectedIndex;
}

if(type=='car' || type=='car_fd'){
	var pucityVal =  form.pucity.value
	var docityVal =  form.docity.value
}

if(type=='lmd' || type=='lastminute'){
	var toDestination = form.in_destform_state;
	var destinationCity = form.in_location_key;
}
else if (type !='air')
{	
	var chk_inVal =  form.chk_in.value;
	var chk_outVal =  form.chk_out.value;	
}
var blnPass = true;

if(type=='hotel' || type=='saverate' || type=='attractions')
	{ 
		if (cityVal == "" || cityVal == validateError.cityError) 
			{
			change("city","formWarning");
			form.city.value=validateError.cityError;
			blnPass = false;
			}
		if(typeof(child) != "undefined" && child!=0 && type !='attractions')
		{	
			for (var i=1; i<=child; i++)
			{
				var selectBox = eval("form.minorsAge" +i);
				
				if(selectBox.selectedIndex == 0)
				{
				change('warn',"warning");
				childrenBox.style.display = "block";
				blnPass = false;
				}
			}
		}
	}

if(type=='airHotel' || type=='air')
	{ 
		if(type == "air")
		{
			var airSearchType;
			
			if(form.flightType.length)
			{
				for (var i=0; i < form.flightType.length; i++)
				{
					if(form.flightType.selectedIndex == i)
					{
//						if(!confirm(form.flightType.selectedIndex))return false;
						airSearchType = form.flightType[i].value;
					}
				}
			}
			if (airSearchType == "roundtrip" || airSearchType == "oneway")		
			{
				if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
					{
					change(form.leavingFrom[0],"formWarning");
					form.leavingFrom[0].value=validateError.cityError;
					blnPass = false;
					}
				if (goingToVal == "" || goingToVal == validateError.cityError) 
					{
					change(form.goingTo[0],"formWarning");
					form.goingTo[0].value=validateError.cityError;
					blnPass = false;
					}
			}
			else
			{	// multiple destinations
				for(i=1; i<=4; i++)
				{
					var flightNum = "flight" + i;
					var currFlight = document.getElementById(flightNum);
					var chk_in1 = eval("form.leavingDate" +i);
					if (currFlight.style.display == 'block')
					{
						var leavingFromVal=eval("form.leavingFrom" +i).value;
						var goingToVal = eval("form.goingTo" +i).value;
						
						if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
							{
							change(form.leavingFrom[i],"formWarning");
							form.leavingFrom[i].value=validateError.cityError;
							blnPass = false;
							}
						if (goingToVal == "" || goingToVal == validateError.cityError) 
							{
							change(form.goingTo[i],"formWarning");
							form.goingTo[i].value=validateError.cityError;
							blnPass = false;
							}
											
						if (chk_in1.value == "" || chk_in1.value == validateError.dateError || chk_in1.value == "mm/dd/yyyy" || chk_in1.value == "dd/mm/yyyy")
						{
							change(eval("form.leavingDate" +i),"formWarning");
							eval("form.leavingDate" +i).value = validateError.dateError;
							blnPass = false;
						}
	
					}
					else
					{
						chk_in1.value = "";
					}
				}				
			}

		  if(form.chk_in[0]!='undefined'){
  			var chk_inVal =  form.chk_in[0].value;
			}else{
				var chk_inVal =  "";
			var chk_outVal =  form.chk_out.value;
			
			if (airSearchType == "oneway")
			{
				if (chk_inVal == "" || chk_inVal == validateError.dateError || chk_inVal == "mm/dd/yyyy")			
				{
					change(form.chk_in[0],"formWarning");
					form.chk_in[0].value = 	validateError.dateError;
					blnPass = false;
				}
			}
			else if(airSearchType == "roundtrip")
			{
				if (chk_inVal == "" || chk_inVal == validateError.dateError || chk_inVal == "mm/dd/yyyy" || chk_outVal == "" || chk_outVal == validateError.dateError || chk_outVal == "mm/dd/yyyy")
				{
					change(form.chk_in[0],"formWarning");
					change(form.chk_out,"formWarning");
					form.chk_in[0].value=validateError.dateError;
					form.chk_out.value=validateError.dateError;
					blnPass = false;
				}
				
			}

		}
		else  // CT
		{
			if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
				{
				change(form.leavingFrom,"formWarning");
				form.leavingFrom.value=validateError.cityError;
				blnPass = false;
				}
			if (goingToVal == "" || goingToVal == validateError.cityError) 
				{
				change(form.goingTo,"formWarning");
				form.goingTo.value=validateError.cityError;
				blnPass = false;
				}
			if (leavingFromVal == "" || leavingFromVal == validateError.cityError) 
				{
				change(form.leavingFrom,"formWarning");
				form.leavingFrom.value=validateError.cityError;
				blnPass = false;
				}
			if (goingToVal == "" || goingToVal == validateError.cityError) 
				{
				change(form.goingTo,"formWarning");
				form.goingTo.value=validateError.cityError;
				blnPass = false;
				}
		}
			
		if(typeof(child) != "undefined" && child!=0)
		{
			if(type=='air')
			{
				for (var i=0; i<child; i++)
				{				
					var selectBox = eval("form.minorsAge" +i);
					if(selectBox.selectedIndex == 0)
					{
						change('warn',"warning");				
						childrenBox.style.display = "block";
						blnPass = false;
					}
				}
			}
			else
			{
				for (var i=1; i<=child; i++)
				{				
					var selectBox = eval("form.minorsAge" +i);
					if(selectBox.selectedIndex == 0)
					{
						change('warn',"warning");				
						childrenBox.style.display = "block";
						blnPass = false;
					}
				}				
			}
		}		
	}
	
if(type=='lmd' || type=='lastminute')
{	
	if (toDestination.selectedIndex == 0)
	{
		change('warn','warning');
		blnPass = false;		
	}
	
	if (destinationCity.selectedIndex == 0)
	{
		change('warn2','warning');
		blnPass = false;		
	}

}
else{
	if(type!="air")
	{
		if (chk_inVal == "" || chk_inVal == validateError.dateError || chk_inVal == "mm/dd/yyyy" || chk_outVal == "" || chk_outVal == validateError.dateError || chk_outVal == "mm/dd/yyyy")
		{
			change(form.chk_in,"formWarning");
			change(form.chk_out,"formWarning");
			form.chk_in.value=validateError.dateError;
			form.chk_out.value=validateError.dateError;
			blnPass = false;
		}
	}
}
		
if(type=='car' || type=='car_fd')
{ 
	// check to see if "same as pickup" checkbox is checked.  Populate dropoff city if check box is checked.
	if (pucityVal == "" || pucityVal == validateError.cityError) 
	{
	change("pucity","formWarning");
	form.pucity.value=validateError.cityError;
	blnPass = false;
	}

	if (searchForm.FillCity.checked)
	{
		if (searchForm.pucity.value != "" && searchForm.pucity.value != validateError.cityError) 
		{	
			searchForm.docity.value = searchForm.pucity.value;
		}
		else
		{
			searchForm.docity.value = "";
		}
	}
	else{
		if (docityVal == "" || docityVal == validateError.cityError) 
		{
		change("docity","formWarning");
		form.docity.value=validateError.cityError;
		blnPass = false;
		}
	}
}

return blnPass;

}*/