///////get the date from onchange event///////////
function getlocation()
{
var loc=document.resform1.pu_location.value;
document.resform1.rt_location.value=loc;
$('#pickuptime').find('option').remove();
$('#dropofftime').find('option').remove();

x='';
$('#pickuptime').append($('<option></option').val(x).html('Select a time'));
$("#datepicker" ).datepicker( "setDate" , '' );
$('#dropofftime').append($('<option></option').val(x).html('Select a time'));
$("#datepicker2" ).datepicker( "setDate" , '' );
document.resform1.pu_minute.value = '';
document.resform1.pu_hour.value ='';
document.resform1.pu_day.value = '';
document.resform1.pu_month.value = '';
document.resform1.pu_year.value = '';

document.resform1.rt_minute.value = '';
document.resform1.rt_hour.value ='';
document.resform1.rt_day.value = '';
document.resform1.rt_month.value = '';
document.resform1.rt_year.value = '';

}

function getlocation2()
{
var location =document.resform1.pu_location.value;
document.resform1.rt_location.value=location;
}


///////////Page Validation///////////////////////////////////////////////////////
function getpage()
{
		dat1=new Date(document.resform1.pu_year.value,parseInt(document.resform1.pu_month.value-1),document.resform1.pu_day.value,document.resform1.pu_hour.value,document.resform1.pu_minute.value,0)
		
		dat2=new Date(document.resform1.rt_year.value,parseInt(document.resform1.rt_month.value-1),document.resform1.rt_day.value,document.resform1.rt_hour.value,document.resform1.rt_minute.value,0)
		
		dat1.setMinutes(dat1.getMinutes()-dat1.getTimezoneOffset());
		dat2.setMinutes(dat2.getMinutes()-dat2.getTimezoneOffset());
        
		aa=dat2.getTime()-dat1.getTime();
		bb=Math.ceil((aa/(3600*24*1000)))
		document.getElementById('days').value=bb
		pickupdate=$( "#datepicker" ).datepicker( "getDate" );
		dropoffdate=$( "#datepicker2" ).datepicker( "getDate" );
		
		pickuptime=$( "#pickuptime option:selected" ).val();
		dropofftime=$( "#dropofftime option:selected" ).val();
	 if(document.resform1.pu_location.value=="-1")
		{
		  alert('Please select pickup location');
		  return false;
		}
		else if(document.resform1.rt_location.value=="-1")
		{
		   alert('Please select pickup location');
		  return false;
		}
		else if(pickupdate=== null)
		{
		   alert('Please select pickup date');
		  return false;
		}
		else if(dropoffdate=== null)
		{
		   alert('Please select dropoff date');
		  return false;
		}
		else if(pickuptime=='')
		{
		   alert('Please select pickup time');
		  return false;
		}
		else if(dropofftime=='')
		{
		   alert('Please select dropoff time');
		  return false;
		}
		else if(aa<=0)
		{
		   alert('The pickup date and time should be greater than dropoff time');
		   return false;
		}
		else
		 return true;
		

}
////////////////check the same location////////////////////////
function checkrt(x){
if(x!=1)
if(document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value!='')
//if(document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value==x)
 {alert('As the pick Up and Drop Off locations are different this is a ONE WAY journey.  One way rentals must be agreed in advance with the locations you have requested.  If available it attracts an additional charge to the vehicle cost.  Depending on the Pick Up and Return locations these charges can range from £50 to £70 for Cars and £150 to £200 for Vans.  For all possible options and precise costing please contact our offices.');
	document.resform1.rt_location.selectedIndex=document.resform1.pu_location.selectedIndex;
 }
}


