﻿function tourvalidate()
 {
   
     if (document.getElementById("dailytour").value=="")
      {
       alert("Please select Any Daily Tour.");
       document.getElementById("dailytour").focus();
       return false;
      } 
      if (document.getElementById("tourvehicle").value=="")
      {
       alert("Please select Type of Vehicle.");
       document.getElementById("tourvehicle").focus();
       return false;
      }
     
	  if(document.getElementById("txttourdate").value=="")
	    {
	     alert("Please select date.");
	     return false;
	     }
      else if(document.getElementById("txttourdate").value!="")
          {
			 t2=document.getElementById("txttourdate").value;
			 t1=document.getElementById("txttoday").value;
			
			//Total time for one day
					var one_day=1000*60*60*24; 
			//Here we need to split the inputed dates to convert them into standard format
			
					var x=t1.split("/");
					var y=t2.split("/");
				
			//date format(Fullyear,month,date) 

					var date1=new Date(x[2],x[0],(x[1]-1));
				var date2=new Date(y[2],y[0],(y[1]-1));
					
					var month1=x[1]-1;
					var month2=y[1]-1;
					
					//Calculate difference between the two dates, and convert to days
					Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day)); 
			        //Diff gives the diffrence between the two dates.
			         
			        if(Diff<0)
			          {
			           alert("Plese select Today's date or Future Date.");
			           return false;
			          } 
			         else
			          {
			            document.getElementById("form1").action="tourbooking.asp"
                        document.getElementById("form1").submit();
			          }  
			 		    
	         }
	         		

	
    
 }
function pointtopointvalidate()
 {
  
     if (document.getElementById("selectgoingfrom").value=="")
      {
       alert("Please select Departure Place.");
       document.getElementById("selectgoingfrom").focus();
       return false;
      } 
      if (document.getElementById("selectgoingto").value=="")
      {
       alert("Please select Transfer Place.");
       document.getElementById("selectgoingto").focus();
       return false;
      } 
       if (document.getElementById("fleet").value=="")
      {
       alert("Please select Type of Vehicle.");
       document.getElementById("fleet").focus();
       return false;
      }
     if((document.getElementById("selectgoingfrom").value)==(document.getElementById("selectgoingto").value))
      {
       alert("There is no service available in these places.");
       document.getElementById("selectgoingfrom").value="";
       document.getElementById("selectgoingto").value="";
       document.getElementById("selectgoingfrom").focus();
       return false;
      } 
      if(document.getElementById("txtdate").value=="")
	    {
	     alert("Please select date.");
	     document.getElementById("txtdate").focus();
	     return false;
	     }
      else if(document.getElementById("txtdate").value!="")
          {
			 t2=document.getElementById("txtdate").value;
			 t1=document.getElementById("txttoday").value;
			
			//Total time for one day
					var one_day=1000*60*60*24; 
			//Here we need to split the inputed dates to convert them into standard format
			
					var x=t1.split("/");
					var y=t2.split("/");
				
			//date format(Fullyear,month,date) 

					var date1=new Date(x[2],x[0],(x[1]-1));
				var date2=new Date(y[2],y[0],(y[1]-1));
					
					var month1=x[1]-1;
					var month2=y[1]-1;
					
					//Calculate difference between the two dates, and convert to days
					Diff=Math.ceil((date2.getTime()-date1.getTime())/(one_day)); 
			        //Diff gives the diffrence between the two dates.
			         
			        if(Diff<0)
			          {
			           alert("Plese select Today's date or Future Date.");
			           return false;
			          } 
			         else
			          {
			            var goingfrom=document.getElementById("selectgoingfrom").value;
						var date1=document.getElementById("txtdate").value;
						var timeval11=document.getElementById("selecttime").value;
						var timeval22=document.getElementById("daynight").value;
						var goingto=document.getElementById("selectgoingto").value;
						var carid=document.getElementById("fleet").value;
						var hiddencars=document.getElementById("tourhiddencars1").value
						var hiddencars22=document.getElementById("tourhiddencars2").value
						//alert(hiddencars);
						document.getElementById("form1").action="act_pointtopointquote.asp?carid="+carid+"&fromplace="+goingfrom+"&toplace="+goingto+"&date1="+date1+"&timeval1="+timeval11+"&timeval2="+timeval22+"&hidcars="+hiddencars+"&hidcars2="+hiddencars22+"&indexid=1";
						document.getElementById("form1").submit();
			          }  
			 		    
	         }
	         	
    
 }
function gotolanguage()
	{
		document.form1.method='post';
		document.form1.action = 'index.asp';
		document.form1.submit();
	}
