function maxlen(emt, len)
{
  return (emt.value.length <= len);
}
$(function()
{
	$("#frmcontact").submit(function()
	{
		var post = {};
		$("#frmcontact input").each(function(){
			post[$(this).attr("name")] = $(this).val();
		});
		$("#frmcontact textarea").each(function(){
			post[$(this).attr("name")] = $(this).val();
		});
		$("#frmcontact select").each(function(){
			post[$(this).attr("name")] = $(this).val();
		});
		// exceptions for radio buttons
		post.landacquired = $("input[name='landacquired']:checked").val(); 
		var good = true;
		$("input.required").each(function()
		{
			if ($(this).val().trim() == "")
				good = false;
		});
		$("select.required").each(function()
		{
			if ($(this).val().trim() == "")
				good = false;
		});
		if ($("input[name='landacquired']:checked").val() == undefined)
			good = false;
		if (!good)
		{
			alert(valmsg);
			return false;
		}
		$.post("/contact-submit.php",post,
		function(msg) 	
		{

			$("#frmcontact").hide();
			var html = '<div id="thankyou" style="display:none;"><br/><h2>'+ty+'<\/h2><\/div>';
			$("#titre_page").append(html);
			$("#thankyou").fadeIn();	
		},"json");
		return false;
	}); 
});

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

