/*Copyright (c) 2008-2009 Beast@themusings.net All rights reserved.

initWoWEnchant.js	 v2.1

Created 12/06/2008 by Beast@themusings.net (Web: http://themusings.net)
Last modified: 3/30/2009

Used to initialize scripts, gloabal variables, and functions needed for all (at least 2+) WoW enchant tables.
*/

/* scripts that need to be run */
var scripts = [
'../../../../blog/wp-content/themes/default/scripts/wz_tooltip.js',
'http://www.wowhead.com/widgets/power.js'
];
/* run each script */
if ( document.getElementsByTagName ) {
	var head = document.getElementsByTagName('HEAD')[0];
	var scriptElement;
	var i = scripts.length;
	while ( i-- ) {
		scriptElement = document.createElement('script');
		scriptElement.type = 'text/javascript';
		scriptElement.src = scripts[i];
		head.appendChild(scriptElement);}
}


/*#######################################################*/
/* Global Definitions for all things WoW Enchant related */
/*#######################################################*/
var br = "<br/>";	/* defined line break */

/***************/
/* image paths */
/***************/
var wowimg = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/";
var wowimg_i = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/item/";
var wowimg_im = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/instance/";
var wowimg_imi = "<img class=\'pinned_tt_image center\' src=\'../../../../blog/wp-content/themes/default/images/wow/instanceitem/";
var wowimg_m = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/map/";
var wowimg_mi = "<img class=\'pinned_tt_image center\' src=\'../../../../blog/wp-content/themes/default/images/wow/mapitem/";
var alliance = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/alliance.gif\' class=\'crest\' alt=\'A\' title=\'Alliance\'>";
var horde = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/horde.gif\' class=\'crest\' alt=\'H\' title=\'Horde\'>";
var neutral = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/neutral.gif\' class=\'crest\' alt=\'N\' title=\'Neutral\'>";
var bc_logo = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/bc_logo.gif\' alt=\'BC\' title=\'Burning Crusade\'/>";
var wotlk_logo = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/wrath_logo.gif\' alt=\'WotLK\' title=\'Wrath of the Lich King\'>";
var copper = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/copper.gif\' alt=\'C\' title=\'Copper\' class=\'currency\'>";
var silver = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/silver.gif\' alt=\'S\' title=\'Silver\' class=\'currency\'>";
var gold = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/gold.gif\' alt=\'G\' title=\'Gold\' class=\'currency\'>";

/* instance maps */
var brd_dck = wowimg_im + "blackrock_depths_dark_coffer_key.jpg\'>";
var dm_key = wowimg_im + "dire_maul_crescent_key.jpg\'";
var scholo_sos = wowimg_im + "scholomance_skin_of_shadow.jpg\'";
var strat_fas = wowimg_im + "stratholme_frayed_as.jpg\'";
var zulg = wowimg_im + "zulgurub.jpg\'>";

/* maps */
var blast = wowimg_m + "blasted_lands.jpg\'>";
var btundra = wowimg_m + "borean_tundra.jpg\'>";
var bstep = wowimg_m + "burning_steppes.jpg\'>";
var dalaran = wowimg_m + "dalaran.jpg\'>";
var dragonb = wowimg_m + "dragonblight.jpg\'>";
var epl = wowimg_m + "eastern_plaguelands.jpg\'>";
var exodar = wowimg_m + "exodar.jpg\'>";
var felwood = wowimg_m + "felwood.jpg\'>";
var hellfire = wowimg_m + "hellfire.jpg\'>";
var hfjord = wowimg_m + "howling_fjord.jpg\'>";
var icecrown = wowimg_m + "icecrown.jpg\'>";
var org = wowimg_m + "orgrimmar.jpg\'>";
var shat = wowimg_m + "shattrath_city.jpg\'>";
var silvermoon = wowimg_m + "silvermoon_city.jpg\'>";
var stormp = wowimg_m + "storm_peaks.jpg\'>";
var sw = wowimg_m + "stormwind.jpg\'>";
var stv = wowimg_m + "stranglethorn.jpg\'>";
var sunwell = wowimg_m + "sunwell.jpg\'>";
var tanaris = wowimg_m + "tanaris.jpg\'>";
var tirisfal = wowimg_m + "tirisfal.jpg\'>";
var ungoro = wowimg_m + "ungoro_crater.jpg\'>";
var wpl = wowimg_m + "western_plaguelands.jpg\'>";
var winter = wowimg_m + "wintergrasp.jpg\'>";
var zangar = wowimg_m + "zangarmarsh.jpg\'>";

