// JavaScript Document

//Text input toggle

$(function(){
	$('.header input:text').events({
		focus: function(){ if(this.value == this.defaultValue) this.value = "" },
		blur: function(){ if(this.value == "") this.value = this.defaultValue; }
	});
	$('.email_alert input:text').events({
		focus: function(){ if(this.value == this.defaultValue) this.value = "" },
		blur: function(){ if(this.value == "") this.value = this.defaultValue; }
	});
	
	shortcut.add("Control+Shift+A",function() {window.location = '/admin';});
	
	if ($('.email_alert form').length) {
		$('.email_alert form').submit(function(e){
			var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!$('.email_alert input[id=email_alert]').attr('value').match(email)) {
				alert('You must enter the email address');
				$('.email_alert input[id=email_alert]').focus();
				e.preventDefault();
			}
		});
	}
});

jQuery.fn.events = function(o){
    for (var i in o) {
        this.bind(i, o[i]);
    }
    return this;
}
