
function validateAndAddEmail() {
	var form = document.forms.sgxemail;
	
	var email = form.elements.email.value;
	var filter=/^.+@.+\..{2,4}$/;

	if (!filter.test(email)) {
		openCoolInfo("Invalid Email", "Please enter a valid email address."); 
	} else {
		try {
			var client = getJSONRPCClient();
			var result = client.callRemote("users.sgxemail", emailSaved, email);
		} catch (e) {}
		
		openCoolInfo("Email Added", "We will email you as we have updated information on the SkyCaddie SGX.  Thank you for your patience."); 
		Styles.setVisible("emailFormDiv",  false);
	}
	return false;
}

function emailSaved() {
}

document.write('<div id="emailFormDiv"><form name="sgxemail" onsubmit="return validateAndAddEmail();" style="display:inline;">');
document.write('<div style="float:left;position:relative;top:-2px;">');
document.write('<input type="textbox" name="email" value="Enter Email" style="width:150px;color:#cccccc;" onfocus="onFirstFocus(this);"/>');
document.write('</div>');
document.write('<a href="javascript:validateAndAddEmail();void(0);" class="btn" style="margin:0px 10px 0px 10px;"><span>Send Me Updates</span></a>');
document.write('</form></div>');



