/**

File Name	: TISearchAll.js

Author		: Tata Consultancy Services



Description	: This javascript displays the TIConnect Search Page on 

				Agency's web page. The destination cities displayed depends 

				on the destRegion selected by the agency/sub-agency



The following lines of code illustrates,

what is required on the customer's web page.



<SCRIPT language="JavaScript" SRC="http://crusader.travimp.com/javascript/TISearchAll.js"></script>

<SCRIPT language="JavaScript">callSearch('33501930','cloud.jpg','Y','N','N','All');</script>



################################## function Signature ####################################################################################################



callSearch('ticonnectId','bkgrnd','calendar','newPage','loadPg','destRegion','searchType','prefDest','prefDep')



Parameter		Values												Description

--------------------------------------------------------------------------------------------------------------------------------------

ticonnectId		<8 digit code>										ARC # of agency or subagency Id

bkgrnd			<image>												Disabled

calendar		Y or N												Disabled

																		Display calendar or not. If yes calendar.html needs to 

																		be copied to the directory where the page is implemented.

newPage			Y or N												Display in a new Window. "Y" displays in a new window

loadPg			Y or N												Load Page "Y" indicates travel agent will load the search box appropriately

																	"N" will load the page automatically. Dates will be starting 15 days out +7 days

destRegion		ALL - All destinations								Display only specific destinations in region

				CARIB - Caribbean destinations						Regions BDA  Bermuda, LAS  Las Vegas,NYC  New York 

				HAW - Hawaii destination							are redundant and can be accessed through the prefDest below.

				MEX - Mexico destinations

				MCH - Mexico, Caribbean and Hawaii destinations

				CARIBONLY - Caribbean destinations without Bermuda

				FL - Florida destinations

				CA - California destinations

				CONTUSA - Destinations in USA continent

				FMF - Ft Lauderdale & Miami

				MC - Mexico and Caribbean	

searchType		VCLO - Vacations and Land Only			    	    Disabled	

				LO - Land Only											Display only 'Land only' or both.

prefDest		"destCode" eg. NYC, LAS, BDA						Disabled

																		A Preferred destination  destRegion= and prefDest=NYC. 

																		Only Newyork will be available in the destination drop down and will be preselected.

																		OR............All destinations/regions with one particular destination pre selected, 

																		eg. destRegion=MEX and prefDest=ACA. Acapulco will be pre selcted with all mexico 

																		destinations in the drop down

prefDep			"depCode" eg. NYC, LAS, BDA							Departure city code 

																		A Preferred departure city will be preselected. If no value provided or the value provided is 

																		invalid the selected value will be - Select a Departure City -

##########################################################################################################################################################

*/

var ticId = '';

var prefDepartureCity = "";

var prefDestination="";

var destReg="";

var hotelCds=null;

function callSearch( ticonnectId, 

						bkgrnd, 	

						calendar, 	// Not in use now

						newPage, 	

						loadPg, 	// Not in use now 	

						destRegion, 

						searchType, // Not in use now

						prefDest,	

						prefDep,

                        hotelcodes,

                        bcolor)

