// Professions Menu script modified from AnyLink JS Drop Down Menu v2.0 - (c) Dynamic Drive DHTML code library - http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

var dd_fishing={items: [ ["Getting Started", "http://www.elsanglin.com/getting_started.html", "Getting Started: Contains information for the beginner. If you've never picked up a fishing pole in your life, or have only just started fishing, this chapter is for you."], ["Training", "http://www.elsanglin.com/training.html", "Training: Teaches you how to level your fishing skill."], ["Equipment", "http://www.elsanglin.com/equipment.html", "Equipment: Describes gear, consumables and enhancements that can be used to bolster your fishing skills, or help you fish."], ["Pools &amp; Wreckage", "http://www.elsanglin.com/pools_and_wreckage.html", "Pools and Wreckage: Describes how to fish pools such as schools or floating debris, where to find pools, and how to efficiently fish them."], ["Valuable Fish", "http://www.elsanglin.com/valuable_fish.html", "Valuable Fish: Details the most valuable fish, and how to catch them."], ["Contests", "http://www.elsanglin.com/contests.html", "Contests: Describes Azeroth's fishing contests: What you need to do, what you can win, and how to win."], ["Quests &amp; Achievements", "http://www.elsanglin.com/quests.html", "Quests and Achievements: Summarises all quests and achievements that involve fishing."], ["Fish Finder", "http://www.elsanglin.com/fish/", "Fish Finder: Where to catch fish, showing skill required, type of water, and variations such as time of day."], ["Advanced Topics", "http://www.elsanglin.com/advanced_topics.html", "Advanced Topics: Detailed guides and analysis, covering specific fish, achievements, mechanics and patches."], ["Fishing Forums", "http://www.elsanglin.com/forums/", "Fishing Forums: Discussion about fishing in World of Warcraft."] ]}

var dd_inscription={items: [ ["Basics", "/inscription/basics.html", "Basics: Information for beginners."], ["Training", "/inscription/training.html", "Training: Teaches you how to level your inscription skill."], ["Inscriptions", "/inscription/inscriptions.html", "Inscriptions: Recipes scibes use to create inscriptions, except glyphs - abilities, inks, items, cards, scrolls, vellum."], ["Glyphs", "/inscription/glyphs.html", "Glyphs: Recipes scibes use to create gluphs."], ["Advanced Topics", "/inscription/advanced_topics.html", "Advanced Topics: In-depth analysis of some of the more advanced aspects Inscription."], ["Inscription Forums", "/forums/forum/inscription", "Inscription Forums: Posts about Inscription and being a scribe."] ]}

if (typeof dd_domreadycheck=="undefined")
var dd_domreadycheck=false

var elmenu={

divclass: 'ddmenu',
menusmap: {},
effects: {delayhide: 50},
dimensions: {},

getoffset:function(what, offsettype){
return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
},

getoffsetof:function(el){
el._offsets={left:this.getoffset(el, "offsetLeft"), top:this.getoffset(el, "offsetTop"), h: el.offsetHeight}
},

getdimensions:function(menu){
this.dimensions={anchorw:menu.anchorobj.offsetWidth, anchorh:menu.anchorobj.offsetHeight,
docwidth:(window.innerWidth ||this.standardbody.clientWidth)-20,
docheight:(window.innerHeight ||this.standardbody.clientHeight)-15,
docscrollx:window.pageXOffset || this.standardbody.scrollLeft,
docscrolly:window.pageYOffset || this.standardbody.scrollTop
}
if (!this.dimensions.dropmenuw){
this.dimensions.dropmenuw=menu.dropmenu.offsetWidth
this.dimensions.dropmenuh=menu.dropmenu.offsetHeight
}
},

isContained:function(m, e){
var e=window.event || e
var c=e.relatedTarget || ((e.type=="mouseover")? e.fromElement : e.toElement)
while (c && c!=m)try {c=c.parentNode} catch(e){c=m}
if (c==m)
return true
else
return false
},

showmenu:function(menuid){
var menu=elmenu.menusmap[menuid]
clearTimeout(menu.hidetimer)
this.getoffsetof(menu.anchorobj)
this.getdimensions(menu)
var posx=menu.anchorobj._offsets.left + (menu.orientation=="lr"? this.dimensions.anchorw : 0)
var posy=menu.anchorobj._offsets.top+this.dimensions.anchorh - (menu.orientation=="lr"? this.dimensions.anchorh : 0)
if (posx+this.dimensions.dropmenuw>this.dimensions.docscrollx+this.dimensions.docwidth){ 
posx=posx-this.dimensions.dropmenuw + (menu.orientation=="lr"? -this.dimensions.anchorw : this.dimensions.anchorw)
}
if (posy+this.dimensions.dropmenuh>this.dimensions.docscrolly+this.dimensions.docheight){ 
posy=Math.max(posy-this.dimensions.dropmenuh - (menu.orientation=="lr"? -this.dimensions.anchorh : this.dimensions.anchorh), this.dimensions.docscrolly)
}
menu.dropmenu.setcss({left:posx+'px', top:posy+'px', visibility:'visible'})
},

setcss:function(param){
for (prop in param){
this.style[prop]=param[prop]
}
},

setcssclass:function(el, targetclass, action){
var needle=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "ig")
if (action=="check")
return needle.test(el.className)
else if (action=="remove")
el.className=el.className.replace(needle, "")
else if (action=="add" && !needle.test(el.className))
el.className+=" "+targetclass
},

