﻿function changeTripMain(searchType)
{
    var strTripType = document.getElementById("flagfare").selectedIndex;
    var strTripTypeName = document.getElementById("flagfare").options[strTripType].text;
    
    if(document.getElementById("cmbSearch_Type")!=null)
    {
            if(document.getElementById("cmbSearch_Type").value != 'M')
            {
                if(strTripTypeName=="One Way")
                {
                    document.getElementById("txtDepartDateFrom").disabled=false;
                    document.getElementById("txtArrivalDateFrom").disabled=true;
                    
                    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
                    {
                        document.getElementById("txtDepartDateTo").disabled=false;
                        document.getElementById("txtArrivalDateTo").disabled=true;
                    }
                    else
                    {
                        document.getElementById("cmbDaysVaryR").disabled=true;
                    }
                }
                else if (strTripTypeName=="Round Trip")
                {
                    document.getElementById("txtDepartDateFrom").disabled=false;
                    document.getElementById("txtArrivalDateFrom").disabled=false;
                    
                    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
                    {
                        document.getElementById("txtDepartDateTo").disabled=false;
                        document.getElementById("txtArrivalDateTo").disabled=false;
                    }
                    else
                    {
                        document.getElementById("cmbDaysVaryR").disabled=false;
                    }        
                    //validate_date('txtArrivalDateFrom')
                    //validate_date('txtArrivalDateTo')
                }
              }  
              else
              {
                    document.getElementById("txtDepartDateFrom").disabled=true;
                    document.getElementById("txtArrivalDateFrom").disabled=true;
                    
                    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
                     {
                        document.getElementById("txtDepartDateTo").disabled=true; 
                        document.getElementById("txtArrivalDateTo").disabled=true;
                     }
                     else
                     {
                        document.getElementById("cmbDaysVaryD").disabled=true;
                        document.getElementById("cmbDaysVaryR").disabled=true;
                     }
              }  
        }
        else
        {
             if(strTripTypeName=="One Way")
                {
                    document.getElementById("txtDepartDateFrom").disabled=false;
                    document.getElementById("txtArrivalDateFrom").disabled=true;
                    
                    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
                    {
                        document.getElementById("txtDepartDateTo").disabled=false;
                        document.getElementById("txtArrivalDateTo").disabled=true;
                    }
                    else
                    {
                        document.getElementById("cmbDaysVaryR").disabled=true;
                    }
                }
                else if (strTripTypeName=="Round Trip")
                {
                    document.getElementById("txtDepartDateFrom").disabled=false;
                    document.getElementById("txtArrivalDateFrom").disabled=false;
                    
                    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
                    {
                        document.getElementById("txtDepartDateTo").disabled=false;
                        document.getElementById("txtArrivalDateTo").disabled=false;
                    }
                    else
                    {
                        document.getElementById("cmbDaysVaryR").disabled=false;
                    }        
                    //validate_date('txtArrivalDateFrom')
                    //validate_date('txtArrivalDateTo')
                }
        }
 } 
        