{

			//var imgpath = "/images/tic/";

 			var imgpath = "http://content.travimp.com/images/tic/";

			var trackOrigin = document.referrer;

			ticId = ticonnectId;

			destReg=destRegion.toUpperCase();		    

		 	if( searchURL == null || searchURL == "" ) {

		 		var searchURL = document.URL;

			}

			if( destRegion != null && destRegion != '') {

				destRegion = destRegion.toUpperCase();

			}			



            hotelCds=hotelcodes;

            //set dynamic bg color

            bgColor="#ffffff";

			

			if(bcolor!=null && bcolor!=""){

			bgColor=bcolor;

			}





			document.write("<HEAD>");

			document.write("<TITLE>TIConnect Search Page</TITLE>");

			document.write("<META http-equiv=Content-Type content='text/html; charset=iso-8859-1'>");

			document.write("<META content='MSHTML 6.00.2900.2873' name=GENERATOR>");

			document.write("<LINK rel='stylesheet' href='http://crusader.travimp.com/calendar.css' media='screen'></LINK>");

            document.write("<LINK rel='stylesheet' href='http://crusader.travimp.com/tic.css' media='screen'></LINK>");



			// UnComment the below code for Production

			//document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/calendarTIC.js'></SCRIPT>");

			//document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/SearchPageLd.js'></SCRIPT>");

			//document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/TISearchAllHotels.js'></SCRIPT>");

			//document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://localhost:8080/TIDirect/javascript/GetlistData.js'></SCRIPT>");

			

			// Comment the below code for Production

			

			document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/calendarTIC.js'></SCRIPT>");

			document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/SearchPageLd.js'></SCRIPT>");

			document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/TISearchAllHotels.js'></SCRIPT>");

			document.write("<SCRIPT language='JavaScript' type='text/javascript' src='http://crusader.travimp.com/javascript/GetlistData.js'></SCRIPT>");

			

			document.write("<style>.colorsb { BACKGROUND-COLOR: "+bgColor+" } </style> ");

			document.write("</HEAD>");



			document.write("<BODY>");

			document.write("<P>&nbsp;");

			document.write("</P>");

			// this opens the wait page in the new window

			if (newPage == 'Y') {

				//document.write("<FORM action='http://crusader.travimp.com/TIDirect/TIDirectFrontServlet' method='GET' id='SearchFormTIC' name='SearchFormTIC' target=_blank>");

				document.write("<FORM action='http://crusader.travimp.com/TIDirect/TIDirectFrontServlet' method='GET' id='SearchFormTIC' name='SearchFormTIC' target=_blank>");

			}

			else { // this opens the wait page in the same window

			 	//document.write("<FORM action='http://crusader.travimp.com/TIDirect/TIDirectFrontServlet' method='GET' id='SearchFormTIC' name='SearchFormTIC'>");

			 	document.write("<FORM action='http://crusader.travimp.com/TIDirect/TIDirectFrontServlet' method='GET' id='SearchFormTIC' name='SearchFormTIC'>");

			}

			 document.write("<input type=hidden name=request_type  value='waitsearch'>")

			 

			document.write("<TABLE class=color05 cellSpacing=0 cellPadding=1 width=322 border=0 id=mainTable>");

  			document.write("<TBODY>");

  			document.write("<TR>");

  			document.write("<TD>");

   			document.write("<TABLE  cellSpacing=0 cellPadding=1 width=320 class=colorsb  border=0 background='http://content.travimp.com/images/tic/" + bkgrnd + "'>");

			document.write("<TBODY>");

			document.write("<TR>");

			document.write("<TD align=right colSpan=2>");

			document.write("<IMG height=10  src='"+imgpath+"mt.gif' width=236");

			document.write("</TD>");

			document.write("</TR>");

			

	// Trip Type

			document.write("<TR >");

			document.write("<TD align=right width=90 height=11>");

			document.write("<SPAN class=style02>Trip  Type:</SPAN>");

			document.write("</TD>");

			document.write("<TD width=246>");

			document.write("<SELECT class=style01 style='WIDTH: 130px' size=1   name='tripType' id='tripType' onChange='displayRoomOpt(this.value)'>");

			if(searchType!="LO"){

			document.write("<OPTION value='FL-HL' selected>Flight and Hotel</OPTION>"); 

			}

            if(searchType!="VC"){

			document.write("<OPTION value='HL'>Hotels</OPTION>");

            }

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");



	// From: (Departure City)

			document.write("<TR>");

			document.write("<TD align=right height=1>");

			document.write("<SPAN class=style02>From:</SPAN>"); 

			document.write("</TD>");

			document.write("<TD>");

			document.write("<SELECT class=style01 style='WIDTH:200px' id=selFrom name=selFrom>");			

			document.write("<OPTION selected value='- Select a Departure City -'>- Select a Departure City-</OPTION>");

			prefDepartureCity = prefDep;

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");

			

	// To: (Destination City)

			document.write("<TR>");

			document.write("<TD align=right height=23>");

			document.write("<SPAN class=style02>To:</SPAN>");

			document.write("</TD>");

			document.write("<TD>");

			document.write("<SELECT class=style01 style='WIDTH:200px' id=selTo name=selTo onChange='resetRButton();'>"); 

			document.write("<OPTION selected value='- Select a Destination City -'>- Select a Destination -</OPTION>");

			prefDestination=prefDest;

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");



	// Departure Date

			document.write("<TR>");

			document.write("<TD align=right height=23 class=style02>");

			document.write("<SPAN ID='lblDepart'>Departure</SPAN><SPAN ID='lblChkIn' STYLE='display:none;'>Check in</SPAN>:");

			document.write("</TD>");

			document.write("<TD>");

			document.write("<INPUT class=style01 maxLength=10 size=8 id='txtLeave' name='txtLeave'>");

			document.write("<SPAN class=style01>&nbsp;(mm/dd/yyyy)&nbsp;</SPAN>");

			document.write("<IMG  height=14 src='"+imgpath+"cal_itin.gif' onclick='displayCalendar(document.SearchFormTIC.txtLeave,\"mm/dd/yyyy\",this)' width=16>");

			document.write("</TD>");

			document.write("</TR>");



	// Return Date

			document.write("<TR>");

			document.write("<TD align=right height=23 class=style02>");

			document.write("<SPAN ID='lblReturn'>Return</SPAN><SPAN ID='lblChkOut' STYLE='display:none;'>Check out</SPAN>:");

			document.write("</TD>");

			document.write("<TD>");

			document.write("<INPUT class=style01 maxLength=10 size=8 id='txtReturn' name='txtReturn' onFocus='return fCalDt()'>");

			document.write("<SPAN class=style01>&nbsp;(mm/dd/yyyy)&nbsp;</SPAN>");

			document.write("<IMG  height=14 src='"+imgpath+"cal_itin.gif' width=16 onclick='fCalDt();displayCalendar(document.SearchFormTIC.txtReturn,\"mm/dd/yyyy\",this)'>");

			document.write("</TD>");

			document.write("</TR>");



	// Select Specific Hotel

		

			document.write("<TR id='lblhotel' name='lblhotel'>");

			document.write("<TD align=right height=23>");

			document.write("<SPAN class=style02>Hotel(s):</SPAN>");

			document.write("</TD>");

			document.write("<TD>");

			document.write("<INPUT name='hotelSel' type='radio' value='Y' onclick='hideHotelList()' Tabindex='5' checked='checked'>"); 

			document.write("<SPAN  class=style01>All </SPAN>");

			document.write("<INPUT name='hotelSel' type='radio' value='N' onclick= 'showHotelData(document.SearchFormTIC.selTo.value)'>");

			document.write("<SPAN class=style01>Select Specific Hotel</SPAN>");

			document.write("</TD>");

			document.write("</TR>");

			document.write("<TR id='l_hotelList' style=display:none;>");

			document.write("<TD align=right height=6>&nbsp;</TD>");

			document.write("<TD><SELECT multiple id=hotelList name=hotelList Tabindex='7' class='style01' style='width: 200px;'> </TD></TR>");

			document.write("<TR>");

			document.write("<TD align=right height=6><IMG height=1 src='TIConnect Search Page_files/mt.gif' width=1></TD>");

			document.write("<TD><IMG height=1 src='TIConnect Search Page_files/mt.gif' width=1></TD></TR>");

	

            // Select Hotel Star Rating

			document.write("<TR id='hotelRating' name='hotelRating'>");

			document.write("<TD align=right height=23 ><SPAN class=style02>Rating:</SPAN></TD>");

			document.write("<TD>");

			document.write("<INPUT type=radio name='hotelRatings' type='radio' value='A' style='display:none'>");

			document.write("<SPAN ID='l_option0' class=style01 style='display:none'>All</SPAN> " ); 

			document.write("<INPUT name='hotelRatings' type='radio' value='4' style='display:none'>");

			document.write("<SPAN id=l_option1 class=style01 style='display:none'>4 & 5 Star</SPAN> ");

			document.write("<INPUT name='hotelRatings' type='radio' value='3' style='display:none'>");

			document.write("<SPAN id=l_option2 class=style01 style='display:none'>3 Star</SPAN>");

			document.write("</TD>");

			document.write("</TR>");

	// No. of Rooms

			document.write("<TR id='lblroom' name='lblroom'>");

			document.write("<TD class=style02 align=right height=23>Rooms:");

			document.write("</TD>");

			document.write("<TD class=style01>");

			document.write("<SELECT class=style01 style='WIDTH: 36px'  id='NoRooms' name='NoRooms' onChange='return room2Rows(this.value);'>"); 

			document.write("<OPTION selected value='1'>1</OPTION>");

			document.write("<OPTION value='2'>2</OPTION>");

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");



	// Room 1 - Label

			document.write("<TR id='Room1' name='Room1' >");

			document.write("<TD class=style02 align=right height=18>Room 1</TD>");

			document.write("<TD class=style02>&nbsp</TD>");

			document.write("</TR>");



	// Room 1 - Adults - Children

			document.write("<TR id='AdultRoom1' name='AdultRoom1'>");

			document.write("<TD class=style02 align=right height=23>Adults:</TD>");

			document.write("<TD class=style01>");

			document.write("<SELECT class=style01 style='WIDTH: 36px'  id='NoAdultsRoom1' name='NoAdultsRoom1' onChange='return show2Opt();'>"); 

			document.write("<OPTION value=1>1</OPTION>");

			document.write("<OPTION selected value=2>2</OPTION>");

			document.write("<OPTION	 value=3>3</OPTION>");

			document.write("<OPTION value=4>4</OPTION>");

			document.write("<OPTION	 value=5>5</OPTION>");

			document.write("<OPTION value=6>6</OPTION>");

			document.write("<OPTION	 value=7>7</OPTION>");

			document.write("</SELECT>");

			document.write("<IMG height=1 src='"+imgpath+"mt.gif' width=50>");

			document.write("<SPAN class=style02>Children:&nbsp;</SPAN>");

			document.write("<SELECT class=style01 style='WIDTH: 36px'  id='NoChldRm1' name='NoChldRm1' onChange='showChildAges(1,this.value)'>"); 

			document.write("<OPTION	 selected value=0>0</OPTION>");

			document.write("<OPTION value=1>1</OPTION>");

			document.write("<OPTION value=2>2</OPTION>");

			document.write("<OPTION value=3>3</OPTION>");

			document.write("<OPTION value=4>4</OPTION>");

			document.write("<OPTION value=5>5</OPTION>");

			document.write("<OPTION value=6>6</OPTION>");

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");



	// Room 1 - Children Ages

			document.write("<TR id=ages1 name=ages1 style=display:none>");

			document.write("<TD class=style02 align=right height=23>Ages:");

			document.write("</TD>");

			document.write("<TD class=style01>");

			document.write("<SELECT class=style01 style='WIDTH: 40px'  id=ChildRoom1Age1 name=ChildRoom1Age1>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01  style='WIDTH: 40px'     id=ChildRoom1Age2 name=ChildRoom1Age2>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01 style='WIDTH: 40px'  id=ChildRoom1Age3 name=ChildRoom1Age3>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01  style='WIDTH: 40px' id=ChildRoom1Age4 name=ChildRoom1Age4>"); 

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21 ; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01 style='WIDTH: 40px' id=ChildRoom1Age5 name=ChildRoom1Age5>"); 

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT><BR>");

			document.write("<SELECT class=style01  style='WIDTH: 40px'  id=ChildRoom1Age6 name=ChildRoom1Age6>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21 ; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");



	// Room 2 - Label

			document.write("<TR id='Room2' name='Room2' >");

			document.write("<TD class=style02 align=right height=18>Room 2</TD>");

			document.write("<TD class=style02>&nbsp</TD>");

			document.write("</TR>");



	// Room 2 - Adults - Children

			document.write("<TR id='AdultRoom2' name='AdultRoom2'>");

			document.write("<TD class=style02 align=right height=23>Adults:</TD>");

			document.write("<TD class=style01>");

			document.write("<SELECT class=style01 style='WIDTH: 36px'  id=NoAdultsRoom2 name=NoAdultsRoom2 onChange='return show2ChildOpt();'>"); 

			document.write("<OPTION value=1>1</OPTION>");

			document.write("</SELECT>");

			document.write("<IMG height=1 src='/TIDirectTest/images/new_search/mt.gif' width=50>");

			document.write("<SPAN class=style02>Children:&nbsp;</SPAN>");

			document.write("<SELECT class=style01 style='WIDTH: 36px'  id='NoChldRm2' name='NoChldRm2' onChange='showChildAges(2,this.value)'>"); 

			document.write("<OPTION selected value=0>0</OPTION>");

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");



	// Room 2 - Children Ages

			document.write("<TR id=ages2 name=ages2 style='display: none'>");

			document.write("<TD class=style02 align=right height=23>Ages:</TD>");

			document.write("<TD class=style01>");

			document.write("<SELECT class=style01 style='WIDTH: 40px'  id=ChildRoom2Age1 name=ChildRoom2Age1>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01  style='WIDTH: 40px'    id=ChildRoom2Age2 name=ChildRoom2Age2>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01 style='WIDTH: 40px' id=ChildRoom2Age3 name=ChildRoom2Age3>");

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01  style='WIDTH: 40px' id=ChildRoom2Age4 name=ChildRoom2Age4>"); 

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("<SELECT class=style01 style='WIDTH: 40px' id=ChildRoom2Age5 name=ChildRoom2Age5>"); 

			document.write("<OPTION selected value='??'>??</OPTION>");

			document.write("<OPTION value='1'>&lt;1</OPTION>");

			for( i = 1; i <= 21; i++ ) {

				document.write("<OPTION  value=" +i+ " >"+i+" ");

				document.write("</OPTION>");

			}

			document.write("</SELECT>");

			document.write("</TD>");

			document.write("</TR>");

	// Flight Carrier

	

			document.write("<TR id='flightCarrier' >");

			document.write("<TD align=right height=23><SPAN class=style02>Airline:</SPAN></TD>");

			document.write("</TD>");

			document.write("<TD>")

			document.write("<INPUT type=radio name='carrierSel' type='radio' value='N' checked='checked' onclick='Javascript:hideCarrierList();'>");

			document.write("<SPAN class=style01>All Carriers</SPAN> " );

			document.write("<INPUT type=radio name='carrierSel' type='radio' value='Y' onclick='JavaScript:showCarrierList();'>");

			document.write("<SPAN class=style01>Select Specific Airline</SPAN> " );

			document.write("</TD>");

			document.write("</TR>");

			

			document.write("<TR id='1_carrierList' style='display : none'>");

			document.write("<TD align=right height=6>&nbsp;</TD>");

			document.write("<TD><SELECT multiple id=carrierList name=carrierList Tabindex='7' class='style01' style='width: 200px;' size=4> </TD></TR>");

			document.write("<TR>");		



	

			

	// Flight Time Preference Row

			//document.write("<TR><TD colspan='2'><SPAN class=style02>&nbsp;&nbsp;Flight Time Preference</SPAN></TD></TR>");

		

			document.write("<TR id='departAirTime'>");

			document.write("<TD align=right height=23  style='width: 100px;'><SPAN class=style02>Departure:</SPAN></TD>");

			document.write("<TD>");

			document.write("<SELECT id=departTimePref name=departTimePref class='style01' style='width: 110px;'>");

			//loadFlightTimes('out');

			

			document.write("</Select>");

			

			document.write("</TD>");

			document.write("</TR>");

			

			document.write("<TR id='returnAirTime'>");

			document.write("<TD align=right height=23  style='width: 100px;'><SPAN class=style02>Return:</SPAN></TD>");

			document.write("<TD>");

			document.write("<SELECT id=retTimePref name=retTimePref class='style01' style='width: 110px;'>");

			//loadFlightTimes('out');

			document.write("</Select>");

			

			document.write("</TD>");

			document.write("</TR>");

			

	// Flight Class

			document.write("<TR id='airClass'>");

			document.write("<TD align=right height=23 ><SPAN class=style02>Class:</SPAN></TD>");

			document.write("<TD>");

			document.write("<INPUT type=radio name='airtype' type='radio' value='C' checked='checked'>");

			document.write("<SPAN class=style01>Coach</SPAN> " ); 

			document.write("<INPUT name='airtype' type='radio' value='F'>");

			document.write("<SPAN class=style01>First</SPAN> ");

			document.write("<INPUT name='airtype' type='radio' value='B'>");

			document.write("<SPAN class=style01>Business</SPAN>");

			document.write("</TD>");

			document.write("</TR>");		

			

	// Non - Stop Row

			document.write("<TR id='airNon-Stop'>");

			document.write("<TD align=right height=23 ><SPAN class=style02>Non-Stop:</SPAN></TD>");

			document.write("<TD>");

			document.write("<INPUT type=checkbox name='nonStop' value='Y'>");

			document.write("</TD>");

			document.write("</TR>");

	//

	

	// Search Button & Hidden Variables

			document.write("<TR>");

			document.write("<TD align=middle colSpan=2 height=33>");

			document.write("<INPUT type=hidden name='source' value='search'>");

			document.write("<INPUT type=hidden name='agencycode' value='" + ticonnectId + "'>");

			document.write("<INPUT type=hidden name='destRegion' value='" + destRegion + "'>");

			document.write("<INPUT type=hidden name='trackOrigin' value='" + trackOrigin + "'>");

			document.write("<INPUT type=hidden name='searchURL' value='" + searchURL + "'>");

			document.write("<INPUT type=hidden name='hr_button' id = 'hr_button' value=''>");

			document.write("<INPUT type=hidden name='cr_button' id = 'cr_button' value=''>");

            document.write("<INPUT type=hidden name='tmpHotelList' id = 'tmpHotelList' value=''>");

			document.write("<INPUT type='image' src='"+imgpath+"tic_search.gif' id='searchBtn' onClick='return fSubmit();'>");

			document.write("</TD>");

			document.write("</TR>");



	// Spacer Row

			document.write("<TR><TD>");

			document.write("<IMG height=1 src='"+imgpath+"mt.gif' width=80>");

			document.write("</TD>");

			document.write("<TD>");

			document.write("<IMG height=1 src='"+imgpath+"mt.gif' width=236>");

			document.write("</TD></TR>");

			document.write("</TBODY>");

			document.write("</TABLE>");

			document.write("</TD></TR>");

			document.write("</TBODY>");

			document.write("</TABLE>");

			

			document.write("</FORM>");

	     

			document.write("</BODY>");	

				            

	// AJAX function to populate Departure & Destination Cities

	// Now added in <BODY onload='...'>

	//		loadCities(ticonnectId);

}			





