var today=new Date();
var todate=today.getDate();
var tomonth=today.getMonth();
var toyear=today.getFullYear();
var checkOK = "0123456789";

function isDate1(dt)
{
        var dtCh= "/";
        var daysInMonth = DaysArray(12)
  	var pos1=dt.indexOf(dtCh)
  	var pos2=dt.indexOf(dtCh,pos1+1)
  	var strMonth=dt.substring(0,pos1)
  	var strDay=dt.substring(pos1+1,pos2)
  	var strYear=dt.substring(pos2+1)
  	var strYr=strYear
  	if (strDay.charAt(0)=="0" && strDay.length>1) var strDay=strDay.substring(1)
  	if (strMonth.charAt(0)=="0" && strMonth.length>1) var strMonth=strMonth.substring(1)
  	for (var i = 1; i <= 3; i++) {
  		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
  	}
  	month=parseInt(strMonth)
  	day=parseInt(strDay)
  	year=parseInt(strYr)
  	if (strMonth.length<1 || month<1 || month>12){
  		alert("Please enter a valid month")
  		return false
  	}
  	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
  		alert("Please enter a valid day")
  		return false
  	}
  	return true    
}



function stripCharsInBag(s, bag)
{
        var i;
        var returnString = "";
        // Search through string's characters one by one.
        // If character is not in bag, append to returnString.
        for (i = 0; i < s.length; i++)
        {   
	    var c = s.charAt(i);
	    if (bag.indexOf(c) == -1) returnString += c;
        }
        return returnString;
}

function daysInFebruary (year)
{
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}




function myfunction()
{
	document.searchform.submit();
}

function CityCheck(indicator)
{

	   var iscity=false;
	   var city=document.searchform.strCity
	   for(i=0;i<indicator;i++)
	   {
		if(city[i].checked)
		{
		   iscity=true;
		}     
	   }
	   if(city[indicator].checked)
	   {

		 if(document.searchform.strOtherCity.value!="")
		 {
		    iscity=true;
		 }
	   }

	   if(iscity==false)
	   {
		   alert("Please enter City Name");
		   document.searchform.strOtherCity.focus();
		   return false;
	       }

	   else
	   {
		    myfunction()
	   } 
}


function DateCheck()
{
var j;
	if(document.searchform.strDestinationType[0].checked)
	{
		j=0;
	}
	
	if(document.searchform.strDestinationType[1].checked)
	{
		j=1;		
	}
	
	if(j==0)
	{
	        
	        document.searchform.strOtherCity.value=document.searchform.strOtherCity0.value;
	
		document.searchform.strCheckindate.value=document.searchform.strCheckindate0.value;
		document.searchform.strCheckinmonth.value=document.searchform.strCheckinmonth0.value;
		document.searchform.strCheckinyear.value=document.searchform.strCheckinyear0.value;
		
		document.searchform.strCheckoutdate.value=document.searchform.strCheckoutdate0.value;
		document.searchform.strCheckoutmonth.value=document.searchform.strCheckoutmonth0.value;
		document.searchform.strCheckoutyear.value=document.searchform.strCheckoutyear0.value;
				
		
	}
	
	if(j==1)
	{
		document.searchform.strOtherCity.value=document.searchform.strOtherCity1.value;
		
		document.searchform.strCheckindate.value=document.searchform.strCheckindate1.value;
		document.searchform.strCheckinmonth.value=document.searchform.strCheckinmonth1.value;
		document.searchform.strCheckinyear.value=document.searchform.strCheckinyear1.value;
	
		document.searchform.strCheckoutdate.value=document.searchform.strCheckoutdate1.value;
		document.searchform.strCheckoutmonth.value=document.searchform.strCheckoutmonth1.value;
		document.searchform.strCheckoutyear.value=document.searchform.strCheckoutyear1.value;
	}
	
		
	var iscity=false;
	var Checkindate=document.searchform.strCheckindate.value;
	
	var Checkinmonth=document.searchform.strCheckinmonth.value;
	Checkinmonth=Number(Checkinmonth);
	
	var Checkinyear=document.searchform.strCheckinyear.value;
	var Checkoutdate=document.searchform.strCheckoutdate.value;
	
	var Checkoutmonth=document.searchform.strCheckoutmonth.value;
	Checkoutmonth=Number(Checkoutmonth);
	
	var Checkoutyear=document.searchform.strCheckoutyear.value;
	var presentday=new Date(toyear,tomonth,todate);
	var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
	var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
	var city=document.searchform.strCity
	var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
	var diff=difference/1000/60/60/24;
	var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear

	  for(i=j*9;i<(8*(j+1))+j;i++)
	  {
	     if(city[i].checked)
	     {
		iscity=true;
	     }


	  }


	  if(city[(8*(j+1))+j].checked)
	  {

	      if(document.searchform.strOtherCity.value!="")
	      {
		 iscity=true;
	      }
	  }
		

	
	if(iscity==false)
	{
	alert("Please enter City Name");

		if(j==0)
		{
		document.searchform.strOtherCity0.focus();
		}
		if(j==1)
		{
		document.searchform.strOtherCity1.focus();
		}

	return false;
	}


	else if(isDate1(dt)==false)
	{
	return false;
	}
	else if(startdate<presentday)
	{
	alert(" CheckIn Date Should Be Higher Than Today's Date");
	return false;
	}
	else if(enddate < startdate)
	{
	alert(" End Date Should Be Higher Than  Start Date");
	return false;
	}

	else if(diff>30)
	{
	alert("Sorry You Cannot Do  Booking For More Than 30 Days");
	return false;
	}

	else
	{
		return true;
	} 
		
}


