/*//<![CDATA[*/

function initEmailRequest() {
	$("#subEmail").bind("click", function() {
		//validate email address
		var ok = false;
		var addr = $("#emailaddress").val();
		addr = jQuery.trim(addr);
		if (addr.length > 0) {
			//have email address, validate format
			var isValid = addr.match(/^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)$/i);
			if (isValid == null) {
			    //value is not a valid email address
			    ok = false;
			    alert("You email address does not appear to be valid. Did you mis-type it?");
			} else {
			    //set valid value to trimmed amount
			    ok = true;
			}
		} else {
			alert("Please enter your email address");
		}		
		if (ok) {
			//send email address via ajax
		        try {
		            $.ajax({
		                url: './proc/email.asp',
		                type: 'POST',
		                data: "send=addr3ss" + "&emailaddress=" + addr,
		                dataType: 'text',
		                timeout: 20000,
		                error: function(){ },
		                success: function(result){ }
		            });
		        } catch (err) {
		        }
		        alert("Thanks! We will send you an email when we have our next Orchard exhibition or workshop.");		        
	    	}
	        return false;
    });
}

/*//]]>*/