var cal19 = new CalendarPopup(); 
cal19.showYearNavigation(); 
cal19.showYearNavigationInput();


function selectvehicle()
  {
  
   
  
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        {
		
         document.getElementById("tourhiddencars").value=xmlHttp.responseText;
         temp=document.getElementById("tourhiddencars").value;
         a=temp.split("|")
        
         valfld=a[0].split(',')
         namefld=a[1].split(',')
         
         
        var dropObj=document.getElementById("tourvehicle");

		for (r=dropObj.options.length-1;r>0;r--)
	    dropObj.options[r]=null

		for(var i=0;i<valfld.length;i++)
		dropObj.options[i]=new Option(namefld[i],valfld[i]);
  
        }
      }
      
    var url="act_tourvehicleselection.asp"
    var tourid1=document.getElementById("dailytour").value;
		
	url=url+"?tourid="+tourid1;
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)  
    
  }
  
  function selectvehicle1()
  {
  
   /*if (document.getElementById("selectgoingfrom").value=="")
      {
       alert("Please select Departure Place");
       document.getElementById("selectgoingto").value="";
       document.getElementById("selectgoingfrom").focus();
       return false;
      } 
   if((document.getElementById("selectgoingfrom").value)==(document.getElementById("selectgoingto").value))
      {
       alert("There is no service available in these places");
       document.getElementById("selectgoingfrom").value="";
       document.getElementById("selectgoingto").value="";
       document.getElementById("selectgoingfrom").focus();
       return false;
      } */
  
  var xmlHttp1;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp1=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp1=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp1=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp1.onreadystatechange=function()
      {
      if(xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
        {
	     
	     if (xmlHttp1.responseText=="")
		  {
		    alert("Sorry no service is available.Please select different palces.");  
		  }
		  else
		  {
			document.getElementById("tourhiddencars1").value=xmlHttp1.responseText;
			temp1=document.getElementById("tourhiddencars1").value;
			b=temp1.split("|")
			valfld1=b[0].split(',')
			namefld1=b[1].split(',')
	         
	         
			var dropObj1=document.getElementById("fleet");

			for (r=dropObj1.options.length-1;r>0;r--)
			dropObj1.options[r]=null

			for(var i=0;i<valfld1.length;i++)
			dropObj1.options[i]=new Option(namefld1[i],valfld1[i]);
         }
        }
      }
      
    var url1="act_pointtopointvehicle.asp"
    var from1=document.getElementById("selectgoingfrom").value;
   // alert(from1);
    
    var to1=document.getElementById("selectgoingto").value;
   // alert(to1);
	
	url1=url1+"?fromplace="+from1+"&toplace="+to1;
	
	xmlHttp1.open("GET",url1,true)
	xmlHttp1.send(null)  
  
  }
  
  function gettoplaces()
  {
  
  /* if (document.getElementById("selectgoingfrom").value=="")
      {
       alert("Please select Departure Place");
       document.getElementById("selectgoingto").value="";
       document.getElementById("selectgoingfrom").focus();
       return false;
      } 
   if((document.getElementById("selectgoingfrom").value)==(document.getElementById("selectgoingto").value))
      {
       alert("There is no service available in these places");
       document.getElementById("selectgoingfrom").value="";
       document.getElementById("selectgoingto").value="";
       document.getElementById("selectgoingfrom").focus();
       return false;
      } */
  
  var xmlHttp2;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp2=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp2.onreadystatechange=function()
      {
      if(xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
        {
	     
	     if (xmlHttp2.responseText=="")
		  {
		    alert("Sorry no service is available.Please select different palces");  
		  }
		  else
		  {
			document.getElementById("tourhiddencars2").value=unescape(xmlHttp2.responseText);
			temp1=document.getElementById("tourhiddencars2").value;
			//alert(temp1);
			b=temp1.split("|")
			valfld1=b[1].split(',')
			namefld1=b[1].split(',')
			//alert(valfld1);
			//alert(namefld1);
	         
	         
			var dropObj1=document.getElementById("selectgoingto");

			for (r=dropObj1.options.length-1;r>0;r--)
			dropObj1.options[r]=null

			for(var i=0;i<valfld1.length;i++)
			dropObj1.options[i]=new Option(namefld1[i],valfld1[i]);
			
			selectvehicle1();
         }
        }
      }
      
    var url2="act_pointtopointtoplaces.asp"
    var from1=document.getElementById("selectgoingfrom").value;
    //var to1=document.getElementById("selectgoingto").value;
	
	url2=url2+"?fromplace="+from1;
	
	xmlHttp2.open("GET",url2,true)
	xmlHttp2.send(null)  
  
  }
  