function checkrt2(x){
pl=document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value;
rt=document.resform1.pu_location.options[document.resform1.rt_location.selectedIndex].value;
if(x!=1)
if(document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value!='-1')
 {
	 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)
		  {
			 var text=xmlHttp.responseText;	  
			 
			 if(text==0)
				{
					alert('One way rentals are not possible between locations with different suffixes (1), (2), (3) etc.  Please select a drop off location which has the same suffix as the Pick Up location.');
					document.resform1.rt_location.selectedIndex=document.resform1.pu_location.selectedIndex;
				}
				else
				{
				  alert('As the pick Up and Drop Off locations are different this is a ONE WAY journey.  One way rentals must be agreed in advance with the locations you have requested.  If available it attracts an additional charge to the vehicle cost.  Depending on the Pick Up and Return locations these charges can range from £50 to £70 for Cars and £150 to £200 for Vans.  For all possible options and precise costing please contact our offices.');


				 
					
					$('#dropofftime').find('option').remove();
					$('#dropofftime').append($('<option></option').val(x).html('Select a time'));
					$("#datepicker2" ).datepicker( "setDate" , '' );
					

					document.resform1.rt_minute.value = '';
					document.resform1.rt_hour.value ='';
					document.resform1.rt_day.value = '';
					document.resform1.rt_month.value = '';
					document.resform1.rt_year.value = '';

				}
		  }
		}
	  xmlHttp.open("GET","samelocation.php?pl="+pl+'&rt='+rt,true);
	  xmlHttp.send(null);
 
 }

}

///////////////////Display the vehicle detail onchange the date//////////////////////////
function display_vehicle()
{
dy=document.resform1.days.value;
pickupmonth=document.resform1.pu_month.value;
pickupyear=document.resform1.pu_year.value;
pickupday=document.resform1.pu_day.value;

pickuphour=document.resform1.pu_hour.value;
pickupminute=document.resform1.pu_minute.value;

pickupdatecheck=pickupyear+'-'+pickupmonth+'-'+pickupday+'-'+pickuphour+'-'+pickupminute;

dropoffmonth=document.resform1.rt_month.value;
dropoffyear=document.resform1.rt_year.value;
dropoffday=document.resform1.rt_day.value;

dropoffhour=document.resform1.rt_hour.value;
dropoffminute=document.resform1.rt_minute.value;

dropoffdatecheck=dropoffyear+'-'+dropoffmonth+'-'+dropoffday+'-'+dropoffhour+'-'+dropoffminute;

 sesrate='no'
if(pickupmonth==12)
if(pickupday>=15 && pickupmonth<=26)
 sesrate='yes'
pl=document.resform1.pu_location.selectedIndex;
ty=document.resform1.type.value;
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)
      {
      var text=xmlHttp.responseText;	
	  //var xmlDoc=loadXMLString(text)
	  //x=xmlDoc.getElementsByTagName("rates")[0];
	 document.getElementById('displayvechile').innerHTML=text;
	  //y=x.childNodes; 
	  y=0;
		for (i=0;i<y.length;i++)
		  { 
			z=y[i].nodeName;
			spltstr=z.split("_");
			zz=spltstr[0]+'_'+spltstr[1];	
			
			if(spltstr[2]!="")
				document.getElementById(zz).innerHTML="&pound; "+spltstr[2];
			else
				document.getElementById(zz).innerHTML="";
			
		  }
      }
    }
 
  xmlHttp.open("GET","ratedetails.php?pl="+pl+'&days='+dy+'&s='+sesrate+'&ty='+ty+'&pd='+pickupdatecheck+'&dd='+dropoffdatecheck,true);
  xmlHttp.send(null);
  }

