var timer_id;
function scroll_iframe(frm,inc,dir) {
  if (timer_id) clearTimeout(timer_id);
  if (window.frames[frm]) {
    if (dir == "v") window.frames[frm].scrollBy(0, inc);
    else window.frames[frm].scrollBy(inc, 0);
    timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);
  }
}

function stopScroll() { if (timer_id) clearTimeout(timer_id); }


function checkMandatoryFields(check)
 {	
 	var sMessage = "";
	if (document.getElementById('pickup_point').value == 0)
	    sMessage = sMessage + "\r\n" + "---Select Pickup Location";
		
	if (document.getElementById('dropoff_point').value == 0)
	    sMessage = sMessage + "\r\n" + "---Select Return Location";
		
	if (emptyField(check.ddate))					
		sMessage = sMessage + "\r\n" + "---Pickup Date";
		
	if (emptyField(check.rdate))					
		sMessage = sMessage + "\r\n" + "---Return Date";	   
		

	ato=document.frmQuote.rdate.value;		
	ato = ato.split("-");
	sato = ato[1] + "/" + ato[0] + "/" + ato[2];
	
	afrom=document.frmQuote.ddate.value;
	afrom = afrom.split("-");
	safrom = afrom[1] + "/" + afrom[0] + "/" + afrom[2];

	if((Date.parse(sato))< (Date.parse(safrom)))
		sMessage = sMessage + "\r\n" + "---Return Date Should not be Less than Pickup Date";
	else if((Date.parse(sato))== (Date.parse(safrom)))
	{
		if (document.frmQuote.pick_hour.value==document.frmQuote.drop_hour.value)
		{
			if (document.frmQuote.pick_min.value==document.frmQuote.drop_min.value)
				sMessage = sMessage + "\r\n" + "---Return Time Should not be equal to Pickup Time On the Same date";	
			else if (document.frmQuote.drop_min.value < document.frmQuote.pick_min.value)
			{
				sMessage = sMessage + "\r\n" + "---Return Time Should be Greater than Pickup Time ";	
			}
		}

		else if ((document.frmQuote.pick_hour.value)*1 > (document.frmQuote.drop_hour.value)*1)
		{
			sMessage = sMessage + "\r\n" + "---Return Time Should be Greater than Pickup Time ";	
		}
	
	}

    			
if (sMessage.length > 0)
	alert("Please fill the following mandatory field" + sMessage);
		
	else		
		return true;
	return false; 	
}

function emptyField(oTextField)
{
	if (oTextField.value.length == 0) return true;
	for (var i=0; i< oTextField.value.length; i++)
	 {
		var ch = oTextField.value.charAt(i);
		if (ch != ' ' && ch != '\t') return false;
	 }
}
function trim(par)
{
	var y = par.length;
	var ret = '';
	var ex=0;
	var bl=0;
	for (i=0;i<y;i++)
	{
		if (par.charAt(i) == ' ')
			bl = bl+1
		else
		{
			ret=ret+par.charAt(i);
			ex = ex+1
		}
	}
	if (bl==y)
		return true;
	else 
		return false;
	
}

function checkMandatoryFieldsBooking(check)
{	
 	var sMessage = "";
	
	if (document.getElementById('pickup_point').value == 0)
	    sMessage = sMessage + "\r\n" + "---Select Pickup Location";
		
	if (document.getElementById('dropoff_point').value == 0)
	    sMessage = sMessage + "\r\n" + "---Select Return Location";
		
	if (emptyField(check.ddate))					
		sMessage = sMessage + "\r\n" + "---Pickup Date";
		
	if (emptyField(check.rdate))					
		sMessage = sMessage + "\r\n" + "---Return Date";	
		
	  
	ato=document.frmbook.rdate.value;		
	ato = ato.split("-");
	sato = ato[1] + "/" + ato[0] + "/" + ato[2];
		
	afrom=document.frmbook.ddate.value;
	afrom = afrom.split("-");
	safrom = afrom[1] + "/" + afrom[0] + "/" + afrom[2];
	

	if((Date.parse(sato))< (Date.parse(safrom)))
		sMessage = sMessage + "\r\n" + "---Return Date Should not be Less than Pickup Date";

	else if((Date.parse(sato))== (Date.parse(safrom)))
	{

			if (document.frmbook.pick_hour.value==document.frmbook.drop_hour.value)
			{
				if (document.frmbook.pick_min.value==document.frmbook.drop_min.value)
					sMessage = sMessage + "\r\n" + "---Return Time Should not be equal to Pickup Time On the Same date";	
				else if (document.frmbook.drop_min.value < document.frmbook.pick_min.value)
				{
					sMessage = sMessage + "\r\n" + "---Return Time Should be Greater than Pickup Time ";	
				}
			}
			
			else if ((document.frmbook.pick_hour.value)*1 > (document.frmbook.drop_hour.value)*1)
			{
				sMessage = sMessage + "\r\n" + "---Return Time Should be Greater than Pickup Time ";	
			}
		
		}	 	
	
		
	if (sMessage.length > 0)
		alert("Please fill the following mandatory field" + sMessage);
			
		else		
			return true;
		return false; 	

}


function checkMandatoryFieldsRent(check)
 {	
 	var sMessage = "";
	
	if (document.getElementById('pickup_point').value == 0)
	    sMessage = sMessage + "\r\n" + "---Select Pickup Location";
			
	if (document.getElementById('dropoff_point').value == 0)
	    sMessage = sMessage + "\r\n" + "---Select Return Location";
		
	if (emptyField(check.ddate))					
		sMessage = sMessage + "\r\n" + "---Pick Up Date";
		
	if (emptyField(check.rdate))					
		sMessage = sMessage + "\r\n" + "---Return Date";									
		  
		ato=document.frmbook.rdate.value;		
		ato = ato.split("-");
		sato = ato[1] + "/" + ato[0] + "/" + ato[2];
		
		afrom=document.frmbook.ddate.value;
		afrom = afrom.split("-");
		safrom = afrom[1] + "/" + afrom[0] + "/" + afrom[2];
		
	if((Date.parse(sato))< (Date.parse(safrom)))
		sMessage = sMessage + "\r\n" + "---Return Date Should not be Less than Pickup Date";
	else if((Date.parse(sato))== (Date.parse(safrom)))
	{
		if ((document.frmbook.pick_hour.value)==(document.frmbook.drop_hour.value))
		{
			if ((document.frmbook.pick_min.value)==(document.frmbook.drop_min.value))
				sMessage = sMessage + "\r\n" + "---Return Time Should not be equal to Pickup Time On the Same date ";	
			else if (document.frmbook.drop_min.value < document.frmbook.pick_min.value)
			{
				sMessage = sMessage + "\r\n" + "---Return Time Should be Greater than Pickup Time ";	
			}
		}
		else if ((document.frmbook.pick_hour.value)*1 > (document.frmbook.drop_hour.value)*1)
		{
			sMessage = sMessage + "\r\n" + "---Return Time Should be Greater than Pickup Time ";	
		}
	}	 			
	
	if (sMessage.length > 0)
		alert("Please fill the following mandatory field" + sMessage);
			
		else		
			return true;
		return false; 	

}