/* special maps */
var blademnts_felarm = wowimg_m + "blades_edge_mountains_felarm.jpg\'>";
var shdwmoon_felarm = wowimg_m + "shadowmoon_valley_felarm.jpg\'>";

/*******************/
/* Table Structure */
/*******************/
/* main column headers */
var t_headers = "<table class=\'wowcolors\'><tr><th class=\'name\'>Name</th><th class=\'modifier\'>Modifier</th><th class=\'source\'>Source</th><th class=\'req\'>Requirements</th></tr>";


/* tables acting as headers */
var t_armor = "<table class=\'wowcolors space\'><tr><td class=\'armor center\'>Armor</td></tr></table>" + t_headers;
var t_cs = "<table class=\'wowcolors space\'><tr><td class=\'class_specific center\'>Class-Specific</td></tr></table>" + t_headers;
var t_effects = "<table class=\'wowcolors space\'><tr><td class=\'effects center\'>Effects</td></tr></table>" + t_headers;
var t_resil = "<table class=\'wowcolors space\'><tr><td class=\'resil center\'>Resilience</td></tr></table>" + t_headers;
var t_resist = "<table class=\'wowcolors space\'><tr><td class=\'resist center\'>Resistance</td></tr></table>" + t_headers;
var t_stats = "<table class=\'wowcolors space\'><tr><td class=\'stats center\'>Stats</td></tr></table>" + t_headers;

/* modifier headers */
var h_style = "<tr><td class=\'title\' colspan=\'4\'>";

var h_agi = h_style + "Agility</td></tr>";
var h_allres = h_style + "All Resistances</td></tr>";
var h_arc = h_style + "Arcane Resistance</td></tr>";
var h_arc_sta = h_style + "Arcane Resistance, Stamina</td></tr>";
var h_armor = h_style + "Armor</td></tr>";
var h_ap = h_style + "Attack Power</td></tr>";
var h_ap_csr = h_style + "Attack Power, Critical Strike Rating</td></tr>";
var h_ap_hr = h_style + "Attack Power, Hit Rating</td></tr>";
var h_csr = h_style + "Critical Strike Rating</td></tr>";
var h_csr_sp = h_style + "Critical Strike Rating, Spell Power</td></tr>";
var h_defr = h_style + "Defense Rating</td></tr>";
var h_defr_dr = h_style + "Defense Rating, Dodge Rating</td></tr>";
var h_defr_sta = h_style + "Defense Rating, Stamina</td></tr>";
var h_dr = h_style + "Dodge Rating</td></tr>";
var h_fire = h_style + "Fire Resistance</td></tr>";
var h_fire_sta = h_style + "Fire Resistance, Stamina</td></tr>";
var h_frost = h_style + "Frost Resistance</td></tr>";
var h_frost_sta = h_style + "Frost Resistance, Stamina</td></tr>";
var h_hstr = h_style + "Haste Rating</td></tr>";
var h_hp = h_style + "Hit Points</td></tr>";
var h_hr_sp = h_style + "Hit Rating, Spell Power</td></tr>";
var h_int = h_style + "Intellect</td></tr>";
var h_int_str = h_style + "Intellect, Strength</td></tr>";
var h_mana = h_style + "Mana</td></tr>";
var h_mregen = h_style + "Mana Regeneration</td></tr>";
var h_mregen_sp = h_style + "Mana Regeneration, Spell Power</td></tr>";
var h_nature = h_style + "Nature Resistance</td></tr>";
var h_nature_sta = h_style + "Nature Resistance, Stamina</td></tr>";
var h_resil_ap = h_style + "Resilience, Attack Power</td></tr>";
var h_resil_sp = h_style + "Resilience, Spell Power</td></tr>";
var h_resil_sta = h_style + "Resilience, Stamina</td></tr>";
var h_shadow = h_style + "Shadow Resistance</td></tr>";
var h_shadow_sta = h_style + "Shadow Resistance, Stamina</td></tr>";
var h_sp = h_style + "Spell Power</td></tr>";
var h_spi = h_style + "Spirit</td></tr>";
var h_sta = h_style + "Stamina</td></tr>";
var h_str = h_style + "Strength</td></tr>";
var h_zan_druid = h_style + "Druid (Intellect, Spell Power, Stamina)</td></tr>";
var h_zan_hunter = h_style + "Hunter (Attack Power, Hit Rating, Stamina)</td></tr>";
var h_zan_mage = h_style + "Mage (Hit Rating, Spell Power)</td></tr>";
var h_zan_pally = h_style + "Paladin (Defense Rating, Spell Power, Stamina)</td></tr>";
var h_zan_priest = h_style + "Priest (Mana Regeneration, Spell Power, Stamina)</td></tr>";
var h_zan_rogue = h_style + "Rogue (Attack Power, Dodge Rating)</td></tr>";
var h_zan_shaman = h_style + "Shaman (Intellect, Spell Power)</td></tr>";
var h_zan_warlock = h_style + "Warlock (Spell Power, Stamina)</td></tr>";
var h_zan_warrior = h_style + "Warrior (Defense Rating, Shield Block, Stamina)</td></tr>";