////////////////////Display the pick up calendar/////////////////////////////////////////
function displayPUCalendarWindow(url, width, height) {
		var pu_supplier = stringSplit ( document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value, ':' );
		url = url + "&pu_location=" + pu_supplier[1];

		if(document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value==-1)
		{
		  alert('Please select pickup location');
		  return;
		}
		LeftPosition = (screen.availWidth) ? (screen.availWidth-width)/2 : 0;
		TopPosition = (screen.availHeight) ? (screen.availHeight-height)/2 : 0;
		
		var Win1 = window.open(url,"Yellohire",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,menubar=no,status=no,left=' + LeftPosition + ',top=' +TopPosition );
	}
	
/////////////Displat the drop calendar/////////////////////////////////////////////////////////	
	function displayRTCalendarWindow(url, width, height) {
		var rt_supplier = stringSplit ( document.resform1.pu_location.options[document.resform1.pu_location.selectedIndex].value, ':' );
		url = url + "&pl=" + document.resform1.rt_location.options[document.resform1.rt_location.selectedIndex].value
		
		LeftPosition = (screen.availWidth) ? (screen.availWidth-width)/2 : 0;
		TopPosition = (screen.availHeight) ? (screen.availHeight-height)/2 : 0;
		
		var p_month = document.resform1.pu_month.value;
		var p_year = document.resform1.pu_year.value;
		var p_day = document.resform1.pu_day.value;
		
		url = url + "&p_day=" + p_day + "&p_month=" + p_month + "&p_year=" + p_year;
		var Win2 = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=no,scrollbars=yes,menubar=no,status=no,left=' + LeftPosition + ',top=' +TopPosition );

		
		
	}
	
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

  
/////////////////Display the popup window of vehicle details//////////////////////
function previewinfo(x){
	
			ScrollXY =getScrollXY() ;
			var dsocleft=ScrollXY[0];		
			var dsoctop=ScrollXY[1];	
			

			 document.getElementById('popupdiv').innerHTML='<div class="border_preview" style="width:400px;"><table border="0"><tr><td  align="right" colspan="3"><div id="loader_container"><div id="loader_preview"><div align="center">Loading...</div></div></div> </td></tr>	</table></div>';
			
			 document.getElementById('popupdiv').style.marginLeft="-"+(dsocleft+200)+'px';
			 document.getElementById('popupdiv').style.marginTop=(dsoctop-200)+'px';
			 document.getElementById('popupdiv').style.display='block';
			 if(x==1)
			 texts='<h2>Vehicle Deposit</h2><p>You are getting a vehicle valued at many thousands of pounds for your hire fee.  This is a small deposit to give some protection to the supplier. </p><p>You will be required to leave details of your credit/debit card for this amount.  For Debit cards, and some credit cards,this sum will be held by the supplier for the hire period. </p>';
			 else if(x==2)
				 texts='<h2>Insurance Excess</h2><p>If you have an accident with this vehicle you will be responsible to pay for any repairs or replacements.  The maximum you will pay is the Insurance Excess amount.</p><p>There is an option to reduce this to zero if you take out the Insurance Excess Reimbursement. ( See below )</p>';
			 else if(x==3)
				 texts='<h2>Insurance Excess Reimbursement</h2><p>( Sometimes called Excess Reduction/Protection )If you have an accident with this vehicle you will be responsible to pay the Excess amount in full.</p><p>With Insurance Excess Reimbursement you will be able to re-claim any excess amount you have paid.</p>';
			 document.getElementById('popupdiv').innerHTML='<div class="border_preview"><div class="texts">'+texts+'</div><div><a href="javascript:void(0)"  style="margin:0 auto;text-decoration:none;color:black;display:block;width:100px;height:20px;background-color:#09c;vertical-align:middle;padding:2px;border:1px solid black;font-weight:bold;font-size:18px;text-align:center" onclick="document.getElementById(\'popupdiv\').style.display=\'none\'" >Close </a></div></div>';
	}
function previewdetail(x){
	//alert(x);
pl=document.resform1.pu_location.selectedIndex;
rt=document.resform1.rt_location.selectedIndex;
noday=document.resform1.days.value;

pickupmonth=document.resform1.pu_month.value;
pickupyear=document.resform1.pu_year.value;
pickupday=document.resform1.pu_day.value;

pickuphour=document.resform1.pu_hour.value;
pickupminute=document.resform1.pu_minute.value;

pickupdatecheck=pickupyear+'-'+pickupmonth+'-'+pickupday+'-'+pickuphour+'-'+pickupminute;

dropoffmonth=document.resform1.rt_month.value;
dropoffyear=document.resform1.rt_year.value;
dropoffday=document.resform1.rt_day.value;

dropoffhour=document.resform1.rt_hour.value;
dropoffminute=document.resform1.rt_minute.value;

dropoffdatecheck=dropoffyear+'-'+dropoffmonth+'-'+dropoffday+'-'+dropoffhour+'-'+dropoffminute;

			ScrollXY =getScrollXY() ;
			var dsocleft=ScrollXY[0];		
			var dsoctop=ScrollXY[1];	
			

			 document.getElementById('popupdiv').innerHTML='<div class="border_preview" style="width:400px;"><table border="0"><tr><td  align="right" colspan="3"><div id="loader_container"><div id="loader_preview"><div align="center">Loading...</div></div></div> </td></tr>	</table></div>';
			
			 document.getElementById('popupdiv').style.marginLeft="-"+(dsocleft+200)+'px';
			 document.getElementById('popupdiv').style.marginTop=(dsoctop-200)+'px';
			 document.getElementById('popupdiv').style.display='block'
if(1==1)
 {
	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)
		  {
			var text=xmlHttp.responseText;	 
			width=0;
			height=0;
			
			ScrollXY =getScrollXY() ;
			var dsocleft=ScrollXY[0];		
			var dsoctop=ScrollXY[1];	
			

			 document.getElementById('popupdiv').innerHTML=text;
			
			 //document.getElementById('popupdiv').style.left=0+'px';
			// document.getElementById('popupdiv').style.top=dsoctop+100+'px';
			 //document.getElementById('popupdiv').style.display='block';
		  }
		}
		 pl=document.resform1.pu_location.selectedIndex;
	    xmlHttp.open("GET","vehiledetail.php?id="+x+"&day="+noday+"&pd="+pickupdatecheck+"&dd="+dropoffdatecheck+"&pl="+pl,true);
	  xmlHttp.send(null);
 
 }

}

