var now = addDays( new Date(),0);
var day =now.getDate();
var month = now.getMonth(); 

var Ret=addDays( new Date(),1);
var retday=Ret.getDate();
var retmonth=Ret.getMonth();


function setDrops(theForm) {

   theForm.pudate_dy.selectedIndex = day;
   theForm.pudate_mo.selectedIndex = month;
   theForm.dodate_dy.selectedIndex = retday;
   theForm.dodate_mo.selectedIndex = retmonth;
}

function addDays(myDate,days) {
    return new Date(myDate.getTime() + days*24*60*60*1000);
}

function monthChange(monthSelect)
{
   if ((monthSelect.name == 'pudate_mo') &&
       (document.CarSearch.dodate_mo.selectedIndex < monthSelect.selectedIndex)
      )
   {
      document.CarSearch.dodate_mo.selectedIndex = monthSelect.selectedIndex;
   }
  
}

function dayChange(daySelect)
{
   selected = daySelect.selectedIndex;
   if ((daySelect.name == 'pudate_dy') &&
       (document.CarSearch.dodate_dy.selectedIndex < selected + 1) &&
       (document.CarSearch.dodate_mo.selectedIndex <= document.CarSearch.pudate_mo.selectedIndex)
      )
   {
      if (selected < daySelect.length - 1)
      {
         document.CarSearch.dodate_dy.selectedIndex = selected + 1;
      }
      else
      {
         document.CarSearch.dodate_mo.selectedIndex += 1;
         document.CarSearch.dodate_dy.selectedIndex = 0;
      }
   }

}

function validate(form) {
  re = /S+/;
  if (!re.test(form.pucity.value)) {
    alert('Please enter a pick-up city');
    return false;
  }
  return true;
}

function check_area()
	{
	
	var number = document.CarSearch.puwhere.selectedIndex;

	if (document.CarSearch.puwhere.options[number].value == 'CITY') 
		{
		document.CarSearch.area.selectedIndex = 1;
		document.CarSearch.area.style.display = '';
		document.all.v1.style.display = 'none';
		document.all.v2.style.display = '';
		}
	else if (document.CarSearch.puwhere.options[number].value == 'AIRPORT') 
		{
		document.CarSearch.area.selectedIndex = -1;
		document.CarSearch.area.style.display = 'none';
		document.all.v1.style.display = '';
		document.all.v2.style.display = 'none';
		}

	return true;
	}

function clear_docity()
	{
	document.CarSearch.docity.value = "";
	return true;
	}


function submit_to(iPu) 
	{
	//alert('pu =' + document.CarSearch.puwhere.value);
	
	var pickup = document.CarSearch.pucity.value;
	var dropoff = document.CarSearch.docity.value;

	var whitesp = /[ \t\n\r\f\v]/g;

	var newpu = pickup.replace(whitesp, "");
	var newdo = dropoff.replace(whitesp, "");

	var pucity = new String(newpu);
	var docity = new String(newdo);
	
	if (pucity.length != 3) 
		{
		alert('Please select a Pick Up City from the Drop Down ');
			return false;
			}

	if (docity.length > 1) 
		{
		if (docity.length != 3) 
			{
			alert('Click OK to select a Drop Off City From a list of locations in Netherlands');
			openDestwin();
			return false;
			}
		}
 if (!iPu){
	var number = document.CarSearch.puwhere.selectedIndex;
  if (document.CarSearch.puwhere.options[number].value == 'CITY')
		{
			var selvendor = document.CarSearch.vendor2.selectedIndex;
			document.CarSearch.vendor.value = document.CarSearch.vendor2.options[selvendor].value;
		} else {
			var selvendor = document.CarSearch.vendor1.selectedIndex;
			document.CarSearch.vendor.value = document.CarSearch.vendor1.options[selvendor].value;
		}

	var number = document.CarSearch.puwhere.selectedIndex;

	if (document.CarSearch.puwhere.options[number].value == 'CITY') 
		{
		document.CarSearch.action = "http://reservations.in-to-las-vegas.com/nexres/cars/locations.cgi";
		}
	else if (document.CarSearch.puwhere.options[number].value == 'AIRPORT') 
		{
		document.CarSearch.action = "http://reservations.in-to-las-vegas.com/nexres/cars/results.cgi";
		}
	} else {
		document.CarSearch.action = "http://reservations.in-to-las-vegas.com/nexres/cars/results.cgi";
	}
	document.CarSearch.pucity.disabled = false;
	document.CarSearch.docity.disabled = false;
	document.CarSearch.vendor1.disabled = true;
	document.CarSearch.vendor2.disabled = true;
	document.CarSearch.submit();
	}

function reset_form()
	{

	document.CarSearch.pucity.value ="";
	document.CarSearch.docity.value ="";
	document.CarSearch.area.selectedIndex = -1;
	document.CarSearch.vendor.selectedIndex = -1;
	document.CarSearch.carcode.selectedIndex = -1;
	document.CarSearch.currency.selectedIndex = -1;
	
	return true;
	}