/* modifier text variables */
var mt_agi = "AGI" + br;		/* Agility */
var mt_arc = "ArcR" + br;		/* Arcane Resistance */
var mt_armor = "Armor" + br;
var mt_ap = "AP" + br;		/* Attack Power */
var mt_csr = "CSR" + br;		/* Critical Stike Rating */
var mt_hitr = "HitR" + br;		/* Hit Rating */
var mt_defr = "DefR" + br;		/* Defense Rating */
var mt_dr = "DR" + br;		/* Dodge Rating */
var mt_fire = "FR" + br;		/* Fire Resistance */
var mt_frost = "FrR" + br;		/* Frost Resistance */
var mt_hstr = "HstR" + br;		/* Haste Rating */
var mt_hp = "HP" + br;		/* Hit Points */
var mt_int = "INT" + br;		/* Intellect */
var mt_mana = "Mana" + br;
var mt_mregen5 = "mana / 5 sec" + br;	/* Mana Regen per 5 sec */
var mt_nature = "NR" + br;		/* Nature Resistance */
var mt_res = "Res" + br;	/* Resistance */
var mt_resil = "Resil" + br;	/* Resilience */
var mt_shadow = "SR" + br;		/* Shadow Resistance */
var mt_shbl = "ShBl" + br;		/* Shield Block */
var mt_sp = "SP" + br;		/* Spell Power */
var mt_spi = "SPI" + br;		/* Spirit */
var mt_sta = "STA" + br;		/* Stamina */
var mt_str = "STR" + br;		/* Strength */

/* requirements table data (td) style */
var reqstyle = "<td class=\'reqstyle\'>";


/************************************
  defining/creating the [M] button
 ************************************
    The following is what the normal html code for a given map might look like:

    <a class="map_button" onclick="Tip(brd_dark_coffer_key_map, TITLE, 'Blackrock Depths - Dark Keeper Key Spawn Locations', WIDTH, 0, CENTERMOUSE, true)">[M]</a>
**********************************************************/
/* variables that break up the above code into something easier to read for a given map */
var mb = "<a class=\'map_button\'";
var mtip = "onclick=\'Tip(createPinnedMap(";
var mtipx = "WIDTH, 1002, CLICKCLOSE, true, FIX, findScroll(this), EXCLUSIVE, true)\'>[M]</a>";	/* universal tooltip parameters for maps */
/*********************************************************/


/************************
 JS item tooltip defs
 ************************
    The following is what the normal html code for a given item might look like:

    1x <a href="#" onclick="return false" class="green" onmouseover="Tip(black_diamond, FIX, [this, x, y], TITLE, 'Black Diamond')" onmouseout="UnTip()">Black Diamond</a>
*********************************************************/
/* variables that break up the above code into something easier to read for a given item */
var fakelink = "<a href=\'#\' onclick=\'return false\' ";
var white = "class=\'white\' ";
var green = "class=\'green\' ";
var blue = "class=\'blue\' ";
var tip = "onmouseover=\'Tip(";
var tt_extra = "FIX, [this, x, y], TITLE, ";	/* universal tooltip parameters for items */
var untip = "onmouseout=\'UnTip()\'>";

/* x,y coordinates for the javascript tooltip */
var x = 168;
var y = -30;

/* styles */
var i_style = "align=\'left\' style=\'padding-right:6px;\'>";	/* item pic style */
var i_header = "<br><span class=\'i_header\'>Requirements:</span><br><br>";
var one = "<span class=\'num_style\'>1) </span>";
var two = "<span class=\'num_style\'>2) </span>";
var three = "<span class=\'num_style\'>3) </span>";
var dash = "<span class=\'num_style\'>- </span>";
var star = "<span class=\'num_style\'>* </span>";
var qcl = "class=\'questcolor\'";	/* quest color link */
var qc = "<span class=\'num_style\' style=\'font-weight: normal;\'>";
var lq = "<span class=\'lq_color\'>*Limited quantity*</span>";

/* expanded list image (plus sign is default) */
var expand = "<img src=\'../../../../blog/wp-content/themes/default/images/wow/plus.gif\' class=\'el_img\' onclick=\'swap(this)\'></a>";

