function check_email (emailStr) {
        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=emailStr.match(emailPat)
        if (matchArray==null) {
                /* Too many/few @'s or something; basically, this address doesn't even fit the general mould of a valid e-mail address. */
                //alert("Email address seems incorrect (check @ and .'s)")
                return false
        }

        var user=matchArray[1]
        var domain=matchArray[2]
        if (user.match(userPat)==null) {
                // user is not valid
                //alert("The username doesn't seem to be valid.")
            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) {
                                //alert("Destination IP address is invalid!")
                                return false
                        }
                 }
                 return true
        }
        // Domain is symbolic name
        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) {
                // the address must end in a two letter or three letter word.
            //alert("The address must end in a three-letter domain, or two letter country.")
            return false
        }

        // Make sure there's a host name preceding the domain.
        if (len<2) {
           //var errStr="This address is missing a hostname!"
           //alert(errStr)
           return false
        }
         return true;
}

function send_contact()
{      if(document.forms[0].hidden_action.value!=''){      	 alert('System is sending your contact!');
      	 return false;      }
      else if(document.forms[0].txtName.value==''){
      	 alert('Please enter your name');
      	 document.forms[0].txtName.focus();
      }
      else if(document.forms[0].txtEmail.value==''){      	 alert('Please enter your email address');
      	 document.forms[0].txtEmail.focus();      }
      else if(!check_email(document.forms[0].txtEmail.value)){
      	 alert('Please enter your valid email address');
      	 document.forms[0].txtEmail.focus();
      }
      else if(document.forms[0].txtDetail.value==''){
      	 alert('Please enter your contact detail');
      	 document.forms[0].txtDetail.focus();
      }
      else{
      	 document.getElementById('button').style.display='none';
      	 document.getElementById('sending').style.display='block';
      	 document.forms[0].hidden_action.value='SENDCONTACT';
      	 document.forms[0].submit();      }}

function send_cv()
{
      if(document.forms[0].hidden_action.value!=''){
      	 alert('System is sending your contact!');
      	 return false;
      }
      else if(document.forms[0].txtName.value==''){
      	 alert('Please enter your name');
      	 document.forms[0].txtName.focus();
      }
      else if(document.forms[0].txtAddress.value==''){
      	 alert('Please enter your address');
      	 document.forms[0].txtAddress.focus();
      }
      else if(document.forms[0].txtPhone.value==''){
      	 alert('Please enter your phone');
      	 document.forms[0].txtPhone.focus();
      }
      else if(document.forms[0].txtEmail.value==''){
      	 alert('Please enter your email address');
      	 document.forms[0].txtEmail.focus();
      }
      else if(!check_email(document.forms[0].txtEmail.value)){
      	 alert('Please enter your valid email address');
      	 document.forms[0].txtEmail.focus();
      }
      else if(document.forms[0].fUpload.value==''){
      	 alert('Please select your CV to upload');
      	 document.forms[0].fUpload.focus();
      }
      else{

      	 document.getElementById('button').style.display='none';
      	 document.getElementById('sending').style.display='block';
      	 document.forms[0].hidden_action.value='SENDCV';
      	 document.forms[0].submit();
      }
}











var menuids=["treemenu","treebanner"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
		if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
			ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
		}
		else{ //else if this is a sub level menu (ul)
		  ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
    	ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
		}
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.visibility="visible"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.visibility="hidden"
    }
    }
  }
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)
