function isValidEmail(str)
{
  // trim starting / ending whitespace
  str = str.replace(/^\s*/, "");
  str = str.replace(/\s*$/, "");

  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)

  if (str.indexOf(at)==-1)
    return false

  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    return false

  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    return false

  if (str.indexOf(at,(lat+1))!=-1)
    return false

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    return false

  if (str.indexOf(dot,(lat+2))==-1)
    return false

  if (str.indexOf(" ")!=-1)
    return false

  return true;
}


// helper function to check to see if a string is empty
function isEmpty(str)
{
  return ((str == null) || (str.length == 0));
}


function ValidateForm() {

var email = document.login.email;
var password = document.login.password;


var error = 0;


if (!email.value) {
document.getElementById('warn_email').innerHTML = 'Required';
error = 1;
} else {
if (isValidEmail(email.value) === false)
              {
                document.getElementById('warn_email').innerHTML = 'Enter a valid email address';
                error = 1;
              } else {

              	if (email.value && email.value.match(/[^-a-zA-Z0-9 .@_]/)) {
				                document.getElementById('warn_email').innerHTML = 'No special characters allowed';
				                error = 1;
				              } else {
				              	document.getElementById('warn_email').innerHTML = '';
				              }



              }
}

if (!password.value) {
document.getElementById('warn_password').innerHTML = 'Required';
error = 1;
} else {
if (password.value && password.value.match(/[^-a-zA-Z0-9 ._&,\!?+@:;\(\)']/))
              {
                document.getElementById('warn_password').innerHTML = 'No special characters allowed';
                error = 1;
              } else {
              	document.getElementById('warn_password').innerHTML = '';
              }
}


if (error == 1) { return false; } else {
	document.login.submit();
	
 	}


}