/**

 *######################################################################

 *	Function	: getXMLHttpRequest()

 *	Purpose		: Creates an XMLHttpRequest objects	

 *				  This method have cross-browser compatibility

 *#######################################################################

 */

var REQ_UNINITIALIZED = 0;

var REQ_LOADING       = 1;

var REQ_LOADED        = 2;

var REQ_INTERACTIVE   = 3;

var REQ_COMPLETED     = 4;

function getXMLHttpRequest() {



	var XMLHTTPREQUEST_MS_PROGIDS = new Array(

		"Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", 

		"Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",

		"Microsoft.XMLHTTP" );

	var httpRequest = null;



	// Create the appropriate HttpRequest object for the browser.

 	if( window.XMLHttpRequest != null )

		httpRequest = new window.XMLHttpRequest();



	else if( window.ActiveXObject != null )	{



		// Must be IE, find the right ActiveXObject.

		var success = false;

		for( var i = 0;

				i < XMLHTTPREQUEST_MS_PROGIDS.length && !success;

				i++ )	{



			try {



				httpRequest = new ActiveXObject(XMLHTTPREQUEST_MS_PROGIDS[i]);

				success = true;

			}

			catch( ex ){}

		}

	}



	// Display an error if we couldn't create one.

	if( httpRequest == null )

		alert("Error in Loading Destinations\n\n" 

			+ "Please try after sometime.");



	// Return it.

	return httpRequest;

}



