function checkNickNameAvailability(){
	var nickname = document.form1.nickname.value;
	if(nickname == ""){
		alert("Please type your nickname so we can check if it's available");
	}//end if
	else{
		
		var illegalChars = /[\W_]/; // allow only letters and numbers
		if ((nickname.length < 4) || (nickname.length > 20)){
			alert("Nicknames must be between 4 and 20 characters long. (letter and numbers only)");
			return false;
		}//end if
		else if (illegalChars.test(nickname)) {
			alert("The nickname you typed contains illegal characters.\nOnly letters and numbers are allowed.");
			return false;
    	}//end else
	
		popNickWindow(nickname);
	}//end else
	
}//end function
function popNickWindow(nickname){
	window.open("/check_nickname_avail.jsp?nickname=" + nickname, 'nick_win', 'scrollbars=no,status=no,width=1,height=1,screenX=1,screenY=1,menubar=no');
}//end function

function isEmail(string) { 
	if (string.search(/^.+\@.+\..+$/) != -1)
		return true; 
	else return false; 
}//end function

function validate(){
	
	var terms_agreed = document.form1.agree.checked;
	if(terms_agreed == false){
		alert("You must check the box stating agreement with Movie Eye's terms of service to continue.");
		return false;
	}//end if
	
	var email = document.form1.email.value;
	if(!isEmail(email)){
		alert("The first email that you typed is not valid.\n\nAOL users, please remove all spaces from your email address.\nFor example, if your screen name is \"john 2275\", type in john2275@aol.com.");
		return false;
	}//end if
	
	var email2 = document.form1.email2.value;
	if(!isEmail(email2)){
		alert("The 2nd email that you typed is not valid.\n\nAOL users, please remove all spaces from your email address.\nFor example, if your screen name is \"john 2275\", type in john2275@aol.com.");
		return false;
	}//end if
	
	if(email != email2){
		alert("The two email addresses that you typed do not match.  It is very important that you type your email addresses carefully as it is used as your Login ID!  Please type them again carefully.\nThank you!");
		return false;
	}//end if
	
	var password = document.form1.password.value;
	if(password == ""){
		alert("Please choose a password.");
		return false;
	}//end if
		
	var password2 = document.form1.password2.value;
	var dub_quote = "\"";
	if(password.indexOf(dub_quote) > -1){
		alert("Please do not use quotes in your password");
		return false;
	}//end if
		
	if(password != password2){
		alert("Your passwords do not match. Please type them again carefully.\nThank you!");
		return false;
	}//end if
	
	var nickname = document.form1.nickname.value;
	if(nickname == ""){
		alert("Nickname is missing.");	
		return false;
	}//end if
	
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ((nickname.length < 4) || (nickname.length > 20)){
		alert("Nicknames must be between 4 and 20 characters long. (letter and numbers only)");
		return false;
	}//end if
	else if (illegalChars.test(nickname)) {
		alert("The nickname you typed contains illegal characters.\nOnly letters and numbers are allowed.");
		return false;
   	}//end else
	
	/*
	var birthday = document.form1.birthday.value;
	if(birthday == ""){
		alert("Please type your birthday. It will not be visible to other members.");
		return false;
	}//end if
	*/
	
	return true;
	
}//end function