/* list declarations */
var liset = "<li class=\'liset\'>";
var liset2 = "<li class=\'liset2\'>";


/***************/
/* css tooltip */
/***************/
var ptl = "<div class=\'pic_title\'>";	/* css tooltip picture title layout */





/*==================*/
/* Global Main Data */
/*==================*/

/***************/
/* Reputations */
/***************/
var soh_h = "<a href=\'http://www.wowwiki.com/Sons_of_Hodir\' class=\'white\'>The Sons of Hodir - Honored</a>";


/***********************/
/* JS tooltip for maps */
/***********************/
/* instance map defs */

/* pinned map defs - npcs */
var cro_p = mb + mtip + "&#039;cts&#039;), TITLE, &#039;Cro Threadstrong - Lower City, Shattrath City&#039;, " + mtipx;
var haferet_p = mb + mtip + "&#039;haf&#039;), TITLE, &#039;Haferet - Traders Tier, The Exodar&#039;, " + mtipx;
var dameron_p = mb + mtip + "&#039;dameron&#039;), TITLE, &#039;Knight Dameron - Wintergrasp Fortress, Wintergrasp&#039;, " + mtipx;
var lillehoff_p = mb + mtip + "&#039;lil&#039;), TITLE, &#039;Lillehoff - Dun Niffelem, The Storm Peaks&#039;, " + mtipx;
var mukar_p = mb + mtip + "&#039;mukar&#039;), TITLE, &#039;Stone Guard Mukar - Wintergrasp Fortress, Wintergrasp&#039;, " + mtipx;
var zaralda_p = mb + mtip + "&#039;zara&#039;), TITLE, &#039;Zaralda - Walk of Elders, Silvermoon City&#039;, " + mtipx;


/*****************/
/* npc locations */
/*****************/
var cro = neutral + "Cro Threadstrong @<br>Lower City, Shattrath City" + cro_p;
var haferet = alliance + "Haferet @<br>Traders' Tier, The Exodar" + haferet_p;
var dameron = alliance + "Knight Dameron @<br>Wintergrasp Fortress, Wintergrasp" + dameron_p;
var lillehoff = neutral + "Lillehoff @<br>Dun Niffelem, The Storm Peaks" + lillehoff_p;
var mukar = horde + "Stone Guard Mukar @<br>Wintergrasp Fortress, Wintergrasp" + mukar_p;
var zaralda = horde + "Zaralda @<br>Walk of Elders, Silvermoon City" + zaralda_p;


/*************/
/* item pics */
/*************/
var bl_i = wowimg_i + "inv_misc_leatherscrap_15.gif\'" + i_style;	/* borean leather */
var bls_i = wowimg_i + "inv_misc_leatherscrap_16.gif\'" + i_style;	/* borean leather scraps */
var hbl_i = wowimg_i + "inv_misc_leatherscrap_19.gif\'" + i_style;	/* heavy borean leather */
var hkl_i = wowimg_i + "inv_misc_leatherscrap_11.gif\'" + i_style;	/* heavy knothide leather */
var kl_i = wowimg_i + "inv_misc_leatherscrap_10.gif\'" + i_style;	/* knothide leather */
var kls_i = wowimg_i + "inv_misc_leatherscrap_09.gif\'" + i_style;	/* knothide leather scraps */
var pattern_i = wowimg_i + "inv_scroll_03.gif\'" + i_style;	/* heavy knothide leather pattern pic */
var skshard_i = wowimg_i + "inv_misc_platnumdisks.gif\'" + i_style;


/***********************/
/* ITEM & TOOLTIP DEFS */
/***********************/
var bl = fakelink + white + tip + "bl_tt, " + tt_extra + "&#039;Borean Leather&#039;)\'" + untip + "Borean Leather</a>";/* see expanded list for tooltip */

var bls = fakelink + white + tip + "bls_tt, " + tt_extra + "&#039;Borean Leather Scraps&#039;)\'" + untip + "Borean Leather Scraps</a>";
var bls_tt = bls_i + "Skinnable from level 70+ mobs in Northrend.";

var hbl = fakelink + white + tip + "hbl_tt, " + tt_extra + "&#039;Heavy Borean Leather&#039;)\'" + untip + "Heavy Borean Leather</a>";/* see expanded list for tooltip */

var hkl = fakelink + white + tip + "hkl_tt, " + tt_extra + "&#039;Heavy Knothide Leather&#039;)\'" + untip + "Heavy Knothide Leather</a>";/* see expanded list for tooltip */

var kl = fakelink + white + tip + "kl_tt, " + tt_extra + "&#039;Knothide Leather&#039;)\'" + untip + "Knothide Leather</a>";/* see expanded list for tooltip */

