// This javascript combines the vertical and horizontal code into one script

// Vertical
var aboutusmenu=new Array()
aboutusmenu[0]='<a href="CompanyMain.aspx">Company Profile</a>'
aboutusmenu[1]='<a href="ServicesMain.aspx">Services</a>'
aboutusmenu[2]='<a href="PrimeHomeBuildersMain.aspx">Prime Home Builders</a>'

var projectsmenu=new Array()
projectsmenu[0]='<a href="ProjectsCurrent.aspx">Current Projects</a>'
projectsmenu[1]='<a href="ProjectsCompleted.aspx">Completed Projects</a>'
projectsmenu[2]='<a href="ProjectsAwards.aspx">Award Winning Projects</a>'

var subcontractorsmenu=new Array()
subcontractorsmenu[0]='<a href="SubcontractorPrequalification.aspx">Prequalification Form</a>'

//IN DESIGN right now, link hidden until Jennifer approves design
//subcontractorsmenu[1]='<a href="CurrentBidInquiry.aspx">Current Bid Inquiries</a>'

var contactusmenu=new Array()
contactusmenu[0]='<a href="ContactUsMain.aspx">Contact Us</a>'
contactusmenu[1]='<a href="ContactUsMain.aspx">Employment Opportunities</a>'
	
//common
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
//Vertical
var horizontaloffset=2 //horizontal offset of menu from default location. (0-5 is a good value)
//Horizontal
var enableanchorlink=1 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
//Horizontal
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)
//Vertical
var ie4=document.all
//Horizontal
var ie5=document.all
//Common
var ns6=document.getElementById&&!document.all
//Vertical
if (ie4||ns6)
document.write('<div id="menuleft_dropmenudiv" style="visibility:hidden;width: 160px" onMouseover="clearhidemenu()" onMouseout="dynamichide_vert(event)"></div>')

//common
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

//Horizontal
function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

//Vertical
function showhide_vert(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

//common
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

//horizontal
function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

//vertical
function clearbrowseredge_vert(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x-obj.offsetWidth < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move menu up?
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
edgeoffset=dropmenuobj.y
}
}
return edgeoffset
}

//vertical
function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

//vertical
function dropdownmenu_vert(obj, e, menucontents, menuwidth){
  if (window.event) event.cancelBubble=true
  else if (e.stopPropagation) e.stopPropagation()
  clearhidemenu()
  dropmenuobj=document.getElementById? document.getElementById("menuleft_dropmenudiv") : menuleft_dropmenudiv
  populatemenu(menucontents)

  //vertical
  if (ie4||ns6){
  showhide_vert(dropmenuobj.style, e, "visible", "hidden", menuwidth)
  dropmenuobj.x=getposOffset(obj, "left")
  dropmenuobj.y=getposOffset(obj, "top")
  dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge_vert(obj, "rightedge")+obj.offsetWidth+horizontaloffset+"px"
  dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge_vert(obj, "bottomedge")+"px"
  }

  return clickreturnvalue_vert()
}

//horizontal
function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

//vertical
function clickreturnvalue_vert(){
if (ie4||ns6) return false
else return true
}

//common
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

//horizontal
function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

//vertical
function dynamichide_vert(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu_vert()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu_vert()
}

//horizontal
function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

//vertical
function delayhidemenu_vert(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

//vertical
function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

//common
function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