var myXmlHttpRequest = getXMLHttpRequest();



/**

 *######################################################################

 *	Function	: loadCities(ticId)

 *	Purpose		: Sends an asynchronous request to server and populates

 *				  the Destination list.

 *#######################################################################

 */

function loadCities() {



	if( myXmlHttpRequest ) {

                      

		//var urlStr = 'http://crusader.travimp.com/TIDirect/DynamicSearchServlet';

		var urlStr = 'http://crusader.travimp.com/TIDirect/DynamicSearchServlet';

		var params = 'ticonnectId='+encodeURI(ticId)+'&source='+encodeURI('TISearchDynamic');

		myXmlHttpRequest.open( "POST", urlStr, true );

		/** 'Content-Type' header is to be used only with 'POST'

		 *  If 'GET' is used the following line should be commented out. 

		 */

		myXmlHttpRequest.setRequestHeader( 'Content-Type','application/x-www-form-urlencoded' );

		myXmlHttpRequest.onreadystatechange = populateCity;

		myXmlHttpRequest.send(params);

	}

}



/**

 *######################################################################

 *	Function	: populateDestinations()

 *	Purpose		: Populates the Destination & Gateway list.

 *#######################################################################

 */

function populateCity() {

	if( myXmlHttpRequest.readyState == REQ_COMPLETED ) {



		var responseIsOK = getRequestStatus();



		if( responseIsOK ) {



			var myList = myXmlHttpRequest.responseXML;



			var errList = myList.getElementsByTagName("Error");

			if( errList.length > 0 ) {

				for( var k = 0; k < deptList.length; k++ )	{

	

					var err = myList.getElementsByTagName("Error")[k].firstChild.data;

					alert(err);

				}

			}

			

			var deptList = myList.getElementsByTagName("Gateways");

			if( deptList.length == 0 ) {

				populateDepartCities('');

			}

			else {

				for( var j = 0; j < deptList.length; j++ )	{

	

					var dept = myList.getElementsByTagName("Gateways")[j].firstChild.data;

					if( dept != null && dept != ''){

						populateDepartCities(dept);

					}

				}

			}



			var destList = myList.getElementsByTagName("Destinations");

			if( destList.length == 0 ) {

				populateDestCities('');

			}

			else {

				for( var i = 0; i < destList.length; i++ ) {

	

					var dest = myList.getElementsByTagName("Destinations")[i].firstChild.data;

					if( dest != null && dest != ''){

						populateDestCities(dest);

					}

				}

			}

		}

	}

}