var kls = fakelink + white + tip + "kls_tt, " + tt_extra + "&#039;Knothide Leather Scraps&#039;)\'" + untip + "Knothide Leather Scraps</a>";
var kls_tt = kls_i + "Skinnable from level 60+ mobs in Outlands and within The Black Morass located in the Caverns of Time.";

var skshard = fakelink + blue + tip + "skshard_tt, " + tt_extra + "&#039;Stone Keeper`s Shard&#039;)\'" + untip + "Stone Keeper's Shard (BoP)</a>";
var skshard_tt = skshard_i + "Reward for completing <a href=\'http://www.wowhead.com/?item=43228#reward-from\' class=\'questcolor\'>daily quests in Wintergrasp</a> or by defeating any instance bosses in Northrend while your faction is in control of Wintergrasp.";

/************/
/* patterns */
/************/
/* heavy knothide leather */
var pat_hkl_tt = pattern_i + i_header + one + "Requires Leatherworking (325)<br>" + two + "Purchase for 5" + gold + " from:<br><br><ul>" + liset + haferet + br + zaralda + br + cro + "<br><br>" + lq + "</li></ul>";


/*************************************************/
/* expanded list declarations for the JS tooltip */
/*************************************************/
/* THIS IS NOT A GOOD METHOD!  Unfortunately, I can't come up with anything else at this time.  Bottom line: for the most part, the order of these matter so be careful about switching them around.  Made-up ex: Suppose that the Heavy Borean Leather tooltip needed to be called in the Burning Essence tooltip.  Well it can't if the tooltips are defined in alphebetical order along with their item.  To make matters worse, if Heavy Borean Leather needed something like Whipper Root Tuber, it would throw an undefined error.  So by placing tooltips with expanded lists at the bottom, there will be no problem with singular tooltips, but expanded tooltips needing other expanded tooltips could be a major issue down the road. 
*/
var bl_tt = bl_i + "Skinnable from level 70+ mobs in Northrend.<br><br>" + "<a href=\'javascript:unhide(&#039;bls&#039;);\'>" + expand + "<span class=\'i\'>Optional:</span> Combine 5x Borean Leather Scraps for 1x Borean Leather<br>" + star + "No Leatherworking requirement" + "<div id=\'bls\' class=\'hidden\'><br><ul>" + liset + bls_tt + "</li></ul></div>";

var hbl_tt = hbl_i + i_header + "<a href=\'javascript:unhide(&#039;bl&#039;);\'>" + expand + "Combine 6x Borean Leather for 1x Heavy Borean Leather<ul>" + liset + star + "Requires Leatherworking (390)</li></ul><div id=\'bl\' class=\'hidden\'><br><ul>" + liset + bl_tt + "</li></ul></div>";

var kl_tt = kl_i + "Skinnable from level 60+ mobs in Outlands and within The Black Morass located in the Caverns of Time.<br><br>" + "<a href=\'javascript:unhide(&#039;kls&#039;);\'>" + expand + "<span class=\'i\'>Optional:</span> Combine 5x Knothide Leather Scraps<br>for 1x Knothide Leather<br>" + star + "Requires Leatherworking (300)<div id=\'kls\' class=\'hidden\'><br><ul>" + liset + kls_tt + "</li></ul></div>";

var hkl_tt = hkl_i + i_header + one + "<a href=\'javascript:unhide(&#039;pkhl&#039;);\'>" + expand + "Pattern: Heavy Knothide Leather<div id=\'pkhl\' class=\'hidden\'><br><ul>" + liset + pat_hkl_tt + "</li></ul><br></div><br><br>" + two + "<a href=\'javascript:unhide(&#039;kl&#039;);\'>" + expand + "Combine 5x Knothide Leather<br><ul>" + liset + "for 1x Heavy Knothide Leather<br>" + star + "Requires Leatherworking (325)<div id=\'kl\' class=\'hidden\'><br><ul>" + liset + kl_tt + "</li></ul></div></li></ul>";


/******************/
/* complete items */
/******************/
var borean_armor_kit = "<tr><td>" + wotlk_logo + br + "<a href=\'http://www.wowhead.com/?item=38375\' class=\'white\'>Borean Armor Kit (BoE)</a></td><td class=\'center\'>12 " + mt_sta + "</td><td>Grand Master Leatherworking Trainer</td>" + reqstyle + "Level 70" + br + "Leatherworking (350)" + br + quant(4) + bl + "</td></tr>";

