function unHiderPick() {
	var where = document.getElementById("where");
	if (where.value == "airport") {
		document.getElementById("airport").style.display = 'block';
		document.getElementById("address").style.display = 'none';
		document.getElementById("poi").style.display = 'none';
	}

	if (where.value == "address") {
		document.getElementById("airport").style.display = 'none';
		document.getElementById("address").style.display = 'block';
		document.getElementById("poi").style.display = 'none';
	}

	if (where.value == "poi") {
		document.getElementById("airport").style.display = 'none';
		document.getElementById("address").style.display = 'none';
		document.getElementById("poi").style.display = 'block';
	}
}


function dropOff() {
	var drop = document.getElementById("diff_yes").checked;
	
	if (drop) {
		document.getElementById("dair").value="";
		//document.getElementById("dwhere").reset();
		document.getElementById("dropoff_diff").style.display = 'block';
	} else {
		document.getElementById("dropoff_diff").style.display = 'none';
		document.getElementById('drop_off_msg').innerHTML='';
	}
}

function discountHide() {
	var drop = document.getElementById("companypref").checked;

	if (drop) {
		document.getElementById("discounts").style.display = 'block';
		document.getElementById("couptitle").style.display = 'block';
		document.getElementById("coupfield").style.display = 'block';
	} else {
		document.getElementById("discounts").style.display = 'none';
		document.getElementById("couptitle").style.display = 'none';
		document.getElementById("coupfield").style.display = 'none';
	}
}

function unHiderDrop() {
	var where = document.getElementById("dwhere");

	if (where.value == "doairport") {
		document.getElementById("dairport").style.display = 'block';
		document.getElementById("daddress").style.display = 'none';
		document.getElementById("dpoi").style.display = 'none';
	}

	if (where.value == "doaddress") {
		document.getElementById("dairport").style.display = 'none';
		document.getElementById("daddress").style.display = 'block';
		document.getElementById("dpoi").style.display = 'none';
	}

	if (where.value == "dopoi") {
		document.getElementById("dairport").style.display = 'none';
		document.getElementById("daddress").style.display = 'none';
		document.getElementById("dpoi").style.display = 'block';
	}
}

function change(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}

function show(idLayer) { document.getElementById(idLayer).style.display='block'; }
function showInline(idLayer) { document.getElementById(idLayer).style.display='inline'; }
function hide(idLayer) { document.getElementById(idLayer).style.display='none'; }

function newWindow(url)
{
   urlWindow = window.open(url, 'AirportCodes', 'width=450,height=350');
   urlWindow.focus;
}

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;
		}
	else if (document.CarSearch.puwhere.options[number].value == 'AIRPORT') 
		{
		document.CarSearch.area.selectedIndex = -1;
		}

	return true;
	}

function update_docity()
	{
	if (document.CarSearch.docity.value) 
		{
		document.CarSearch.same.checked = false;
		}
	return true;
	}

function clear_docity()
	{
	document.CarSearch.docity.value = "";
	return true;
	}

function check_dropoff()
	{
	if (document.CarSearch.same.checked == true) 
		{
		clear_docity();
		}
	return true;
	}

function submit_to() 
	{
	//alert('pu =' + document.CarSearch.puwhere.value);

	update_docity();
	
	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('Invalid or missing pick up airport code');
		return false;
		}

	if (docity.length > 1) 
		{
		if (docity.length != 3) 
			{
			alert('Invalid or missing drop off airport code');
			return false;
			}
		}

	var number = document.CarSearch.puwhere.selectedIndex;
	var selvendor = document.CarSearch.vendor.selectedIndex;
	if (document.CarSearch.puwhere.options[number].value == 'CITY')
		{
		var ven = new String(document.CarSearch.vendor.options[selvendor].value);
		if (ven.length == 0) 
			{
			alert('Please select a Rental Company preference for city searches.');
			return false;
			}
		}

	var number = document.CarSearch.puwhere.selectedIndex;

	if (document.CarSearch.puwhere.options[number].value == 'CITY') 
		{
		document.CarSearch.action = "/nexres/cars/locations.cgi";
		}
	else if (document.CarSearch.puwhere.options[number].value == 'AIRPORT') 
		{
		document.CarSearch.action = "/nexres/cars/results.cgi";
		}

	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;
	}

