function switch_companies()
{	
	//EMAIL VALIDATION
	var goodEmail 	= $F("email").match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
	apos		= $F("email").indexOf("@");
	dotpos		= $F("email").lastIndexOf(".");
	lastpos		= $F("email").length-1;
	var badEmail 	= (apos<1 || dotpos-apos<2 || lastpos-dotpos<2);
	$("okmessage").hide();

	if ($F("name")=="")
	{
		$("message").show();
		$("message").innerHTML="Please enter your name";
		$("name").focus();
		return false;
	}
	else if (($F("email") == "") || (!goodEmail && badEmail))		
	{
		$("message").show();
		$("message").innerHTML="Please enter a valid email";
		$("email").focus();
		return false;
	}
	else if ($F("phone") == "")		
	{
		$("message").show();
		$("message").innerHTML="Please enter your phone number";
		$("phone").focus();
		return false;
	}
	else if ($F("keypads") == "")		
	{
		$("message").show();
		$("message").innerHTML="Please enter the number of keypads you have";
		$("keypads").focus();
		return false;
	}
	else if ($F("current_provider") == "")		
	{
		$("message").show();
		$("message").innerHTML="Please select your current provider";
		return false;
	}
	else if ($F("brand") == "")		
	{
		$("message").show();
		$("message").innerHTML="Please select the brand of your system";
		return false;
	}
	
	//YOU MAY WANT TO CHANGE THE URL IN THE LINE BELOW
	var url = "scripts/switch_companies.php";
	var params='email='+$F("email")+'&name='+encodeURIComponent($F("name"))+'&messagebody='+encodeURIComponent($F("messagebody"))+'&phone='+encodeURIComponent($F("phone"))+'&keypads='+encodeURIComponent($F("keypads"))+'&brand='+$F("brand")+'&current_provider='+$F("current_provider")+'&type='+$F("type");
	new Ajax.Request(url, {onComplete:showResponse, onException:showException, onFailure:showException, asynchronous:true, method:"post", evalScripts:false, postBody:params});
	$("submit").hide();
	$("loading").show();

	function showResponse(req)
	{	
		if (req.responseText=="1" || req.responseText=="0")
		{
			$("message").hide();
			$("loading").hide();
			$("okmessage").show();
			$("submit").show();
			$("name").clear();
			$("email").clear();
			$("phone").clear();
			$("keypads").clear();
			$("messagebody").clear();
		}
		else
		{
			$("message").show();
			$("message").innerHTML="There was an error. Please try again.";
			$("loading").hide();
			$("okmessage").hide();
			$("submit").show();
		}
	}
	function showException()
	{
		$("message").show();
		$("message").innerHTML="There was an error. Please try again.";
		$("loading").hide();
		$("okmessage").hide();
		$("submit").show();
		$("name").clear();
		$("email").clear();
		$("phone").clear();
		$("keypads").clear();
		$("messagebody").clear();
	}
}
