function sf(fo,fi){eval('document.' + fo + '.' + fi + '.focus()');}

function MM_validateForm(fn) { 
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	
    for (i=1; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=args[i+1]; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain a valid e-mail address.\n<br>';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n<br>';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n<br>';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n<br>'; }
    }
	if (errors) {
	var	errorobj = document.getElementById('error_display');
		errorobj.style.display="block";
 	 	errorobj.innerHTML = "<strong>The following error(s) occurred:</strong><br>"+errors+"<br><form action='#' method='post'><input class='button' type='button' value='Close' onclick='hide();' onMouseOver=\"this.className='button buttonhov'\" onMouseOut=\"this.className='button'\"></form>";
	
	}
	if (document.MM_returnValue = (errors == '')&&(fn=='contact')) {
		var errorobj = document.getElementById('error_display');
		errorobj.style.display="none";
 		//eval('document.'+fn+'.submit()');
		var inputName = eval('document.'+fn+'.name.value');
		var inputAddr1 = eval('document.'+fn+'.address1.value');
		var inputAddr2 = eval('document.'+fn+'.address2.value');
		var inputTown = eval('document.'+fn+'.town.value');
		var inputCounty = eval('document.'+fn+'.county.value');
		var inputCode = eval('document.'+fn+'.code.value');
		var inputCountry = eval('document.'+fn+'.country.value');
		var inputPhone = eval('document.'+fn+'.phone.value');
		var inputFax = eval('document.'+fn+'.fax.value');
		var inputEmail = eval('document.'+fn+'.email.value');
		var inputRequest = eval('document.'+fn+'.request.value');
		var inputLogfile = eval('document.'+fn+'.logfile.value');
		var inputChallenge = eval('document.'+fn+'.recaptcha_challenge_field.value');
		var inputResponse = eval('document.'+fn+'.recaptcha_response_field.value');
		var Obj=document.getElementById('contactMsgBox');
		Obj.style.display = 'block';
		Obj.innerHTML = "<iframe id='contactFrame' src='http://www.haliden.co.uk/cgi-bin/" + fn + ".cgi?name=" + inputName + "&address1=" + inputAddr1 + "&address2=" + inputAddr2 + "&town=" +inputTown + "&county=" +inputCounty + "&code=" + inputCode + "&country=" + inputCountry + "&phone=" + inputPhone + "&fax="  +inputFax + "&email=" +inputEmail + "&request=" + inputRequest + "&logfile=" + inputLogfile + "&recaptcha_challenge_field=" + inputChallenge + "&recaptcha_response_field=" + inputResponse +"' scrolling='auto' frameborder='0'></iframe><form method='post'><input type='button' class='button' value='Close' onMouseOver=\"this.className='button buttonhov'\" onMouseOut=\"this.className='button'\" onClick='closeBox();'></form>"; 
	}
}}

function hide() {
	obj = document.getElementById('error_display');
	obj.style.display = 'none';
	}
	
function closeBox() {
	var Obj=document.getElementById('contactMsgBox');
	Obj.style.display = 'none';
}
