<!--

 var viewportwidth;
 var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }
 
 
//-->


$(document).ready(function(){
	
	$("#submit").click(function(){	
		   				   
		$(".error").hide();
		var hasError = false;
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		
		var emailFromVal = $("#emailFrom").val();
		if(emailFromVal == '') {
			$("#submit").after('<div class="error">Please fill in an e-mailaddress to receive some love.</div>');
			hasError = true;
		} else if(!emailReg.test(emailFromVal)) {	
			$("#submit").after('<div class="error">We can\'t send you love if you enter a wrong e&#8209;mailaddress.</div>');
			hasError = true;
		}
		
		if(hasError)
		{
			$(".error").delay(5000).fadeOut(1000);	
		}
	
		
		if(hasError == false) {
			$(this).hide();
			$("#sendEmail").append('<img src="/img/loading.gif" alt="Loading" id="loading" />');
			
			$.post("subscribe.php",
   				{ emailFrom: emailFromVal },
   					function(data){
						$("#sendEmail").slideUp("normal", function() {				   
							
							$("#sendEmail").after('<div class="feedback">Thanks, love is in the air.</p>');											
						});
   					}
				 );
		}
		
		return false;
	});						   
});
