//Quick Booking Box
//@author Jason Gabriele, Travwell
//@revised by Nick Knopf, SwiftTrip
var agencyID = 0;
var agencyPrefix = "";
var defaultSource = "";
var secureSite = "http://secure.skyharbors.com/"; //Default Secure Site

var codeFields = ['origin','destination'];

var carCodeFields = ['pickupLocation', 'dropOffLocation'];

var hotelCodeFields = ['placeString'];


//for IE
var selectFields = ['departTime','returnTime','departTimes[0]','departTimes[1]',
                    'departTimes[2]','departTimes[3]','numberOfAdults','numberOfChildren','numberOfMilitary','numberOfInfSeat','numberOfInfLap'];

var carSelectFields = ['pickupDate','dropOffDate']; 

var hotelSelectFields = ['checkinDate','checkoutDate'];

var qForm = null;
var qElements = null;
var hasRun = false;

function calendarFlightDisplay(dateField1, dateField2, dateField3) {
	if(!hasRun) {
		startBooking();
		hasRun=true;
	}
	showCalendar(dateField1, dateField2, dateField3);
}

function showMultiFlightCalendar(p_form, p_element_name, p_prev_element_name) {
    
	
	if(validateLastFlight(multiDestFlightNum) == 0)
		{
		return false;	
		}
    var item1 = null;
    var item2 = null;
    
    for (var i = 0; i < p_form.elements.length; i++) {
        if (p_form.elements[i].name == p_element_name) {
            item1Name = "forms[0].elements[" + i + "]";
            item1 = p_form.elements[i];
            break;
        }
    }

    if (p_prev_element_name != null) {
        for (var i = 0; i < p_form.elements.length; i++) {
            if (p_form.elements[i].name == p_prev_element_name) {
                item2 = p_form.elements[i];
                break;
            }
        }
    }
    
    calendarFlightDisplay(item1, item2, item1);
}

//sets up main settings - called from box js
function setupMainSettings(agencyid,prefix) {
    agencyID = agencyid;
    //Check if prefix is none
	if(prefix.toUpperCase() == "NONE") {	    
	    agencyPrefix = "";
	    defaultSource = "";
	} else {    
    	agencyPrefix = prefix.toLowerCase();
    	if(prefix.length == 3 && prefix.toUpperCase().match(/[A-Z][A-Z][A-Z]/)) {
    		    defaultSource = prefix.toUpperCase();
    	} else {
    		defaultSource = "";
    	}
	}
}

//Booking start
function startBooking() {
	if(OKToRun(1)) {
        qForm = document.forms['quick_booking_tool'];
        qElements = qForm.elements;
        if(typeof calFrameOn != "undefined") {
    	   	daySkip = 3;
    	   	iFrameSource = "";
			createCalenderHTML();
    	   	//switch frame on to take effect
    	   	calFrameOn();
    	   	createCal();
    	   	calFrameOff();
        	initBooking("departDate","returnDate");
    	}
	}
}

function startBookingNext() {
	if(OKToRun(1)) {
         bookingEngineType = "Flight";
        qForm = document.forms['quick_booking_tool'];
        qElements = qForm.elements;
        if(typeof calFrameOn != "undefined") {
        	//finish
        	initBooking("departDate","returnDate");
    	}
	}

}

function startHotelBooking() {
	if(OKToRun(1)) {
        bookingEngineType = "Hotel";
        qForm = document.forms['quick_booking_tool'];
        qElements = qForm.elements;
        //if(typeof calFrameOn != "undefined") {
        	//finish
        	initNonFlightBooking("checkinDate","checkoutDate");
    	//}
    	   	qForm.rooms.selected = 'true';
    	   	qForm.numberOfAdults.selected = 'true';	  
	}
}

function startCarBooking() {
	if(OKToRun(1)) {
         bookingEngineType = "Car";
        qForm = document.forms['quick_booking_tool'];
        qElements = qForm.elements;
        //if(typeof calFrameOn != "undefined") {
        	//finish
        	initCarBooking("pickupDate","dropOffDate");
    	//}
	}
}

