/**
* Copyright Toolbox Studios, Inc.
* http://toolboxstudios.com
**/

function bindConstantContact( constantContact) {
	try {
		var form = document.getElementById( constantContact);
		var inputs = form.getElementsByTagName( 'input');
		for ( var i = 0; i < inputs.length; i++) {
			if ( inputs[i].name == 'ea') {
				inputs[i].onfocus = function(e){
					if ( this.value == this.defaultValue)
						this.value = '';
				};
				inputs[i].onblur = function(e){
					this.value == this.value.replace( /(^\s|\s$)/g, '');
					if ( this.value == '')
						this.value = this.defaultValue;
				};
			}
			else if ( inputs[i].name == 'submitBtn') {
				inputs[i].onclick = function(e) {
					if ( goodConstantContactForm( this.form))
						this.form.submit();
					return false;
				};
//				inputs[i].onmouseover = function(e) {
//					this.src = '../_images/page/btn2StateOver.gif';
//				};
//				inputs[i].onmouseout = function(e) {
//					this.src = '../_images/page/btn2State.gif';
//				};
			}
		}
		form.onsubmit = function(e) {
			return goodConstantContactForm( this);
		};
	}
	catch (error) {
	}
}
function goodConstantContactForm( form) {
	var inputs = form.getElementsByTagName( 'input');
	var good = true;
	for ( var i = 0; i < inputs.length; i++) {
		if ( inputs[i].name == 'ea') {
			good = inputs[i].value.match( /^([\w\.-]+)@([\w-]+\.)+\w{2,6}$/);
			break;
		}
	}
	if ( !good)
		alert( 'Enter your email address to sign up');
	return good;
}
