$(function(){

	$('#emailSignup').bind('submit', function(){
		var email = $('#emailSignup input[type="text"]').val();
		if (email == 'E-mail address') return false;
		if (!isEmail(email)) {
			alert("The email address entered does not appear to be valid.  Please check the address and try again.");
			$('#emailSignup input[type="text"]').get(0).focus();
			return false;
		}
		//$.post($(this).attr('action'), $(this).serialize());
		//$(this).slideUp().html('Thank you for signing up for our e-newsletter!');
		//return false;
	});
	
	$('#emailSignup input[type="text"]').bind('focus', function(){
		if ($(this).val() == 'E-mail address') $(this).val('');
	});
	$('#emailSignup input[type="text"]').bind('blur', function(){
		if ($(this).val() == '') $(this).val('E-mail address');
	});
		
	$('img.roll').bind('mouseover', function(){
		this.src = this.src.replace(/(.*)\.(jpg|gif|png)$/i, "$1-over.$2");
	});
	$('img.roll').bind('mouseout', function(){
		this.src = this.src.replace(/(.*)-over\.(jpg|gif|png)$/i, "$1.$2");
	});				
});

function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}