// SALES FORCE CONTACT FORM

function sendForm() {
	
	var theForm = $('#contact-form');
	var locn = document.location;
	var localHost = locn.protocol + "//" + locn.host;
	var apos = $("#email").val().indexOf("@");
	var dotpos = $("#email").val().lastIndexOf(".");

	if (apos<1||dotpos-apos<2)
	{

		alert("Please enter a valid email address so we can contact you.");
		$("#email").focus();

	}
	else if ( $("#contactTypeSales")[0].checked )
	{

		$('#contactDescription').val( $('#subject').val() + "\n" + $('#contactDescription').val() );
		var sendUrl = "https://salesforce.ringlead.com/cgi-bin/1104/1/dedup.pl";
		theForm.attr("action",sendUrl);
		$('#retURL').val( localHost + "/contact/thanks" );
		//alert($('#retURL').val());
		theForm.submit();

	}
	else if ( $("#contactTypeSupport")[0].checked )
	{

		$('#name').val( $('#first_name').val() + " " + $('#last_name').val() );
		var sendUrl = "https://www.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8";
		theForm.attr("action",sendUrl);
		$('#retURL').val( localHost + "/contact/thanks" );
		//alert($('#retURL').val());
		theForm.submit();

	}
	else
	{

		alert("Please select either Sales or Support\nto ensure your message is received \nby the appropriate group.");
		$("#contactTypeSales")[0].focus();

	}

	return false;
	
}
