


function MM_preloadImages() 
{ 
  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];
			}
	}
}


var fld
function checkInqForm(form){
catSel=form.fSelect.options[form.fSelect.selectedIndex].text;
form.hid.value=catSel;
result=true;
	result=true;
	if (!checkName(form.fName.value))
		result=false;
	if (!checkCo(form.fCo.value))
		result=false;
	if (!checkNum(form.fTel.value))
		result=false;
	if (!checkEmail(form.fMail.value))
		result=false;
	if (form.elements["fSelect"].selectedIndex<=0) {
		alert("Please select a category.\nIf match not present please select the 'Other Stationery' option");
		result=false;
	}
	if (!checkText(form.fDesc.value,"Description"))
		result=false;
	if (!checkBlank(form.fSize.value,"Size"))
		result=false;
	if (!checkText(form.fCover.value,"Cover Paper"))
		result=false;
	if (!checkText(form.fInner.value,"Inner Paper"))
		result=false;
	if (!checkText(form.fQty.value,"Quantity"))
		result=false;

return result;
}

function checkForm(form){

	result=true;
	if (!checkName(form.fName.value))
		result=false;
	if (!checkCo(form.fCo.value))
		result=false;
	if (!checkNum(form.fTel.value))
		result=false;
	if (!checkEmail(form.fMail.value))
		result=false;
return result;
}
// NAME

function checkName(varText){
var chk,chars;
chars = /@|\^|~|!|#|\$|%|&|\*|\(|\)|\+|,|\?|[0-9]|-|'|"|<|>|`|\.|\/|\\|_|=|:|\|/;
chk = varText.match(chars);
if (varText==''||varText<5){
	alert("Name Field Blank or Less Than 5 Characters");
	return false;
}
if (chk!=null){
	alert("Invalid Character/s in Name Field");
	return false;
}
return true;
}

// EMAIL

function checkEmail(varMail){
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]\\*\&\\%\\$\\#\\!"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=varMail.match(emailPat)
	if (matchArray==null) {
		alert("Email address seems incorrect (check @ and .'s)")
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
	    alert("The username doesn't seem to be valid.")
	    return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("Destination IP address is invalid!")
				return false
			}
		}
 		return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		alert("The domain name doesn't seem to be valid.")
		return false
	}

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>3) {
		alert("The email must end in a three-letter domain, or two letter country.")
		return false
	}
	if (len<2) {
		var errStr="This address is missing a hostname!"
		alert(errStr)
		return false
	}
	return true;

}




// NUMERIC

function checkNum(varNum){
	if (isNaN(varNum)||(varNum=='')){
		alert("Phone Field Empty or Incorrect");
	 	return false;
	}
	return true;
}

//COMPANY-ORGANISATION

function checkCo(varCo){
var chck,char;
char = /@|\^|~|!|#|\$|%|&|\*|\(|\)|\+|,|\?|'|"|<|>|`|\.|\/|\\|_|=|:|\|/;
chck = varCo.match(char);
if (varCo==''||varCo<3){
	alert("Company/Organisation Blank or Less Than 3 Characters");
	return false;
}
if (chck!=null){
	alert("Invalid Characters in Company/Organisation Field");
	return false;
}
return true;
}

function checkText(varText,errMsg){
var chk,chars;
chars = /@|\^|~|!|#|\$|%|&|\*|\(|\)|\+|,|\?|-|'|"|<|>|`|\.|\/|\\|_|=|:|\|/;
chk = varText.match(chars);
if (varText==''||varText<5){
	alert(errMsg+" Field Blank or Less Than 5 Characters");
	return false;
}
if (chk!=null){
	alert("Invalid Character/s in "+errMsg +" Field ");
	return false;
}
return true;
}

function checkBlank(varText,errMsg){
if (varText<5){
	alert(errMsg+" Field Blank or Less Than 5 Characters");
	return false;
}
return true;
}

function showProfile(title)
{
window.open(title+'htm',title,'width=475,height=400,toolbar=no,status=no,menubar=no,scrollbar=yes,scrolling=auto')
}

function checkAll(chk){
intIndex = 0;
intNumOfElems = frmPaper.elements.length;
for (;intIndex <intNumOfElems;intIndex++)
{
	var e = frmPaper.elements(intIndex);
	if(e.type == 'checkbox')
		e.checked = chk.checked;
}
}

function showPopUp(stat)
{
window.open(stat,'product','width=540,height=400,toolbar=no,status=no,menubar=no,resize=no,scrollbars=yes,scrolling=auto')
}