function checkValidations(searchType)
{
            var sessionval
			sessionval = document.frmCalendarSample.userCategoryId.value;
			//var Today = new Date(document.frmCalendarSample.validation_date.value).valueOf()
            
            if(isClicked==0)        
			{
				if (document.getElementById("cmb_originCity").options[document.getElementById("cmb_originCity").selectedIndex].value=="")
				{
					//alert("Please select a departure city, we can't find you a flight without knowing from where you're going")Changed By vipul on 20 OCT as per client req.
					alert("Please select a departure city")
					document.getElementById("cmb_originCity").focus();
					return false;
				}
				if (document.getElementById("cmb_destCity").options[document.getElementById("cmb_destCity").selectedIndex].value=="")
				{
					//alert("Please enter a destination city, we can't find you a flight without knowing where you're going") Changed By vipul on 20 OCT as per client req.
					alert("Please select a destination city")
					document.getElementById("cmb_destCity").focus();
					return false;
				}
				if(document.getElementById("cmb_originCity").options[document.getElementById("cmb_originCity").selectedIndex].value == document.getElementById("cmb_destCity").options[document.getElementById("cmb_destCity").selectedIndex].value)
				{
					alert("Origin city and Destination city cannot be same")
					return false;
				}
				
				//DateValidation();
				var chkVarDate;
				if(searchType=='FIRST')	
			    {
				    chkVarDate=FirstSearchDateValidation(searchType)
				}
				else
				{
				    chkVarDate=DateValidation(searchType)
				}
				
				//chkVarDate=DateValidation(searchType)
				if (chkVarDate==false)
				{
				    return false;
				}
			
			    if(searchType!='SCHEDULE')	
			    {
			   	    if(!checkPassengers(document.getElementById("txt_adult"),document.getElementById("txt_child"),document.getElementById("txt_infant"),document.getElementById("max_seats")))
				    {
					    return false;
				    }
    				
			        if (document.frmCalendarSample.txt_adult.value == "")
				    {
					    document.frmCalendarSample.txt_adult.value = "0"
				    }
				    if (document.frmCalendarSample.txt_child.value == "")
				    {
					    document.frmCalendarSample.txt_child.value = "0"
				    }
				    if (document.frmCalendarSample.txt_infant.value == "")
				    {
					    document.frmCalendarSample.txt_infant.value = "0"
				    }
    				
            	    if (document.getElementById("cmbSearch_Type").options[document.getElementById("cmbSearch_Type").selectedIndex].value=="")
				    {
					    alert("Please select search type!")
					    document.getElementById("cmbSearch_Type").focus();
					    return false;
				    }
    				
				    if (document.getElementById("cmbSearch_Type").value == 'C' )
				    {
					    if (document.getElementById("txt_fareCeiling").value == "")
					    {
						    alert('Enter Fare Ceiling Value');
						    document.getElementById("txt_fareCeiling").focus();
						    return false;
					    }
					    else
					    {
						    if(!isNumericInteger(document.getElementById("txt_fareCeiling"), 'Ceiling'))
						    {
						       return false;
						    }
					    }
				    }
			    }	
			    
				var obj=document.getElementById("imgSubmit");
				if(obj)
				{
					isClicked=1
					obj.src=img.src;
					obj.style.cursor="default";
					obj.alt="";
					return true;
					
	            }
			}
		    else
			{
				return false;							
			}
        }
        
        //Validates date in the format dd/mm/yyyy (e.g. 19/10/2009)
        function validateInputDate(dateString) 
        {
            var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
            if ((dateString.match(RegExPattern)) && (dateString.value!='')) 
            {
                return true;
            } 
            else 
            {
                return false;
            } 
        }
        
        
        
        
         function DateValidation(searchType)
         {
            var TripType = document.getElementById("flagfare").selectedIndex;
            var TripTypeName = document.getElementById("flagfare").options[TripType].text;
           
           if(document.getElementById("txtDepartDateFrom"))
                {
                    if(validateInputDate(document.getElementById("txtDepartDateFrom").value)==false)
                    {
                        alert("Please input date in the format dd/mm/yyyy.");
                        document.getElementById("txtDepartDateFrom").focus();
                        return false;
                    }
                 }
             
             if(document.getElementById("txtDepartDateTo")!=null)
                {
                    if(validateInputDate(document.getElementById("txtDepartDateTo").value)==false)
                    {
                        alert("Please input date in the format dd/mm/yyyy.");
                        document.getElementById("txtDepartDateTo").focus();
                        return false;
                    }
                 }
            
            if (TripTypeName=="Round Trip")
             {
                if(document.getElementById("txtArrivalDateFrom"))
                {
                    if(validateInputDate(document.getElementById("txtArrivalDateFrom").value)==false)
                    {
                        alert("Please input date in the format dd/mm/yyyy.");
                        document.getElementById("txtArrivalDateFrom").focus();
                        return false;
                    }
                 }
                 
                if(document.getElementById("txtArrivalDateTo")!=null)
                {
                    if(validateInputDate(document.getElementById("txtArrivalDateTo").value)==false)
                    {
                        alert("Please input date in the format dd/mm/yyyy.");
                        document.getElementById("txtArrivalDateTo").focus();
                        return false;
                    }
                }
            }
             
           
           var Today = document.frmCalendarSample.validation_date.value;
           Today= new Date(Today).valueOf()
           //alert(Today);
           
           // Start: Validation for Outbound Dates           
           var out_dateFromTmp = document.getElementById("txtDepartDateFrom").value;  
           var out_dateToTmp = document.getElementById("txtDepartDateTo").value;  
           
           out_dateFromTmp = out_dateFromTmp.split("/")
           out_dateFrom = out_dateFromTmp[1] + "/" + out_dateFromTmp[0] + "/" + out_dateFromTmp[2]
           
           out_dateToTmp = out_dateToTmp.split("/")
           out_dateTo = out_dateToTmp[1] + "/" + out_dateToTmp[0] + "/" + out_dateToTmp[2]
           
           out_dateFrom = new Date(out_dateFrom).valueOf()
           out_dateTo = new Date(out_dateTo).valueOf()
           
           days_diffDeparture = (out_dateTo - out_dateFrom)
           
           if ((days_diffDeparture/(1000*60*60*24)) > 7)
			{
			    alert("Departure date range should not be greater than seven days");
			    document.getElementById("txtDepartDateTo").focus();
			    return false; 
			}
           
           if (days_diffDeparture < 0)
			{
				alert("Departure date To should not be less then From date");
				document.getElementById("txtDepartDateTo").focus();
				return false; 
			}
          // End: Validation for Outbound Dates           
			
			
		// Start: Validation for Inbound Dates           	
		   var in_dateFromTmp = document.getElementById("txtArrivalDateFrom").value;  
           var in_dateToTmp = document.getElementById("txtArrivalDateTo").value;  
           
           in_dateFromTmp = in_dateFromTmp.split("/")
           in_dateFrom = in_dateFromTmp[1] + "/" + in_dateFromTmp[0] + "/" + in_dateFromTmp[2]
           
           in_dateToTmp = in_dateToTmp.split("/")
           in_dateTo = in_dateToTmp[1] + "/" + in_dateToTmp[0] + "/" + in_dateToTmp[2]
           
           in_dateFrom = new Date(in_dateFrom).valueOf()
           in_dateTo = new Date(in_dateTo).valueOf()
           
           days_diffReturn = (in_dateTo - in_dateFrom)
           
           if (TripTypeName=="Round Trip")
			{
               if ((days_diffReturn/(1000*60*60*24)) > 7)
			    {
			        alert("Return date range should not be greater than seven days");
			        document.getElementById("txtArrivalDateTo").focus();
			        return false; 
			    }
               
               if (days_diffReturn < 0)
			    {
				    alert("Return date To should not be less then From date");
				    document.getElementById("txtArrivalDateTo").focus();
				    return false; 
			    }
		   }
		
        // End: Validation for Inbound Dates           				
        
          if(out_dateFrom < Today)
			{
				alert("Search is not allowed for dates earlier than current date");
				document.getElementById("txtDepartDateFrom").focus();
				return false;
			}
         
          if (TripTypeName=="Round Trip")
			{
			    if(in_dateFrom < out_dateFrom)
				{
					alert("Return Date cannot be less than depart date")
					document.getElementById("txtArrivalDateFrom").focus();
					return false;
				}
			}
           
           if(searchType!='SCHEDULE')	
		   {
               book_allow_date = document.frmCalendarSample.booking_period.value;
               days_diff = (out_dateFrom - Today) 							
               
     		    if(days_diff > book_allow_date)
			    {
			 	    alert("You can't search Departing flights beyond "+document.frmCalendarSample.search_days.value+" days.")
				    document.getElementById("txtDepartDateFrom").focus();
				    return false;
			    }
    			
			    if (TripTypeName=="Round Trip")
			    {
			        in_dateFrom=(in_dateFrom-Today)
			 	    if(in_dateFrom > book_allow_date)
				    {
					    alert("You can't search Return flights beyond "+document.frmCalendarSample.search_days.value+" days.") 
					    document.getElementById("txtArrivalDateFrom").focus();
					    return false;
				    }
			    }
			 }   
		    return true;
   	}
   	   	
   	  function FirstSearchDateValidation(searchType)
         {
            var TripType = document.getElementById("flagfare").selectedIndex;
            var TripTypeName = document.getElementById("flagfare").options[TripType].text;
           
           if(document.getElementById("txtDepartDateFrom"))
                {
                    if(validateInputDate(document.getElementById("txtDepartDateFrom").value)==false)
                    {
                        alert("Please input date in the format dd/mm/yyyy.");
                        document.getElementById("txtDepartDateFrom").focus();
                        return false;
                    }
                 }
                      
            if (TripTypeName=="Round Trip")
             {
                if(document.getElementById("txtArrivalDateFrom"))
                {
                    if(validateInputDate(document.getElementById("txtArrivalDateFrom").value)==false)
                    {
                        alert("Please input date in the format dd/mm/yyyy.");
                        document.getElementById("txtArrivalDateFrom").focus();
                        return false;
                    }
                 }
            }
           
           var Today = document.frmCalendarSample.validation_date.value;
           Today= new Date(Today).valueOf()
           //alert(Today);
           
           // Start: Validation for Outbound Dates           
           var out_dateFromTmp = document.getElementById("txtDepartDateFrom").value;  
           out_dateFromTmp = out_dateFromTmp.split("/")
           out_dateFrom = out_dateFromTmp[1] + "/" + out_dateFromTmp[0] + "/" + out_dateFromTmp[2]
           out_dateFrom = new Date(out_dateFrom).valueOf()
           
           
           
           var in_dateFromTmp = document.getElementById("txtArrivalDateFrom").value;  
           in_dateFromTmp = in_dateFromTmp.split("/")
           in_dateFrom = in_dateFromTmp[1] + "/" + in_dateFromTmp[0] + "/" + in_dateFromTmp[2]
           in_dateFrom = new Date(in_dateFrom).valueOf()
        
            if(out_dateFrom < Today)
			{
				alert("Search is not allowed for dates earlier than current date");
				document.getElementById("txtDepartDateFrom").focus();
				return false;
			}
         
             if (TripTypeName=="Round Trip")
			{
			    if(in_dateFrom < out_dateFrom)
				{
					alert("Return Date cannot be less than depart date")
					document.getElementById("txtArrivalDateFrom").focus();
					return false;
				}
			}
			
               book_allow_date = document.frmCalendarSample.booking_period.value;
               days_diff = (out_dateFrom - Today) 							
               if(days_diff > book_allow_date)
			    {
			 	    alert("You can't search Departing flights beyond "+document.frmCalendarSample.search_days.value+" days.")
				    document.getElementById("txtDepartDateFrom").focus();
				    return false;
			    }
    			if (TripTypeName=="Round Trip")
			    {
			        in_dateFrom=(in_dateFrom-Today)
			 	    if(in_dateFrom > book_allow_date)
				    {
					    alert("You can't search Return flights beyond "+document.frmCalendarSample.search_days.value+" days.") 
					    document.getElementById("txtArrivalDateFrom").focus();
					    return false;
				    }
			    }
		    return true;
   	}