function Checkhotel(i)
{
    var Checkindate=document.forms[i].strCheckindate.value;
    var Checkinmonth=document.forms[i].strCheckinmonth.value;
    Checkinmonth=Number(Checkinmonth);
    var Checkinyear=document.forms[i].strCheckinyear.value;
    var Checkoutdate=document.forms[i].strCheckoutdate.value;
    var Checkoutmonth=document.forms[i].strCheckoutmonth.value;
    Checkoutmonth=Number(Checkoutmonth);
    var Checkoutyear=document.forms[i].strCheckoutyear.value;

    var presentday=new Date(toyear,tomonth,todate);
    var enddate=new Date(Checkoutyear,Checkoutmonth-1,Checkoutdate);
    var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
   
   
    var difference = Date.UTC(enddate.getYear(),enddate.getMonth(),enddate.getDate(),0,0,0)- Date.UTC(startdate.getYear(),startdate.getMonth(),startdate.getDate(),0,0,0);
    var diff=difference/1000/60/60/24;
    var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear
    if(isDate1(dt)==false)
    {
           return false;
    }
    
    else if(startdate<presentday)
    {
       alert(" Check-In-Date Should Be Higher Than Current Date");
       return false;
    }
    else if(enddate < startdate)
    {
        alert(" Check-Out-Date Should Be Higher Than  Check-In-Date");
        return false;
    }
    
        else if(diff>30)
        {
              alert("Sorry You Cannot Do  Booking For More Than 30 Days");
              return false;
    }
  
  
    else
    {
         return true;
    } 
}


function othercity(i)
{
   document.searchform.strCity[(i*9)+8].checked=true;
}

function text(i)
{
   document.searchform.strOtherCity[i].focus();
}


function carothercity(i)
{
   document.carsearchform.strCarCity[(i*9)+8].checked=true;
}


function cartext(i)
{
   document.carsearchform.strCarOtherCity[i].focus();
}