/**

 *######################################################################

 *	Function	: getRequestStatus()

 *	Purpose		: Checks the response from server.

 * 				  Returns true, if response is OK, i.e. Status is 200

 *				  Else alerts with appropriate message and 

 *				  returns false.

 *#######################################################################

 */

function getRequestStatus() {



	var respStatus = myXmlHttpRequest.status;

	if( respStatus == 200 ) {



		return true;

	}

	else {

		var responseStatus = [

						//["100","Continue"],

						//["101","Switching protocols"],

						//["200","OK"],

						//["201","Created"],

						//["202","Accepted"],

						["203","Non-Authoritative Information"],

						["204","No Content"],

						["205","Reset Content"],

						["206","Partial Content"],

						["300","Multiple Choices"],

						["301","Moved Permanently"],

						//["302","Found"],

						//["303","See Other"],

						["304","Not Modified"],

						["305","Use Proxy"],

						["307","Temporary Redirect"],

						["400","Bad Request"],

						["401","Unauthorized"],

						["402","Payment Required"],

						["403","Forbidden"],

						["404","Not Found"],

						["405","Method Not Allowed"],

						["406","Not Acceptable"],

						["407","Proxy Authentication Required"],

						["408","Request Timeout"],

						["409","Conflict"],

						//["410","Gone"],

						["411","Length Required"],

						["412","Precondition Failed"],

						["413","Request Entity Too Large"],

						["414","Request-URI Too Long"],

						["415","Unsupported Media Type"],

						["416","Requested Range Not Suitable"],

						["417","Expectation Failed"],

						["500","Internal Server Error"],

						["501","Not Implemented"],

						["502","Bad Gateway"],

						["503","Service Unavailable"],

						["504","Gateway Timeout"],

						["505","HTTP Version Not Supported"]

					 ]



		 for( var i = 0; i < responseStatus.length; i++ ) {



		 	if( responseStatus[i][0] == respStatus ) {

		 	

		 		alert("An error was enountered while setting the destinations\n\r\n\r" +

		 			  "Error: " + responseStatus[i][0] + " - " + responseStatus[i][1]);

		 	}

		 }

		 return false;

	}

}



