// 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.texaco.com/search/search.idq';
      document.SearchForm.submit();
     }

      if (self.parent.frames.length != 0) {
      small_window.document.SearchForm.action='http://www.texaco.com/search/search.idq';
      small_window.document.SearchForm.submit();
     }
 }
}



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() {
  var f3;
  var f5;
 if (document.getElementById('queryForMap')) {
	if (document.getElementById('address')) f1=document.getElementById('address').value
	if (document.getElementById('city')) f2=document.getElementById('city').value
	if (document.getElementById('stateProvince')) f3=document.getElementById('stateProvince').options[document.getElementById('stateProvince').selectedIndex].value
	if (document.getElementById('postalCode')) f4=document.getElementById('postalCode').value

  if((f2.length==0 && f3.length==0 && f4.length==0) || (f2.length > 0 && f3.length==0 && f4.length==0) ||  (f3.length > 0 && f2.length==0 && f4.length==0)) {
    alert("Please enter at least a city and state or zip code")
	return false
  }


  // 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') && f3.length==0) {document.getElementById('country').value="US"}
   return true
 } else alert ("You need DOM compliant javascript to submit this form.");
}


function routeCheck() {
  var f3;
  var f5;

 if (document.getElementById('queryForMap')) {
 
	if (document.getElementById('origaddress')) f1=document.getElementById('origaddress').value
	if (document.getElementById('origcity')) f2=document.getElementById('origcity').value
	if (document.getElementById('origstateProvince')) f3=document.getElementById('origstateProvince').options[document.getElementById('origstateProvince').selectedIndex].value
	if (document.getElementById('origpostalCode')) f4=document.getElementById('origpostalCode').value

 if((f2.length==0 && f3.length==0 && f4.length==0) || (f2.length > 0 && f3.length==0 && f4.length==0) ||  (f3.length > 0 && f2.length==0 && f4.length==0)) {
    alert("Please enter at least an originating city and state or zip code")
	return false
  }
  
  // British Columbia is in Canada, not US
	if (f3=="BC") {document.getElementById('origcountry').value = "CA"}
  // If no country, then enter US
  if (document.getElementById('origcountry') && f3.length==0) {document.getElementById('origcountry').value="US"}
   
  // now for destination - desti
if (document.getElementById('destaddress')) f1=document.getElementById('destaddress').value
	if (document.getElementById('destcity')) f2=document.getElementById('destcity').value
	if (document.getElementById('deststateProvince')) f3=document.getElementById('deststateProvince').options[document.getElementById('deststateProvince').selectedIndex].value
	if (document.getElementById('destpostalCode')) f4=document.getElementById('destpostalCode').value

  if((f2.length==0 && f3.length==0 && f4.length==0) || (f2.length > 0 && f3.length==0 && f4.length==0) ||  (f3.length > 0 && f2.length==0 && f4.length==0)) {
    alert("Please enter a destination city and state or zip code")
	return false
  }
  
  // British Columbia is in Canada, not US
	if (f3=="BC") {document.getElementById('destcountry').value = "CA"}
  // If no country, then enter US
  if (document.getElementById('destcountry') && f3.length==0) {document.getElementById('destcountry').value="US"}
  
   
   return true   
   
 } else {
     alert ("You need DOM compliant javascript to submit this form.");
     return false
  }
}





function reset() {  
	document.getElementById('queryForMap').reset()
}