//ALREADY THERE
        function ChangeOptions(lstPrimary, lstSecondary, strArray) 
			{			
			var selectedval,strArrayNum, strArrayVal
			strArrayNum="0"
			strArrayVal="jj"
			var alen    = eval(strArray + ".length")
			var listLen = 1;
			var strKey  = eval("document.frmCalendarSample." + lstPrimary + ".options[document.frmCalendarSample." + lstPrimary + ".selectedIndex].value")
			
			eval("document.frmCalendarSample." + lstSecondary + ".options.length = 0");
			eval("document.frmCalendarSample." + lstSecondary + ".options[0] = new Option('Select Destination City','' )");
			for (var i = 0; i < alen; i++) 
			{			  
			  if (eval(strArray)[i][0] == strKey)
			  {
			  eval("document.frmCalendarSample." + lstSecondary + ".options[listLen] = new Option(" + strArray + "[i][2], " + strArray + "[i][1]" + " + '|'+ " + strArray +"[i][2])");
			  listLen = listLen + 1;
			  } 
			  //eval("document.frmCalendarSample."+lstSecondary+".focus()");
			}
			}
			
		
//ALREADY THERE		  		
		function isNumericInteger(str,fldname)
        {
	            if(str.value.charAt(0)==" ")
	            {
		            alert("Invalid entry, space not allowed")
		            str.focus();
		            return false;
	            }
            	
            	
	            if(isNaN(str.value))
	            {
		            alert("Invalid entry, only digits are allowed.")
		            str.focus();
		            return false;
	            }
            	
	            if(str.value !='')
	            {
		            if (str.value < 0) 
		            {
			            alert("Invalid entry ,please enter correct number of " + fldname+".");
			            str.focus();
			            return false;
		            }
		            strval = str.value
		            if(strval.indexOf(".")>=0)
		            {
			            alert("Invalid entry, please enter correct number of " + fldname +".")
			            str.focus();
			            return false;
		            }
	            }
	            return true;
        }