function setCheckOutDate(i)
{

  var checkindate;
  var checkinmonth;
  var checkinyear;
  var checkout;
  
    if(i==0)
    {
    
	checkindate=document.searchform.strCheckindate0.value;
	checkinmonth=Number(document.searchform.strCheckinmonth0.value)-1;
	checkinyear=document.searchform.strCheckinyear0.value;
	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)

	document.searchform.strCheckoutdate0.value = checkout.getDate();
	document.searchform.strCheckoutmonth0.value = (checkout.getMonth()+1);
	document.searchform.strCheckoutyear0.value = checkout.getYear();
    }
    
    else if(i==1)
    {
    	checkindate=document.searchform.strCheckindate1.value;
    	checkinmonth=Number(document.searchform.strCheckinmonth1.value)-1;
    	checkinyear=document.searchform.strCheckinyear1.value;
    	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
    
    	document.searchform.strCheckoutdate1.value = checkout.getDate();
    	document.searchform.strCheckoutmonth1.value = (checkout.getMonth()+1);
    	document.searchform.strCheckoutyear1.value = checkout.getYear();
    }
    
    else 
    {
	checkindate=document.searchform.strCheckindate.value;
	checkinmonth=Number(document.searchform.strCheckinmonth.value)-1;
	checkinyear=document.searchform.strCheckinyear.value;
	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)

	document.searchform.strCheckoutdate.value = checkout.getDate();
	document.searchform.strCheckoutmonth.value = (checkout.getMonth()+1);
	document.searchform.strCheckoutyear.value = checkout.getYear();
    }
   
      
}

function setCheckOutDateFlight(i)
 {
      var checkindate;
        var checkinmonth;
        var checkinyear;
  var checkout;
      if(i==2)
      {
          	checkindate=document.flightsearchForm.departureDay0.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth0.value)-1;
          	checkinyear=now.getFullYear();
          	//checkinyear=document.flightsearchForm.strCheckinyear1.value;
          	
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay0.value = checkout.getDate();
          	document.flightsearchForm.returnMonth0.value = (checkout.getMonth()+1);
          	checkout=now.getFullYear();
          	//document.flightsearchForm.strCheckoutyear1.value = checkout.getYear();
      }
      if(i==3)
      {
          	checkindate=document.flightsearchForm.departureDay0.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth0.value)-1;
          	checkinyear=document.flightsearchForm.departureYear0.value;
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay0.value = checkout.getDate();
          	document.flightsearchForm.returnMonth0.value = (checkout.getMonth()+1);
          	document.flightsearchForm.returnYear0.value = checkout.getYear();
          } if(i==4)
          {
          	checkindate=document.flightsearchForm.departureDay1.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth1.value)-1;
          	checkinyear=now.getFullYear();
          	//checkinyear=document.flightsearchForm.strCheckinyear1.value;
          	
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay1.value = checkout.getDate();
          	document.flightsearchForm.returnMonth1.value = (checkout.getMonth()+1);
          	checkout=now.getFullYear();
          	//document.flightsearchForm.strCheckoutyear1.value = checkout.getYear();
          } if(i==5)
          {
          	checkindate=document.flightsearchForm.departureDay1.value;
          	checkinmonth=Number(document.flightsearchForm.departureMonth1.value)-1;
          	checkinyear=document.flightsearchForm.departureYear1.value;
          	checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
          
          	document.flightsearchForm.returnDay1.value = checkout.getDate();
          	document.flightsearchForm.returnMonth1.value = (checkout.getMonth()+1);
          	document.flightsearchForm.returnYear1.value = checkout.getYear();
    }
 }


function setCheckOutDate1(i)
{
   var checkindate=document.searchform[i].strCheckindate.value;
   var checkinmonth=Number(document.searchform[i].strCheckinmonth.value)-1;
   var checkinyear=document.searchform[i].strCheckinyear.value;
   var checkout=new Date(Number(checkinyear), Number(checkinmonth), Number(checkindate)+1)
   document.searchform[i].strCheckoutdate.value = checkout.getDate();
   document.searchform[i].strCheckoutmonth.value = (checkout.getMonth()+1);
   document.searchform[i].strCheckoutyear.value = checkout.getYear();
   
}




