//function to check empty fields

function isEmpty(strfname, strphone) {


//change "fname, lname and phone" to your field names
strfname = document.forms[0].fname.value
strphone = document.forms[0].phone.value

  //First Name field
    if (strfname == "" || strfname == null || !isNaN(strfname) || strfname.charAt(0) == ' ')
    {
    alert("\"First Name\" field is required.\nPlease amend and retry.")
    return false;
    }

  //Phone Number field
    if (strphone == "" || strphone == null || strphone.charAt(0) == ' ')
    {
    alert("\"Phone Number\" field is required.\nPlease amend and retry.")
    return false;
    }
    return true;
}


//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1)
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    }
    return true;
}


//function that performs all functions, defined in the onsubmit event handler

function ValidateForm(form){
if (isEmpty(form.fname)){
  if (isEmpty(form.lname)){
    if (isEmpty(form.phone)){
		if (isValidEmail(form.email)){
		  return true;
		}
	  }
  }
}
return false;
}

//function for highlight current page

function setActive() {
  aObj = document.getElementById('verticalmenu').getElementsByTagName('a');
  for(i=0;i<aObj.length;i++) {
    if(document.location.href.indexOf(aObj[i].href)>=0) {
      aObj[i].className='active';
    }
  }
}
window.onload = setActive;

//pop up menu

var menuids=new Array("verticalmenu") //Enter id(s) of UL menus, separated by commas
var submenuoffset=-2 //Offset of submenus from main menu. Default is -2 pixels.

function createcssmenu(){
for (var i=0; i<menuids.length; i++){
  var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
    var spanref=document.createElement("span")
		spanref.className="arrowdiv"
		spanref.innerHTML="&nbsp;&nbsp;"
		ultags[t].parentNode.getElementsByTagName("a")[0].appendChild(spanref)
    ultags[t].parentNode.onmouseover=function(){
    this.getElementsByTagName("ul")[0].style.left=this.parentNode.offsetWidth+submenuoffset+"px"
    this.getElementsByTagName("ul")[0].style.display="block"
    }
    ultags[t].parentNode.onmouseout=function(){
    this.getElementsByTagName("ul")[0].style.display="none"
    }
    }
  }
}


if (window.addEventListener)
window.addEventListener("load", createcssmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu)