/*#############################################################################

FILE:	SB/ataGlanceSearch.js

	Copyright (c) 2005 Navitaire Inc. All rights reserved.

	This source code is (i) proprietary to and a trade secret of Navitaire Inc.
	and (ii) protected by copyright law and international treaties.
	Unauthorized disclosure, reproduction, distribution or alteration of this
	source code, or any portion of it, may result in severe civil and criminal
	penalties and will be prosecuted to the maximum extent possible under
	the law.

	www.navitaire.com

DESCRIPTION:

	Contains javascript for the search form.  Note that this file relies on
	javascript from the jAtaGlanceSearch.wld template and dateValidation.js.

#############################################################################*/

function clicker(){
		$('#oneWayRadio').click(function() {
			  clicker();
			});
		if(document.getElementById('displaybox'))
		{
		var thediv=document.getElementById('displaybox');
		if(thediv.style.display == "none"){
			thediv.style.display = "";
			thediv.innerHTML = "<table width='100%' height='100%'><tr><td align='right' valign='middle' width='100%' height='100%'><div class='overlay_window' onClick='return clicker();'>(X)</div></td></tr><tr><td align='center' valign='middle' width='100%' height='100%'></td></tr><tr><td align='center' valign='middle' width='100%' height='100%'> Yogesghdgsdfbvgjkldfhgkldfhklhfjklhdfdfgjklhdfgjkhdfgkhdfgklhdfgkldfghdfjklghseruioti</td></tr></table>";
		}else{
			thediv.style.display = "none";
			thediv.innerHTML = '';
		}
		}
		return false;
	}
	