//Cal and Code Field init
//param string input name
function initNonFlightBooking(cal1,cal2,cal3,cal4) {
    if(arguments.length < 1) return false;
    if(OKToRun(1) && typeof calFrameOn != "undefined") {
	   	//Start calendar
	   	var tArgs = "qElements['" + arguments[0] + "']";
	   	for(var i=1;i<arguments.length;i++) {
	   	    tArgs += ",qElements['" + arguments[i] + "']";
	   	}
		eval("setupFields(" + tArgs + ")");
	}
}

//Cal and Code Field init
//param string input name
function initCarBooking(cal1,cal2,cal3,cal4) {
    if(arguments.length < 1) return false;
    if(OKToRun(1) && typeof calFrameOn != "undefined") {
	   	//Start calendar
	   	var tArgs = "qElements['" + arguments[0] + "']";
	   	for(var i=1;i<arguments.length;i++) {
	   	    tArgs += ",qElements['" + arguments[i] + "']";
	   	}
		eval("setupFields(" + tArgs + ")");
	}
}

//Cal and Code Field init
//param string input name
function initBooking(cal1,cal2,cal3,cal4) {
    if(arguments.length < 1) return false;
    if(OKToRun(1) && typeof calFrameOn != "undefined") {
	   	//Start calendar
	   	var tArgs = "qElements['" + arguments[0] + "']";
	   	for(var i=1;i<arguments.length;i++) {
	   	    tArgs += ",qElements['" + arguments[i] + "']";
	   	}
	    eval("setupFields(" + tArgs + ")");
	}
}

var isIE = false;
//Does browser support advanced features
//@param int Level of browser required
function OKToRun(level) {
	isIE = (document.all) ? true : false;
	var agent = navigator.userAgent.toLowerCase();
	if(level == 1) {
		if((document.all || document.getElementById) && agent.indexOf('windows ce')==-1 &&
			agent.indexOf('blackberry')==-1) {
			return true;
		} else {
			return false;
		}
	} else if(level == 2) {
	    if(agent.toLowerCase().indexOf("khtml")!=-1 && agent.toLowerCase().indexOf("applewebkit")!=-1) {
	        var appleTest = agent.toLowerCase().indexOf("applewebkit");
	        var appleVersion = parseFloat(agent.substring(appleTest+12,appleTest+17));
	        //417.8 is the version that supports setselection
	        if(!isNaN(appleVersion) && appleVersion>=417.8) { 
	            return true;
            } else {
                return false;
            }
	    } else if(agent.indexOf("msie 6.")!=-1 || agent.indexOf('gecko')!=-1 || agent.indexOf("msie 7.")!=-1) {
			return true;
		} else {
			return false;
		}
	}
}


function submitForm() {
    if(typeMode == "flights-multi") {
        for(var i=0;i<4;i++) {
            if(qElements['origins[' + i + ']'].value=="" && qElements['dests[' + i + ']'].value=="") {
                qElements['departDates[' + i + ']'].value = "";
            }
        }
    }
	qElements['submitbutton'].disabled = true;
	qForm.submit();
}