window.onload = function () { 

	loadPage();

    //loadCities();

    getData();

};



function getData(){

	//var url = 'http://crusader.travimp.com/TIDirect/DynamicSearchServlet?';

	var url = 'http://crusader.travimp.com/TIDirect/DynamicSearchServlet?';

	url += 'ticonnectId='+encodeURI(ticId)+'&source='+encodeURI('TISearchDynamic')+

					'&dataNeeded='+encodeURI('cities')+'&callback=loadData';

	var headElement = document.getElementsByTagName("head").item(0);

	var scriptTag = document.createElement("script");

	scriptTag.setAttribute("type", "text/javascript");

	scriptTag.setAttribute("src", url);

    headElement.appendChild(scriptTag);

}





function loadData( cityObj ){

	var cities = eval(cityObj);

	populateDepartCities(cityObj.Gateways);

   // change image button with agency specific style

    changeStyleWithAgcyPrefered(cityObj.AgencyStyle);

	/***********************************************************************************************************/

	/* 	31-12-2007 : The code below will select a default value for the departure city field in the search page. 

		The preferred departure city code provided is validated against the restricted departure codes for the 

		particular agency. If found invalid the default value will be - Select a Departure City -

	*/

	var isValid = false;

	var selBox = document.getElementById('selFrom');

	if(isNotNullOrEmpty(prefDepartureCity)) {

		if(null != cityObj.Gateways && "" != cityObj.Gateways) {

			var tokens = cityObj.Gateways.split(",");

			for(var j=0; j < tokens.length; j++) {		

				if(prefDepartureCity == tokens[j]) {

					isValid = true;

					break;

				}

			}

		} else {

			for(var i=0; i<departCodes.length; i++) {

				if(departCodes[i][0] == prefDepartureCity) {

					isValid = true;

					break;

				}

			}

			

		}

	}	

	if(isValid == true) {

		selBox.value = prefDepartureCity;		

	} else {

		selBox.value = "- Select a Departure City -";

	} 

	/***********************************************************************************************************/

	var preSelect = false;

	if(destReg!=null && destReg!="undefined" && destReg!="null" && destReg!=''){

	var stat=populateDestRegionCities(destReg);

			

	if(!stat){

	populateDestCities(cityObj.Destinations);

	}

	

	}else{

	//Populate All the destinations in the preffered destination list.This works only if the region value is ''.

	if(prefDestination!=null && prefDestination!=''){

	

	populateDestCities(prefDestination);

	

	if(prefDestination.length>3){

	preSelect=true;

	}

	

	}else{

	//Populate all the destinations

	populateDestCities(cityObj.Destinations);



	}

}	

	

	

	/* 	31-12-2007 : The code below will select a default value for the destination city field in the search page. 

		The preferred destination city code provided is validated against the restricted destination codes for the 

		particular agency. If found invalid the default value will be - Select a Departure City -

	*/

	

	var selBox = document.getElementById('selTo');

	

	if(!preSelect && isNotNullOrEmpty(prefDestination)) {

	

	 // try {

               //      document.SearchFormTIC.selTo[1].selected=true;



                  // } catch(Ex){



                   //

                 //  document.SearchFormTIC.selTo[1].setAttribute('selected', true);





            //   }



                   for(var i=0;i<document.SearchFormTIC.selTo.length;i++) {



                       if(document.SearchFormTIC.selTo[i].value == prefDestination) {



                           try {

                             document.SearchFormTIC.selTo[i].selected=true;



                           } catch(Ex){





                           document.SearchFormTIC.selTo[i].setAttribute('selected', true);





                       }







                       }

                  }





    

	

      if(hotelCds!=null && hotelCds!=""){



          loadSpecificHotels();  



      }



	  	}	

	

	

//populate thr flight time preference

loadFlightTimes("out");	

loadFlightTimes("in");		

makeHotelRatingCheckBoxes(cityObj.HotelRatings);	

	/***********************************************************************************************************/

}

