var bo_ns_id = 0;

function startIeFix(){
  if(isIE()){
    document.write('<div id="bo_ns_id_' + bo_ns_id + '"><!-- ');
  }
}

function endIeFix(){
  if(isIE()){
    document.write('</div>');
    var theObject = document.getElementById("bo_ns_id_" + bo_ns_id++);
    var theCode = theObject.innerHTML;
    theCode = theCode.substring(4 ,9+theCode.indexOf("</object>"))
    document.write(theCode);
  }
}

function isIE(){
  // only for Win IE 6+
  // But not in Windows 98, Me, NT 4.0, 2000
  var strBrwsr= navigator.userAgent.toLowerCase();
  if(strBrwsr.indexOf("msie") > -1 && strBrwsr.indexOf("mac") < 0){
    if(parseInt(strBrwsr.charAt(strBrwsr.indexOf("msie")+5)) < 6){
      return false;
    }
    if(strBrwsr.indexOf("win98") > -1 ||
       strBrwsr.indexOf("win 9x 4.90") > -1 ||
       strBrwsr.indexOf("winnt4.0") > -1 ||
       strBrwsr.indexOf("windows nt 5.0") > -1)
    {
      return false;
    }
    return true;
  }else{
    return false;
  }
}

function checkDetails(){

var titl = document.subm.title.value;
var genr = document.subm.genre.value;
var autho = document.subm.author.value;
var submittedb = document.subm.submittedby.value;
var addres = document.subm.address.value;
var phon = document.subm.phone.value;
var emai = document.subm.email.value;
var synopsi = document.subm.synopsis.value;
var message = "";
var error="false";
var at_em = emai.indexOf('@');
var dot_em = emai.indexOf('.');
var illegalChars = /[\(\)\}\{\!\#\~\%\^\*\&\£\$\<\>\,\;\:\\\/\"\[\]]/;

if (titl ==""){
	error = "true";
	message = message + "<li>enter the title of your script</li>";
}

if (genr ==""){
	error = "true";
	message = message + "<li>enter the genre of your script</li>";
}

if (autho ==""){
	error = "true";
	message = message + "<li>enter the author of your script</li>";
}

if (submittedb ==""){
	error = "true";
	message = message + "<li>enter the name of who is submitting the synopsis</li>";
}

if (addres ==""){
	error = "true";
	message = message + "<li>enter your postal address</li>";
}

if (phon ==""){
	error = "true";
	message = message + "<li>enter your phone number</li>";
}

if (emai ==""){
	error = "true";
	message = message + "<li>enter your email address</li>";
}

if (((emai !="") &&(at_em<1 || at_em==(emai.length-1)|| dot_em<3 || dot_em==(emai.length-1) || dot_em == at_em +2)) ||(emai.match(illegalChars))){	
		error="true";
		message = message+"<li>check your email address</li>";
		}

if (synopsi ==""){
	error = "true";
	message = message + "<li>enter the synopsis of your script</li>";
}

if (error=="true"){			
	win = window.open('submissions-form.php','message','scrollbars=yes,toolbars=no,height=150,width=500');
	win.document.write('<title>Please check your details</title>');
	win.document.write('<body bgcolor = #ffcc33>');
	win.document.write('<font face=helvetica,sans-serif size=2><p>Please <ul>' +message+ '</ul></font>');
	win.location.reload();		
	win.focus()	
}
else
	{
		document.subm.submit();
	}
}