var heavy_borean_armor_kit = "<tr><td>" + wotlk_logo + br + "<a href=\'http://www.wowhead.com/?item=38376\' class=\'green\'>Heavy Borean Armor Kit (BoE)</a></td><td class=\'center\'>18 " + mt_sta + "</td><td>Grand Master Leatherworking Trainer</td>" + reqstyle + "Level 70" + br + "Leatherworking (395)" + br + quant(4) + hbl + "</td></tr>";

var heavy_knothide_armor_kit = "<tr><td>" + bc_logo + br + "<a href=\'http://www.wowhead.com/?item=34330\' class=\'white\'>Heavy Knothide Armor Kit (BoE)</a></td><td class=\'center\'>10 " + mt_sta + "</td><td>Master Leatherworking Trainer</td>" + reqstyle + "Level 60" + br + "Leatherworking (350)" + br + quant(3) + hkl + "</td></tr>";



/*###########*/
/* FUNCTIONS */
/*###########*/

/***************************************
  createPinnedMap() function  
  **************************************
  creates the effect of having one or more pins placed on a map.
  
  The function takes the original World of Warcraft in-game x,y coordinates and translates them into pixel value x,y coordinates.  The new coords are given a pin image and these pins are displayed on a map with the original WoW coordinates being shown via css tooltip on a mouseover (a:hover, not a javascript mouseover).
  
  arguments:
  	mapString:  string value that holds the id of specific map data that needs to be found; is subsequently passed to whichever function has the required map data (headmaps() for ex.)
  
  ****************
  note: the css has been completely split up in the function.  To understand what's going on with the css, here's an example of what the code would look like minus all the javascript:
  
  <div class=map_container> 
  	<div class="pin_container><a href="#" onclick="return false" class="tooltip"><img src="../../../../blog/wp-content/themes/default/images/wow/pin.png" style="position:absolute; left:---px; top:---px;"><span style="position:absolute; left:--px; top--px; width:---px;">tooltip text</span></a></div> 
  	<img src="../../../../blog/wp-content/themes/default/images/wow/some_map.jpg">
  </div>
  
  	The pins are called first because this places them in the upper left corner after the map is called.
	For some reason, absolute position needs to be called again within the pin image element because the pins won't move otherwise even though absolute positioning was defined in the pin_container.
****************************************/
/* globals */
var coordtext = 0;	/* 1 true, 0 false */
var pin = [];
var coords = [];		/* WoW in-game coords */
var tt_text = [];		/* additional text for css tooltip */
var map = "";	/* map to use */
var aa = "<div class=\'pin_container\'><a href=\'#\' onclick=\'return false\' class=\'tooltip\'><img src=\'../../../../blog/wp-content/themes/default/images/wow/pin_lb.png\' style=\'position:relative;";	/* item pin */
var bb = "<div class=\'pin_container\'><a href=\'#\' onclick=\'return false\' class=\'tooltip\'><img src=\'../../../../blog/wp-content/themes/default/images/wow/pin_y.png\' style=\'position:relative;";	/* npc pin */
var oo = "<div class=\'pin_container\'><a href=\'#\' onclick=\'return false\' class=\'tooltip\'><img src=\'../../../../blog/wp-content/themes/default/images/wow/pin_im.gif\' style=\'position:absolute;";	/* instance map pin */
var zz = "<div class=\'pin_container\'><a href=\'#\' onclick=\'return false\' class=\'tooltip\'><img src=\'../../../../blog/wp-content/themes/default/images/wow/pin_im_test.gif\' style=\'position:absolute;";	/* instance map test layout pin */

