$(document).ready(function() {
	$("#subForm input").labelify({text: "label", labelledClass: "labelinside"});
	$(".service_teaser").click(function(){ window.location=$(this).find("a").attr("href"); return false; });
	
	$(function()
	{
		$("#subForm button:submit").click(function() {	
			$('form#subForm').submit(function() { return false; });
			formAction = $("form#subForm").attr("action");
			// If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
			emailId = "pqkki";
			emailId = emailId.replace("/", "");
			emailId = emailId + "-" + emailId;
			if (!checkEmail(emailId)) 
			{
				alert("Please enter a valid email address");
				return;
			}
			var str = $("form#subForm").serialize();
			final = str + "&action=" + formAction;
			$.ajax({
				url: "/scripts/proxy.php",
				type: "POST",
				data: final,
				success: function(html){
					$("#subForm_fields").hide(); // If successfully submitted hides the form
					$("#confirmation").slideDown("slow");  // Shows "Thanks for subscribing" div
				}
			});
		});
	});
	function checkEmail(email)
	{	
		var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var emailVal = $("#" + email).val();
		return pattern.test(emailVal);
	}	
});