//ALREADY THERE
     function checkPassengers(adult,child,infant,Maxpax)
    {
        var paxnum;
	    //Do not remove these steps ,their is problem with javascript in using paxnum as integer value otherwise.
	    paxnum = parseInt(Maxpax.value)
	    //
    				
	    if (adult.value == "")
		       adult.value = 0;

    	
	    if ((adult.value+child.value) < 1 )
	    {
		    alert("Please enter number of people traveling");
		    adult.focus();
		    return false;
	    }
    	
    	
	    if(!isNumericInteger(adult,'Adult'))
	    {
		    return false;
	    }

	    if (child.value!='')
	    { 
		    if(!isNumericInteger(child,'Child'))
		    {
			    return false;
		    }
	    }

	    if (infant.value!='')
	    { 
		    if(!isNumericInteger(infant,'Infant'))
		    {
			    return false;
		    }
	    }
    	
    	
	    if ((adult.value > 0) && (adult.value > paxnum))
	    {		
		    alert("Total number of Adults travelling cannot be more than " + paxnum+".");
		    adult.focus();
		    return false;
	    }
    	
	    if ((child.value > 0) && (child.value > paxnum))
	    {
		    alert("Total number of Children travelling cannot be more than" + paxnum+".");
		    child.focus();
		    return false;
	    }
    	
	    if (isNaN(child.value))
	    {
		    alert("Invalid entry, only digits are allowed.\nPlease re-enter");
		    child.focus();
		    return false;
	    }
    	
	    /*if (child.value==" " || child.value=="" )
	    {
		    return true;
	    }
	    */
    	
        if ( (parseInt(adult.value)+parseInt(child.value)) > paxnum )
	    {
		    alert("You can't book online if the total passenger exceeds" + paxnum+", which includes both adults and children in single journey.\nYou may reduce the total number of passengers accordingly");
		    child.focus();
		    return false;
	    }
    	
	    if(infant!="")	
	    {
		    if (isNaN(infant.value))
		    {
			    alert("Invalid entry, only digits are allowed.\nPlease re-enter");
			    infant.focus();
			    return false;
		    }
		    if (infant.value==" " || infant.value=="" )
		    {
			    return true;
		    }
    		
		    if ( parseInt(infant.value) > parseInt(adult.value) )
		    {
			    alert("Number of infants should not exceed number of adults");	
			    infant.focus();
			    return false;
		    }
    	
	    }	
    	
    	
    return true
}

