var type = "";
	var disabled = false;
	
	function validateEmail() {
		$("#email_address")
				.filter(function() {
					matchString = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/;
					if(!$("#email_address").val().match(matchString)) {
						$("#email_address").addClass("err");
						$("#send_notification").hide();
					} else {
						$("#email_address").removeClass("err");
						$("#send_notification").show();
					}

				});
	}
		
	
	$(document).ready(function(){

		$("#compact_ed").click(function(){ clicked("compact"); });
		$("#design_ed").click(function(){ clicked("designer"); });
		
		$("#close_notify").click(function(){
			$("#notify_me").hide();
		});
		
		app = "notify.php";
		
		validateEmail();
		
		
		$("#email_address").keyup(function(){
			
			validateEmail();
				
		});
		
		
	

		
		$("#send_notification").click(function(){
			
			email = $("#email_address").val();
			
			if(email != "") {
				
				$("#send_notification").hide();
						
				$.post(app, { email_address:email, type:type },
				function(data){
					if(data == "1") {
						$("#notify_msg").show();
						$("#notify_form").hide();
						
						$("#notify_msg h1").html("Thank you! You will be personally contacted by our customer service representative!");
						
						disabled = true;
						
						setTimeout("hideNotification()", 2000);
						
					} else {
						disabled = false;
						$("#notify_msg").show();
						$("#notify_msg h1").html("Unable to process your request.  You might be providing an invalid account Please try again.");
						
						setTimeout("hideNotification()", 2000);
					}
				});
				
			}
		});
		
	})
	
	function hideNotification() {
		$("#notify_msg").hide()
		$("#notify_form").show();
		
		disabled = false;
	}
	function clicked(tp) {
		
		if(!disabled) {
			$("#notify_msg").hide();
			$("#notify_form").show();
			
			type = tp;
			
			$("#notify_me").show();
			$("#selected").removeClass()
			$("#selected").addClass(tp);
			
			$("#email_address").focus();	
			$("#email_address").val("");
		}
	}

