/* Copyright NetCore 1997-2008. Licensed to Ash Alom. ashalom [AT] gmail [DOT-COM]
*********************************************************************************/


function ValidateLogin(){
	var LoginFORM = eval("document.LoginForm");
	LoginFORM.eMail.style.backgroundColor="";
	LoginFORM.Password.style.backgroundColor="";
	if(!ValidateeMail(LoginFORM.eMail.value)){
		LoginFORM.eMail.style.backgroundColor="#FFC0C0";
		alert("ERROR: Invalid eMail Address\n\nPlease enter a valid eMail address.");
		LoginFORM.eMail.select();
		return false;
	}
	if(LoginFORM.Password.value.length<2){
		LoginFORM.Password.style.backgroundColor="#FFC0C0";
		alert("ERROR: Invalid Password\n\nPlease enter a valid password.");
		LoginFORM.Password.select();
		return false;
	}
	LoginFORM.Password.value=Encode64(LoginFORM.Password.value);
	document.ProcessingImage_Login.style.visibility="Visible";
	LoginFORM.ButtonLogin.style.cursor="Wait";
	LoginFORM.ButtonLogin.value="Logging In";
	LoginFORM.ButtonLogin.disabled=true;
	LoginFORM.action="login.php";
	LoginFORM.Process.value="Login";
	setTimeout("document.LoginForm.submit();document.LoginForm.Password.value='';",1000);
}

function ValidateRegister(){
	var RegisterFORM = eval("document.RegisterForm");
	RegisterFORM.Name.style.backgroundColor="";
	RegisterFORM.Alias.style.backgroundColor="";
	RegisterFORM.Address.style.backgroundColor="";
	RegisterFORM.City.style.backgroundColor="";
	RegisterFORM.State.style.backgroundColor="";
	RegisterFORM.PostCode.style.backgroundColor="";
	RegisterFORM.Country.style.backgroundColor="";
	RegisterFORM.Phone.style.backgroundColor="";
	RegisterFORM.eMail.style.backgroundColor="";
	//RegisterFORM.Image1.style.backgroundColor="";
	//RegisterFORM.Image2.style.backgroundColor="";
	if(RegisterFORM.Name.value.length<5){
		RegisterFORM.Name.style.backgroundColor="#FFC0C0";
		alert("ERROR: Your Full Name is Missing\n\nPlease enter your full name.");
		RegisterFORM.Name.select();
		return false;
	}
	if(RegisterFORM.Alias.value.length<3){
		RegisterFORM.Alias.style.backgroundColor="#FFC0C0";
		alert("ERROR: Your Forum Alias is Missing\n\nPlease enter your name or an Alias. This will be how people will refer to you on the Message Boards.");
		RegisterFORM.Alias.select();
		return false;
	}
	if(RegisterFORM.Address.value.length<5){
		RegisterFORM.Address.style.backgroundColor="#FFC0C0";
		alert("ERROR: Your Address is Missing\n\nPlease enter your delivery address.");
		RegisterFORM.Address.select();
		return false;
	}

	if(RegisterFORM.City.value.length<2){
		RegisterFORM.City.style.backgroundColor="#FFC0C0";
		alert("ERROR: Your City is Missing\n\nPlease enter your delivery City.");
		RegisterFORM.City.select();
		return false;
	}

	if(!RegisterFORM.State.value){
		RegisterFORM.State.style.backgroundColor="#FFC0C0";
		alert("ERROR: State not selected\n\nPlease select your US State.");
		return false;
	}
	if(RegisterFORM.PostCode.value.length<4){
		RegisterFORM.PostCode.style.backgroundColor="#FFC0C0";
		alert("ERROR: Your Zip Code is Missing\n\nPlease enter your delivery Zip Code.");
		RegisterFORM.PostCode.select();
		return false;
	}
//	if(!RegisterFORM.Country.value){
//		RegisterFORM.Country.style.backgroundColor="#FFC0C0";
//		alert("We only deliver to US.");
//		return false;
//	}
	if(RegisterFORM.Phone.value.length<10){
		RegisterFORM.Phone.style.backgroundColor="#FFC0C0";
		alert("ERROR: Your Phone Number is Missing\n\nPlease enter your Phone Number.");
		RegisterFORM.Phone.select();
		return false;
	}
	if(!ValidateeMail(RegisterFORM.eMail.value)){
		RegisterFORM.eMail.style.backgroundColor="#FFC0C0";
		alert("ERROR: Invalid eMail Address\n\nPlease enter a valid eMail address.\n\nYour eMail address will be your login name so please ensure you enter it correctly.\nWe will send the password to your eMail address you specify.");
		RegisterFORM.eMail.select();
		return false;
	}

//	if(RegisterFORM.Password1.value.length<2){
//		RegisterFORM.Password1.style.backgroundColor="#FFC0C0";
//		alert("ERROR: Invalid Password\n\nPlease enter a longer password.");
//		RegisterFORM.Password1.select();
//		return false;
//	}
//	if(RegisterFORM.Password1.value!=RegisterFORM.Password2.value){
//		RegisterFORM.Password1.style.backgroundColor="#FFC0C0";
//		RegisterFORM.Password2.style.backgroundColor="#FFC0C0";
//		alert("ERROR: Passwords Don't Match\n\nThe two passwords you entered are not the same. Please try again.");
//		RegisterFORM.Password1.select();
//		return false;
//	}
//	if(RegisterFORM.Image1.options[RegisterFORM.Image1.selectedIndex].value==""){
//		RegisterFORM.Image1.options[RegisterFORM.Image1.selectedIndex].style.backgroundColor="#FFC0C0";
//		alert("ERROR: Validation Image 1 Not Selected\n\nUsing the drop down menu, select what you think you can see as the first white symbol in the image below it.");
//		RegisterFORM.Image1.options[RegisterFORM.Image1.selectedIndex].focus();
//		return false;
//	}
//	if(RegisterFORM.Image2.options[RegisterFORM.Image2.selectedIndex].value==""){
//		RegisterFORM.Image2.options[RegisterFORM.Image2.selectedIndex].style.backgroundColor="#FFC0C0";
//		alert("ERROR: Validation Image 2 Not Selected\n\nUsing the drop down menu, select what you think you can see as the second white symbol in the image below it.");
//		RegisterFORM.Image2.options[RegisterFORM.Image2.selectedIndex].focus();
//		return false;
//	}
	document.ProcessingImage_Register.style.visibility="Visible";
	RegisterFORM.ButtonRegister.style.cursor="Wait";
	RegisterFORM.ButtonRegister.value="Registering";
	RegisterFORM.ButtonRegister.disabled=true;
	document.LoginForm.ButtonLogin.disabled=true;
	RegisterFORM.action="login.php";
	RegisterFORM.Process.value="Register";
	setTimeout("document.RegisterForm.submit();",1000);
}

function LoadValidationImage(){
	document.Ash.style.background="url(http://www.healthyways.net/img.php)";
	self.focus();
}

function SetAlias(X){
	var RegisterFORM = eval("document.RegisterForm");
	RegisterFORM.Alias.value = X.value;
}
