function showPopUp(fileURL, WinHeight, WinWidth)
{
window.open(fileURL,'_Main','height='+WinHeight+', width='+WinWidth+',toolbar=no,status=no,menubar=no,resize=no,scrollbars=yes,scrolling=auto')
}

function showDomFrame()
{
window.open('domDir.htm')
}

function checkForm(form){
  
  result=true;
	if (!checkName(form.fName.value,"Name "))
		result=false;
	if (!checkCo(form.fCo.value,"Organisation"))
		result=false;
	if (!checkEmail(form.fMail.value))
		result=false;
	if (!checkNum(form.fTel.value, "Phone Field Empty or Incorrect"))
		result=false;
return result;

}


function checkResume(form){
posSel=form.fPost.options[form.fPost.selectedIndex].text;
form.hid.value=posSel;
result=true;
	if (!checkName(form.fName.value,"Name "))
		result=false;
	if (!checkEmail(form.fMail.value))
		result=false;
	if (!checkNum(form.fTel.value, "Phone Field Empty or Incorrect"))
		result=false;
	if (!checkBlank(form.fAddr.value,"Address "))
		result=false;
	if (form.elements["fPost"].selectedIndex<=0) {
		alert("Please Select a Post");
		result=false;
	}
	if (!checkNum(form.fExp.value,"Experience not entered"))
		result=false;
	if (!checkNum(form.fSal.value,"Salary Field Empty or Incorrect"))
		result=false;
return result;

}


function checkDomain(form){
posDom=form.fDom.options[form.fDom.selectedIndex].text;
form.fhid.value=posDom;
result=true;
	if (!checkName(form.fName.value,"Name "))
		result=false;
	if (!checkBlank(form.fAddr.value,"Address "))
		result=false;
	if (!checkNum(form.fTel.value, "Phone Field Empty or Incorrect"))
		result=false;
	if (!checkEmail(form.fMail.value))
		result=false;
	if (!checkHost(form.fHost.value))
		result=false;
	if (!checkName(form.fOwn.value,"Owners Name "))
		result=false;
return result;

}


function checkName(varText, errMsg)
{
var chk,chars;
chars = /@|\^|~|!|#|\$|%|&|\*|\(|\)|\+|,|\?|[0-9]|-|'|"|<|>|`|\.|\/|\\|_|=|:|\|/;
chk = varText.match(chars);
if (varText==''||varText.length<5){
	alert(errMsg+"must have more than 5 valid characters");
	return false;
}
if (chk!=null){
	alert("Invalid Character/s in "+errMsg+" Field");
	return false;
}
return true;
}

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;

}

function checkNum(varNum,errMsg){
	if (isNaN(varNum)||(varNum=='')){
		alert(errMsg);
	 	return false;
	}
	return true;
}

function checkCo(varCo,errMsg){
var chck,chr;
chr = /@|\^|~|!|#|\$|%|&|\*|\(|\)|\+|,|\?|'|"|<|>|`|\.|\/|\\|_|=|:|\|/;
chck = varCo.match(chr);
if (varCo==''||varCo<3){
	alert(errMsg+" Blank or Less Than 3 Characters");
	return false;
}
if (chck!=null){
	alert("Invalid Characters in "+errMsg +" Field");
	return false;
}
return true;
}


function checkBlank(varBlank, errMsg){
if (varBlank==''){
	alert(errMsg + "Field Blank");
	return false;
}
return true;
}

function checkHost(varHost){
var chck,chr;
chr = /@|\^|~|!|#|\$|%|&|\*|\(|\)|\+|,|\?|'|"|<|>|`|\.|\/|\\|_|=|:|\|/;
chck = varHost.match(chr);
if (varHost==''||varHost<2){
	alert("Hostname Blank or Less Than 2 Characters");
	return false;
}
if (chck!=null){
	alert("Invalid Characters in Hostname");
	return false;
}
return true;
}