function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cleardetails(e){
	e.value="";
}

function checkEmail(){
	st=compareEmail();
	
	if (st==false){
		alert("Please check your email addresses, as they don't match.");
	}
}

function compareEmail(){
	var frm=document.frm1;
	var st=true;
	
	if (frm.frm1e5c.value!=frm.frm1e5cC.value){
		st=false;
	}
	return st
}

function checkEmailformat(e){
	var st=formatEmail(e);
	
	if (st==false){
		alert("Please verify that your email address is valid.");
	}
}

function formatEmail(e){
	var st=true;
	
	if ((e.value.indexOf ('@',0) == -1 ||
		e.value.indexOf ('.',0) == -1) &&
		e.value != ""){
		st=false;
	}
	return st
}

function loginValidator(){
	var error = ""; 
	var st=true;
	var stEm=true;
	var theForm=document.frm1;
	
	for (var i=0; i < theForm.frm1e2.length; i++){
   		if (theForm.frm1e2[i].checked){
      		var opt_val = theForm.frm1e2[i].value;
      	}
   	}

	if (opt_val == "yes"){
		if (theForm.frm1e1.value == ""){
			error += "- Your email address is required.\n";
		}
		if (theForm.frm1e3.value == ""){
			error += "- Your password is required.\n";
		}
		
		if (error != ""){
			alert("The following errors have occured:\n\n" + error);
			return (false);
		}else{
			answer = confirm("\n Are your details correct? \n");
		}
		if (answer!="1"){
			return(false)
		}
	}
}

function RegValidator(){
	var error = ""; 
	var st=true;
	var stEm=true;
	var theForm=document.frm1;
	
	if (theForm.frm1e2c.value == ""){
		error += "- Your first name is required.\n";
	}
	if (theForm.frm1e3c.value == ""){
		error += "- Your surname name is required.\n";
	}
	if (theForm.frm1e4c.value == ""){
		error += "- Your daytime telephone number is required.\n";
	}
	if (theForm.frm1e5c.value == ""){
		error += "- Your email address is required.\n";
	}
	if ((theForm.frm1e5c.value.indexOf ('@',0) == -1 ||
		theForm.frm1e5c.value.indexOf ('.',0) == -1) &&
		theForm.frm1e5c.value != ""){
		error += "- Please verify that your email address is valid.\n";
	}
	st=compareEmail();	
	if (st==false){
		error += "- Please check your email addresses, as they don't match.\n";
	}
	
	if (theForm.frm1e6c.value != ""){
		if (theForm.frm1e7c.value == ""){
			error += "- Your customer registration password is missing.\n";
		}
	}
	
	if (theForm.frm1e1a.value == ""){
		error += "- The first line of the card holder's address is required.\n";
	}
	if (theForm.frm1e4a.value == ""){
		error += "- The card holder's address town is required.\n";
	}
	if (theForm.frm1e6a.value == ""){
		error += "- The card holder's address postcode is required.\n";
	}
	
	if (error != ""){
		alert("The following errors have occured:\n\n" + error);
		return (false);
	}else{
		answer = confirm("\n Are your details correct? \n");
	}
	if (answer!="1"){
		return(false)
	}
}

function checkSampleRequest(){
	var error = ""; 
	var st=true;
	var stEm=true;
	var theForm=document.frm1;
	
	if (theForm.frm1e2.value == ""){
		error += "- Your full name is required.\n";
	}
	if (theForm.frm1e3.value == ""){
		error += "- Your email address is required.\n";
	}
	if ((theForm.frm1e3.value.indexOf ('@',0) == -1 ||
		theForm.frm1e3.value.indexOf ('.',0) == -1) &&
		theForm.frm1e3.value != ""){
		error += "- Please verify that your email address is valid.\n";
	}
	
	if (theForm.frm1e4.value == ""){
		error += "- Your telephone number is required.\n";
	}
	if (theForm.frm1e5.value == ""){
		error += "- Your postal address including postcode is required.\n";
	}
	
	if (error != ""){
		alert("The following errors have occured:\n\n" + error);
		return (false);
	}else{
		answer = confirm("\n Are your details correct? \n");
	}
	if (answer!="1"){
		return(false)
	}
}

function checkCommentDetails(){
	var error = ""; 
	var st=true;
	var stEm=true;
	var theForm=document.frm1;
	
	if (theForm.frm1e1.value == ""){
		error += "- Your full name is required.\n";
	}
	if (theForm.frm1e2.value == ""){
		error += "- Your email address is required.\n";
	}
	if ((theForm.frm1e2.value.indexOf ('@',0) == -1 ||
		theForm.frm1e2.value.indexOf ('.',0) == -1) &&
		theForm.frm1e2.value != ""){
		error += "- Please verify that your email address is valid.\n";
	}
	
	if (theForm.frm1e4.value == ""){
		error += "- Your comments are required.\n";
	}
	
	if (error != ""){
		alert("The following errors have occured:\n\n" + error);
		return (false);
	}else{
		answer = confirm("\n Are your details correct? \n");
	}
	if (answer!="1"){
		return(false)
	}
}

function checkPasswordHint(){
	var error = ""; 
	var st=true;
	var stEm=true;
	var theForm=document.frm1;
	
	if (theForm.frm1e1.value == ""){
		error += "- Your email address is required.\n";
	}
	if ((theForm.frm1e1.value.indexOf ('@',0) == -1 ||
		theForm.frm1e1.value.indexOf ('.',0) == -1) &&
		theForm.frm1e1.value != ""){
		error += "- Please verify that your email address is valid.\n";
	}
	
	if (error != ""){
		alert("The following errors have occured:\n\n" + error);
		return (false);
	}else{
		answer = confirm("\n Are your details correct? \n");
	}
	if (answer!="1"){
		return(false)
	}
}

function deleteOrder(){
	answer = confirm("\n Do you want to delete the order? \n");
	if (answer=="1"){
		document.frm1.frm1e0.value='delete';
		document.frm1.submit();
	}
}

function findImage(e,type,i){
	var url='../inc/image/find_ref.php?eid=' + e.name + '&type=' + type + '&itype=' + i;
	window.open(url,"File_Reference","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=650,height=550,top=200,left=200");
}