//Taken from http://www.quirksmode.org/about/copyright.html
function bookFindPos(obj) {
	var curleft = 0;
	var curtop = 0;
	if(obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else if(obj.x) {
		curleft += obj.x;
		curtop += obj.y;
	}
	return {x: curleft, y: curtop};
}

/*this function will change the number of adults select box from 1 to 0
  if the military selected is 1 */
  function checkForMilitary(){
	var numMil = document.quick_booking_tool.numberOfMilitary.value ;
	if( numMil > 0 ){
		document.quick_booking_tool.numberOfAdults.value = 0 ;
	}
	else{
		document.quick_booking_tool.numberOfAdults.value = 1 ;
	}
  }
  
 
  
  /*This function will check if the child alone is 
  selected before processing requests  */
  function checkForChildAlone()
  { 	
  

	var numAdlt = document.quick_booking_tool.numberOfAdults.value ;
	//var numSnr = document.quick_booking_tool.numberOfSeniors.value ;
	var numChild = document.quick_booking_tool.numberOfChildren.value ;
	
	if( ( numAdlt == 0 )  && (numChild > 0 ) ) 
	{
		alert( "Child must be accompanied by at least one adult, or senior.");	
		document.quick_booking_tool.submitbutton.disabled = true ;
	}
	else
	{
		document.quick_booking_tool.submitbutton.disabled = false ;
	}

  }
  
    /*This function will check if the child alone is 
  selected before processing requests  */
  function checkForChildAloneHotel()
  { 	
  
	var numAdlt = document.quick_booking_tool.numberOfAdults.value ;
	var numChild = document.quick_booking_tool.numberOfChildren.value ;
	var numMil = 0;
	if( (( numAdlt == 0 )) && (numChild > 0 ) ) 
	{
		alert( "Child must be accompanied by at least one adult, or senior or military.");	
		document.quick_booking_tool.submitbutton.disabled = true ;
	}
	else
	{
		document.quick_booking_tool.submitbutton.disabled = false ;
	}

  }
  
  /* This function will prompt the user to advanced search
     if they select yes in the infant dd box */
  function checkForInfantLap(){
	var numInfLap = document.quick_booking_tool.numberOfInfSeat.value;
	
	if( numInfLap > 0 )
	{
		window.location.href= secureSite + agencyPrefix + '/do/flight/RoundTripSearch?ag=' + agencyID;	
	}
  }
  
  function writeBox(aid,prefix,x) {
	setupMainSettings(aid,prefix);
	
	if(OKToRun(1)) {
		if(x == 0)
			getFlights();
		else if(x == 1)
			getHotels();
		else if(x == 2)
			getCars();
		else if(x == 3)
			getCruises();
		else if(x == 4)
			getVacations();
	}
}

function getFlights() {
	//
	document.getElementById('replace').innerHTML = "<form name='quick_booking_tool' action='http://secure.thetravelauthority.com/do/flight/ProcessRoundTripSearch?ag=32' method='post'>		<table width='454' border='0' cellspacing='0' cellpadding='0' class='bookingsearchA'><tr><td width='316' height='140' align='center' valign='top'><table width='306' height='100' border='0' cellpadding='0' cellspacing='0'><tr><td width='151' height='10'></td><td width='10' height='10'></td><td width='149' height='10'></td></tr><tr><td align='left' height='15'>Leaving From:</td><td height='15'></td><td align='left' height='15'>Going to:</td></tr><tr><td align='left' height='23'><input name='origin' type='text' id='depart' onfocus='void hideCalendar()' onblur=\"replaceLocation('origin')\" autocomplete='off' onKeyPress='return disableEnterKey(event)' onkeyup='showHint(event,this)'  size='15' /></td><td height='23'></td><td align='left' height='23'><input name='destination' type='text' id='arrive' onfocus='void hideCalendar()' onKeyPress='return disableEnterKey(event)' onblur=\"replaceLocation('destination')\" autocomplete='off' onkeyup='showHint(event,this)'  size='15' /></td></tr><tr><td height='52'><table width='150' height='47' border='0' cellpadding='0' cellspacing='0'><tr><td align='left' width='97' height='15'>Departing:</td><td align='left' width='53' height='15'>Time:</td></tr><tr><td align='left'><input type='text' onfocus='javascript:setCalOption(1);calendarFlightDisplay(qForm.departDate, qForm.departDate, qForm.returnDate);' value='' size='8' maxlength='10' name='departDate'/></td><td align='left'><select name='departTime' onfocus='void hideCalendar()' style='width:68px' id='booking_timeofday_1'><option value='anytime'>All Day</option><option value='06:00'>Morning</option><option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></td></tr></table></td><td height='52'></td><td height='52'><table width='150' height='47' border='0' cellpadding='0' cellspacing='0'><tr><td align='left' width='97' height='15'>Return:</td><td align='left' width='53' height='15'>Time:</td></tr><tr><td align='left'><input type='text' onfocus='javascript:setCalOption(2);calendarFlightDisplay(qForm.returnDate, qForm.departDate, qForm.returnDate);' value='' size='8' maxlength='10' name='returnDate'/></td><td align='left'><select name='returnTime' onfocus='void hideCalendar()' style='width:68px' id='booking_timeofday_3'><option value='anytime'>All Day</option><option value='06:00'>Morning</option><option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></td></tr></table></td></tr></table><table align='left' width='307' border='0' cellspacing='0' cellpadding='0' class='bookingsearch'><tr><td width='5'></td><td align='left'>Adults (18-64)</td><td align='left'></td><td align='left'>Child (0-17)</td></tr><tr><td width='5'></td><td align='left'><select name='numberOfAdults' onfocus='void hideCalendar()' onchange='checkForChildAlone()'><option value='0'>0</option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></td><td align='left'></td><td align='left'><select name='numberOfChildren' onfocus='void hideCalendar()' onchange='checkForChildAlone()'><option value='0' selected>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></td></tr></table></td><td width='1'><img src='/structure/images/login-dottedline-ver.gif' width='1' height='120'></td><td width='135' align='right' valign='top'><table width='128' height='135' border='0' cellspacing='0' cellpadding='0' class='bookingsearchB'><tr><td height='15'></td></tr><tr><td height='20'><input type='image' src='/structure/images/booking-search.gif' onMouseOver='compareFields()' alt='Search for Flights' border='0' /></td></tr><tr><td height='15' align='center'></td></tr><tr><td height='50'></td></tr><tr><td height='35' align='center'><a style='color:#FFFFFF;'  href='https://secure.thetravelauthority.com/do/flight/RoundTripSearch?ag=32'>Advanced Search Options:<br />(One way, multi-dest., etc...)</a></td></tr></table></td></tr></table></form>";
	qForm = document.forms['quick_booking_tool'];
    qElements = qForm.elements;
	initBooking("departDate","returnDate");
}

function getHotels() {
		//
		document.getElementById('replace').innerHTML = "<form name='quick_booking_tool' action='http://secure.thetravelauthority.com/do/hotel/ProcessHotelSearch?ag=32' method='post'>		<table width='454' border='0' cellspacing='0' cellpadding='0' class='bookingsearchA'><tr><td width='316' height='140' align='center' valign='top'><table width='306' height='100' border='0' cellpadding='0' cellspacing='0'><tr><td height='10'></td></tr><tr><td align='left' height='15'>Destination:</td></tr><tr><td height='25'><input name='placeString' autocomplete='off'  onfocus='void hideCalendar()' onkeyup='showHint(event,this)' onKeyPress='return disableEnterKey(event)' type='text' id='depart' size='20' /></td></tr><tr><td align='left' width='97' height='15'>Check-in:</td><td height='15'></td><td align='left'  height='15'>Check-out:</td></tr><tr><td align='left'><input type='text' name='checkinDate' value='mm/dd/yyyy' size='12' class='datebox' onfocus='javascript:setCalOption(1);calendarFlightDisplay(qForm.checkinDate, qForm.checkinDate, qForm.checkoutDate);'></td><td></td><td align='left'><input type='text' name='checkoutDate' size='12' value='mm/dd/yyyy' class='datebox' onfocus='javascript:setCalOption(2);calendarFlightDisplay(qForm.checkoutDate, qForm.checkinDate, qForm.checkoutDate);'></td></tr></table><table width='307' border='0' cellspacing='0' cellpadding='0' class='bookingsearch'><tr><td align='left' width='96'>Rooms:</td><td align='left' width='111'>Adults (18+)</td><td align='left' width='100'>Child (0-17)</td></tr><tr><td align='left'><select name='rooms' onfocus='void hideCalendar()'><option value='0'>0</option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option></select></td><td align='left'><select name='numberOfAdults' onfocus='void hideCalendar()' onchange='checkForChildAloneHotel()'><option value='0'>0</option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></td><td align='left'><select name='numberOfChildren' onfocus='void hideCalendar()' onchange='checkForChildAloneHotel()'><option value='0' selected>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select></td></tr><tr><td height='4'></td></tr></table></td><td width='1'><img src='/structure/images/login-dottedline-ver.gif' width='1' height='120'></td><td width='135' align='right' valign='top'><table width='128' height='135' border='0' cellspacing='0' cellpadding='0' class='bookingsearchB'><tr><td height='15'></td></tr><tr><td height='20'><input type='image' src='/structure/images/booking-search.gif' alt='Search for Flights' border='0' /></td></tr><tr><td height='15' align='center'>&nbsp;</td></tr><tr><td height='50' align='center'>Enter City Name or <br>Airport codes<br> for Destination</td></tr><tr><td height='35' align='center'></td></tr></table></td></tr></table><input type='hidden' value='1' name='searchType'/><input type='hidden' value='1' name='formValue'/><input type='hidden' value='-1' name='placeId'/><input type='hidden' value='19' name='sid'/><input type='hidden' value='-1' name='engine'/></form>";
		qForm = document.forms['quick_booking_tool'];
    qElements = qForm.elements;
	startHotelBooking();
}
function getCars() {
		//
		document.getElementById('replace').innerHTML = "<form name='quick_booking_tool' action='http://secure.thetravelauthority.com/do/car/ProcessCarSearch?ag=32' method='post'>		<table width='454' border='0' cellpadding='0' cellspacing='0' class='bookingsearchA'><tr><td width='316' height='140' align='center' valign='top'><table width='306' height='140' border='0' cellpadding='0' cellspacing='0'><tr><td width='151' height='10'></td><td width='10' height='10'></td><td width='149' height='10'></td></tr><tr><td align='left' height='15'>Pick-up location:</td><td height='15'></td><td align='left' height='15'>Drop-off location:</td></tr><tr><td align='left' height='23'><input name='pickupLocation' onfocus='void hideCalendar()' autocomplete='off' onKeyPress='return disableEnterKey(event)' onblur=\"replaceLocation('dropOffLocation')\" onkeyup='showHint(event,this)'  type='text' size='13' /></td><td height='23'></td><td align='left' height='23'><input name='dropOffLocation' onfocus='void hideCalendar()' onKeyPress='return disableEnterKey(event)' onblur=\"replaceLocation('dropOffLocation')\" autocomplete='off' onkeyup='showHint(event,this)'  type='text' id='arrive' size='13' /></td></tr><tr><td height='52'><table width='150' height='47' border='0' cellpadding='0' cellspacing='0'><tr><td align='left' width='97' height='15'>Pick-up date:</td></tr><tr><td align='left'><input type='text' size='13' name='pickupDate' value='mm/dd/yyyy' class='datebox' onfocus='javascript:setCalOption(1);calendarFlightDisplay(qForm.pickupDate, qForm.pickupDate, qForm.dropOffDate);'></td></tr></table></td><td height='52'></td><td height='52'><table width='150' height='47' border='0' cellpadding='0' cellspacing='0'><tr><td align='left' width='97' height='15'>Drop-off date:</td></tr><tr><td align='left'><input type='text' size='13' name='dropOffDate' value='mm/dd/yyyy' class='datebox' onfocus='javascript:setCalOption(2);calendarFlightDisplay(qForm.dropOffDate, qForm.pickupDate, qForm.dropOffDate);'></td></tr></table></td></tr><tr><td height='40'>&nbsp;</td><td height='40'></td><td height='40'>&nbsp;</td></tr></table></td><td width='1'><img src='/structure/images/login-dottedline-ver.gif' width='1' height='120'></td><td width='135' align='right' valign='top'><table width='128' height='135' border='0' cellspacing='0' cellpadding='0' class='bookingsearchB'><tr><td height='15'></td></tr><tr><td height='20'><input type='image' src='/structure/images/booking-search.gif' alt='Search for Flights' border='0' /></td></tr><tr><td height='15' align='center'>&nbsp;</td></tr><tr><td height='40'>Enter Airport codes for Pick-up and Drop-off locations</td></tr><tr><td height='35' align='center'></td></tr></table></td></tr></table><input type='hidden' value='' name='sid'/><input type='hidden' value='1' name='formValue'/><input type='hidden' value='-1' name='engine'/><input type='hidden' value='12:00' name='pickupTime'/><input type='hidden' value='12:00' name='dropOffTime'/></form>";
		qForm = document.forms['quick_booking_tool'];
    qElements = qForm.elements;
		startCarBooking();
}


function getVacations() {
		var replacement = "<form name='quick_booking_tool' action='/ppo_results.php?vacation=true' method='post'>		<table width='454' border='0' cellspacing='0' cellpadding='0' class='bookingsearchA'><tr><td width='316' height='140' align='center' valign='top'><table width='306' height='100' border='0' cellpadding='0' cellspacing='0'><tr><td width='151' height='10'></td><td width='10' height='10'></td><td width='149' height='10'></td></tr><tr><td align='left' height='15'>Travel Type:</td><td height='15'></td><td align='left' height='15'>Destination:</td></tr><tr><td align='left' height='23'><select name='srchTravType'><option value='CRVA'>Cruises/Vacations</option><option value='CRUZ'>Cruises</option><option value='PKG'>Vacations</option><option value='TOUR'>Tours</option><option value='AUTO'>International Auto</option><option value='LODG'>Lodging</option><option value='AIR'>Air</option></select></td><td align='left' height='23'></td><td align='left' height='23'><select name='srchDestId'><option value=''>Any Destination</option><option value='62221*'>Africa</option><option value='62468*'>Alaska</option><option value='62222*'>Antarctica</option><option value='107508,62226,62228*'>Asia &amp; Middle East</option><option value='62321*'>Bahamas</option><option value='62493*'>Bermuda</option><option value='106355,106357,106365,106374,62482,62483,62484,65788,62486*'>Canada/New Eng</option><option value='62319,62442,62320,106434*'>Western Caribbean</option><option value='62327,62325,62329,62326,62321,62322,62328*'>Eastern Caribbean</option><option value='62331,62338,62336,62340,62330,62341,62342,62339,62333,62334*'>South Caribbean</option><option value='62234,62232,62235,62236,62233,62400,62408,62399,62392,62410,62396*'>Mediterranean</option><option value='62386,62373,62413,62414,62371,62372,60175,62379,62403*'>Northern Europe</option><option value='62380,62375,62385,62378,62379,62391*'>Western Europe</option><option value='62469*'>Hawaii</option><option value='62231,106338*'>Latin America</option><option value='106337*'>Mexico</option><option value='62520*'>Panama Canal</option><option value='62231*'>South America</option><option value='106339,62223*'>South Pacific</option><option value='62471,106372,106386*'>Western US</option><option value='106356,62491,106368,106375*'>Eastern US</option></select></td></tr><tr><td height='52'><table width='150' height='40' border='0' cellpadding='0' cellspacing='0'><tr><td align='left' width='97' height='15'>Month of Travel:</td></tr><tr><td align='left'><select name='srchStartTravDate'><option value=''>Any Month</option>";
		var arrMonthName = new Array();
		arrMonthName = ["January","February","March","April","May","June","July","August","September","October","November","December"];
		var ThisDate = new Date();
		var ThisMonth = ThisDate.getMonth();
		var ThisYear = ThisDate.getFullYear();
		var tmpMonthYear;
		var tmpMonthYearName;
		for ( i = 0; i < 24; i++) {
			if ( ThisMonth == 12 ) {
				ThisMonth = ThisMonth - 12;
				ThisYear = ThisYear + 1;
			}
			if ( (ThisMonth + 1) < 10 ) {
				tmpMonthYear = '0' + (ThisMonth + 1) + '*' + ThisYear + '*';
			}
			else {
				tmpMonthYear = (ThisMonth + 1) + '*' + ThisYear + '*';
			}
			tmpMonthYearName = arrMonthName[ThisMonth] + ' ' + ThisYear;
			replacement += "<option value='" + tmpMonthYear + "'>" + tmpMonthYearName + "</option>";
			ThisMonth = ThisMonth + 1;
		}
		replacement += "</select></td></tr></table></td><td height='52'></td><td height='52'>&nbsp;</td></tr></table><table width='307' border='0' cellspacing='0' cellpadding='0' class='bookingsearch'><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td height='25'></td><td height='25'></td><td height='25'></td></tr></table></td><td width='1'><img src='/structure/images/login-dottedline-ver.gif' width='1' height='120'></td><td width='135' align='right'><table width='128' height='135' border='0' cellspacing='0' cellpadding='0' class='bookingsearchB'><tr><td height='14'></td></tr><tr><td height='20'><input type='image' src='/structure/images/booking-search.gif' alt='Search for Flights' border='0' /></td></tr><tr><td height='15' align='center'></td></tr><tr><td height='50'></td></tr><tr><td height='35' align='center'></td></tr></table></td></tr></table></form>";
		document.getElementById('replace').innerHTML = replacement;
}
function getCruises() {
		var replacement = "<form name='quick_booking_tool' action='/ppo_results.php?cruise=true' method='post'>		<table width='454' border='0' cellspacing='0' cellpadding='0' class='bookingsearchA'><tr><td width='316' height='140' align='center' valign='top'><table width='306' height='140' border='0' cellpadding='0' cellspacing='0'><tr><td width='150' height='5'></td><td width='20' height='5'></td><td width='141' height='5'></td></tr><tr><td align='left' height='15'>Destination:</td><td width='20' height='15'></td><td align='left' height='15'>Length of Cruise:</td></tr><tr><td align='left' width='20' height='23'><select name='srchDestId'><option value=''>Any Destination</option><option value='62221*'>Africa</option><option value='62468*'>Alaska</option><option value='62222*'>Antarctica</option><option value='107508,62226,62228*'>Asia & Middle East</option><option value='62321*'>Bahamas</option><option value='62493*'>Bermuda</option><option value='106355,106357,106365,106374,62482,62483,62484,65788,62486*'>Canada/New England</option><option value='62319,62442,62320,106434*'>Western Caribbean</option><option value='62327,62325,62329,62326,62321,62322,62328*'>Eastern Caribbean</option><option value='62331,62338,62336,62340,62330,62341,62342,62339,62333,62334*'>Southern Caribbean</option><option value='62234,62232,62235,62236,62233,62400,62408,62399,62392,62410,62396*'>Mediterranean</option><option value='62386,62373,62413,62414,62371,62372,60175,62379,62403*'>Northern Europe</option><option value='62380,62375,62385,62378,62379,62391*'>Western Europe</option><option value='62469*'>Hawaii</option><option value='62231,106338*'>Latin America</option><option value='106337*'>Mexico</option><option value='62520*'>Panama Canal</option><option value='62231*'>South America</option><option value='106339,62223*'>South Pacific</option><option value='62471,106372,106386*'>Western US</option><option value='106356,62491,106368,106375*'>Eastern US</option></select></td><td width='20' height='23'></td><td align='left' style='right:5px' height='23'><select name='srchTravLength'><option value=''>Any Length</option><option value='0*2*'>0-2 nights</option><option value='3*6*'>3-6 nights</option><option value='7*9*'>7-9 nights</option><option value='10*14*'>10-14 nights</option><option value='14**'>Over 14 nights</option></select></td></tr><tr><td align='left' height='12'>Cruise Line:</td><td width='20'></td><td width='97' height='12'>Date:</td></tr><tr><td align='left' height='21'><select name='srchTravSupp'><option value='Azamara+Cruises'>Azamara Cruises</option><option value='Brendan+Worldwide+Vacations'>Brendan Vacations</option><option value='Carnival+Cruise+Line'>Carnival Cruise Line</option><option value='Celebrity+Cruises'>Celebrity Cruises</option><option value='Crystal+Cruises'>Crystal Cruises</option><option value='Cosmos'>Cosmos</option><option value='Cunard'>Cunard</option><option value='Disney+Cruise+Line'>Disney Cruise Line</option><option value='Globus'>Globus</option><option value='Holland+America+Line'>Holland America Line</option><option value='Norwegian+Cruise+Line'>Norwegian Cruise Line</option><option value='Oceania+Cruises'>Oceania Cruises</option><option value='Princess+Cruises'>Princess Cruises</option><option value='Regent+Seven+Seas+Cruises'>Regent Seven Seas</option><option value='Royal+Caribbean'>Royal Caribbean</option><option value='Seabourn+Cruise+Lines>Seabourn Cruises</option><option value='Silver+Sea+Cruises'>Silver Sea Cruises</option><option value='Uniworld+Grand+River+Cruises'>Uniworld Cruises</option><option value='Windstar+Cruises'>Windstar Cruises</option></select></td><td height='21' width='20'></td><td height='21'><select name='srchStartTravDate'><option value=''>Any Month</option>";
		var arrMonthName = new Array();
		arrMonthName = ["January","February","March","April","May","June","July","August","September","October","November","December"];
		var ThisDate = new Date();
		var ThisMonth = ThisDate.getMonth();
		var ThisYear = ThisDate.getFullYear();
		var tmpMonthYear;
		var tmpMonthYearName;
		for ( i = 0; i < 24; i++) {
			if ( ThisMonth == 12 ) {
				ThisMonth = ThisMonth - 12;
				ThisYear = ThisYear + 1;
			}
			if ( (ThisMonth + 1) < 10 ) {
				tmpMonthYear = '0' + (ThisMonth + 1) + '*' + ThisYear + '*';
			}
			else {
				tmpMonthYear = (ThisMonth + 1) + '*' + ThisYear + '*';
			}
			tmpMonthYearName = arrMonthName[ThisMonth] + ' ' + ThisYear;
			replacement += "<option value='" + tmpMonthYear + "'>" + tmpMonthYearName + "</option>";
			ThisMonth = ThisMonth + 1;
		}
							
		replacement += "</select></td></tr><tr><td height='36'></td><td width='20' height='36'></td><td height='36'></td></tr></table></td><td width='1'><img src='/structure/images/login-dottedline-ver.gif' width='1' height='120'></td><td width='135' align='right' valign='top'><table width='128' height='100' border='0' cellspacing='0' cellpadding='0' class='bookingsearchB'><tr><td height='15'></td></tr><tr><td height='20'><input type='image' src='/structure/images/booking-search.gif' alt='Search for Flights' border='0' /></td></tr><tr><td height='15' align='center'>&nbsp;</td></tr><tr><td height='50'></td></tr></table></td></tr></table></form>";
		document.getElementById('replace').innerHTML = replacement;
	}


function checkForChildAlone()
  { 	
  
  	var numMil = document.quick_booking_tool.numberOfMilitary.value ;
	var numAdlt = document.quick_booking_tool.numberOfAdults.value ;
	//var numSnr = document.quick_booking_tool.numberOfSeniors.value ;
	var numChild = document.quick_booking_tool.numberOfChildren.value ;
	
	var totalAdult = numMil + numAdlt;
	
	if( (totalAdult == 0) && (numChild > 0 ) ) 
	{
		alert( "Child must be accompanied by at least one adult, or senior or military.");	
		document.quick_booking_tool.submitbutton.disabled = true ;
	}
	else
	{
		document.quick_booking_tool.submitbutton.disabled = false ;
	}

  }

function createCal() {
	var calHTML = "<html><head>";
	if(typeof customBookingCSS != "undefined") {
		calHTML+= "<link rel='stylesheet' href='" + customBookingCSS + "' type='text/css'>";
	} else {
		calHTML+= "<link rel='stylesheet' href='http://secure.thetravelauthority.com/common/pub/css/calstyles.css' type='text/css'>";
	}
	calHTML+= "</head><body id='cal'><form name='calendarForm' id='calendarFormID'>";
	if(typeof customBookingPath != "undefined") {
		calHTML+= "<a href='javascript:void parent.moveMonthBackward()'><img src='" + customBookingPath + "left_arrow.gif' alt='Move backward one month'></a>";
	} else {
		calHTML+= "<a href='javascript:void parent.moveMonthBackward()'><img src='http://www.swifttrip.com/apps/calendar/left_arrow.gif' alt='Move backward one month'></a> ";
	}
	calHTML+= "<select name='monthDrop' onchange='parent.updateCalendar()'><option value='1'>January</option>";
	calHTML+= "<option value='2'>February</option><option value='3'>March</option><option value='4'>April</option>";
	calHTML+= "<option value='5'>May</option><option value='6'>June</option><option value='7'>July</option>";
	calHTML+= "<option value='8'>August</option><option value='9'>September</option><option value='10'>October</option>";
	calHTML+= "<option value='11'>November</option><option value='12'>December</option></select>";
	calHTML+= "<select name='yearDrop' onchange='parent.updateCalendar()'>";
	var currentYear = new Date().getFullYear();
	
	calHTML+= "<option value='" + currentYear + "'>" + currentYear + "</option>";
	calHTML+= "<option value='" + (currentYear+1) + "'>" + (currentYear+1) + "</option></select> ";
	if(typeof customBookingPath != "undefined") {
		calHTML+= "<a href='javascript:void parent.moveMonthForward()'><img src='" + customBookingPath + "right_arrow.gif' alt='Move forward one month'></a> ";
	} else {
		calHTML+= "<a href='javascript:void parent.moveMonthForward()'><img src='http://www.swifttrip.com/apps/calendar/right_arrow.gif' alt='Move forward one month'></a>";
	}
	calHTML+= "</form><table class='calholder'><tr><td valign='top'><div id='calendar1'>Loading...</div></td>";
	calHTML+= "<td valign='top'><div id='calendar2'>Loading...</div></td></tr></table>";
	calHTML+= "<span class='closeCal'><a href='javascript:parent.hideCalendar();'>Cancel</a> | <a href='javascript:parent.hideCalendar(true);'>Save</a></span>";
	calHTML+= "</body></html>";
	
	window.frames['cal_frame'].document.open();
	window.frames['cal_frame'].document.write(calHTML);
	window.frames['cal_frame'].document.close();
}
