function trim(str)

{

   return str.replace(/^\s+|\s+$/g,'');

}
function Validate(){

	var login=document.frm.login.value;

	var pass=document.frm.pass.value;
	
	var membertype = document.frm.membertype.value;		

	if(login==''){

		alert('Please enter your email');

		document.frm.login.focus();

		return false;

	}

	if(login!=''){

	   if(emailcheck(login)==false)

	   {

	   	  document.frm.login.value='';	

	      document.frm.login.focus();

		  return false;

		}  

	   

	}

	if(pass==''){

		alert('Please enter your password');

		document.frm.pass.focus();

		return false;

	

	}
	
	if (membertype == "" || membertype== "0" || membertype == "-1" ||membertype.indexOf("Select") != -1) 
	{
		alert("Please choose user type");
		document.frm.membertype.focus();	   	
		return false;
	}	
	
	document.frm.action = 'login.php';
	document.frm.submit();
}
function emailcheck(str) 

{

if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(trim(str)))

//if((str.indexOf('@')<0) ||(str.indexOf('@')!=-1) && (str.charAt(str.length-4)!='.') && (str.charAt(str.length-3)!='.') && str.charAt(0)=='@'))

{

alert("Please enter a valid email address eg: username@domainname.com");

return false;

}

}
function echeck(str) {

if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str))

//if((str.indexOf('@')<0) ||(str.indexOf('@')!=-1) && (str.charAt(str.length-4)!='.') && (str.charAt(str.length-3)!='.') && str.charAt(0)=='@'))

{

alert("Invalid Email");

return false;

}

}
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