$(document).ready(function() {

	      		 $(".vikram").hover(function()
	      		 		 {
							 $(this).css('position', 'relative');
	                      $(this).css({'z-index' : '100000000'}); /*Add a higher z-index value so this image stays on top*/ 
	                      $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
	                          .animate({
					marginTop: '-65px', /* Set alignment back to default */
					marginLeft: '0',

	                              top: '23%',
	                              left: '2%',
	                              width: '200px', /* Set new width */
	                              height: '60px', /* Set new height */
	                              borderWidth: "0px",
	                              padding: '20px'
	                          }, 1000); /* this value of "200" is the speed of how fast/slow this hover animates */
	                  
	                      } , function() {
	                      $(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	                      $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
	                      
	                          .animate({
	                              marginTop: '0', /* Set alignment back to default */
	                              marginLeft: '0',
	                              top: '0',
	                              left: '0',
	                              width: '0px', /* Set width back to default */
	                              height: '0px', /* Set height back to default */
	                              padding: '0px',
	                              borderWidth: "0px",
	                              display: 'none'
	                          }, 300);
	                           
	                      });  
	      		
	      		 $(".vikram1").hover(function()
	      		 		 {
						        	  $(this).css('position', 'relative');
	                      $(this).css({'z-index' : '10034'}); /*Add a higher z-index value so this image stays on top*/ 
	                      $(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
	                          .animate({
	                            	top: '2%',
	                              left: '2%',
	                              width: '200px', /* Set new width */
	                              height: '200px', /* Set new height */
	                              borderWidth: "0px",
	                              padding: '20px'
	                                     }, 1000); /* this value of "200" is the speed of how fast/slow this hover animates */
	                  
	                      } , function() {
	                      $(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	                      $(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
	                      
	                          .animate({
	                              marginTop: '0', /* Set alignment back to default */
	                              marginLeft: '0',
	                              top: '0',
	                              left: '0',
	                              width: '0px', /* Set width back to default */
	                              height: '0px', /* Set height back to default */
	                              padding: '0px',
	                              borderWidth: "0px",
	                              display: 'none'
	                          }, 300);
	                           
	                      });  
	                      
	                      
	      	});
		
	var searchText 	= new Object();
	var searchPrefs	= new Object();
	captureSearchText(searchText);
	captureSearchPrefs(searchPrefs);
	/*##############################################
	#
	# Function: setDest()
	#
	# Parameter: 
	#		mkt : 1 - outbound
	#		      2 - Inbound
	#			
	#
	# Description: 
	#	       Captures the selected destination city for outbound or inbound
	#	       to be put in the skylights form.
	#*/
	function setDest( mkt )
	{
		if(document.getElementById( "to" + mkt + "Select" ))
		{
		var toList		= document.getElementById( "to" + mkt + "Select" );
		eval( "document.skylightsForm.toCity" + mkt + ".value = toList.value" );
		}
	}
	
	function fillCountry(cc)
		{
	
					while (cc.hasChildNodes()) 
					{
					cc.removeChild(cc.firstChild);
					}
					if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FAE')
					{
					var       opt         = document.createElement("option");
					opt.value        = 'AE';
					opt.appendChild(document.createTextNode('UAE, Dirhams'));
					cc.appendChild(opt);
					}
					
					else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FOM')
										{
										var       opt         = document.createElement("option");
										opt.value        = 'OM';
										opt.appendChild(document.createTextNode('Oman, Rials'));
										cc.appendChild(opt);
					}
					
					else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FSG')
										{
										var       opt         = document.createElement("option");
										opt.value        = 'SG';
										opt.appendChild(document.createTextNode('Singapore, Dollars'));
										cc.appendChild(opt);
					}
					
					else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FNP')
										{
										var       opt         = document.createElement("option");
										opt.value        = 'NP';
										opt.appendChild(document.createTextNode('Nepal, Nepal Rupees'));
										cc.appendChild(opt);
					}
					else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FTH')
					{
										var       opt         = document.createElement("option");
										opt.value        = 'TH';
										opt.appendChild(document.createTextNode('Thailand, Baht'));
										cc.appendChild(opt);
					}
																
					
					else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true')
					{
	
					var	opt         = document.createElement("option");
					opt.value        = 'IN';
					opt.appendChild(document.createTextNode('India, Indian Rupees'));
					cc.appendChild(opt);
	
					var       opt         = document.createElement("option");
					opt.value        = 'NP';
					opt.appendChild(document.createTextNode('Nepal, Nepal Rupees'));
					cc.appendChild(opt);
					
					if(searchPrefs.isAgency)
					{
					var       opt         = document.createElement("option");
					opt.value        = 'OM';
					opt.appendChild(document.createTextNode('Oman, Rials'));
					cc.appendChild(opt);
					}
					var       opt         = document.createElement("option");
					opt.value        = 'SG';
					opt.appendChild(document.createTextNode('Singapore, Dollars'));
					cc.appendChild(opt);
					var       opt         = document.createElement("option");
					opt.value        = 'TH';
					opt.appendChild(document.createTextNode('Thailand, Baht'));
					cc.appendChild(opt);
					var       opt         = document.createElement("option");
					opt.value        = 'AE';
					opt.appendChild(document.createTextNode('UAE, Dirhams'));
					cc.appendChild(opt);
					}
	
	
					return true;
	
				}
	
	function setCurrency(mkt)
	{	
		//alert(mkt);
//		var country_index_code="";
		
		var 		cc =document.getElementById("Currency_Required_Select");
		if(document.getElementById( "from" + mkt + "Select" ))
		{
			var fromList                        = document.getElementById( "from" + mkt + "Select" );
		}
		if (!fromList)
			{
			return;
			}
			
		var toList                              = document.getElementById( "to" + mkt + "Select" );
		var orig                 = fromList.options[ fromList.selectedIndex ].value;
		var dest                                = eval( "document.skylightsForm.toCity" + mkt + ".value" );
//		alert(eval("searchPrefs."+orig+"ValidINTCITYRTT")+eval("searchPrefs."+dest+"ValidINTCITYRTT"));
		if(orig != '???' && dest !='???')
		{
                   document.skylightsForm.isinternationalsector.value = 'false' ;
			if( eval("searchPrefs."+orig+"ValidINTCITYRTT")  == 'true' || eval("searchPrefs."+dest+"ValidINTCITYRTT")  == 'true' )
			{
				 document.skylightsForm.isinternationalsector.value = 'true' ;
        			if(document.getElementById('vikram1'))
				  {
				  document.getElementById('vikram1').style.display='none';
				  document.skylightsForm.SNRCITIZEN.checked=false;
          
        			  }				
			     fillCountry(cc);
			     setCurrency_Index(eval("searchPrefs."+orig+"_Currency"));

			}
			else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FAE')
			{
				while (cc.hasChildNodes()) {
												
								cc.removeChild(cc.firstChild);
				}
				var       opt         = document.createElement("option");
				opt.value        = 'AE';
				opt.appendChild(document.createTextNode('UAE, Dirhams'));
				cc.appendChild(opt);
				}
			else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FOM')
			{
				while (cc.hasChildNodes()) {
												
								cc.removeChild(cc.firstChild);
				}
				var       opt         = document.createElement("option");
				opt.value        = 'OM';
				opt.appendChild(document.createTextNode('Oman, Rials'));
				cc.appendChild(opt);
				}
					
			else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FSG')
			{
				while (cc.hasChildNodes()) {
												
								cc.removeChild(cc.firstChild);
				}
				var       opt         = document.createElement("option");
				opt.value        = 'SG';
				opt.appendChild(document.createTextNode('Singapore, Dollars'));
				cc.appendChild(opt);
			}

			else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FNP')
			{
				while (cc.hasChildNodes()) {
												
								cc.removeChild(cc.firstChild);
				}
				var       opt         = document.createElement("option");
				opt.value        = 'NP';
				opt.appendChild(document.createTextNode('Nepal, Nepal Rupees'));
				cc.appendChild(opt);
			}
			else if(searchPrefs.INTERNATIONAL_FLIGHTS=='true' && searchPrefs.agencyNumberthree == 'FTH')
			{
				while (cc.hasChildNodes()) {
												
								cc.removeChild(cc.firstChild);
				}
				var       opt         = document.createElement("option");
				opt.value        = 'TH';
				opt.appendChild(document.createTextNode('Thailand, Baht'));
				cc.appendChild(opt);
			}
			else
			{
				
				 if(document.getElementById('vikram1'))
				  {
				    document.getElementById('vikram1').style.display='';
				  }
				while (cc.hasChildNodes()) {
								
				cc.removeChild(cc.firstChild);
				}
				
				var			opt         = document.createElement("option");
				opt.value              = 'IN';
				opt.appendChild(document.createTextNode('Indian Rupees(INR)'));
				cc.appendChild(opt);
				//setCurrency_Index('IN');
//				alert('Domestic Flights Can be Paid In INR only');
			}
		}
		
	}
	/*##############################################
	#
	# Function: resetDest()
	#
	# Parameter: 
	#		mkt : 1 - outbound
	#		      2 - Inbound
	#			
	#
	# Description: 
	#	       Resets the city options for destination depending on the selected 
	#	       origin city.
	#*/
			function resetDest( mkt )
			{
			var fromList                        = document.getElementById( "from" + mkt + "Select" );

			//one roundtrip, this is called for market2, but we have hidden the controls
			if (!fromList)
			{
			return;
			}

			var toList                              = document.getElementById( "to" + mkt + "Select" );
			var orig                 = fromList.options[ fromList.selectedIndex ].value;
			var dest                                = eval( "document.skylightsForm.toCity" + mkt + ".value" );
			if(orig != '???')
			{

						setCurrency_Index(eval("searchPrefs."+orig+"_Currency"));
						
			}
			// create options and attach to optgroups
			// var cereal = document.createElement("option");
			//  cereal.value = "cereal";
			// cereal.appendChild(document.createTextNode("Cereal"));

			while (toList.hasChildNodes()) {
			   toList.removeChild(toList.firstChild);
			}
			toList.length       = 1;
			toList.options[0] = new Option("Destination");
			toList.options[0].value  = "???";
			toList.options[0].setAttribute('style', 'font-size: 1.1em;color: #1d3d90;padding:0px;border:none');

			if ( fromList.selectedIndex == 0 )
			{
			for (var i = 0; i < Airports.length; i++)
			{
			 var l_ix                  = toList.length - 1;
			 var opt_str                          = Airports[i].name;
			 //alert(opt_str+' 1 '+Airports[i].code);
			if ( searchPrefs.DISPLAY_AIRPORT_CITY_CODES == 'true' )
			{
			opt_str                 +=  " (" + Airports[i].code + ")";
			}
		 	if( eval("searchPrefs."+Airports[i].code+"ValidINTCITYRTT")  == 'true' )
			{
			opt         = document.createElement("option");
			opt.value              = Airports[i].code;
			opt.appendChild(document.createTextNode(opt_str));
			opt.setAttribute('style', 'font-size: 1.1em;color: #c42db8;font-weight: bold;padding-left:0px;padding-top:2px;padding-bottom:2px;');
			toList.appendChild(opt);
			
       
			}
			else
			{
			opt          = document.createElement("option");
			opt.value              = Airports[i].code;
			opt.appendChild(document.createTextNode(opt_str));
			opt.setAttribute('style', 'font-size: 1.1em;color: #1d3d90;padding:0px;border:none');
			toList.appendChild(opt);

			}
			
			}
			
			}
			else
			{  
			var notinternational = 0  ;
			var air                    = getAirport( orig );
			for (var i = 0; i < air.dests.length; i++)
			{
			dest_air                               = getAirport( air.dests[i] );
			// toList.length       += 1;
			//var l_ix                  = toList.length - 1;
			var opt_str                          = dest_air.name;
			var opt;
			

			if ( searchPrefs.DISPLAY_AIRPORT_CITY_CODES == 'true' )
			{
			opt_str                 +=  " (" + dest_air.code + ")";
			}


			if( eval("searchPrefs."+dest_air.code+"ValidINTCITYRTT")  == 'true' )
			{
			opt         = document.createElement("option");
			opt.value              = dest_air.code;
			opt.appendChild(document.createTextNode(opt_str));
			opt.setAttribute('style', 'font-size: 1.1em;color: #c42db8;font-weight: bold;padding-left:0px;padding-top:2px;padding-bottom:2px;');
			toList.appendChild(opt);
			 
			}
			else
			{
			opt          = document.createElement("option");
			opt.value              = dest_air.code;
			opt.appendChild(document.createTextNode(opt_str));
			opt.setAttribute('style', 'font-size: 1.1em;color: #1d3d90;padding:0px;border:none');
			toList.appendChild(opt);
		
			}

			if ( dest == dest_air.code )
			{

			opt.selected       = true;
			}
			}
			
			

//	setCurrency_Index(eval("searchPrefs."+orig+"_Currency"),eval("searchPrefs."+dest+"_Currency"));
			}

			setDest( mkt );
			setCurrency(mkt);

	}
	/*##############################################
	#
	# Function: resetDest()
	#
	# Parameter: 
	#		checkDates: flag if roundtrip flight is selected
	#		 
	#			
	#
	# Description: 
	#	       Validates and adjust the inbound date drop down boxes referring to the outbound date.
	#	       
	#*/
	function resetDates(checkDates)
	{
		var m1d_ix		= document.skylightsForm.departDay1.selectedIndex;
		var m1y_ix		= document.skylightsForm.departMonth1.selectedIndex;

		if ( checkDates ) {
			if ( m1y_ix > document.skylightsForm.departMonth2.selectedIndex ) {
				document.skylightsForm.departMonth2.selectedIndex	=  m1y_ix;
				document.skylightsForm.departDay2.selectedIndex	=  m1d_ix;
			}
			if ( ( (m1y_ix) == document.skylightsForm.departMonth2.selectedIndex )
			  && ( m1d_ix > document.skylightsForm.departDay2.selectedIndex ) ) {
				document.skylightsForm.departDay2.selectedIndex	=  m1d_ix;
			}
		}
	}
	/*##############################################
	#
	# Function: validCities()
	#
	# Parameter: 
	#			
	#
	# Description: 
	#	       Verifies if both origin and destination cities are filled-up.
	#
	# Return:	
	#		True: both origin and destination is not blank
	#		false: if otherwise
	#*/
	function validCities()
	{
		var is_valid	= true;
		if ( document.skylightsForm.from1.selectedIndex == 0 )
		{
			alert( searchText.missingDepartCity );
			is_valid	= false;
		}
		else if ( document.skylightsForm.to1.selectedIndex == 0 )
		{
			alert( searchText.missingArriveCity );
			is_valid	= false;
		}
		else if ((searchPrefs.OFFER_OPEN_JAW_ROUTES == "true") && (document.skylightsForm.travel[2].checked))
		{
			is_valid = validateOpenJawConnections();
		}
		
		return is_valid;
	}
	/*##############################################
	#
	# Function: validPax()
	#
	# Parameter: 
	#			
	#
	# Description: 
	#	       Verifies if the number of passengers are valid with this conditions:
	#		1. Does not exceed the Max allowable number of passengers (setting in PREF)
	#		2. There should be 1 or more passengers
	#		3. Number of adults should be greater or equal to number of infants 
	#
	# Return:	
	#		True: satisfies all conditions
	#		false: if otherwise
	#*/
	function validPax()
	{
		var adults = document.skylightsForm.ADULT.value;
		var infants = document.skylightsForm.INFANT.value;
		var paxTotal = 0;
		
		for (i = 0; i < searchPrefs.paxTypes.length; i++)
		{
			var paxType 	= searchPrefs.paxTypes[i];
			var paxSelect	= document.getElementById(paxType +"Select");
			paxTotal		= eval(paxTotal) + eval(paxSelect.options[paxSelect.selectedIndex].value);
		}

		if ((paxTotal > searchPrefs.MAX_PASSENGERS_ALLOWED) && ( searchPrefs.MAX_PASSENGERS_ALLOWED > 0 ))
		{
			alert("\n"	+ searchText.popup_max_passenger_amount_1
						+ searchPrefs.MAX_PASSENGERS_ALLOWED
						+ searchText.popup_max_passenger_amount_2 + "\n");
			return false;
		}

		if ( paxTotal < 1)
		{
			alert(searchText.popup_missing_passenger_amount);
			return false;
		}

		if ( (adults  / infants) < 1 )
		{
			alert(searchText.popup_too_many_infants);
			document.skylightsForm.INFANT.focus();
/*
			// If there is a default, reset it
			if( document.skylightsForm.defaultADULT.value > -1 )
			{
				var adultSelect = document.skylightsForm.ADULT;
				for(x1=0; x1 < adultSelect.length; x1++)
				{
					if( adultSelect[x1].value == document.skylightsForm.defaultADULT.value )
					{
						document.skylightsForm.ADULT.selectedIndex = x1;
						break;
					}
				}
			}
			
			var infantSelect = document.skylightsForm.INFANT;
			for(x2=0; x2 < infantSelect.length; x2++)
			{
				if( (document.skylightsForm.defaultINFANT.value == -1 && infantSelect[x2].value == 0) || 
				    (document.skylightsForm.defaultINFANT.value != -1 && infantSelect[x2].value == document.skylightsForm.defaultINFANT.value) )
				{
					document.skylightsForm.INFANT.selectedIndex = x2;
					break;
				}
			}
*/			
			return false;
		}

		return true;
	}
	/*##############################################
	#
	# Function: validDates()
	#
	# Parameter: 
	#		beginDate: valid start date (set in PREFs)
	#		endDate:  valid end date (set in PREFs)
	#
	# Description: 
	#	       Checks the selected dates against the beginDate and endDate parameter
	#	       
	#
	# Return:	
	#		True: valid date/s
	#		false: if otherwise
	#*/
	function validDates(beginDate, endDate)
	{
		var is_valid			= true;
		var beginDateString		= new String (beginDate);
		var endDateString		= new String (endDate);
		var departDateString	= captureDateString("departDay1", "departMonth1");
		var arriveDateString	= captureDateString("departDay2", "departMonth2");

		date_message = searchText.popup_pre_flight_date_1 +
						searchText.popup_initial_flight_date +
						searchText.popup_pre_flight_date_2;
						
		if ( departDateString < beginDateString )
		{
			alert( date_message );
			setDate( "departDay1", "departMonth1", beginDateString );
			if( isRoundTrip() && arriveDateString < beginDateString )
				setDate( "departDay2", "departMonth2", beginDateString );
			return false;
		}

		if ( searchPrefs.final_date_used )
		{
			if( departDateString > endDateString )
			{
				is_valid = false;
				setDate( "departDay1", "departMonth1", endDateString );
			}
			if( isRoundTrip() && ( arriveDateString > endDateString ) )
			{
				is_valid = false;
				setDate( "departDay2", "departMonth2", endDateString );
			}
			if( !is_valid )
			{
				alert( searchText.popup_post_live_flight_date_1 +
						searchText.popup_final_flight_date +
						searchText.popup_post_live_flight_date_2 );
				return false;
			}
		}

		// check that dates are valid calandar dates
		if(!validateCalendarDate("departDay1", "departMonth1", true, true))
		{
			if( isRoundTrip() || ( !isOneWay() && searchPrefs.OFFER_OPEN_JAW_ROUTES == 'true' ) )
			{
				validateCalendarDate("departDay2", "departMonth2", false, true);
			}
			return false;
		}
		if(	( isRoundTrip() || ( !isOneWay() && searchPrefs.OFFER_OPEN_JAW_ROUTES == 'true' ) ) && !validateCalendarDate("departDay2", "departMonth2", true, true) )
		{
			return false;
		}

		if ( isRoundTrip() || ( !isOneWay() && searchPrefs.OFFER_OPEN_JAW_ROUTES == 'true' ) )
		{
			if ( !validateDateOverlap("departDay1", "departMonth1", "departDay2", "departMonth2", true, true) )
			{
				return false;
			}
			else if ( searchText.sameDayWarning && arriveDateString == '' + departDateString )
			{
				is_valid		= confirm( searchText.sameDayWarning );
			}
		}
		
		if( isOneWay())
				
		{
		
		if(!document.skylightsForm.SNRCITIZEN.checked)

		   {

		   if(!searchPrefs.isAgency)
		     {
		   //  alert("IndiGo offers attractive RoundTrip fares on select sectors with lower base fares and \nlower fuel surcharge. You can avail them by choosing the RoundTrip option on the \nSearch menu, else click OK to proceed.");
		     }

		   }
		}

		
		
		return is_valid;
	}
	/*##############################################
	#
	# Function: formatDates()
	#
	# Parameter: 
	#
	# Description: 
	#	       Arranged the captured day and month values selected for inbound and outbound flights	
	#	       
	#
	#*/
	function formatDates()
	{
		document.skylightsForm.departDate1.value		= 		captureDateString("departDay1", "departMonth1");
		if ( document.skylightsForm.numberMarkets.value > 1 )
		{
			document.skylightsForm.departDate2.value	= captureDateString("departDay2", "departMonth2");
		}
	}
	/*##############################################
	#
	# Function: validateOpenJawConnections()
	#
	# Parameter: 
	#
	# Description: 
	#	       Verifies if the selected cities are valid for open jaw routes.
	#	       
	#
	# Return:	
	#		True: valid open jaw routes
	#		false: if otherwise
	#*/	
	function validateOpenJawConnections()
	{
		if ( ( ( document.skylightsForm.from1.value == document.skylightsForm.to2.value ) ||
				( document.skylightsForm.to1.value == document.skylightsForm.from2.value ) ) 
				&& ( document.skylightsForm.from2.value != '???') && ( document.skylightsForm.to2.value != '???'))
		{
			return true;
		}
		else
		{
			alert(searchText.popup_illogical_open_jaw);
			return false;
		}
	}


// Begin Oneway/Roundtrip javascript
	/*##############################################
	#
	# Function: isOneWay()
	#
	# Parameter: 
	#
	# Description: 
	#	       Returns true if one way radio button is selected, else.
	#	       false
	#
	#*/
	function isOneWay()
	{
		return ( document.skylightsForm.travel[1].checked );
	}
	/*##############################################
	#
	# Function: isRoundTrip()
	#
	# Parameter: 
	#
	# Description: 
	#	       Returns true if round trip radio button is selected, else.
	#	       false
	#
	#*/	
	function isRoundTrip()
	{
		return ( document.skylightsForm.travel[0].checked );
	}
	function alertOneway()
	{
		alert('IndiGo offers attractive RoundTrip fares on select sectors with lower base fares and \nlower fuel surcharge. You can avail them by choosing the RoundTrip option on the \nSearch menu, else click OK to proceed.');
	}
	/*##############################################
	#
	# Function: swapTravel()
	#
	# Parameter: 
	#
	# Description: 
	#	       Dynamically changes the display in the search display
	#	       depending on the selected travel option( round trip, one way or open jaw)
	#
	#*/
	function swapTravel()
	{
		// switched to round trip
		if ( document.skylightsForm.travel[0].checked )
		{
			document.skylightsForm.numberMarkets.value			= 2;
			showDiv(true, 'dateSel2');
			if (searchPrefs.OFFER_OPEN_JAW_ROUTES == 'true')
			{
				showDiv(false, 'fromToSel2');
			}
		}
		// switched to one way
		else if ( document.skylightsForm.travel[1].checked )
		{
		
		
			document.skylightsForm.numberMarkets.value			= 1;
			showDiv(false, 'dateSel2');
			if (searchPrefs.OFFER_OPEN_JAW_ROUTES == 'true')
			{
				showDiv(false, 'fromToSel2');
			}
		}
		//switched to open jaw
		else
		{
			document.skylightsForm.numberMarkets.value			= 2;
			showDiv(true, 'dateSel2');
			showDiv(true, 'fromToSel2');
		}
		if (eval(document.skylightsForm.farePriority))
		{
			showDateFlex();
		}
		balanceHeight('wrapper', 'right', 'left');
	}
	
	/*##############################################
	#
	# Function: showDateFlex()
	#
	# Parameter: 
	#
	# Description: 
	#	       Dynamically changes the display in the search display
	#	       depending on the selected fare priority option( Standard Search or LFS)
	#
	#*/
	function showDateFlex()
	{
		var option_val = document.skylightsForm.farePriority[document.skylightsForm.farePriority.selectedIndex].value;
		var elem_id;
		for (i = 1; i <= document.skylightsForm.numberMarkets.value; i++)
		{
			elem_id = "depart" + i + "FlexBySelect";

			if (option_val == 1) // selected Stardard search mode
			{
			      
			      showDiv(true, elem_id,'inline');
			}
			else  // selected LFS search mode
			{
			      showDiv(false, elem_id );
			}
		}
	
	}
// Begin Search Submit Form javascript
	/*##############################################
	#
	# Function: submitSearch()
	#
	# Parameter: 
	#		beginDate: valid start date (set in PREFs)
	#		endDate:  valid end date (set in PREFs) 
	#
	# Description: 
	#	       Verifies all fields are in proper values, then
	#	       submits the form to start the flight availability search.
	#
	#*/
	function submitSearch(beginDate, endDate)
	{
		if ( validCities() && validDates(beginDate, endDate) && validPax())
		{
			
			finalDate();
			
			/*
			# Removing this line as the templates will concatenate 
			# the month year and day values.
			#
			#formatDates();
			*/
			
			if(document.skylightsForm.SNRCITIZEN.checked)
												{
				               								
										alert('Applicable if you are a currently serving or retired Armed Forces personnel, Paramilitary Forces personnel or war widow.\nFor serving or retired Armed Forces and Paramilitary personnel, the offer is also applicable for their spouse and dependant children.\nValid photo id and relevant military (Armed Forces, Paramilitary Forces, Ex-serviceman, Spouse, Dependant or War widow) ID must \nbe presented at check in, failing which passenger will be denied boarding. Conditions Apply.');
												
												document.skylightsForm.promoCode.value 	= '6EDFNS02';
												
						}
			document.skylightsForm.page.value 	= 'SEARCH';
			document.skylightsForm.module.value	= 'SB';			
			document.skylightsForm.event.value 	= 'search';
			document.skylightsForm.submit();

		}
	}
	/*##############################################
	#
	# Function: onLoadAtaGlance()
	#
	# Parameter: 
	#
	# Description: 
	#	       initializes the display and field values for 
	#	       search page.
	#
	#*/
/*##############################################
	#
	# Function: onLoadAtaGlance()
	#
	# Parameter: 
	#
	# Description: 
	#	       initializes the display and field values for 
	#	       search page.
	#
	#*/
	function onLoadAtaGlance()
	{
		swapTravel();
		for (i = 1; i <= document.skylightsForm.numberMarkets.value; i++)
		{
		
			resetDest(i);
		}
		
							
	}
	
function setCurrency_Index(selected_Currency)
	{
								
	var grabEl = document.getElementById("Currency_Required_Select");

		fillCountry(grabEl);

				for (var itemIndex = 0; itemIndex < grabEl.options.length ; itemIndex++)
				{
					//	alert(itemIndex+grabEl[itemIndex].value);							
					if (grabEl[itemIndex].value == selected_Currency && grabEl[itemIndex].value!=null ) 
					{
								try{
					            grabEl[itemIndex].selected = true;
								}
								catch(e)
								{
								}
								
					}
				}	
	}
function setCurrency_Index_onload(selected_Currency)
	{
								
	var grabEl = document.getElementById("Currency_Required_Select");
//							fillCountry(grabEl);
		for (var itemIndex = 0; itemIndex < grabEl.options.length ; itemIndex++)
		{
			//	alert(itemIndex+grabEl[itemIndex].value);							
			if (grabEl[itemIndex].value == selected_Currency) 
			{
				try{
					grabEl[itemIndex].selected = true;
				}
								catch(e)
								{
								}
			}
		}	
       }	



       
       
       
       
       //Fetches PNR and Hotel Name from query string and saves it in browser Cookies.
       function setCookieFromQueryString() {
       
       alert('raja');
           var parameters = getPNRFromQueryString();
           if (parameters != null) {
               for (var i = 0; i < parameters.length; i++) {
                   var paramName = parameters[i].split('=');
                   if ((paramName[0] == "PNR") || (paramName[0] == "hotelName")) {
                       setCookie(paramName[0], paramName[1], 1);
                   }
               }
       SaveDetails(); 
           }
       }
       
       //Fetches PNR and Hotel Name from query string.
       function getPNRFromQueryString() {
           var Url = document.URL;
           var indexOfParameters = Url.indexOf('?');
           if (indexOfParameters > -1) {
               var queryString = Url.substring(indexOfParameters + 1, Url.length);
               var parameters = queryString.split('&');
               if (parameters.length > 0) {
                   return parameters;
               }
           }
           else {
               return null;
           }
       }
       
       //Creating Cookie.
       function setCookie(c_name, value, exdays) {
           var exdate = new Date();
           exdate.setDate(exdate.getDate() + exdays);
           var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
           document.cookie = c_name + "=" + c_value;
       }
       
       //Fetches Cookie.
       function getCookie(c_name) {
           var i, x, y, ARRcookies = document.cookie.split(";");
           for (i = 0; i < ARRcookies.length; i++) {
               x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
               y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
               x = x.replace(/^\s+|\s+$/g, "");
               if (x == c_name) {
                   return unescape(y);
               }
           }
       }
       
       //Checking if PNR & Hotel Name exists in cookies. If yes, saving it in
       //db along with page details.
       function SaveDetails() {
           var iCallID;
           var xmlHttpReq;
           var browser = navigator.appName;
           if (browser == "Microsoft Internet Explorer") {
               xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
           } else {
               xmlHttpReq = new XMLHttpRequest();
           }
       
           if (xmlHttpReq.overrideMimeType) {
               xmlHttpReq.overrideMimeType('text/xml');
           }
           var pnr = getCookie("PNR");
           var hotelname = getCookie("hotelName");
           if (pnr != null && pnr != "" && hotelname != null && hotelname != "") {
            // xmlHttpReq.open("POST", "http://localhost/ME.TrackingServiceInstaller/TrackingService.asmx/SaveTrackingDetails");
            xmlHttpReq.open("POST", "http://10.10.11.30/ME.TrackingServiceInstaller/TrackingService.asmx/SaveTrackingDetails");
               xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
               iCallID = xmlHttpReq.send("RecordLocator=" + pnr + "&HotelName=" + hotelname + "&pageTitle=" + document.title + "&PageURL=" + document.URL);
           }
       }
       
       //Checks if cookie exists. If not setting cookies.
       function checkCookie() {
           var pnr = getCookie("PNR");
           var hotelname = getCookie("hotelName");
           if (pnr != null && pnr != "" && hotelname != null && hotelname != "") {
               SaveDetails();
               alert("Welcome again " + pnr);
           }
           else {
               username = prompt("Please enter PNR:", "");
               hotelname = prompt("Please enter hotel name:", "");
               if (pnr != null && pnr != "") {
                   if (hotelname != null && hotelname != "") {
                       setCookie("PNR", pnr, 1);
                       setCookie("hotelName", hotelname, 1);
                   }
               }
           }
       }
       
       
       