hidemenu:function(menuid){
var menu=elmenu.menusmap[menuid]
clearInterval(menu.animatetimer)
menu.dropmenu.setcss({visibility:'hidden', left:0, top:0})
},

getElementsByClass:function(targetclass){
if (document.querySelectorAll)
return document.querySelectorAll("."+targetclass)
else{
var classnameRE=new RegExp("(^|\\s+)"+targetclass+"($|\\s+)", "i") 
var pieces=[]
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (var i=0; i<alltags.length; i++){
if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1)
pieces[pieces.length]=alltags[i]
}
return pieces
}
},

addDiv:function(divid, divclass){
var el=document.createElement("div")
if (divid)
el.id=divid
el.className=divclass
document.body.appendChild(el)
return el
},

getmenuHTML:function(menuobj){
var menucontent=[]
for (var i=0; i<menuobj.items.length; i++){
menucontent.push('<li><a href="' + menuobj.items[i][1] + '" title="' + menuobj.items[i][2] + '">' + menuobj.items[i][0] + '</a></li>')
}
return '<ul>' + menucontent.join('') + '</ul>'
},

addEvent:function(targetarr, functionref, tasktype){
if (targetarr.length>0){
var target=targetarr.shift()
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)})
this.addEvent(targetarr, functionref, tasktype)
}
},

domready:function(functionref){
if (dd_domreadycheck){
functionref()
return
}
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", function(){
document.removeEventListener("DOMContentLoaded", arguments.callee, false )
functionref();
dd_domreadycheck=true
}, false )
}
else if (document.attachEvent){
if ( document.documentElement.doScroll && window == window.top) (function(){
if (dd_domreadycheck) return
try{
document.documentElement.doScroll("left")
}catch(error){
setTimeout( arguments.callee, 0)
return;
}
functionref();
dd_domreadycheck=true
})();
}
if (document.attachEvent && parent.length>0)
this.addEvent(window, function(){functionref()}, "load");
},

addState:function(anchorobj, state){
elmenu.setcssclass(anchorobj, "selectedanchor", state)
},

addState:function(anchorobj, state){
elmenu.setcssclass(anchorobj, "selectedanchor", state)
},

setupmenu:function(targetclass, anchorobj, pos){
this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
var relattr=anchorobj.getAttribute("rel")
dropmenuid=relattr.replace(/\[(\w+)\]/, '')
var dropmenuvar=window[dropmenuid]
var dropmenu=this.addDiv(null, this.divclass)
dropmenu.innerHTML=this.getmenuHTML(dropmenuvar)
var menu=this.menusmap[targetclass+pos]={
id: targetclass+pos,
anchorobj: anchorobj,
dropmenu: dropmenu,
orientation: anchorobj.getAttribute("rev")=="lr"? "lr" : "ud"
}
menu.anchorobj._internalID=targetclass+pos
menu.anchorobj._isanchor=true
menu.dropmenu._internalID=targetclass+pos
menu.dropmenu.setcss=this.setcss
this.addEvent([menu.anchorobj, menu.dropmenu], function(e){
var menu=elmenu.menusmap[this._internalID]
if (this._isanchor && !elmenu.isContained(this, e)){
elmenu.showmenu(menu.id)
elmenu.addState(this, "add")
}
else if (typeof this._isanchor=="undefined"){
clearTimeout(menu.hidetimer)
}
}, "mouseover")
this.addEvent([menu.anchorobj, menu.dropmenu], function(e){
if (!elmenu.isContained(this, e)){
var menu=elmenu.menusmap[this._internalID]
menu.hidetimer=setTimeout(function(){
elmenu.addState(menu.anchorobj, "remove")
elmenu.hidemenu(menu.id)
}, elmenu.effects.delayhide)
}
}, "mouseout")

},

init:function(targetclass){
this.domready(function(){elmenu.trueinit(targetclass)})
},

trueinit:function(targetclass){
var anchors=this.getElementsByClass(targetclass)
for (var i=0; i<anchors.length; i++){
this.setupmenu(targetclass, anchors[i], i)
}
}

}
	
