// JavaScript Document

function writeBox(aid,prefix) {
	setupMainSettings(aid,prefix);
	
	if(OKToRun(1)) {
		document.write("<form name='quick_booking_tool' action='http://" + agencyPrefix + "/do/flight/ProcessRoundTripSearch?ag=" + agencyID + "' method='POST'>");
		document.write("<table class='bookingtool'>");
		document.write("<tr id='booking_fieldset_1'><td colspan='2'>");
		document.write("<p><label id='booking_field_1_label'>");
		if(typeof customBookingCode1Title != "undefined") {
	        document.write(customBookingCode1Title);
	    } else {
	        document.write("Departing Airport Code:");
	    }
		document.write("<br><input type='text' name='origin' accesskey='d' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('origin')\" autocomplete='off' value='" + defaultSource + "'></label> <a href=\"javascript:void codeList('origin')\">Airport codes</a></p>");
        document.write("<p><label id='booking_date_1_label'>Departure Date:<br><input type='text' name='departDate' value='mm/dd/yyyy' class='datebox' onfocus=\"void showCalendar(qElements['departDate'],qElements['departDate'],qElements['returnDate']);\"></label> ");
        document.write("<select name='departTime' onfocus='void hideCalendar()' id='booking_timeofday_1'><option value='anytime'>Entire Day</option><option value='06:00'>Morning</option>");
        document.write("<option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></p></td></tr>");
        document.write("<tr id='booking_fieldset_2'><td colspan='2'>");
        document.write("<p><label id='booking_field_2_label'>");
        if(typeof customBookingCode2Title != "undefined") {
	        document.write(customBookingCode2Title);
	    } else {
	        document.write("Returning Airport Code:");
	    }
        document.write("<br><input type='text' name='destination' accesskey='r' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('destination')\" autocomplete='off'></label> <a href=\"javascript:void codeList('destination')\">Airport codes</a></p>");
        document.write("<p id='booking_return_date'><label id='booking_date_2_label'>Return Date:<br><input type='text' name='returnDate' value='mm/dd/yyyy' class='datebox' onfocus=\"void showCalendar(qElements['returnDate'],qElements['departDate'],qElements['returnDate']);\"></label> ");
        document.write("<select name='returnTime' onfocus='void hideCalendar()' id='booking_timeofday_3'><option value='anytime'>Entire Day</option><option value='06:00'>Morning</option>");
        document.write("<option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></p>");
        document.write("</td></tr><tr id='booking_titleset_3' style='display: none'><td colspan='2' class='titlebar' id='booking_title_3'>Flight 1:</td>");
        document.write("</tr><tr id='booking_fieldset_3' style='display: none'><td colspan='2'>");
        document.write("<p><label id='booking_field_3_label'>From (Airport Code):<br><input type='text' name='origins[0]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('origins[0]')\" autocomplete='off' value='" + defaultSource + "'></label> <a href=\"javascript:void codeList('origins[0]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_field_3b_label'>To (Airport Code):<br><input type='text' name='dests[0]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('dests[0]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('dests[0]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_date_3_label'>Departure Date:<br><input type='text' name='departDates[0]' value='mm/dd/yyyy' class='datebox'></label> ");
        document.write("<select name='departTimes[0]' onfocus='void hideCalendar()' id='booking_timeofday_3'><option value='anytime'>Entire Day</option>");
        document.write("<option value='06:00'>Morning</option><option value='12:00'>Afternoon</option><option value='18:00'>Evening</option>");
        document.write("</select></p></td></tr><tr id='booking_titleset_4' style='display: none'><td colspan='2' class='titlebar' id='booking_title_4'>Flight 2 (Optional):</td>");
        document.write("</tr><tr id='booking_fieldset_4' style='display: none'><td colspan='2'>");
        document.write("<p><label id='booking_field_4_label'>From (Airport Code):<br><input type='text' name='origins[1]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('origins[1]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('origins[1]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_field_4b_label'>To (Airport Code):<br><input type='text' name='dests[1]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('dests[1]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('dests[1]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_date_4_label'>Departure Date:<br><input type='text' name='departDates[1]' value='mm/dd/yyyy' class='datebox'></label> ");
        document.write("<select name='departTimes[1]' onfocus='void hideCalendar()' id='booking_timeofday_4'><option value='anytime'>Entire Day</option>");
        document.write("<option value='06:00'>Morning</option><option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></p>");
    	document.write("</td></tr><tr id='booking_titleset_5' style='display: none'><td colspan='2' class='titlebar' id='booking_title_5'>Flight 3 (Optional):</td>");
    	document.write("</tr><tr id='booking_fieldset_5' style='display: none'><td colspan='2'>");
    	document.write("<p><label id='booking_field_5_label'>From (Airport Code):<br><input type='text' name='origins[2]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('origins[2]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('origins[2]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_field_5b_label'>To (Airport Code):<br><input type='text' name='dests[2]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('dests[2]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('dests[2]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_date_5_label'>Departure Date:<br><input type='text' name='departDates[2]' value='mm/dd/yyyy' class='datebox'></label> ");
        document.write("<select name='departTimes[2]' onfocus='void hideCalendar()' id='booking_timeofday_5'><option value='anytime'>Entire Day</option><option value='06:00'>Morning</option>");
        document.write("<option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></p></td></tr><tr id='booking_titleset_6' style='display: none'>");
        document.write("<td colspan='2' class='titlebar' id='booking_title_6'>Flight 4 (Optional):</td></tr><tr id='booking_fieldset_6' style='display: none'><td colspan='2'>");
        document.write("<p><label id='booking_field_6_label'>From (Airport Code):<br><input type='text' name='origins[3]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('origins[3]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('origins[3]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_field_6b_label'>To (Airport Code):<br><input type='text' name='dests[3]' class='airportcodebox' onfocus='void hideCalendar()' onblur=\"replaceLocation('dests[3]')\" autocomplete='off'></label> <a href=\"javascript:void codeList('dests[3]')\">Airport codes</a></p>");
        document.write("<p><label id='booking_date_6_label'>Departure Date:<br><input type='text' name='departDates[3]' value='mm/dd/yyyy' class='datebox'></label> ");
        document.write("<select name='departTimes[3]' onfocus='void hideCalendar()' id='booking_timeofday_6'><option value='anytime'>Entire Day</option>");
        document.write("<option value='06:00'>Morning</option><option value='12:00'>Afternoon</option><option value='18:00'>Evening</option></select></p>");
        document.write("</td></tr>");
        document.write("<tr id='booking_optionset_1'><td><label id='booking_numadults_1'>Adults: </label></td><td align='left'><select name='numberOfAdults' onfocus='void hideCalendar()'  onchange='checkForChildAlone()'>");
        document.write("<option value='0'>0</option><option value='1' selected>1</option><option value='2'>2</option><option value='3'>3</option>");
        document.write("<option value='4'>4</option><option value='5'>5</option></select></td></tr>");
        
		document.write("<tr id='booking_optionset_1'><td><label id='booking_numchildren_1'>Children (2-15): </label></td><td align='left'><select name='numberOfChildren' onfocus='void hideCalendar()'><option value='0' selected>0</option>");
        document.write("<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>");
        document.write("</select></td></tr>"); 
        document.write("<tr><td class='searchbarl'><a href='http://" + agencyPrefix + "/do/flight/RoundTripSearch?ag=" + agencyID + "' id='booking_adv_link'>");
        if(typeof customBookingAdvLinkTitle != "undefined") {
	        document.write(customBookingAdvLinkTitle);
	    } else {
	        document.write("Advanced Search");
	    }
    	document.write("</a></td><td><input type='button' name='submitbutton' onclick='submitForm()' onmouseover='checkForChildAlone()' value='Search Flights' id='booking_button' class='s_btn'></td></tr></table></form>");
	} else {
		document.write("<table class='bookingtool'><tr>");
		document.write("<td>To search flights please use the <a href='https://" + agencyPrefix + "/do/flight/RoundTripSearch?ag=" + agencyID + "'>Flight Search Page</a></td>");
		document.write("</tr></table>");
	}
}
