function VerifyFields ()
  {
  formObj = document.frmRegister;
  var ysnVerifyFields = true;
  if (formObj.elements["txtFirst"].value == "") {ysnVerifyFields = false;}
  if (formObj.elements["txtLast"].value == "") {ysnVerifyFields = false;}

  if (formObj.elements["txtEmail1"].value == "") {ysnVerifyFields = false;}
  if (formObj.elements["txtEmail1"].value == "") {ysnVerifyFields = false;}
  if (formObj.elements["txtPassword1"].value == "") {ysnVerifyFields = false;}
  if (formObj.elements["txtPassword2"].value == "") {ysnVerifyFields = false;}
  return ysnVerifyFields;
  }
  
function VerifyPassword ()
  {
  formObj = document.frmRegister;
  var ysnVerifyFields = true;
  if (formObj.elements["txtPassword1"].value != formObj.elements["txtPassword2"].value) {ysnVerifyFields = false;}
  return ysnVerifyFields;
  }
function VerifyEmailMatch ()
  {
  formObj = document.frmRegister;
  var ysnVerifyEmailMatch = true;
  if (formObj.elements["txtEmail1"].value != formObj.elements["txtEmail2"].value) {ysnVerifyEmailMatch = false;}
  return ysnVerifyEmailMatch;
  }
  
function VerifyEmail(){
	var str = formObj.elements["txtEmail1"].value;
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}
	if (str.indexOf(" ")!=-1){
		return false
	}
 	return true					
}

/*
function VerifyEmail()
  {
  formObj = document.frmRegister;
  var ysnVerifyEmail = true;
  var strEmail;
  strEmail= formObj.elements["txtEmail1"].value
  if (strEmail.search("@") == -1) {ysnVerifyEmail = false;}
  return ysnVerifyEmail;
  }  
*/
function validate() 
{
	var verified = true;
	if (VerifyFields () != true)
	{
		alert("You have not filled in all the required fields.  Please check your form and re-submit again.");
		return false;
	}
    /*else if (VerifyDate() != true)
      {
         verify=false;
         event.returnValue=false;
         alert("Please enter your date of birth.");
      }*/
	else if (VerifyNickName () != true)
	{
		return false;
	}
	else if (VerifyPassword () != true)
	{
		alert("Your passwords do not match.  Please re-type your passwords and resubmit your informatation.");
		return false;
	}
	else if (VerifyEmail () != true)
	{
		alert("You have not entered a valid email address.  Please correct your email address and resubmit your information.");
		return false;
	}
	else if (VerifyEmailMatch () != true)
	{
		alert("Your email does not match.  Please re-type your email addresses and resubmit your informatation.");
		return false;
	}
	return true;
}
  
function validate_login() 
  {
	if (VerifyLoginFields () != true)
      {
      alert("You have not filled in all the fields.  Please check your form and re-submit again.");
      event.returnValue=false;
      }
  }
function VerifyLoginFields ()
  {
  //Loop through all the elements on the page and make sure there has been data
  //entered.  I am making all fields to be required!
  formObj = document.frmLogin;
  var ysnVerifyFields = true;
  
  if (formObj.elements["txtEmail1"].value == "") {ysnVerifyFields = false;}
  if (formObj.elements["txtPassword1"].value == "") {ysnVerifyFields = false;}
  return ysnVerifyFields;
  }
  
//-->

// ----------------------------------------------------------------------
function VerifyNickName () {
	var isValid = true;
	var str = formObj.elements["txtNickName"].value
	
	if (str.length >= 1)
	{
		for (i = 0; i < str.length; i++) 
		{
			if ( !( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) || ((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || (str.charAt(i) == "_")  || (str.charAt(i) == "-") ) )
			{
				alert("You have not entered a valid Nick Name. \r\n\r\nIllegal characters used. Only A-Z and 0-9 can only be used.");
				isValid = false;
				break;	
			}
			else 
			{ 
				isValid = true; 
			}			
		} 
	}
	else
	{
		if (!confirm("You have not filled in a nickname.\r\n\r\nYour first and last name will be used as your nickname when posting on websites.\r\nAre you sure you wish to continue?")) 
      		{
      			event.returnValue=false;
			isValid = true;
      		}	
	} 
	return isValid;
}
function VerifyDate()
{
	formObj = document.frmRegister;
	var age = 13;
	var frmyear = formObj.elements["dobyear"].value
	var currentyear = formObj.elements["currentyear"].value
	currentyear = currentyear * 1;
	frmyear = frmyear * 1;
	var isValid = true;
	
	if ( formObj.elements["dobmonth"].value == "" )
	{
		isValid = false;
	}

	if ( formObj.elements["dobday"].value == "" )
 	{
		isValid = false;
	}
	
	if ( formObj.elements["dobyear"].value == "" )
	{
 		isValid = false;
	}
  	if ( currentyear - frmyear < age)
	{
 		isValid = false;
		alert("Sorry, you must be at least " + age + " years or older to create a Stardock.net account.")
	}	
return isValid;
}