function enablefareceiling(searchType)
{
    var strTripType = document.getElementById("flagfare").selectedIndex;
    var strTripTypeName = document.getElementById("flagfare").options[strTripType].text;

	if (document.frmCalendarSample.cmbSearch_Type.value == 'C')
	{
		document.frmCalendarSample.txt_fareCeiling.disabled=false;
		if (strTripTypeName=="Round Trip")
		{
		    document.getElementById("txtDepartDateFrom").disabled=false;
		    document.getElementById("txtArrivalDateFrom").disabled=false;
		    
		    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
		    {
		        document.getElementById("txtArrivalDateTo").disabled=false;
		        document.getElementById("txtDepartDateTo").disabled=false;
		    }
		    else
		    {
		        document.getElementById("cmbDaysVaryD").disabled=false;
		        document.getElementById("cmbDaysVaryR").disabled=false;
		    }
		}
		else
		{
		    document.getElementById("txtDepartDateFrom").disabled=false;
		    document.getElementById("txtArrivalDateFrom").disabled=true;
		    
		    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
		    {
		        document.getElementById("txtDepartDateTo").disabled=false;
		        document.getElementById("txtArrivalDateTo").disabled=true;
		    }
		    else
		    {
		        document.getElementById("cmbDaysVaryD").disabled=false;
		        document.getElementById("cmbDaysVaryR").disabled=true;
		    }
		}
	}
	else if (document.frmCalendarSample.cmbSearch_Type.value == 'M')
	{
	    document.frmCalendarSample.txt_fareCeiling.value = "";
		document.frmCalendarSample.txt_fareCeiling.disabled=true;
		document.getElementById("txtDepartDateFrom").disabled=true;
		document.getElementById("txtArrivalDateFrom").disabled=true;
		
		if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
		{
			    document.getElementById("txtArrivalDateTo").disabled=true;
		        document.getElementById("txtDepartDateTo").disabled=true;
		}
		else
		{
		        document.getElementById("cmbDaysVaryD").disabled=true;
		        document.getElementById("cmbDaysVaryR").disabled=true;
		}
	}		
	else
	{
		document.frmCalendarSample.txt_fareCeiling.value = "";
		document.frmCalendarSample.txt_fareCeiling.disabled=true;
		if (strTripTypeName=="Round Trip")
		{
		    document.getElementById("txtDepartDateFrom").disabled=false;
		    document.getElementById("txtArrivalDateFrom").disabled=false;
		
		    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
		    {
	    	    document.getElementById("txtDepartDateTo").disabled=false;
	            document.getElementById("txtArrivalDateTo").disabled=false;
	        }   
	        else
	        {
	            document.getElementById("cmbDaysVaryD").disabled=false;
		        document.getElementById("cmbDaysVaryR").disabled=false;
	        }
		}
		else
		{
		    document.getElementById("txtDepartDateFrom").disabled=false;
		    document.getElementById("txtArrivalDateFrom").disabled=true;
		    
		    if(document.getElementById("txtDepartDateTo")!=null && document.getElementById("txtArrivalDateTo")!=null)
		    {
		        document.getElementById("txtDepartDateTo").disabled=false;
		        document.getElementById("txtArrivalDateTo").disabled=true;
		    }   
		    else
		    {
		        document.getElementById("cmbDaysVaryD").disabled=false;
		        document.getElementById("cmbDaysVaryR").disabled=true;
		    }
		}
	}
}