//////////////////////Page validate////////////////////////////////////////
function emailme(which) {
//alert(which);
		dat1=new Date(document.resform1.pu_year.value,parseInt(document.resform1.pu_month.value-1),document.resform1.pu_day.value,document.resform1.pu_hour.value,document.resform1.pu_minute.value,0)
		
		dat2=new Date(document.resform1.rt_year.value,parseInt(document.resform1.rt_month.value-1),document.resform1.rt_day.value,document.resform1.rt_hour.value,document.resform1.rt_minute.value,0)
		
		dat1.setMinutes(dat1.getMinutes()-dat1.getTimezoneOffset());
		dat2.setMinutes(dat2.getMinutes()-dat2.getTimezoneOffset());
        
		aa=dat2.getTime()-dat1.getTime();
		bb=aa/(3600*24*1000)
		
		theone=false;
		x=document.getElementsByName('cars');
		ddays=parseInt(document.resform1.days.value);
		//if(x['length']!=0)
		if(document.resform1.cars.value!='-1')
		{
			xx='stopsell_'+document.resform1.cars.value;
			//if (document.resform1.cars[i].checked==true)
			//{
			theone=true			
			if(document.getElementById(xx).value=='1')
				{
				  alert('At this location this vehicle is either in very short supply or SOLD OUT.  Call our office on  (UK) 8704-99-77-11  for other options.Or  select another location.');
				  return false;
				}
			//}
			
		}
		
		
		if(document.resform1.pu_location.value==-1)
		{
		  alert('Please select pickup location');
		  return false;
		}
		else if(document.resform1.rt_location.value==-1)
		{
		   alert('Please select pickup location');
		  return false;
		}

		else if(theone==false)
		{
		   alert('Please select a  vehicle. ');
		   return false;
		}
		else if(aa<=0)
		{
		   alert('The pickup date and time should be greater than dropoff time');
		   return false;
		}
		else
			{
			if(which==1)
				{
					document.resform1.action='https://www.yellohire.com/drive.php';
					//document.resform1.action='index.php?fn=drive';
					return true;
					}
			else
				{ 
				if(ddays>21)
					{
					   alert('Contact office for special rate for extended rentals.');
					   return false;
					}

				document.resform1.action='https://www.yellohire.com/booking.php';
				//document.resform1.action='index.php?fn=booking';
				return true;
				}
			}
	}
