function emailCheck(element) {
      	emailStr=element.value;
      
        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 + ")"
        // The following pattern describes the structure of the user
        var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
        var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
      
      
        var matchArray=emailStr.match(emailPat)
        if (matchArray==null) {
          window.alert("Email address seems incorrect.")
          element.focus();
          element.select();
          return false
      	}
			
        var user=matchArray[1]
        var domain=matchArray[2]
        
        // See if "user" is valid 
        if (user.match(userPat)==null) {
          // user is not valid
          window.alert("The email username doesn't seem to be valid.")
          element.focus();
          element.select();
          return false
        }
        
        var IPArray=domain.match(ipDomainPat)
        if (IPArray!=null) {
          // this is an IP address
          for (var i=1;i<=4;i++) {
            if (IPArray[i]>255) {
              window.alert("Destination email IP address is invalid!")
              element.focus();
              element.select();
              return false
            }
          }
        }					
					
        // Domain is symbolic name
        var domainArray=domain.match(domainPat)
        if (domainArray==null) {
          window.alert("The email domain name doesn't seem to be valid.")
          element.focus();
          element.select();
          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>4) {
          // the address must end in a two letter or three letter word.
          window.alert("The email address must end in a three-letter domain, or two letter country.")
          element.focus();
          element.select();
          return false
        }
        
        // Make sure there's a host name preceding the domain.
        if (len<2) {
          var errStr="The email address is missing a hostname!"
          window.alert(errStr)
          element.focus();
          element.select();
          return false
        }
        
        return true;
			}


      var openhlp;
      var oldplace;
      function helpWin(objEvt, sType) {
        openhlp="oHlp"+sType;
        if (oldplace==undefined) {
        	oldplace=openhlp;
        }
        if (openhlp!=oldplace) {
          document.getElementById(oldplace).style.display="none";
          oldplace=openhlp;
        }
        document.getElementById(openhlp).style.display="block";
        
        var intXPos;
        var intYPos;
        var intDivSizeW = document.getElementById(openhlp).offsetWidth;
        var intDivSizeH = document.getElementById(openhlp).offsetHeight;
        var intScreenSizeW = document.body.offsetWidth;
        var intScreenSizeH = document.body.offsetHeight;
        
        intXPos=intScreenSizeW/2-intDivSizeW/2;
        intYPos=objEvt.clientY;
        
        document.getElementById(openhlp).style.left=intXPos+"px";
        document.getElementById(openhlp).style.top=intYPos+"px";
        if (document.all) {
          for (i=0; i<document.ENQUIRY.elements.length; i++) {
            oMe=document.ENQUIRY.elements[i];
            if (oMe.tagName=="SELECT") {
            	oMe.style.visibility="hidden";
          	}            	
        	}
        }		
      }
      function helpWinClose() {
        document.getElementById(openhlp).style.display="none";
        if (document.all) {          
          for (i=0; i<document.ENQUIRY.elements.length; i++) {
            oMe=document.ENQUIRY.elements[i];
            if (oMe.tagName=="SELECT") {
            	oMe.style.visibility="inherit";
            }            	
          }
        }	
      }
      
// Open help popup function
var UKIopenhlp;
var UKIoldplace;
function UKIhelpWin(objEvt, sType) {
	UKIopenhlp="oHlp"+sType;
	if (UKIoldplace==undefined) {
		UKIoldplace=UKIopenhlp;
	}
	if (UKIopenhlp!=UKIoldplace) {
		document.getElementById(UKIoldplace).style.display="none";
		UKIoldplace=UKIopenhlp;
	}

	document.getElementById(UKIopenhlp).style.display="block";
}
function UKIhelpWinClose() {
	document.getElementById(UKIopenhlp).style.display="none";
}