// JavaScript Document
function changetoggle(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function checkLogin(login){
	var email = login.login_email.value;
	var passd = login.login_password.value;
	var fwd = login.fwd.value;
	
	if (echeck(email)){
		if (email.length >3 ) {
			if (passd.length >2){
				login.action='login.php';
				login.method='POST';
				login.submit();								
			}else{
				alert('Password incorrect');						
			}
		}else{
			alert ('Invalid Email Address');	
		}
	}

return false;
}

function checkEnter(e){ //e is event object passed from function invocation
	var characterCode //literal character code will be stored in this variable

	if(e && e.which){ //if which property of event object is supported (NN4)
		e = e
		characterCode = e.which //character code is contained in NN4's which property
	}else{
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}

	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
		checkLogin(document.login) //submit the form
		return false 
	}else{
		return true 
	}
}

///checking email validation.
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid Email Address");
	   return (false);
	}	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid Email Address");
	   return (false);
	}	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid Email Address");
		return (false);
	}	
	if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid Email Address");
		return (false);
	}	
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid Email Address");
		return (false);
	}	
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid Email Address");
		return (false);
	}	
	if (str.indexOf(" ")!=-1){
		alert("Invalid Email Address");
		return (false);
	}	
	 return true;			
}