
function submitRegisterForm(eventTarget, eventArgument) 
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
		theform = document.forms["FormNewAccount"];
	}
	else {
		theform = document.FormNewAccount;
	}
	theform.ns_EventTarget.value   = eventTarget.split("$").join(":");
	theform.ns_EventArgument.value = eventArgument;
	
	theform.submit();
}



function ns_ValidateNewUser() 
{
	if (ns_check_Email("txtEmailReg") == false) 
	  return false;
	 
	
	if (ns_check_password("txtPasswordReg") == false) 
	  return false;
	 

	if (ns_confirm_checkbox("terms") == false) 
	  return false;
	 
	ns_SetLocaTimezoneOffset();

	return true;
}

function ns_join(source) 
{
	if (! ns_ValidateNewUser() ){
      return;
	}
	submitRegisterForm('join', source);
}

function ns_check_Email(fieldName) 
{
	var email = document.getElementById(fieldName).value; 
	var ok = true;
	if (email.indexOf("@") == -1)
	{
	  ok = false;
	}
	
	if (email.indexOf(".") == -1)
	{
	  ok = false;
	}
	
	if (email.indexOf("'") != -1)
	{
	  ok = false;
	}
	
	if (ok == false)
	  alert('Please enter a valid e-mail address.');

	return ok;
}

function ns_check_password(fieldName){
	var password 		=	document.getElementById(fieldName).value; 
	
	if (password.length < 6 ){
		alert('The Password should have at least 6 characters');
		return false;
	}
	
	return true;
}	

function ns_confirm_checkbox(fieldName){
	if (document.getElementById(fieldName).checked == 0){
		alert('You must accept the Terms of Use to create an eSnips account');
		return false;
	}

	return true;
}	

function ns_SetLocaTimezoneOffset(){
	var offset =	document.getElementById("ns_LocaTimezoneOffset"); 
	
	offset.value	=	new Date().getTimezoneOffset();	
	
	return;
}

/* ajax stuff */

