
	function fn_clearrepsearch(vObj) {
	
		if (vObj.value == vObj.defaultValue) {
			vObj.style.color = '#000000';
        	vObj.value = '';
        	vObj.maxLength = 5;
     		}
		}

		
	function fn_resetrepsearch(vObj) {
	
		if (vObj.value == "") {
			vObj.style.color = '#78A22E';
			vObj.maxLength = '';
        	vObj.value = 'enter zip code';
     		}
		}		
		
	function fn_validaterepsearch(vObj) {
		var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	
		if ((vObj.value.length < 5) || (vObj.value == 'enter zip code')) {
			alert('invalid Zip code.')
			vObj.value="";
			setfocus(vObj);
			return false;
			} 
		if (objRegExp.test(vObj.value) == false) {
			alert('invalid Zip code.')
			vObj.value="";
			setfocus(vObj);
			return false;
			}
		}
		
	function fn_validatemainrepsearch(vObj) {
		var objRegExp  = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
			
		if ((document.getElementById('mainrepsearch').value.length < 5) || (document.getElementById('mainrepsearch').value == 'enter zip code')) {
			alert('You must enter a valid zip code to search.');
			return false;
			setfocus(vObj);
			} 
		if (objRegExp.test(document.getElementById('mainrepsearch').value) == false) {
			alert('invalid Zip code.')
			return false;
			setfocus(vObj);
			}
		}
		
		
function ajaxContact()
{


var xmlHttp;
var params = '';

if (fnValidateContactForm() != false) {

try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById("ajaxcontact").innerHTML=xmlHttp.responseText;
      document.getElementById("alttext").innerHTML="";
      }
    }
    
    params = "name=" + encodeURI(document.getElementById("name").value)+
    		"&email=" + encodeURI(document.getElementById("email").value)+
    		"&company=" + encodeURI(document.getElementById("company").value)+
    		"&phone=" + encodeURI(document.getElementById("phone").value)+
    		"&body=" + encodeURI(document.getElementById("body").value)+
    		"&zip=" + encodeURI(document.getElementById("zip").value);

		xmlHttp.open("POST","include/ajax_contact_server.php",true);
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
	
		}
		//alert(fnValidateContactForm());
	}	
	
	
	function fnValidateEmail(obj) 
		{
		var string;
		string = obj.value;
	    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	    	{
	        //no action
	        }
	    else
	    	{
	        alert("Please Enter a Valid Email Address.");
			obj.value='';
			setfocus(obj);
			}
		}                      	
	
	function textCounter( field, countfield, maxlimit ) 
		{
		if ( field.value.length > maxlimit )
			{
			field.value = field.value.substring( 0, maxlimit );
			alert( 'Text entry can only be ' + maxlimit + ' characters in length.' );
			countfield.style.color = 'red';
			countfield.innerHTML = maxlimit - field.value.length;
			return false;
			}
		else
			{
			if ((maxlimit - field.value.length) < 100)
				{
				countfield.style.color = 'red';
				countfield.innerHTML = maxlimit - field.value.length;
				}
			else
				{
				countfield.style.color = 'black';
				countfield.innerHTML = maxlimit - field.value.length;
				}
			}	
		}
		
		
	function fnValidateContactForm()
		{
	 		if (	
	 		(document.getElementById("name").value.length < 1) || 
	 		(document.getElementById("email").value.length < 1) ||
	 		(document.getElementById("company").value.length < 1) || 
	 		(document.getElementById("phone").value.length < 1) ||
	 		(document.getElementById("body").value.length < 1) ||
	 		(document.getElementById("zip").value.length < 1) ) {
	 		alert('Please fill in all of the fields.');
	 		return false;
	 		}
		}
		
	function validEmail(src) {
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		return regex.test(src);
		}

	function validatePhoneNumber(obj) {
		var string;
		string = obj.value;
	    if (string.search( /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/) != -1)
	    	{
	        //no action
	        }
	    else
	    	{
	        
	        alert("Please Enter a Valid phone number and area code.");
			obj.value='';
			setfocus(obj);
			}
		}
		
		
		
// --------------------------------------------
//                  setfocus
// Delayed focus setting to get around IE bug
// --------------------------------------------

function setFocusDelayed()
{
  global_valfield.focus();
}

function setfocus(valfield)
{
  // save valfield in global variable so value retained when routine exits
  global_valfield = valfield;
  setTimeout( 'setFocusDelayed()', 100 );
}
