/***********************************************
* AnyLink Drop Down Menu- Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menus
/* Dynamic Dropdowns...keep for future development
	<c:forEach items="${headerChildren}" var="currentMenuItem" varStatus="stats">
		var menu<c:out value="${currentMenuItem.key}" />=new Array()
<c:forEach items="${currentMenuItem.value}" var="item" varStatus="stats2">
	<c:if test="${item.navType != 'vb' && item.depth == 2}">
menu<c:out value="${currentMenuItem.key}" />[<c:out value="${stats2.index}" />]='<a href="<c:out value="${item.uri}" />" class="mainNavDropdown"><c:out value="${item.label}" /> </a>'
	</c:if>
</c:forEach>
	</c:forEach>
*/

// Lincoln Product Divisions
var menu1=new Array()
menu1[0]='<a href="/products/pclpdfconverter.htm" class="mainNavDropdown" title="PCL to PDF Converter">PCL to PDF Converter</a>'
menu1[1]='<a href="/products_solutions/pcl6.htm" class="mainNavDropdown" title="PCL Converter">PCL Converter</a>'
menu1[2]='<a href="/products_solutions/psconverter.htm" class="mainNavDropdown" title="PostScript Converter">PostScript Converter</a>'
menu1[3]='<a href="/products/ldvviewer.htm" class="mainNavDropdown" title="PCL and PostScript Viewers">PCL and PostScript Viewers</a>'

// Support and Services
var menu2=new Array()
menu2[0]='<a href="/support/faq.htm" class="mainNavDropdown" title="Frequently Asked Questions">Frequently Asked Questions</a>'
menu2[1]='<a href="/customers/applications.htm" class="mainNavDropdown" title="Product Applications">Product Applications</a>'

// Downloads
var menu3=new Array()
menu3[0]='<a href="/download-trial-software.htm" class="mainNavDropdown" title="Download Trial Software">Download Trial Software</a>'
menu3[1]='<a href="/download-datasheets.htm" class="mainNavDropdown" title="Download Datasheets">Download Datasheets</a>'

// OEM& VAR Resources
var menu4=new Array()
menu4[0]='<a href="/oem.htm" class="mainNavDropdown" title="OEM & VAR Inquiries">OEM & VAR Inquiries</a>'

// About the Company
var menu5=new Array()
menu5[0]='<a href="/company/index.htm" class="mainNavDropdown_c" title="About Lincoln & Co.">About Lincoln & Co.</a>'
menu5[1]='<a href="/customers.htm" class="mainNavDropdown_c" title="Our Customers">Our Customers</a>'
menu5[2]='<a href="/contact.htm" class="mainNavDropdown_c" title="Contact Us">Contact Us</a>'
menu5[3]='<a href="/company/directions.htm" class="mainNavDropdown_c" title="Directions">Directions </a>'

var menuwidth='100px' //default menu width
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

var xOffset = 2; // number of pixels to offset menu right or left
var yOffset = -7; // number of pixels to offset menu up or down

/////No further editting needed
var ie4=document.all
var ns6=document.getElementById&&!document.all
if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

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;
}

function showhide(obj, e, visible, hidden){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
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
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(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 < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
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)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}

function toggleSelectBoxes(arg) {
	if (navigator.appName=="Microsoft Internet Explorer") {
		var n = document.getElementsByTagName('select');
		for(var i=0;i<n.length;i++) {
			if (arg=='hide' && n[i].id == 'hidemenu') {
				n[i].style.visibility =  'hidden';
			} else {
				n[i].style.visibility =  'visible';
			}
		}
	}
}

function dropdownmenu(obj, e, menucontents, menuwidth){
  if (menucontents.length > 0) {
	toggleSelectBoxes('hide');
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)
	if (ie4||ns6){
	  showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
	  dropmenuobj.x=getposOffset(obj, "left") + xOffset;
	  dropmenuobj.y=getposOffset(obj, "top") + yOffset;
	  dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	  dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
  }
}

function clickreturnvalue(){
  if (ie4||ns6) return false
  else return true
}

function contains_ns6(a, b) {
  try {
    while (b.parentNode)
      if ((b = b.parentNode) == a){
        return true;
      }
    return false;
  } catch (err) {
    return false;
  }
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
  delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
  delayhidemenu()
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
	if (ie4||ns6)
		dropmenuobj.style.visibility="hidden"
	}
	toggleSelectBoxes('show');
}

function delayhidemenu(){
	if (ie4||ns6) {
		delayhide=setTimeout("hidemenu()",disappeardelay)
	}
}

function clearhidemenu(){
  if (typeof delayhide!="undefined")
    clearTimeout(delayhide)
}
if (hidemenu_onclick=="yes")
document.onclick=hidemenu

// DONNY - defining menu behaviour for the company item

//var companymenuwidth='110px' //default menu width
var companyxOffset = -26; // number of pixels to offset menu right or left
var companyyOffset = -7; // number of pixels to offset menu up or down

function companydropdownmenu(obj, e, menucontents, companymenuwidth){
  if (menucontents.length > 0) {
	toggleSelectBoxes('hide');
	if (window.event) event.cancelBubble=true
	else if (e.stopPropagation) e.stopPropagation()
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)
	if (ie4||ns6){
	  showhide(dropmenuobj.style, e, "visible", "hidden", companymenuwidth)
	  dropmenuobj.x=getposOffset(obj, "left") + companyxOffset;
	  dropmenuobj.y=getposOffset(obj, "top") + companyyOffset;
	  dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
	  dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
  }
}