function createPinnedMap(mapString) {
	var i = 0, k = 0, j = 0, m = 0, n = 0;	
	var tt_coords = [], xArray = [], yArray = [], locArray = [];
	var pin_locs = "";	/* final pin data */
	var xmult = 9.92;	/* x offset multiplier */
	var ymult = 6.63;	/* y offset multiplier */
	

	/* fill maps with data */
	if (mapCheck() == 1){headMaps(mapString);}
	if (mapCheck() == 2){shoulderMaps(mapString);}
	
	fillMaps(mapString);
	

	/* grab coordinates for tooltip display as well as any additional text */
	for (i=0;i<(coords.length / 2);i++) {

		/* for maps with no coordinates */
		if (coordtext === 0) {
			tt_text[i] = "" + tt_text[i];
			tt_coords[i] = tt_text[i];
		}else{
			tt_coords[i] = coords[m].toFixed(1) + ", " + coords[m+1].toFixed(1) + br + br + tt_text[i]; /* toFixed rounds a number to the given number of decimal places; needed this for .0 to show up, ex: 50.0 */
		}
		m = m + 2;
	}

	/* translate WoW x-coordinate into pixel x-coordinate for the map */
	for (i=0;k=coords[i];i=i+2) {
		k = Math.round(k * xmult);
		xArray[j] = k;
		j++;}
	/* translate WoW y-coordinate into pixel y-coordinate for the map */
	for (i=1;k=coords[i];i=i+2) {
		k = Math.round(k * ymult);
		yArray[n] = k;
		n++;}
	/* create the pin points, position tooltips, and set tooltip width */
	for (i=0;k=xArray[i];i++) {	/* could have used yArray[i] too; just needed the correct number of pins to make */

		var tt_width = 0;		/* width of css tooltip */
		xTooltip = xArray[i] + 22;	/* css tooltip x-coord */
		yTooltip = yArray[i] - 16;	/* css tooltip y-coord */
		/* re-position tooltip if it clips off the map */
		if (yArray[i] >= 480 && yArray[i] <= 515){yTooltip = yTooltip - 50;}
		else if (yArray[i] > 515 && yArray[i] <= 530){yTooltip = yTooltip - 80;}
		else if (yArray[i] > 530 && yArray[i] <= 560){yTooltip = yTooltip - 120;}
		else if (yArray[i] > 560){yTooltip = yTooltip - 150;}
	
		/* find width of css tooltip based on the number of characters per index */
		var tt_length = tt_text[i].length;
		if (tt_length <= 12) {tt_width = 60;}
		else if (tt_length > 12 && tt_length < 60) {tt_width = 100;}
		else if (tt_length >= 60 && tt_length < 210){tt_width = 120;}
		else {tt_width = 230;}
	
  		/* pin data (image, x,y pixel coords, tooltip width,text) */
  		locArray[i] = pin[i] + "left:" + xArray[i] + "px;top:" + yArray[i] + "px;\'><span style=\'position:relative;left:" + xTooltip + "px;top:" + yTooltip + "px;width:" + tt_width + "px;\'>" + "<p style=\'margin: 0 0 0 4px;color: yellow;\'>" + tt_coords[i] + "</p></span></a></div>";
	
  		/* load up pin_locs variable with locArray data */
  		pin_locs = pin_locs + locArray[i];
	}

	/* map with pin data */
	var pinned_map = "<div class=\'map_container\'>" + pin_locs + map + "</div>";

	return pinned_map;
}


/***********************************
  fillMaps() function
  **********************************
  used for maps items that are in two or more different enchant tables. finds the necessary data to pass back to createPinnedMap().
  
  arguments:
  	mapString:  string value that determines which map, WoW coordinates, and tooltip info to use.
  	
  After createPinnedMap() is called, fillMaps finds which map data it needs based on which enchant table was called.  After calling this function, all the data needed to create a specific pinned map is called and passed - via global variables - back to createPinnedMap().
***********************************/
function fillMaps(mapString){

/*******************************/
/* map css tooltip definitions */
/*******************************/
/* instance map items */


/* map items */
var cro_mi = ptl + "Cro Threadstrong</div>" + wowimg_mi + "cro_threadstrong.gif\'>";
var haferet_mi = ptl + "Haferet</div>" + wowimg_mi + "haferet.gif\'>";
var dameron_mi = ptl + "Knight Dameron</div>" + wowimg_mi + "knight_dameron.gif\'><pre>                                 </pre>";
var lillehoff_mi = ptl + "Lillehoff</div>" + wowimg_mi + "lillehoff.gif\'>";
var mukar_mi = ptl + "Stone Guard Mukar</div>" + wowimg_mi + "stone_guard_mukar.gif\'><pre>                           </pre>";
var zaralda_mi = ptl + "Zaralda</div>" + wowimg_mi + "zaralda.gif\'>";

/* example of how to place two pictures side by side 
var roleo_mi = "<div style=\'float:left;\'>" + ptl + "Rohan the Assassin</div>" + wowimg_mi + "rohan_the_assassin.gif\' style=\'float:left;margin-left:24px;\'></div>" + ptl + "Huntsman Leopold</div>" + wowimg_mi + "huntsman_leopold.gif\'>";
*/


/**************************/
/* find the map to create */
/**************************/
/**********************
 instance map items
 ***************************
   note on instance map items:
   unfortunately, finding the x and y coords isn't a simple task, but do the following to get in the ballpark:
   1)  make sure map is 1002x668, anything else will mess up the coordinate positioning
   2)  to find x, open the map up in an editor, scroll to the middle of the number/letter, and use the x pixel coordinate as the value for the array.
   	ex: if you get 708, the value to place in the array is 70.8
   3) for y, do the same as x except take the number from close to the top right of the number/letter, then divide the y pixel by the total and the resulting percentage is the y coord to use.
   	ex: if you get 345, divide it by 668 (345/668) which gives you 0.5164... so the value to place in the array is 51.6
*****************************/


/*******************/
/* world map items */
/*******************/
/* cro threadstrong */
if (mapString == "cts") {
	map = shat;
	coords = [66.9, 67.3];
	pin = [bb];
	tt_text = [cro_mi];
	coordtext = 1;
}
/* haferet */
if (mapString == "haf") {
	map = exodar;
	coords = [66.0, 74.6];
	pin = [bb];
	tt_text = [haferet_mi];
	coordtext = 1;
}
/* knight dameron */
if (mapString == "dameron") {
	map = winter;
	coords = [51.7, 17.5];
	pin = [bb];
	tt_text = [dameron_mi];
	coordtext = 1;
}
/* lillehoff */
if (mapString == "lil") {
	map = stormp;
	coords = [66.2, 61.4];
	pin = [bb];
	tt_text = [lillehoff_mi];
	coordtext = 1;
}
/* stone guard mukar */
if (mapString == "mukar") {
	map = winter;
	coords = [51.7, 17.5];
	pin = [bb];
	tt_text = [mukar_mi];
	coordtext = 1;
}
/* zaralda */
if (mapString == "zara") {
	map = silvermoon;
	coords = [84.0, 78.8];
	pin = [bb];
	tt_text = [zaralda_mi];
	coordtext = 1;
}
}

