$(document).ready(function(){var E=0;var D=$("#popupCall");function B(){if(E==0){$("#popupBackground").css({opacity:"0.75"});$("#popupBackground").fadeIn("slow");D.fadeIn("slow");E=1}}function C(){if(E==1){$("#popupBackground").fadeOut("slow");D.fadeOut("slow");E=0}}function A(){var F=document.documentElement.clientWidth;var I=document.documentElement.clientHeight;var H=D.height();var G=D.width();D.css({position:"absolute",top:I/2-H/2,left:F/2-G/2});$("#popupBackground").css({height:I})}$("#call").click(function(){$("#popupCall").css({padding:30,height:325,width:230});D=$("#popupCall");A();B();return false});$("#email").click(function(){D=$("#popupEmail");A();B();return false});$("#cancel").click(function(){C();return false});$("#popupBackground").click(function(){C()});$(document).keypress(function(F){if(F.keyCode==27&&E==1){C()}});$("#submit").click(function(){$(".error").queue(function(){$(this).slideUp("slow");$(this).removeClass("error");$(this).text("");$(this).dequeue()});var G=0;var F=false;var J=/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;var I=$("#emailFrom").val();if(I==""){$("#emailFrom+span").text("Surely you have an email address, yeah?");$("#emailFrom+span").addClass("error");F=true}else{if(!J.test(I)){$("#emailFrom+span").text("Don't be silly. Only valid email addresses go here.");$("#emailFrom+span").addClass("error");F=true}else{if(I=="hello@seangaffney.cc"){$("#emailFrom+span").text("I can haz real email address?");$("#emailFrom+span").addClass("error");F=true}}}var L=$("#subject").val();if(L==""){$("#subject+span").text("You forgot to enter the subject.");$("#subject+span").addClass("error");F=true}var K=$("#message").val();if(K==""){$("#message+span").text('Nothing to say? How about, "You\'re quite handsome."');$("#message+span").addClass("error");F=true}if(F==false){$(this).hide();$("#cancel").text("Close");$.post("http://seangaffney.cc/php/sendemail.php",{emailFrom:I,subject:L,message:K},function(M){$("#popupEmail").animate({top:"+=100"});$("ol li").not(".buttons").slideUp("normal");H()})}else{$(".error").slideDown()}function H(){$("form h1, form p").fadeOut().queue(function(){$("form h1").text("Success").fadeIn();$("form p").text("Your email was sent.").fadeIn();$(this).dequeue()})}return false})});