// Removes leading whitespaces
        function LTrim( value )
		 {
		    var re = /\s*((\S+\s*)*)/;
			return value.replace(re, "$1");
	     }

		// Removes ending whitespaces
		function RTrim( value )
		 {
			var re = /((\s*\S+)*)\s*/;
	 		return value.replace(re, "$1"); 
		}
		// Removes leading and ending whitespaces
	 	function trim( value )
		 {
			return LTrim(RTrim(value));
	     }  	          
		function book()
		 {	 		 		 
		   var round= document.Form1.rdbWay[0].checked;		   
		   var one= document.Form1.rdbWay[1].checked;		   
		   var selFrom=document.Form1.selFrom.options[document.Form1.selFrom.selectedIndex].value;
		   var selTo=document.Form1.selTo.options[document.Form1.selTo.selectedIndex].value;
		   var txtCheckIn =document.getElementById("txtCheckIn").value;		   
		   var selAdult=document.Form1.selAdult.options[document.Form1.selAdult.selectedIndex].value;
		   var selChild=document.Form1.selChild.options[document.Form1.selChild.selectedIndex].value;
		   var selInfant=document.Form1.selInfant.options[document.Form1.selInfant.selectedIndex].value;
		   var check;
		   check=parseInt(selAdult)+parseInt(selChild) +parseInt(selInfant);		   
		 if(selFrom=="0")
		 {
		  alert("Select the From City");
		  document.Form1.selFrom.focus();
		  return false;
		 }
		  if(selTo=="0")
		 {
		  alert("Select the To City");
		  document.Form1.selTo.focus();
		  return false;
		 }
		 if(selFrom==selTo)
		 {
		  alert("From and To City can not same");
		  document.Form1.selFrom.focus();
		  return false;
		 }
		 if(trim(txtCheckIn)=="")
		 {
		  alert("Departure Date can not blank");
		  document.Form1.txtCheckIn.focus();
		  return false;
		 } 
		
		 if(round)
		 {
		    var  txtCheckOut =document.getElementById("txtCheckOut").value;
			
			if(trim(txtCheckOut)=="")
			{
			alert("Return Date can not blank");
			document.Form1.txtCheckOut.focus();
			return false;
			}
			 /*if(Date.parse(txtCheckOut)<=Date.parse(txtCheckIn))
			{
			alert("CheckOut Date can greater than CheckIn Date");
			document.Form1.txtCheckOut.focus();
			return false;
			}*/			
			tmp = txtCheckIn.split("/")
			xDate = tmp[1]+"/"+tmp[0]+"/"+tmp[2];
			refDate = calcJulian(xDate);
			tmp = txtCheckOut.split("/")
			xDate = tmp[1]+"/"+tmp[0]+"/"+tmp[2];
			fwdDate = calcJulian(xDate);
			if (fwdDate <= refDate)
			{
				alert("Please select Return Date must be greather then Travel Date ");					
				document.Form1.txtCheckOut.focus();
				return false;
			}			 
		 } 
		 if(check >=10)
		 {
		  alert("No of Pax. less than or equal to 9");
		  document.Form1.selAdult.focus();
		  return false;
		 } 
		 
		 }
		 function calcJulian(isDate)
		{			
			gregDate = new Date(isDate);
			year = gregDate.getFullYear(); 
			month = gregDate.getMonth()+1; 
			day = gregDate.getDate();
			A = Math.floor((7*(year+Math.floor((month+9)/12)))/4);
			B = day+Math.floor((275*month)/9)
			isJulian = (367*year)-A+B+1721014;
			return isJulian; 
		}	
         