// Fishing 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_start={items: [ ["Why Fish?", "/why_fish.html", "Why Fish?: The reasons you should learn to fish."], ["First Catch", "/first_catch.html", "Your First Catch: Illustrated step by step guide to catching your first fish. How to get basic training, buy your first fishing pole, cast, and reel in your first fish!"], ["Junk", "/junk.html", "(Not) Catching Junk: Explains why you might catch junk items, and how to avoid them."], ["Skill", "/role_of_skill.html", "Fishing Skill: Introduces the concept of fishing skill, and explains how your skill will increase with successful catches."], ["Equipment &amp; Pools", "/equipment_and_pools.html", "Equipment and Pools: Illustrated introduction to using equipment with a bonus to fishing skill (poles, hats, lures), and catching fish from pools."], ["Skill &amp; Locations", "/skill_and_location.html", "Skill and Locations: Skill needed to avoid catching junk in each area, with a simple explanation of where different types of fish are found."], ["FAQ", "/faq.html", "Frequently Asked Questions: Have questions? The FAQ contains answers to the most common questions. From 'where should I go to improve skill?' to 'how can I track pools on the mini-map?'"] ]}

var dd_training={items: [ ["Ranks", "/ranks.html", "Ranks: An introduction to skill ranks and training, from Apprentice, through Journeyman, Expert, and Artisan, to Master and Grand Master."], ["Developing", "/developing_skill.html", "Developing Your Fishing Skill: Strategies for training/leveling fishing skill."], ["1-450 Fast", "/leveling_fast.html", "Fishing 1-450 Fast: Walkthrough for training fishing as fast as possible."], ["1-450 Gold", "/leveling_with_gold.html", "Fishing 1-450 with Gold: Level fishing while making plenty of gold."], ["1-450 Cook Alliance", "/fishing_and_cooking_alliance.html", "Fishing and Cooking 1-450 Alliance: Detailed guide to leveling fishing and cooking skills together, for Alliance."], ["1-450 Cook Horde", "/fishing_and_cooking_horde.html", "Fishing and Cooking 1-450 Horde: Detailed guide to leveling fishing and cooking skills together, for Horde."], ["1-450 Cook II", "/fishing_and_cooking_ii.html", "Fishing and Cooking 1-450 Part 2: Combined second part of the fishing and cooking leveling guide, covering fishing in Outland and Northrend."] ]}

var dd_equipment={items: [ ["Poles", "/poles.html", "Fishing Poles: Complete list of fishing poles, with skill bonus, requirements, and source."], ["Gear", "/fishing_gear.html", "Fishing Gear: Hats, boots, lines, rum. This section describes the other items of equipment that will improve your effective fishing skill."], ["Lures", "/lures.html", "Lures: Bait that adds a temporary fishing skill bonus to your pole. These are essential for fishing in areas with very high skill requirements."], ["Other", "/other_equipment.html", "Other Equipment: Equipment which will help you fish, but does not give a bonus to skill: Weather-Beaten Journal, fishing chair."], ["Addons", "/addons.html", "Addons and Utilities: User interface modifications and utilities that will help you fish or keep track of your catches."], ["Automation", "/automation.html", "Automation: Macros, controllers, and other ways to automate the process of fishing."] ]}

var dd_pools={items: [ ["Pool Fishing", "/pool_fishing.html", "Pool Fishing: Introduction to pools/schools of fish, including pool types, and how to find and fish them."], ["Locations", "/pool_locations.html", "Pool Locations: Lists the zones that contain different pool types."], ["Spawning", "/pool_spawning.html", "Pool Spawning: The rules governing school appearance. Why you a particular pool cannot be found."], ["Unusual Pools", "/unusual_pools.html", "Unusual Pools: Unusual schools include Elemental and Pure Water, Muddy Churning Waters, Strange Pools, and even a School of Fish."], ["Strategies", "/pool_strategies.html", "Pool Strategies: How to efficiently fish pools."] ]}

var dd_valuable={items: [ ["What's Valuable?", "/whats_valuable.html", "What's Valuable?: Explains what makes a fish valuable and how to make gold from fishing."], ["Buff Food", "/buff_food.html", "Buff Food: Valuable fish that gives a buff when cooked and eaten."], ["Supplies", "/supplies.html", "Supplies: Valuable fish used in other professions (except cooking)."], ["Gear", "/valuable_gear.html", "Valuable Gear: Items of valuable gear that can only be found by fishing: weapons, off-hand fish, rings."], ["Minipets &amp; Mounts", "/minipets.html", "Minipets and Mounts: Non-combat pets, companions and mount found by fishing - including the Magical Crawdad, 'Bucket Pets', and Sea Turtle."], ["Other", "/valuable_fished_items.html", "Other Valuable Fished Items: Other valuable items gained by fishing, including junk, strange parts, and boss loot."] ]}

var dd_contests={items: [ ["STV Contest", "/stranglethorn_contest.html", "Stranglethorn Extravaganza Contest: When and where the Stranglethorn Fishing Extravaganza takes places, and what you have to do to compete."], ["STV Rewards", "/stranglethorn_rewards.html", "Stranglethorn Extravaganza Rewards: The rewards from winning the Stranglethorn Fishing Extravaganza, plus the items that can be obtained by catching rare fish."], ["STV Preparation", "/stranglethorn_preparation.html", "Stranglethorn Extravaganza Preparation: What fishing skill is needed, and how to prepare for the Stranglethorn Fishing Extravaganza."], ["STV Strategy", "/stranglethorn_extravaganza_strategy.html", "Stranglethorn Extravaganza Strategy: Discusses winning contest strategies for the Stranglethorn Fishing Extravaganza. Or fishing where others are not, and move between pools as fast as possible."], ["Kalu'ak Derby", "/kaluak_fishing_derby.html", "Kalu'ak Fishing Derby: When and where the Kalu'ak Fishing Derby takes places, what you have to do to compete, and what rewards you can gain."], ["Kalu'ak Strategy", "/kaluak_derby_strategy.html", "Kalu'ak Fishing Derby Strategy: Discusses preparation and strategies for winning the Kalu'ak Fishing Derby."] ]}

var dd_quests={items: [ ["Northrend Daily", "/northrend_daily_quests.html", "Northrend Daily Fishing Quests: Guide to daily fishing quests that start in Dalaran."], ["Outland Daily", "/daily_fishing_quests.html", "Outland Daily Fishing Quests: Walkthrough for all the level 70 daily fishing quests, with rewards."], ["Pagle", "/artisan_fishing_quest.html", "Nat Pagle, Angler Extreme: Walkthrough for the fishing quest, Nat Pagle, Angler Extreme, which rewards Nat's Lucky Fishing Pole."], ["Other Quests", "/other_quests.html", "Other Fishing Quests: Other quests related to fishing."], ["Achievements", "/achievements.html", "Fishing Achievements: Introduction to fishing-related personal achievements."], ["Salty", "/salty.html", "Salty: Guide to completing the Accomplished Angler achievement, and gaining the 'Salty' title."] ]}

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)
}
}

}
	
