$(document).ready(function() {
	var WindowHeight=$(window).height();
	var MinimumHeight=$('.proper').height();
	var EmailLabel='Your Email Address';
	var EmailError='The email address you provided is invalid. Please check and try again.';
	var EmailSuccess='Your email address has been registered to receive updates. Thank You.';
	//INIT
	___gh3aStroker(WindowHeight,MinimumHeight);
	//EVENTS
	$(window).resize(function() {
		WindowHeight=$(window).height();
		___gh3aStroker(WindowHeight,MinimumHeight);
	});
	$('.notify .controls a').click(function() {
		if (___gh3aValidator($('.notify .textbox input').val())) {
			$('.proper .message').removeClass('fail').addClass('pass').text(EmailSuccess).fadeIn(200);
			WindowHeight=$(window).height();
			MinimumHeight=$('.proper').height();
			___gh3aStroker(WindowHeight,MinimumHeight);
			
			var xmlhttp;
			if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
			  xmlhttp=new XMLHttpRequest();
			} else { // code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.open("GET","sendmail.php?t=" + $('.notify .textbox input').val(),false);
			xmlhttp.send();
			
			setTimeout('___gh3aTerminator()',3000);
			$('.notify .textbox input').val(EmailLabel);
		} else {
			$('.proper .message').removeClass('pass').addClass('fail').text(EmailError).fadeIn(200);
			WindowHeight=$(window).height();
			MinimumHeight=$('.proper').height();
			___gh3aStroker(WindowHeight,MinimumHeight);
		}
	});
	$('.notify .textbox input').click(function() {
		if ($(this).val()==EmailLabel) {
			$(this).val('');
		}
		___gh3aTerminator();
	});
	$('.notify .textbox input').blur(function() {
		if ($(this).val()=='') {
			$(this).val(EmailLabel);
		}
	});
});

___gh3aStroker = function(argsWindowHeight,argsMinimumHeight) {
	if (argsWindowHeight>=argsMinimumHeight) {
		$('#wrapper .stroke').height(argsWindowHeight);
	} else {
		$('#wrapper .stroke').height(argsMinimumHeight);
	}
};

___gh3aValidator = function(argsEmailAddress) {
	var EmailRegEx = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
 	return EmailRegEx.test(argsEmailAddress);
};

___gh3aTerminator = function() {
	$('.proper .message').fadeOut();
};