function showHotelData(destCode){

if(destCode == "- Select a Destination City -" || destCode == null) {

	alert("Please select a destination city");

	document.SearchFormTIC.selTo.focus();

	document.SearchFormTIC.hotelSel[0].checked=true;

	return false;

}

document.getElementById("hotelRating").style.display = "none";

if(hotelCds==null || hotelCds=='' || hotelCds=='null' || hotelCds==undefined || hotelCds=='undefined'){

getHotelData(destCode);

}else{

   getCustomHotelData();

}

}





function makeHotelRatingCheckBoxes(hotelRatings){

	var hotelRatingtokens = hotelRatings.split(",");

	if( hotelRatings != "null" && 

		document.SearchFormTIC.hotelRatings != undefined) {

		var len = document.SearchFormTIC.hotelRatings.length;

		for(var i = 0; i < hotelRatingtokens.length; i++) {

			for(var j=0; j < len; j++) {

				if(document.SearchFormTIC.hotelRatings[j].value == hotelRatingtokens[i]) {

					if(i==0){

							document.SearchFormTIC.hotelRatings[j].checked = true;

							continue;

					}

					document.SearchFormTIC.hotelRatings[j].style.display = "";

					document.getElementById("l_option"+j).style.display = "";

				}

			}

		}	

	}

}



