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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function edituser(var1){
	if (frmedit.submit){
		document.frmedit.editid.value = var1
		document.frmedit.submit();
		return false;
	}
	else return true;
}
function disableuser(var1){
	document.frmdis.disid.value = var1
	document.frmdis.submit();
	return false;
}
function enableuser(var1){
	document.frmenable.enableid.value = var1
	document.frmenable.submit();
	return false;
}

function checkMemberNo()
{
	var ok;

	var re;                     //Declare variables.
	re = /\d{4}/;
	
	ok = document.frm.mem1.value == "3083";
	if (ok)
		{
		ok = re.test(document.frm.mem2.value);
		if (ok)
			{
			var re2;
			re2 = /26\d{2}/;
			ok = re2.test(document.frm.mem2.value);
			}
		}
	
	if (ok)
		ok = re.test(document.frm.mem3.value);
	if (ok)
		ok = re.test(document.frm.mem4.value);

	return ok;
}

function checkFields() {
	missinginfo = "";
	if (document.frm.RepType1.checked)
	{
		if (document.frm.txtsearch.value == "") {
			missinginfo += "\n     -  VIN or Registration Number";
		}
		else if (document.frm.txtsearch.value.length > 7 && document.frm.txtsearch.value.length != 17) {
			missinginfo += "\n     -  Too many characters for a registration plate or the VIN number is invalid (ie, not 17 characters)";
			// alert(missinginfo);
			// return false;
		}
	}

	if ((document.frm.email.value == "") || 
		(document.frm.email.value.indexOf('@') == -1) || 
		(document.frm.email.value.indexOf('.') == -1)) {
		missinginfo += "\n     -  Email address";
	}	
	
	/* 
	if (document.frm.survay.value == "") {
		missinginfo += "\n     -  Please specify how you heard about LemonCheck";
	}
	*/
	
	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"Please enter all the required information:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease complete the form and submit again";
		alert(missinginfo);
		return false;
	}

	return true;
}

function confirmSubmitHandler() {
	document.frm.submitBtn.value = "Processing report. Please wait...";
	document.frm.submitBtn.disabled = true;
	return(true);
}

function loginval() {
	missinginfo = "";
	
	if (document.frm.dealerpin.value == "") {
		missinginfo += "\n     -  Account Pin";
	}
	
	if (document.frm.username.value == "") {
		missinginfo += "\n     -  User Name";
	}
	
	if (document.frm.password.value == "") {
		missinginfo += "\n     -  Password";
	}
	
	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"You failed to Enter all the required Information:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease complete the form and retry login!";
		alert(missinginfo);
		return false;
	}
	else return true;
}

function checkapp() {
	missinginfo = "";
	if (document.frm.business.value == "") {
		missinginfo += "\n     -  Business Name";
	}
	
	if (document.frm.businesstypeid.value == "") {
		missinginfo += "\n     -  Business Type";
	}
	if (document.frm.bphone.value == "") {
		missinginfo += "\n     -  Business Phone";
	}
	if (document.frm.bemail.value == "") {
		missinginfo += "\n     -  Business Email";
	}
	if (document.frm.postaladdress.value == "") {
		missinginfo += "\n     -  Business Postal Address";
	}
	if (document.frm.postalsuburb.value == "") {
		missinginfo += "\n     -  Business Postal Suburb";
	}
	if (document.frm.postalcity.value == "") {
		missinginfo += "\n     -  Business Postal City";
	}

	if (missinginfo != "") {
		missinginfo ="_____________________________\n" +
		"You failed to Enter all the required Information:\n" +
		missinginfo + "\n_____________________________" +
		"\nPlease complete the form and submit again";
		alert(missinginfo);
		return false;
	}
	else
	{ 
		var ok = window.confirm("I confirm that this application is for a registered company and I am authorised to act as agent in the capacity of this agreement.");
		return ok;
	}
}

function delrec(){
	if (confirm("Are you sure you want to delete this Record"))
		return true;
	else
		return false;
}