/***************************************
  unhide() function  (expander/collapser)
  **************************************
  This function looks at the current class set on your DIV and if it's marked as hidden, 
  it it changes it to unhidden, if it's marked as unhidden, it changes it to hidden. 
  This is what toggles the DIV on and off.
  
  arguments:
  	divID:  the exact unique ID you want to show or hide  
***************************************/
function unhide(divID) {
	var item = document.getElementById(divID);
	if (item) {
		item.className=(item.className=='hidden')?'unhidden':'hidden';}
}

/***************************************
  swap() function  
  **************************************
  swaps out one image for another using the replace() function.
  
  In this case it's two specific images that are being swapped, plus.gif and minus.gif
  plus shows up before the list is expanded, and if the image is clicked (to expand the list), 
  minus takes its place until it is clicked.
  
  arguments:
  	x:  full image path
  
  notes:
  	I looked for countless ways to do this function, and this was the best I could do.
  	x.src returns the value of the whole path.
  		ex: http://127.0.0.1/blog/wp-content/themes/default/images/wow/plus.gif
  	Because of this, a comparison can't be made to ../../../../blog/wp-content/themes/default/images/wow/plus.gif
  	because it's literally not the same thing.
***************************************/
function swap(x) {
	var r = x.src;
	if (x.src == r.replace(/plus.gif/, "plus.gif")){
		x.src = '../../../../blog/wp-content/themes/default/images/wow/minus.gif';}
	if (x.src == r.replace(/minus.gif/, "minus.gif")){
		x.src = '../../../../blog/wp-content/themes/default/images/wow/plus.gif';}
}

/***********************************
  quant() function
  **********************************
  simple function that takes a number and adds an 'x' plus a space.
  
  arguments:
  	b: the number of items
***********************************/
function quant(b){
	b = b + "x ";
return b;
}

/***********************************
  findScroll() function
  **********************************
  finds the X,Y coords of the screen based on the position of the scroll
  
  arguments:
  	obj:  the object that needs positioning
  
  ****************
  This nifty function grabs the X,Y coordinates of the current position of the screen (based on the scroll) starting from the top of the browser window.  0,0 is the top-left of the screen, and slowly increases and you scroll down or to the right.  It currently uses DOM functions to adjust the image (pinned maps in this case) to fit close to the center of the screen, depending on resolution.
***********************************/  
function findScroll(obj){
	// get scroll X, Y coords
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
	//Netscape compliant
	scrOfY = window.pageYOffset;
	scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	//DOM compliant
	scrOfY = document.body.scrollTop;
	scrOfX = document.body.scrollLeft;
	} else if( ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { // else if ( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
	//IE6 standards compliant mode - IE7 workaround because it's dumb and doesn't use innerwidth or innerheight, but this will at least keep the image on screen, just not centered.
	scrOfY = document.documentElement.scrollTop;
	scrOfX = document.documentElement.scrollLeft;
	return [scrOfX, scrOfY];}

	/* attempt to somewhat center the image */
	scrOfX = scrOfX + (window.innerWidth/(scrOfX+10));
	scrOfY = scrOfY + (window.innerHeight*'.05');

	return [scrOfX, scrOfY];
}
