var msie3=false;
var win;
browserVer=parseInt( navigator.appVersion );
if( browserVer == 2 && navigator.appName == "Microsoft Internet Explorer" ) { browserVer++; msie3=true; }

function msg_alert( name, text, height )
{
  if( typeof( height) == "undefined" ) { height = 200; }
  if( msie3 != true && typeof( win ) == "object" && !win.closed ) { win.close(); }
  win=open( "", "msg_alert", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=" + height);
  if ( msie3 == true ) while( typeof( win.document )=='undefined' );
  win.document.write( '<HTML><HEAD><TITLE>'+ name +'</TITLE></HEAD>\n<BODY BGCOLOR="#FFFFFF" MARGINWIDTH=0 MARGINHEIGHT=0>\n' );
  win.document.write( '<TABLE CELLPADDING=6 CELLSPACING=0 WIDTH="100%" BORDER=0><TR><TD BGCOLOR="#CC0000"><div align="center"><FONT FACE="arial,helvetica" COLOR="#FFFFFF" SIZE=4><B>' + name +'</B></FONT></DIV></TD></TR>' );
  win.document.write( '<TR><TD><FONT FACE="arial,helvetica" SIZE=2>'+ text +'</FONT></TD></TR>' );
  win.document.write( '<TR><TD ALIGN=CENTER><FORM><INPUT TYPE=submit VALUE="OK" onClick="window.close();"></FORM></TD></TR></TABLE>' );
  win.document.write( '</BODY></HTML>\n' );
  win.document.close();
}

function checkForm(form)
{
  if( browserVer <= 2 ) { return true; }

  var height = 130;
  var error_msg = "";
  var error = false;  
  
  var tmp = form.name.value;
  num = tmp.length;
  
  if( num == 0 )
  { 
     error_msg =  "Please enter your name.<P>";
     error = true;
  }

//Email
  var email = form.email.value;
  num = isValidEmail(email)
  if (num == 0 )
  {
     error_msg = error_msg +  "Please enter a valid e-mail address. Make sure it has a \"\@\" symbol, contains full points rather than commas and contains no spaces.<P>";
     height = height + 60;
     error = true;
  }


//Message
  var tmp = form.message.value;
  if( tmp.length == 0 )
  {
     error_msg = error_msg + "We did not detect any content in your message. Please enter some.<P>";
     height = height + 60;
     error = true;
  }

  if (error == true)
  {
     msg_alert("Missing Information",error_msg,height);
  }
   return !(error);
}

function isValidEmail(email)
{
  var tld = email.substring(email.lastIndexOf(".")+1, email.length)  
  var host = email.substring(email.indexOf("@")+1, email.indexOf(".",email.lastIndexOf("@")))  
  var user = email.substring(0, email.indexOf("@"))  

  if (email.indexOf("@") == -1 || email.indexOf("@") != email.lastIndexOf("@")) { return false; }
  if (email.indexOf(".") == -1) { return false; }
  if (tld.length < 2) { return false; }
  if (host.length == 0) { return false; }
  if (user.length == 0) { return false; }
  if (email.indexOf(" ") != -1) { return false; }
  if (email.indexOf(",") != -1) { return false; }

  return true;
}