function formsubmit(index,count)
{         
           if(indicator<1)
	   {
	       document.MoreInfoForm.submit();
	   }
	   else
	   {
	       document.MoreInfoForm[Number(index)].submit();
	   }
}

function formsubmitcity(index)
{
   if((document.MoreInfoForm.length)!=1)
   {
       document.MoreInfoForm[index].submit();
   }
   else
   {
       document.MoreInfoForm.submit();
   }
}


function CarDateCheck()
{
	  var j;
	  if(document.carsearchform.strHireType[0].checked)
	  {
	      j=0;
	     
	      if(document.carsearchform.strDays.value.length==0)
	      {
	          alert("Please Enter No. Of Days");
	          document.carsearchform.strDays.focus();
	          return false;
	      }
	     
	      else if(Number(document.carsearchform.strDays.value)>30)
	      {
	          alert("No. Of Days Should be less than 30 days");
	          document.carsearchform.strDays.focus();
	          return false;
	      }
	      else if(Number(document.carsearchform.strDays.value)==0)
	      {
		       alert("No. of days should not be zero");
		       document.carsearchform.strDays.focus();
		       return false;
              }
	     
	      
	      var check = document.carsearchform.strDays.value;
	      var allValid = true;
	      var allNum = "";
	      var l=0;
              for (i = 0;  i < check.length;  i++)
	      {
			ch = check.charAt(i);
			for (k = 0;  k < checkOK.length;  k++)
			if (ch == checkOK.charAt(k))
			break;
			if (k == checkOK.length)
			{
			    allValid = false;
				break;
			}
              }
	      if (!allValid)
	      {
			alert("Please enter only digit characters in the No. Of Days field.");
			return false;
	      }
		 
	  }
  
	  else if(document.carsearchform.strHireType[1].checked)
	  {
              if(document.carsearchform.airport[0].checked)
	      {
		  j=1;
		  if(document.carsearchform.strDropPoint.value.length==0)
		  {
		           alert("Please Enter Drop Point");
		           document.carsearchform.strDropPoint.focus();
		           return false;
		  }
              }
	      else if(document.carsearchform.airport[1].checked)
	      {
		  j=2;
		  if(document.carsearchform.strPickUpPoint.value.length==0)
		  {
		            alert("Please Enter PickUp Point");
		            document.carsearchform.strPickUpPoint.focus();
		            return false;
		  }
	      }
          }
       
	  if(j==0)
	  {
	   	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity0.value;
	   	document.carsearchform.strPeople.value=document.carsearchform.strPeople0.value;
	   	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate0.value;
	   	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth0.value;
	   	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear0.value;
	   	
	   	
	  }
	 
	  if(j==1)
	  {
	     	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity1.value;
	     	document.carsearchform.strPeople.value=document.carsearchform.strPeople1.value;
	     	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate1.value;
	     	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth1.value;
	     	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear1.value;
	     	document.carsearchform.strFlightDetail1.value=document.carsearchform.strFlightDetail11.value;
	     	document.carsearchform.strFlightDetail2.value=document.carsearchform.strFlightDetail21.value;
	     	if(document.carsearchform.strFlightDetail1.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail11.focus();
		     return false;
	    	}

	        else if(document.carsearchform.strFlightDetail2.value.length==0)
	        { 
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail21.focus();
		     return false;
	        }
	     
	  }
	  if(j==2)
	  {
	     	document.carsearchform.strCarOtherCity.value=document.carsearchform.strCarOtherCity2.value;
	     	document.carsearchform.strPeople.value=document.carsearchform.strPeople2.value;
	     	document.carsearchform.strCheckindate.value=document.carsearchform.strCheckindate2.value;
	     	document.carsearchform.strCheckinmonth.value=document.carsearchform.strCheckinmonth2.value;
	     	document.carsearchform.strCheckinyear.value=document.carsearchform.strCheckinyear2.value;
	     	document.carsearchform.strFlightDetail1.value=document.carsearchform.strFlightDetail12.value;
	     	document.carsearchform.strFlightDetail2.value=document.carsearchform.strFlightDetail22.value;
	     	if(document.carsearchform.strFlightDetail1.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail12.focus();
		     return false;
	     	}
		else if(document.carsearchform.strFlightDetail2.value.length==0)
	     	{
		     alert("Please Enter Flight Detail");
		     document.carsearchform.strFlightDetail22.focus();
		     return false;
	   	}
	     
	  }
	  var iscity=false;
	  var Checkindate=document.carsearchform.strCheckindate.value;
	  var Checkinmonth=document.carsearchform.strCheckinmonth.value;
	  Checkinmonth=Number(Checkinmonth);
	  var Checkinyear=document.carsearchform.strCheckinyear.value;
	  var presentday=new Date(toyear,tomonth,todate+2);
	  var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear  
	  
	  var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
	  var city=document.carsearchform.strCarCity
	 
	  for(i=j*9;i<(8*(j+1))+j;i++)
	  {
	     if(city[i].checked)
	     {
	        iscity=true;
	     }
	     
	       
	  }
  
    
	  if(city[(8*(j+1))+j].checked)
	  {
	      
	      if(document.carsearchform.strCarOtherCity.value!="")
	      {
	         iscity=true;
	      }
	  }
	  if(iscity==false)
	    {
	        alert("Please enter City Name");
	        return false;
	  }
	  else if(isDate1(dt)==false)
	  {
	         return false;
          }
	  
	  else if(startdate<presentday)
	  {
	     alert(" Bookin Time Should Be 48 Hour Before Renting Time");
	     return false;
	  }
	  
	  
	  else if(document.carsearchform.strPeople.value.length==0)
	  {
	    alert("Please Enter No. Of People");
	    
	    return false;
	  }
	  
	  
	  var check = document.carsearchform.strPeople.value;
	  
	  allValid = true;
	  var allNum = "";
	  var l=0;
          for (i = 0;  i < check.length;  i++)
	  {
	    	ch = check.charAt(i);
			for (l = 0;  l < checkOK.length;  l++)
			if (ch == checkOK.charAt(l))
			break;
			if (l == checkOK.length)
			{
			    allValid = false;
				break;
			}
          }
          if (!allValid)
	  {
		alert("Please enter only digit characters in the No. Of People field.");
		return false;
	  }
  
	  
	  else
	  {
	     return true;
	  } 
}

