// validate search form


function ValidateSubmit()
{

if (self.parent.frames.length == 0) {

  if (document.SearchForm.CiRestriction.value == "" || document.SearchForm.CiRestriction.value == null)
  {
    alert("Please enter a value for the \"Search Box\" field.");
    document.SearchForm.CiRestriction.focus();
    return (false);
  }

  if (document.SearchForm.CiRestriction.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Search Box\" field.");
    document.SearchForm.CiRestriction.focus();
   return (false);
  }

  return(true);
 }

if (self.parent.frames.length != 0) {

   if (small_window.document.SearchForm.CiRestriction.value == "" || small_window.document.SearchForm.CiRestriction.value == null)
  {
    alert("Please enter a value for the \"Search Box\" field.");
    small_window.document.SearchForm.CiRestriction.focus();
    return (false);
  }

  if (small_window.document.SearchForm.CiRestriction.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Search Box\" field.");
    small_window.document.SearchForm.CiRestriction.focus();
   return (false);
  }
  return(true);
 }


}

function SearchSubmit() 
 {
  if (ValidateSubmit()==true) {

      if (self.parent.frames.length == 0) {
      document.SearchForm.action='http://www.chevron.com/products/search.idq';
      document.SearchForm.submit();
     }

      if (self.parent.frames.length != 0) {
      small_window.document.SearchForm.action='http://www.chevron.com/products/search.idq';
      small_window.document.SearchForm.submit();
     }
 }
}




// dont' know if below are used (mcjm)

function checkfields()
  {
  if (SearchForm.q1.value == "")
  {
    alert("Please enter a value for the \"Search Box\" field.");
    SearchForm.q1.focus();
    return (false);
  }

  if (SearchForm.q1.value.length > 100)
  {
    alert("Please enter at most 100 characters in the \"Search Box\" field.");
    SearchForm.q1.focus();
    return (false);
  }
	
	 return true
  }

function check() {
  if (document.getElementById('city').value == "") {
    document.getElementById('city').value = " ";
  }
  var f3;
  var f5;
 if (document.getElementById('queryForMap')) {
	if (document.getElementById('addr')) f1=document.getElementById('addr').value
	if (document.getElementById('city')) f2=document.getElementById('city').value
	if (document.getElementById('state')) f3=document.getElementById('state').options[document.getElementById('state').selectedIndex].value
	if (document.getElementById('zip')) f4=document.getElementById('zip').value
	if (document.getElementById('country')) f5=document.getElementById('country').value

   //  alert (f1+" - "+f2+" - "+f3+" - "+f4+" - "+f5);
  if(f1.length==0 && f2.length==0 && f3.length==0 && f4.length==0) {
    alert("Please enter at least a city, state or zip code")
	return
  }
   
   
  // British Columbia is in Canada, not US
	if (f3=="BC") {document.getElementById('country').value = "CA"}
  // If no country, then enter US
  if (document.getElementById('country') && f5.length==0) {document.getElementById('country').value="US"}
  document.getElementById('queryForMap').submit()
 } else alert ("You need DOM compliant javascript to submit this form.");
}

function reset() {  
	document.getElementById('queryForMap').reset()
}



