win=null;

window.onerror = null; 

function msgw(t1,t2) {
   win=window.open("", "msg", "width=250,height=100");
   win.document.open("text/html");
   win.document.writeln("<head><title>Error</title></head>");
   win.document.writeln("<body><ul>");
   win.document.writeln(t1);
   win.document.writeln("<br>");
   win.document.writeln(t2);
   win.document.writeln("<br>");
   win.document.writeln("<center>");
   win.document.writeln("<form><input type=button value=o.k. onclick=self.window.close()></form>");
   win.document.writeln("</center>");
   win.document.writeln("</ul></body>");
   win.document.close();
   if(win.focus != null) win.focus();
}

function check_email(f)
{
 var em	= f.email.value;
 
 var res = false;

 {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(em));
 }
  if (!res) {
      msgw('Please enter a valid email address','');
  }
  else {
      f.submit();
   }
 }

function check_data(f) {
var fn	= f.firstname.value;
var ln	= f.lastname.value;
var or	= f.organization.value;
var ad  = f.address.value;
var pc  = f.postalcode.value;
var ci  = f.city.value;
var co  = f.country.value;
var em	= f.email.value;
var res = false;
// var a   = f.agree.checked;

reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
res = (reg.test(em));
   
   if (fn=="" || ln=="" || or=="" || ad=="" || pc=="" || ci=="" || co=="" || em=="") {
      msgw('Please fill in all mandatory fields (*)!','');
   }
   
 else if (!res) {
      msgw('Please enter a valid email address!','')
 }
   else {
      f.submit();
   }
}