function Checkcarrental()
{
  	  var Checkindate=document.carsearchform.strCheckindate.value;
  	  var Checkinmonth=document.carsearchform.strCheckinmonth.value;
  	  Checkinmonth=Number(Checkinmonth);
  	  var Checkinyear=document.carsearchform.strCheckinyear.value;
	  var presentday=new Date(toyear,tomonth,todate+2);
  	  var startdate=new Date(Checkinyear,Checkinmonth-1,Checkindate);
  	  var dt=Checkinmonth+"/"+Checkindate+"/"+Checkinyear 
  
	  if(startdate<presentday)
	  {
	     alert(" Bookin Time  Should Be AtLeast 48 hour from Renting Time");
	     return false;
	  }

	  else if(document.carsearchform.strDays.value.length==0)
	  {
		 alert("Please Enter No. Of Days");
		 document.carsearchform.strDays.focus();
		 return false;
	  }

	  else if(Number(document.carsearchform.strDays.value)>30)
	  {
		alert("No. Of Days Should be less than 30 days");
		document.carsearchform.strDays.focus();
		return false;
	  }

	  else if(document.carsearchform.strPeople.value.length==0)
	  {
	    alert("Please Enter No. Of People");
	    document.carsearchform.strPeople.focus();
	    return false;
	  } 

	  else if(isDate1(dt)==false)
	  {
		 return false;
	  }
  

	  var checkday = document.carsearchform.strDays.value;
	  var allValidday = true;
	  for (i = 0;  i < checkday.length;  i++)
	  {
		ch = checkday.charAt(i);
		for (k = 0;  k < checkOK.length;  k++)
		if (ch == checkOK.charAt(k))
		break;
		if (k == checkOK.length)
		{
		    allValidday = false;
			break;
		}
	  }
	  if (!allValidday)
	  {
		alert("Please enter only digit characters in the No. Of Days field.");
		return false;
	  }
  
	  var checkpeople= document.carsearchform.strPeople.value;
	  allValidpeople = true;
	  for (i = 0;  i < checkpeople.length;  i++)
	  {
		ch = checkpeople.charAt(i);
		for (l = 0;  l < checkOK.length;  l++)
		if (ch == checkOK.charAt(l))
		break;
		if (l == checkOK.length)
		{
			allValidpeople = false;
			break;
		}
	  }
          if (!allValidpeople)
	  {
		alert("Please enter only digit characters in the No. Of People field.");
		return false;
	  }

	  else
	  {
	     return true;
	  } 
}




