function doEcho()	
{
	if(validate())
	{
		$.ajax({
			url: "ContactUs.php",
			data: "Name="+$("#Name").val()+"&Phone="+$("#Phone").val()+"&Email="+$("#Email").val() +"&Company="+$("#Company").val()+"&Website="+$("#Website").val()+"&Message="+$("#Message").val()+"&Distributor_Com_Name="+$("#distributor_com_name").val()+"&Contact_Name="+$("#contact_name").val()+"&toemail="+$("#toemail").val()+"&fullurl="+$("#fullurl").val()+ "&action=send",
			dataType: "html",
			complete: function (xhr) {
				$("#Name").val("");
				$("#Phone").val("");
				$("#Email").val("");
				$("#Company").val("");
				$("#Website").val("");
				$("#Message").val("");
				$("#successmsg").show();
				$("#successmsg").html(xhr.responseText);
			},
			error: function() {
				$("#error").show();				
			}
		});
	}
}
function validate() {
	if(!$("#Name").val())
	{
		$("#NameError").show();					
		$("#Name").focus();
		return false;
	} 
	else {
		$("#NameError").hide();
	}

	if(!$("#Phone").val())
	{
		$("#PhoneError").show();
		$("#Phone").focus();
		return false;
	}
	else
	{
		$("#PhoneError").hide();
	}
	
	var email = $("#Email").val();
	if (!email) 
	{
		$("#EmailError1").show();
		$("#Email").focus();
		return false;
	}
	else 
	{	$("#EmailError1").hide();
		if (!validateEmail(email)) 
		{
			$("#EmailError2").show();
			$("#Email").focus();
			return false;
		}
		else
			$("#EmailError2").hide();
	}
	
	if(!$("#Message").val())
	{
		$("#MessageError").show();
		$("#Message").focus();
		return false;
	}
	else
	{
		$("#MessageError").hide();
	}
	return true;
}
function validateEmail(email) {
	var at = email.lastIndexOf("@");

	// Make sure the at (@) sybmol exists and  
	// it is not the first or last character
	if (at < 1 || (at + 1) === email.length)
		return false;

	// Make sure there arenot multiple periods together
	if (/(\.{2,})/.test(email))
		return false;

	// Break up the local and domain portions
	var local = email.substring(0, at);
	var domain = email.substring(at + 1);

	// Check lengths
	if (local.length < 1 || local.length > 64 || domain.length < 4 || domain.length > 255)
		return false;

	// Make sure local and domain dont start with or end with a period
	if (/(^\.|\.$)/.test(local) || /(^\.|\.$)/.test(domain))
		return false;

	// Check for quoted-string addresses
	// Since almost anything is allowed in a quoted-string address,
	// we are just going to let them go through
	if (!/^"(.+)"$/.test(local)) {
		// It"s a dot-string address...check for valid characters
		if (!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&""+=_\.]*$/.test(local))			
			return false;
	}

	// Make sure domain contains only valid characters and at least one period
	if (!/^[-a-zA-Z0-9\.]*$/.test(domain) || domain.indexOf(".") === -1)
		return false;	

	return true;
}
