function popupWin(strURL, strTarget, strWinOptions)
 {
  var myWin = window.open(strURL, strTarget, strWinOptions);
  return false;
}

function popuplogin(){
	popupWin('login/index.html','login','height=290,width=492,screenX=200,screenY=5,scrollbars=no');
}

function newUser(){
	opener.location.href = "newUser.php";
	self.close();
}
function checkPassword(){
	opener.location.href = "forgotPwd.php";
	self.close();
}
/* ************************************************************************************ */

function validateForm(){
	var msg
	var sUsername
	var exp1,exp2
	msg = "";
	exp1 = /\W/i;
		
	sUsername = new String(document.frmSignup.sUsername.value)
	
	if (sUsername.search(exp1) != -1)
	   msg = "- Invalid username, please use alphabetic or numeric characters only.\n";
	
	if (document.frmSignup.sUsername.value == ""){
		msg = "- You have not entered a username.\n";
	}
	if (document.frmSignup.sUsername.value.length < 4 | document.frmSignup.sUsername.value.length > 20){
		msg = "- Your username must be between 4 and 20 characters in length.\n";
	}
	if (document.frmSignup.sPassword.value == ""){
		msg = msg + "- You have not entered a password.\n";
	}
	if (document.frmSignup.sPasswordConfirmation.value == ""){
		msg = msg + "- You have not confirmed your password.\n";
	}
	if (document.frmSignup.sPasswordConfirmation.value != document.frmSignup.sPassword.value){
		msg = msg + "- Your password confirmation does not match the password you entered.\n";
	}
	if (document.frmSignup.eEmail.value == ""){
		msg = msg + "- You have not entered your email.\n";
	}
	if (document.frmSignup.eEmail.value != "" & (document.frmSignup.eEmail.value.indexOf("@") == -1 | document.frmSignup.eEmail.value.indexOf(".") == -1)){
		msg = msg + "- You have not entered a valid email.\n";
	}
	if (msg == ""){
		document.frmSignup.submit(); 
	}
	else{
		alert(msg);
	}
}



function validateFormForgot(){
	var msg
	var sUsername
	var exp1,exp2
	msg = "";
	exp1 = /\W/i;
		
	sUsername = new String(document.frmSignup.sUsername.value)
	
	
	
	if (sUsername.search(exp1) != -1)
	   msg = "- Invalid username, please use alphabetic or numeric characters only.\n";
	
	if (document.frmSignup.sUsername.value == ""){
		msg = "- You have not entered a username.\n";
	}
	if (document.frmSignup.sUsername.value.length < 4 | document.frmSignup.sUsername.value.length > 20){
		msg = "- Your username must be between 4 and 20 characters in length.\n";
	}

	
	
	
	if (document.frmSignup.sEmailAddress.value == ""){
		msg = msg + "- You have not entered your email.\n";
	}
	if (document.frmSignup.sEmailAddress.value != "" & (document.frmSignup.sEmailAddress.value.indexOf("@") == -1 | document.frmSignup.sEmailAddress.value.indexOf(".") == -1)){
		msg = msg + "- You have not entered a valid email.\n";
	}
	if (msg == ""){
		document.frmSignup.submit(); 
	}
	else{
		alert(msg);
	}
}





function validateFormLogin(){
	var msg
	var sUsername
	var exp1,exp2
	msg = "";
	exp1 = /\W/i;
		
	sLogin = new String(document.frmSignup.sLogin.value)
	
	
	
	if (sLogin.search(exp1) != -1)
	   msg = "- Invalid username, please use alphabetic or numeric characters only.\n";
	
	if (document.frmSignup.sLogin.value == ""){
		msg = "- You have not entered a username.\n";
	}
	if (document.frmSignup.sLogin.value.length < 4 | document.frmSignup.sLogin.value.length > 20){
		msg = "- Your username must be between 4 and 20 characters in length.\n";
	}
	
	if (document.frmSignup.sPassword.value == ""){
		msg = msg + "- You have not entered a password.\n";
	}
	if (msg == ""){
		document.frmSignup.submit(); 
	}
	else{
		alert(msg);
	}
}

function validateFormSubscription(){
        var msg
        var sUsername
        var exp1,exp2
        msg = "";
        exp1 = /\W/i;

        Lastname= new String(document.frmSignup.Lastname.value)

        //if (Lastname.search(exp1) != -1)
        //   msg = "- Invalid Lastname, please use alphabetic or numeric characters only.\n";

        if (document.frmSignup.Lastname.value == ""){
                msg = "- You have not entered a Lastname.\n";
        }
        if (document.frmSignup.Lastname.value.length < 2 | document.frmSignup.Lastname.value.length > 200){
                msg = "- Your Lastname must be between 2 and 200 characters in length.\n";
        }
        
        Firstname= new String(document.frmSignup.Firstname.value)

//        if (Firstname.search(exp1) != -1)
//           msg = "- Invalid Firstname, please use alphabetic or numeric characters only.\n";

        if (document.frmSignup.Firstname.value == ""){
                msg = "- You have not entered a Firstname.\n";
        }
        if (document.frmSignup.Firstname.value.length < 2 | document.frmSignup.Firstname.value.length > 200){
                msg = "- Your Firstname must be between 2 and 200 characters in length.\n";
        }

        if (document.frmSignup.street.value == ""){
                msg = msg + "- You have not entered a Street address.\n";
        }
        if (document.frmSignup.city.value == "" && document.frmSignup.sCodCountry.value!="US"){
                msg = msg + "- You have not entered a city.\n";
        }
        if (document.frmSignup.phone.value == ""){
                msg = msg + "- You have not entered a phone.\n";
        }
        if (document.frmSignup.email.value == ""){
                msg = msg + "- You have not entered a email.\n";
        }

        if (document.frmSignup.email.value != "" & (document.frmSignup.email.value.indexOf("@") == -1 | document.frmSignup.email.value.indexOf(".") == -1)){
		msg = msg + "- You have not entered a valid email.\n";
	}


    iChecked = false;	
	for (i = 0; i < document.frmSignup["Hobbies[]"].length; i++)
	if (document.frmSignup["Hobbies[]"][i].checked) iChecked = true;
	
	if (!iChecked){
	    if (document.frmSignup.OthersHobbies.value == ""){
	    msg = msg + "- You have not entered a Hobbies.\n";
		}
	}
						    




        if (msg == ""){
                document.frmSignup.submit();
        }
        else{
                alert(msg);
        }
}


/* ************************************************************************************ */