function getHotelData(destCode){

   //alert(ticId);

	//var url = 'http://crusader.travimp.com/TIDirect/DynamicSearchServlet?';

	var url = 'http://crusader.travimp.com/TIDirect/DynamicSearchServlet?';

	url += 'ticonnectId='+encodeURI(ticId)+'&source='+encodeURI('TISearchDynamic')+

			 '&destCode='+encodeURI(destCode)+'&dataNeeded='+encodeURI('hotel')+'&callback=loadHotelData';

	var headElement = document.getElementsByTagName("head").item(0);

	var scriptTag = document.createElement("script");

	scriptTag.setAttribute("type", "text/javascript");

	scriptTag.setAttribute("src", url);

    headElement.appendChild(scriptTag);

}





function loadHotelData(hotelObj) {

    //alert(hotleObj);

	var hotels = eval(hotelObj);

    //alert(hotels.);

	populateHotelData(hotelObj.Hotels);	

}



function getCustomHotelData(){

document.getElementById("tmpHotelList").value=hotelCds;



 populateBookitHotelData();  

}



/*******************************  METHOD TO CHECK IF A GIVEN STRING IS VALID *******************************/

function isNotNullOrEmpty(aString) {

	var valid = true;

	if(aString == 'undefined' || aString == null || aString == 'null' || aString == "") {

		valid = false;

	}

	return valid;

}



function loadSpecificHotels(){



    document.getElementById("tmpHotelList").value=hotelCds;





    if(prefDestination!=null && prefDestination.length==3 && document.getElementById("tmpHotelList").value!=null && hotelCds!=""){

         

         var destVal = prefDestination;//document.getElementById('selTo').value;



          	

		if(destVal != "- Select a Destination City -" &&  destVal != null) {

         document.SearchFormTIC.hotelSel[1].checked=true;



        loadHotel();



         if(hotelCds.length=6){

         document.SearchFormTIC.hotelList[0].selected = true;

         }





        }





     }



}





function loadHotel(){







	



		var destCode = prefDestination;

		

	

		document.getElementById("hotelList").length = 0;		



		var selbox	= document.getElementById("hotelList");



		htlCodes=document.getElementById("tmpHotelList").value;	

		





        var anyHotel=false;

		

		var startIndex = 0;



		var endIndex=0;



		var tokens = htlCodes.split(",");

		

		



		var indexArray	= new Array(tokens.length);



       	var index = 0;



		var flag = 0;



		for(var i=0; i<hotelCodes.length; i++) {



			



			if(hotelCodes[i][0] == destCode) {



				if(flag == 0) {



					startIndex = i;



				}



				flag = 1;



				



			} else if(flag == 1) {



				endIndex = i;



				break;



			} 



			



		}





		for(var i = 0; i < tokens.length; i++) {



		



			for(var j = startIndex; j <= endIndex; j++) {



			



				if(hotelCodes[j][1] == tokens[i].substring(3)) {



					



					indexArray[i] = j;

                    anyHotel=true;



					break;



					



				}



			}		



		}







     	indexArray.sort(SortNumeric);



         

		for(var i=0; i<indexArray.length; i++) {







           		



			var j = indexArray[i];











			



         if("undefined" != typeof(j)){



                        



             selbox.options[i] = new Option(hotelCodes[j][2],hotelCodes[j][1]);







            }



					



		}



		selbox.size=4;



		if(selbox.length<4){



		selbox.size=selbox.length;



		} 

		

	

       

		if (tokens == 'ALLHOTEL' || htlCodes=="" || anyHotel==false) {

	



			showHotelsList();	

			

			selbox.size=4;		



		}



	



		document.getElementById("l_hotelList").style.display="";



}



/****  method to change button with the style selected by the main agency *******/

function changeStyleWithAgcyPrefered(styleChoice) {

	if (styleChoice != "blue" && styleChoice != "") {

        document.getElementById("searchBtn").src = '/images/themes/'+styleChoice+'/tic_search.gif';

		var styleName = document.getElementById("mainTable").className;

		document.getElementById("mainTable").className = styleChoice+'_'+styleName;

		

	  

	}

}

/****  method to generate option FL either when FL is passed as searchtype or the flightonly flag set "Y" in the TIC_AGENCY table *******/

function allowFlightOnly(flightOnlyFlag){

 	var selTripType=document.getElementById("tripType");

	var type=document.getElementById("searchType").value;

 	if(type=='FL'||flightOnlyFlag=="Y"){

    	var optn = document.createElement("OPTION");

		optn.text = 'Flight Only';

		optn.value = 'FL';

		selTripType.options.add(optn);

	}

}