function switchImg(what,newImg)
{ 
	if (document.images)
	{	
		document.images[what].src = eval(newImg + ".src");
	}
}
if (document.images) 
{
	var img1On = new Image(); img1On.src = "images/india_1on.gif";
	var img1Off = new Image(); img1Off.src = "images/india_1off.gif";
	var img2On = new Image(); img2On.src = "images/india_2on.gif";
	var img2Off = new Image(); img2Off.src = "images/india_2off.gif";
	var img3On = new Image(); img3On.src = "images/india_3on.gif";
	var img3Off = new Image(); img3Off.src = "images/india_3off.gif";
	var img4On = new Image(); img4On.src = "images/india_4on.gif";
	var img4Off = new Image(); img4Off.src = "images/india_4off.gif";
	var img5On = new Image(); img5On.src = "images/india_5on.gif";
	var img5Off = new Image(); img5Off.src = "images/india_5off.gif";
	var img6On = new Image(); img6On.src = "images/india_6on.gif";
	var img6Off = new Image(); img6Off.src = "images/india_6off.gif";
	var img7On = new Image(); img7On.src = "images/india_7on.gif";
	var img7Off = new Image(); img7Off.src = "images/india_7off.gif";
	var img8On = new Image(); img8On.src = "images/india_8on.gif";
	var img8Off = new Image(); img8Off.src = "images/india_8off.gif";
}