////get all locations //
function getalllocation()
{
	
	 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)
		  {
			 var text=xmlHttp.responseText;	
			 var st1 = text.split("***");
			 document.resform1.pu_location.length=0;
			 document.resform1.rt_location.length=0;
			 document.resform1.pu_location.options[0]=new Option('Select a location',-1)
			 document.resform1.rt_location.options[0]=new Option('Select a location',-1)
			 ii=1
			 for(x in st1)
			  {
				 y=st1[x].split("@@@");
				 document.resform1.pu_location.options[ii]=new Option(y[1],y[0]);
				 document.resform1.rt_location.options[ii]=new Option(y[1],y[0])
				 ii++;
				 
			  }		
			 
           }
		}
	  xmlHttp.open("GET","getalllocations.php",true);
	  xmlHttp.send(null);
}

$(function() {

		
		$( "#datepicker" ).datepicker({
			showOn: "button",
			buttonImage: "images/icon_cal.gif",
			buttonImageOnly: true,
			numberOfMonths: 2,
			showButtonPanel: false,
			
			dateFormat:'dd/mm/yy',		
			
			onSelect: function(dateText, inst) { 
				//alert('gettime.php?pl='+$('#pu_location').val()+'&date='+dateText+'&t=d');
				$.getJSON('gettime.php?pl='+$('#pu_location').val()+'&date='+dateText+'&t=p', function(data) {
				  
				  p_minute='';
				  p_hour='';
				  p_month='';
				  p_day='';
				  p_year='';
				 

				 $( "#datepicker2" ).datepicker( "setDate" , dateText );
				 $( "#datepicker2").datepicker( "option", "minDate", dateText );
				 $('#pickuptime').find('option').remove();
				 $('#dropofftime').find('option').remove();
				
				  if(data['msg']=='success')
					{
					  
					  
					  $('#pickuptime').append($('<option></option').val('').html('select a time'));
					  $('#dropofftime').append($('<option></option').val('').html('select a time'));

					  for(x in data['openhours'])
						{
							
							$('#pickuptime').append($('<option></option').val(x).html(data['openhours'][x]));
							$('#dropofftime').append($('<option></option').val(x).html(data['openhours'][x]));
						}
						min=data['minmin'];

						$date=dateText.split('/');

						p_day=parseInt($date[0],10);
						p_month=parseInt($date[1],10);
						p_year=parseInt($date[2],10);
						p_minute='';
						p_hour='';

					}
					else
					{
						$('#pickuptime').append($('<option></option').val('').html(data['openhours']));
					    $('#dropofftime').append($('<option></option').val('').html(data['openhours']));
					}
					document.resform1.pu_minute.value =p_minute;
					document.resform1.pu_hour.value = p_hour;
					document.resform1.pu_day.value = p_day;
					document.resform1.pu_month.value = p_month;
					document.resform1.pu_year.value = p_year;

					document.resform1.rt_minute.value = p_minute;
					document.resform1.rt_hour.value = p_hour;
					document.resform1.rt_day.value = p_day;
					document.resform1.rt_month.value = p_month;
					document.resform1.rt_year.value = p_year;
					$('#days').val('0');
					if($('#displayvechile').length>0)	display_vehicle();
				});
			},

			beforeShow: function(input, inst) { 
				if($(this).datepicker('isDisabled'))
				{
				}
			}
			
		});

		
		$( "#datepicker2" ).datepicker({
			showOn: "button",
			buttonImage: "images/icon_cal.gif",
			buttonImageOnly: true,
			numberOfMonths: 2,
			showButtonPanel: false,
			minDate: +2 ,
			dateFormat:'dd/mm/yy',		
			
			onSelect: function(dateText, inst) { 
				
				$.getJSON('gettime.php?pl='+$('#rt_location').val()+'&date='+dateText+'&t=d', function(data) {
				  
				  p_minute='';
				  p_hour='';
				  p_month='';
				  p_day='';
				  p_year='';
				   $('#dropofftime').find('option').remove();
				  if(data['msg']=='success')
					{
					 
					  $('#dropofftime').append($('<option></option').val('').html('select a time'));

					  for(x in data['openhours'])
						{
							
							$('#dropofftime').append($('<option></option').val(x).html(data['openhours'][x]));
						}
					  
					    min=data['minmin'];
						
						$date=dateText.split('/');
						p_day=parseInt($date[0],10);
						p_month=parseInt($date[1],10);
						p_year=parseInt($date[2],10);
						p_minute='';
						p_hour='';
					}
					else
					{
						
					    $('#dropofftime').append($('<option></option').val('').html('closed'));
					}
					document.resform1.rt_minute.value = p_minute;
					document.resform1.rt_hour.value = p_hour;
					document.resform1.rt_day.value = p_day;
					document.resform1.rt_month.value = p_month;
					document.resform1.rt_year.value = p_year;
					$('#days').val('0');
					if($('#displayvechile').length>0)	display_vehicle();
				});
			},

			beforeShow: function(input, inst) { 
				if($(this).datepicker('isDisabled'))
				{
				}
			}
			
		});
		$("#datepicker" ).datepicker( "setDate" , '' );
		$("#datepicker2" ).datepicker( "setDate" , '' );

		cal="+"+$('#calender_start_date').val();
		
		$( "#datepicker").datepicker( "option", "minDate", cal );
		$( "#datepicker2").datepicker( "option", "minDate", cal );

		$('#pickuptime').change(function(){
			
			v=$(this).val();
			if(v!='')
			{
				p_minute=v%60;
				p_hour=parseInt(v/60);
				document.resform1.pu_minute.value = p_minute;
				document.resform1.pu_hour.value = p_hour;
			}
			$('#days').val(calculateDays());
			if($('#displayvechile').length>0)	display_vehicle();
		});
	
		$('#dropofftime').change(function(){
			
			v=$(this).val();
			if(v!='')
			{
				p_minute=v%60;
				p_hour=parseInt(v/60);
				document.resform1.rt_minute.value = p_minute;
				document.resform1.rt_hour.value = p_hour;
			}
			$('#days').val(calculateDays());
			if($('#displayvechile').length>0)	display_vehicle();
		});

		$('#calpickup').click(function(e){
			$("#datepicker" ).datepicker( "show");
			e.preventDefault();
		});

		$('#caldropoff').click(function(e){
			$("#datepicker2" ).datepicker( "show");
			e.preventDefault();
			
		});
	});

function calculateDays()
{
	dat1=new Date(document.resform1.pu_year.value,parseInt(document.resform1.pu_month.value-1),document.resform1.pu_day.value,document.resform1.pu_hour.value,document.resform1.pu_minute.value,0)
		
		dat2=new Date(document.resform1.rt_year.value,parseInt(document.resform1.rt_month.value-1),document.resform1.rt_day.value,document.resform1.rt_hour.value,document.resform1.rt_minute.value,0)
		
		dat1.setMinutes(dat1.getMinutes()-dat1.getTimezoneOffset());
		dat2.setMinutes(dat2.getMinutes()-dat2.getTimezoneOffset());
        
		aa=dat2.getTime()-dat1.getTime();
		bb=Math.ceil((aa/(3600*24*1000)))
		return bb;
}

