function dealerform_onClick()
{
  if (validate_dealerform()==true)
  {
    document.dealerform.method="post";
    document.dealerform.action="dealers.cfm";
    document.dealerform.submit();	
  }
}

function validate_dealerform()
{
	document.dealerform.fullname.value = GS_nolrspaces(document.dealerform.fullname.value);
	document.dealerform.email.value = GS_nolrspaces(document.dealerform.email.value);
	document.dealerform.phone.value = GS_nolrspaces(document.dealerform.phone.value);
	document.dealerform.companyname.value = GS_nolrspaces(document.dealerform.companyname.value);
	document.dealerform.county.value = GS_nolrspaces(document.dealerform.county.value);
	document.dealerform.ValidationString.value = GS_nolrspaces(document.dealerform.ValidationString.value);
	
    document.getElementById('fullnameREQUIRED').style.display = "none";
    document.getElementById('emailREQUIRED').style.display = "none";
    document.getElementById('phoneREQUIRED').style.display = "none";
    document.getElementById('companynameREQUIRED').style.display = "none";
    document.getElementById('countyREQUIRED').style.display = "none";
	
  if (document.dealerform.fullname.value == "")
  {
    document.getElementById('fullnameREQUIRED').style.display = "";
	alert("Please provide your name.");
    return false;
  }
  if (document.dealerform.email.value == "")
  {
    document.getElementById('emailREQUIRED').style.display = "";
    alert("Please provide your email address.");
    return false;
  }
  if (document.dealerform.phone.value == "")
  {
    document.getElementById('phoneREQUIRED').style.display = "";
    alert("Please provide your phone number.");
    return false;
  }
  if (document.dealerform.companyname.value == "")
  {
    document.getElementById('companynameREQUIRED').style.display = "";
    alert("Please provide the name of your company.");
    return false;
  }  
  if (document.dealerform.county.value == "")
  {
    document.getElementById('countyREQUIRED').style.display = "";
    alert("Please provide your county.");
    return false;
  }  
  
  if (document.dealerform.ValidationString.value == "")
  {
    alert("Please type the verification code to continue.");
    return false;
  }
  
  return true;
}

// strip off leading and trailing spaces from string ///////////////////
function GS_nolrspaces(strinx)
{
	while (strinx.charCodeAt(0)==32)
		{ strinx = strinx.substring(1, strinx.length); 
		}
	while (strinx.charCodeAt(strinx.length-1)==32)
		{ strinx = strinx.substring(0, strinx.length - 1); 
		}
	return strinx;
}