function checkSelectPage(indicator)
{

	if(toyear<1900)
        {
      		toyear=toyear+1900;
        }
    	var reportingpoint = document.carBookingForm.arrReportingPoint
   	var date=document.carBookingForm.arrDD;
    	var month=document.carBookingForm.arrMM;
    	var year=document.carBookingForm.arrYY;
    	var presentday=new Date(toyear,tomonth,todate);
        if(indicator==1)
    	{
         	year1=year.value;
         	if(year1<1900)
      		{
      			year1=Number(year.value)+1900;
       		}
         	var startdate=new Date(year1,(month.value)-1,date.value);
         	if(startdate<presentday)
      		{ 
           		alert("Date should be greater than today's date");
           		date.focus();
           		return false;
      		}   
        	if(reportingpoint.value.length==0)
      		{
        		alert("Please enter reporting point");
        		reportingpoint.focus();
        		return false;
      		}
        }
    
    	else
    	{
         	for(i=0;i<indicator;i++)
      		{ 
     			if(reportingpoint[i].value.length==0)
      			{
        			alert("Please enter reporting point");
        			reportingpoint[i].focus();
        			return false;
      			}
     		}
     
     		if(indicator==2)
     		{
        		var firstday=new Date(year[0].value,(month[0].value)-1,date[0].value);
        		var secondday=new Date(year[1].value,(month[1].value)-1,date[1].value);
        		var finalday=new Date(year[0].value,(month[0].value)-1,Number(date[0].value)+30);
        		if(firstday<presentday)
        		{
          			alert("Date should be greater than today's date");
          			date[0].focus();
          			return false;
        		}
			if(firstday>secondday)
			{
			       alert("Date should be greater than previous date");
			    	date[1].focus();
			    	return false;
			}
			if(secondday>finalday)
			{
			    alert("Renting date should not be more than 30 days from First renting date");
			    date[1].focus();
			    return false;
			}
        
     		}
    		else if(indicator>2)
    		{
        		var firstday=new Date(year[0].value,(month[0].value)-1,date[0].value);
			var secondday=new Date(year[1].value,(month[1].value)-1,date[1].value);
			var lastdate=new Date(year[indicator-1].value,(month[indicator-1].value)-1,date[indicator-1].value);
			var secondlastdate=new Date(year[indicator-2].value,(month[indicator-2].value)-1,date[indicator-2].value);
			var finalday=new Date(year[0].value,(month[0].value)-1,Number(date[0].value)+30);

			if(firstday<presentday)
			{
			  alert("Date should be greater than today's date");
			  date[0].focus();
			  return false;
			}
			if(firstday>secondday)
			{
			    alert("Date should be less than next date");
			    date[0].focus();
			    return false;
			}
			if(lastdate<secondlastdate)
			{
			       alert("Date should be greater than previous date");
			    date[indicator-1].focus();
			    return false;
			}
			if(lastdate>finalday)
			{
			    alert("Renting date should not be more than 30 days from First Renting Date");
			    date[indicator-1].focus();
			    return false;
			}
     			for(i=1;i<indicator-1;i++)
      			{
          			var enddate=new Date(year[i+1].value,(month[i+1].value)-1,date[i+1].value);
          			var startdate=new Date(year[i].value,(month[i].value)-1,date[i].value);
          			var previousdate=new Date(year[i-1].value,(month[i-1].value)-1,date[i-1].value);
          			if(startdate>enddate)
          			{
            				alert("Date should be in-between previous date and next date");
           				 date[i+1].focus();
            				return false;
          			}
          			if(startdate<previousdate)
            			{
                			alert("Date should be in-between previous date and next date");
                			date[i].focus();
             				return false; 
         			}
         			if(startdate<presentday)
				{
				    alert("Date should be greater than today's date");
				    date[i].focus();
				    return false;
				}  
         			if(enddate>finalday)
            			{
             				alert("Renting date should not be more than 30 days from First renting date");
             				date[i+1].focus();
             				return false;
            			} 
            		}
    		}
         
   	}
   	return true;
}

function carothercity(i)
{
   document.carsearchform.strCarCity[(i*9)+8].checked=true;
}


function cartext(i)
{
   document.carsearchform.strCarOtherCity[i].focus();
}


function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) 
{
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function desiyaIndiaDate(i)

{
    var startdate=new Date(toyear,tomonth,todate+1);
    var enddate=new Date(toyear,tomonth,todate+2);
    
    for(var j=0;j<i;j++)
    {
    	document.searchform[j].strCheckindate.value = startdate.getDate();
    	document.searchform[j].strCheckinmonth.value = startdate.getMonth()+1;
    	document.searchform[j].strCheckinyear.value = startdate.getFullYear();
    
    	document.searchform[j].strCheckoutdate.value = enddate.getDate();
    	document.searchform[j].strCheckoutmonth.value = enddate.getMonth()+1;
    	document.searchform[j].strCheckoutyear.value = enddate.getFullYear();
   }
}

function CarCityCheck(indicator)
{
   
   var iscity=false;
   var city=document.carsearchform.strCarCity
   for(i=0;i<indicator;i++)
   {
        if(city[i].checked)
        {
           iscity=true;
        }     
   }
   if(city[indicator].checked)
   {
         
         if(document.carsearchform.strCarOtherCity.value!="")
         {
            iscity=true;
         }
   }
   if(iscity==false)
   {
           alert("Please enter City Name");
           document.carsearchform.strCarOtherCity.focus();
           return false;
   }
       
   else
   {
            document.carsearchform.submit();
   } 
}






  