var bMSIE = false;
var browserName
function sniffTheBrowser()
{
    var ua = navigator.userAgent;
    var an = navigator.appName;

    // is it IE?
    bMSIE = (ua.indexOf("MSIE")>=1);
    // else please send your working sniffers for other browsers to michaele@microsoft.com

	if (bMSIE)
        browserName = "IE";
    else if (an == "Netscape")
        browserName = "Netscape";
    else
        browserName = "Not supported";
//	alert(browserName)
}


function fillData(searchType)
		{
			sniffTheBrowser()
			var str_cookie,oval,cval
			//Code Commented By Girish Kalia on 25 May 2010 to stop session mentainence on all POS Search Pages
			/*str_cookie = document.cookie
			index1 = str_cookie.indexOf("igtsAirIndia")
			
			if (index1 >=0)
			{
				strcookie1 = str_cookie.substr(index1,str_cookie.length)
				
				index2 = strcookie1.indexOf(";")
				if (index2 >=0)
				{
					strcookie2 = strcookie1.substring(strcookie1.indexOf("=")+1,index2)
				}
				else
				{
					strcookie2 = strcookie1.substring(strcookie1.indexOf("=")+1,strcookie1.length)
				}
				cookies_ary = strcookie2.split('&')
				//alert(cookies_ary)
				for(cnt_elements=0;cnt_elements<cookies_ary.length ;cnt_elements++)
				{
					val = cookies_ary[cnt_elements].split('=')
					if (val[0] == "porigincity")
					{
						selectbox(document.frmCalendarSample.cmb_originCity,val[1])
						oval = val[1]
						ChangeOptions("cmb_originCity","cmb_destCity","ArrCity")
					}	
				
					
					if (val[0] == "pdepartdate")
					{
					   
						document.frmCalendarSample.departdate.value = val[1].substr(5,2)+"/"+val[1].substr(0,2)+"/"+val[1].substr(10,4)
						frmCalendarSample.tbSelYear.value = val[1].substr(10,4)
						frmCalendarSample.tbSelMonth.value = val[1].substr(0,2)
						monthVal1 = frmCalendarSample.tbSelMonth.value
						monthVal1 = monthVal1.toString()			
						if(monthVal1.length==1)
						{
							monthVal1 = "0"+monthVal1
						}
						month_name(monthVal1)
						
						//UpdateCal('yr',frmCalendarSample.tbSelYear.value,'mn',frmCalendarSample.tbSelMonth.value,'page')
						UpdateCal('yr',frmCalendarSample.tbSelYear.value,'mn',frmCalendarSample.tbSelMonth.value,'page')
																	
						dispval.innerText =   month_nm + " " + val[1].substr(10,4)
					}
			
					if (val[0] == "preturndate")
					{
						if(val[1]!="")
						{
							document.frmCalendarSample.returndate.value = val[1].substr(5,2)+"/"+val[1].substr(0,2)+"/"+val[1].substr(10,4)
							frmCalendarSample.tbSelYear2.value = val[1].substr(10,4)
							frmCalendarSample.tbSelMonth2.value = val[1].substr(0,2)	
							monthVal2 = frmCalendarSample.tbSelMonth2.value
							monthVal2 = monthVal2.toString()			
							if(monthVal2.length==1)
							{
								monthVal2 = "0"+monthVal2
							}
							month_name(monthVal2)
							UpdateCal2('yr',frmCalendarSample.tbSelYear2.value,'mn',frmCalendarSample.tbSelMonth2.value,'page')
							dispval2.innerText =   month_nm + " " + val[1].substr(10,4)
						}
						else
						{
							frmCalendarSample.tbSelYear2.value = year1
							frmCalendarSample.tbSelMonth2.value = month1
							monthVal2 = frmCalendarSample.tbSelMonth2.value
							monthVal2 = monthVal2.toString()			
							if(monthVal2.length==1)
							{
								monthVal2 = "0"+monthVal2
							}
							month_name(monthVal2)
							dispval2.innerText =   month_nm + " " + year1							
							document.frmCalendarSample.returndate.value = day1 +"/"+ month1 +"/"+ year1
						}
					}
					
				
					if (val[0] == "flagfare")
					{
						trip_type = val[1]
						document.frmCalendarSample.flagfare.value = trip_type 
						if (trip_type == "O")
						{
							//changetrip(1)		
						}
						else
						{
							//changetrip(2)		
						}
						
					}
					
					 if(searchType!='SCHEDULE')	
			         {
			            if (val[0] == "padus")
					    {
						    eval("document.frmCalendarSample.txt_adult.value ='" + val[1] +"'")
					    }	
					    if (val[0] == "pchild")
					    {
						    eval("document.frmCalendarSample.txt_child.value ='" + val[1] +"'")
					    }	
					    if (val[0] == "pinfant")
					    {
						    eval("document.frmCalendarSample.txt_infant.value='" + val[1] +"'")
					    }
					    if (val[0] == "pclass")
					    {
						    eval("document.frmCalendarSample.str_class.value='" + val[1] +"'")
					    }
					 } 	
					 
					    if (val[0] == "pdestcity")
					    {
						    cval = val[1]
					    }			
				}
				fillOptions(oval,cval)
				
				changeTripMain(searchType)
				if(searchType!='SCHEDULE')	
				{
				    enablefareceiling(searchType)
			 	}
			}
			else
			{	
			    		
				var dCurDate = new Date();
						
				frmCalendarSample.tbSelYear.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth.value = dCurDate.getMonth()+1;
				frmCalendarSample.tbSelYear2.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth2.value = dCurDate.getMonth()+1;
				monthVal1 = frmCalendarSample.tbSelMonth.value
				monthVal2 = frmCalendarSample.tbSelMonth2.value
				
				monthVal1 = monthVal1.toString()			
				if(monthVal1.length==1)
				{
					monthVal1 = "0"+monthVal1
				}
					monthVal2 = monthVal2.toString()			
				
				month_name(monthVal1)	
				////document.getElementById("dispval").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval.innerText =   month_nm + " " + dCurDate.getFullYear()
				
				if(monthVal2.length==1)
				{
					monthVal2 = "0"+monthVal2
				}
				
				month_name(monthVal2)
				////document.getElementById("dispval2").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval2.innerText =   month_nm + " " + dCurDate.getFullYear()
					
				
				document.frmCalendarSample.flagfare.value="O"				
				changetrip(1)
				document.frmCalendarSample.departdate.value = day1 +"/"+ month1 +"/"+ year1
				document.frmCalendarSample.returndate.value = day1 +"/"+ month1 +"/"+ year1
	            
	            if(searchType!='SCHEDULE')	
				{
				    enablefareceiling(searchType)
			        changeTripMain(searchType)
				}
			
			}*/
			 	
				var dCurDate = new Date();
						
				frmCalendarSample.tbSelYear.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth.value = dCurDate.getMonth()+1;
				frmCalendarSample.tbSelYear2.value = dCurDate.getFullYear();
				frmCalendarSample.tbSelMonth2.value = dCurDate.getMonth()+1;
				monthVal1 = frmCalendarSample.tbSelMonth.value
				monthVal2 = frmCalendarSample.tbSelMonth2.value
				
				monthVal1 = monthVal1.toString()			
				if(monthVal1.length==1)
				{
					monthVal1 = "0"+monthVal1
				}
					monthVal2 = monthVal2.toString()			
				
				month_name(monthVal1)	
				////document.getElementById("dispval").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval.innerText =   month_nm + " " + dCurDate.getFullYear()
				
				if(monthVal2.length==1)
				{
					monthVal2 = "0"+monthVal2
				}
				
				month_name(monthVal2)
				////document.getElementById("dispval2").innerText = month_nm + " " + dCurDate.getFullYear()
				dispval2.innerText =   month_nm + " " + dCurDate.getFullYear()
					
				
				document.frmCalendarSample.flagfare.value="O"				
				changetrip(1)
				document.frmCalendarSample.departdate.value = day1 +"/"+ month1 +"/"+ year1
				document.frmCalendarSample.returndate.value = day1 +"/"+ month1 +"/"+ year1
	            
	            if(searchType!='SCHEDULE')	
				{
				    enablefareceiling(searchType)
			        changeTripMain(searchType)
				}
		}
		
		
		function fillOptions(origCityVal,destCityVal)  
			{
			var selectedval
			strArray = "ArrCity"
			strArrayNum="0"
			strArrayVal="jj"
			var alen    = eval(strArray + ".length")
			var listLen = 1;
			//var strKey  = eval("document.frmCalendarSample.cmb_originCity.options[document.frmCalendarSample.cmb_originCity.selectedIndex].value")
			var strKey = origCityVal
			eval("document.frmCalendarSample.cmb_destCity.options.length = 0");
			eval("document.frmCalendarSample.cmb_destCity.options[0] = new Option('Select Destination City','' )");
			for (var i = 0; i < alen; i++) 
			{
			  
			  if (eval(strArray)[i][0] == strKey)
			  {
			  eval("document.frmCalendarSample.cmb_destCity.options[listLen] = new Option(" + strArray + "[i][2], " + strArray + "[i][1]" + " + '|' + " + strArray +"[i][2])");
					if(eval( strArray + "[i][1] =='" +destCityVal+ "'"))
					{
						eval("document.frmCalendarSample.cmb_destCity.selectedIndex = listLen")
					}
			  listLen = listLen + 1;
			  } 
			  //eval("document.frmCalendarSample.cmb_destCity.focus()");
			}
			}



