function login_sf(){
	if (document.login_form!= null){
		if (document.login_form.user.value.length <1 ) document.login_form.user.focus();
		else document.login_form.password.focus()
	}
}

function signup_sf(){
	if (document.signup!= null){
		document.signup.user.focus();
	}
}

function lostit_sf(){
	if (document.lostit!= null){
		 document.lostit.email.focus();
	}
}

//Verify's that an email address is reasonable


function is_alpha_numeric(checkStr){
		// allow ONLY alphanumeric keys, no symbols or punctuation
	// this can be altered for any "checkOK" string you desire
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
	}
	if (!allValid)	return (false);
	
	return true;
}


	

function login_validator(theForm) {
	//Need better error checking
	if (theForm.user.value.length < 3 || theForm.user.length > 20 || !is_alpha_numeric(theForm.user.value)){
		alert('Please enter a valid username. It must be 3 to 20 characters and contain only numbers and letters.');
		theForm.user.focus();
 			return (false);
	}
	if (theForm.password.value.length < 1){
		alert('No Password entered');
		theForm.password.focus();
   		return (false);
	}
	
	e=new Date(); e.setTime(e.getTime()+40000000000000);
	document.cookie='user='+theForm['user'].value+'; expires='+e.toGMTString()+'; path=/; domain=ic.org';
	return true;
}

function signup_validator(theForm) {
		
	//Need better error checking
	if (theForm.user.value.length < 3 || theForm.user.length > 20 || !is_alpha_numeric(theForm.user.value)){
		alert('Please enter a valid username. It must be between 3 and 20 characters and contain only numbers and letters.');
		theForm.user.focus();
 			return (false);
	}
	
	if (echeck(theForm.email.value)==false){
		alert('Please enter a valid email address');
		theForm.email.focus()
		return false
	}
	
	if (theForm.email.value != theForm.email_confirmation.value){
		alert('Your Email Address Confirmation does not match your Email Address');
		theForm.email.focus()
		return false
	}
	
	if (theForm.password.value.length < 4 ){
		alert('Please enter a valid password. It must be at least 4 characters.');
		theForm.password.focus();
 			return (false);
	}
	
	if (theForm.password.value != theForm.password_confirmation.value){
		alert('Your Password Confirmation does not match your Password ');
		theForm.password.focus()
		return false
	}
	

/*	e=new Date(); e.setTime(e.getTime()+40000000000);
	document.cookie='user='+theForm['user'].value+'; expires='+e.toGMTString()+'; path=/; domain=ic.org';
*/	return true;
}

