function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

$(document).ready(function(){
    
    $("#imageleft").cycle({timeout: 5000, autostop: 3});
    $("#imageright").cycle({timeout: 3000, autostop: 3});
    $("#imagecenter").cycle({timeout: 7000, autostop: 3});
	$("#headline-rotate").cycle({timeout: 3000});
	
	$("#privacy").click(
		function () {
			if($('#privacy-text').is(':visible')) {
				$('#privacy-text').fadeOut('fast');
			} else {
				$('#privacy-text').fadeIn('fast');
			}
		}
	)

	$("#email-address").focus(function () {
		$(this).css('background-color', '#ffc');
		if($(this).val() == "one types one's email here") {
			$(this).val('').css('color', '#000');
		}
	})
	
	$("#email-address").blur(function () {
		$(this).css('background-color', '#fff');
		if($(this).val() == '') {
			$(this).val("one types one's email here").css('color', '#888');
		}
	})
	
	$("#subscribe").click(function () {
		$('#contactform').submit();
	})

	$("#contactform").submit(function () {
		var email = $("#email-address").val();
		if(echeck(email)) {
			$("#email-address").attr("disabled","disabled");
			$.post("http://fugupress.com/scripts/email.php", {email: email} ,
				function(data) {
					$('#contactform').hide();
					$('#thanksmuch').fadeIn('fast')
				});
		} else {
			alert('Perhaps another look at that email address is in order, old chap.');
		}
		return false;
	})

})

