function TalentCalculator() {

/*--------------------------------------------*/
//              Private Variables             //
/*--------------------------------------------*/

var talentVars;
var whichClass;
var pageMode = '';
var petMode = false;
var uniqueId = '';
var talentTrees;
var talentLookup = {};
var petFamilies;
var currentPetTree;

/*--------------------------------------------*/
//                 Constants                  //
/*--------------------------------------------*/

var ICON_PREFIX      = '/wow-icons/_images/_talents31x31/';
var ICON_PREFIX_GREY = '/wow-icons/_images/_talents31x31/grey/';
var ICON_TREE_PREFIX = '/wow-icons/_images/21x21/'; 

/*--------------------------------------------*/
//               Public Methods               //
/*--------------------------------------------*/

this.initTalentCalc = function(WhichClass, TalStr, PageMode, PetMode, UniqueId, TalentData, PetData) {

	WhichClass  = parseInt(WhichClass);
	pageMode    = PageMode;
	petMode     = (PetMode == 'true');
	uniqueId    = UniqueId;
	talentTrees = TalentData;
	petFamilies = PetData;

	talentVars = {
		talHolder:            $('#' + getUniqueId('talContainer')),
		pointsLeft:           $("#pointsLeft"),
		pointsSpent:          $("#pointsSpent"),
		reqLevel:             $("#requiredLevel"),
		talentPtsStr:         $('#' + getUniqueId('linkToBuild')),
		pts:                  0,
		basePts:              (petMode ? 16 : 71),
		extraPts:             0,
		maxTrees:             3,
		maxTiers:             (petMode ? 6 : 11),
		pointsPerTier:        (petMode ? 3 : 5),
		beastMasteryReqLevel: 60,
		beastMasteryExtraPts: 4
	};
	talentVars.maxPts = talentVars.basePts + talentVars.extraPts;

	// First pass: only store a reference to each talent
	for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum)
	{
		var tree = talentTrees[treeNum];

		for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum)
		{
			var talent = tree.talents[talentNum];

			// Store a direct reference to each talent for later use
			talentLookup[talent.id] = talent;
		}
	}

	// Second pass: actual initialization
	for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum)
	{
		var tree = talentTrees[treeNum];

		tree.nameLbl   = $('#' + getUniqueId('treeName'  + '_' + treeNum));
		tree.iconDiv   = tree.nameLbl.parent();
		tree.ctr       = $('#' + getUniqueId('treeSpent' + '_' + treeNum));
		tree.num       = treeNum;
		tree.pts       = 0;
		tree.tierVals  = [0,0,0,0,0,0,0,0,0,0,0];
		tree.reqArrows = [];

		for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum)
		{
			var talent = tree.talents[talentNum];

			talent.num       = talentNum;
			talent.pts       = 0;
			talent.maxPts    = talent.ranks.length;
			talent.ele       = $('#' + getUniqueId(talent.id + '_talentHolder'));
			talent.iconEle   = $('#' + getUniqueId(talent.id + '_iconHolder'));
			talent.ctr       = $('#' + getUniqueId(talent.id + '_numPoints'));
			talent.tree      = treeNum;

			// TODO: Have this data stored in the JS array directly.
			talent.spellInfo = ($("#spellInfo_" + talent.id) ? $("#spellInfo_" + talent.id).html() : null);

			if(talent.requires)
			{
				talent.reqArrows = [];

				// Store reverse lookup array (direct references to the dependent talents)
				var reqTalent = talentLookup[talent.requires];
				if(reqTalent) {
					if(!reqTalent.dependencies) {
						reqTalent.dependencies = [];
					}
					reqTalent.dependencies.push(talent);
				}
			}

			// Disable context menu so we can right-click talent to subtract
			talent.ele.bind('contextmenu', blockEvent);
		}
	}

	if(petMode)
	{
		if(WhichClass > 0) { // A specific pet family was passed
			changePetTree(null, WhichClass);
		}
		else {
			// Support for pet tree URLs (e.g. ?pid=-1 for Ferocity)
			if(WhichClass >= -3 && WhichClass <= -1)
				changePetTree(-WhichClass - 1);
			else
				changePetTree(0); // Default tree (Ferocity)
		}
	}
	else
	{
		whichClass = WhichClass;
		drawRequiredArrows();
	}

	if(!applyTalents(TalStr))
		updatePointsLeftDisplay();
}

this.addTalent = function(id, e){
	addTalent(id, e);
}

this.makeTalentTooltip = function(id) {
	makeTalentTooltip(id);
}

this.applyTalents = function(build) {
	applyTalents(build);
}

this.resetAllTalents = function() {
	resetAllTalents();	
}

this.resetTalents = function(treeNum, check) {
	resetTalents(treeNum, check);
}

this.changePetTree = function(treeNum, family, e) {
	changePetTree(treeNum, family, e);
}

this.toggleBeastMastery = function() {
	toggleBeastMastery();
}

this.displayBeastMasteryTooltip = function() {
	displayBeastMasteryTooltip();
}

this.displayPetFamilyTooltip = function(id) {
	displayPetFamilyTooltip(id);
}

this.showPrintableVersion = function() {
	showPrintableVersion();
}

/*--------------------------------------------*/
//              Private Methods               //
/*--------------------------------------------*/

// Makes a unique identifier for a DOM element
// (e.g. 'talContainer' becomes 'talContainer_wenld36')
function getUniqueId(id) {
	return id + '_' + uniqueId;
}

// Draws required arrows in the currently visible tree(s)
function drawRequiredArrows() {

	var parentOffset = $(talentVars.talHolder).offset();
	var arrowClass   = "";
	var treeNums     = getVisibleTrees();

	for(var i = 0; i < treeNums.length; ++i) {

		var treeNum = treeNums[i];
		var tree    = talentTrees[treeNum];

		if(tree.reqArrows.length > 0) // Skip tree if already drawn
			continue;

		for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) {		
	
			var talent = tree.talents[talentNum];
			if(!talent.requires) continue; // Skip talent if no prerequisite
	
			var reqTalent = talentLookup[talent.requires];
			if(!reqTalent) continue;
	
			var requiredSpellOffset = reqTalent.ele.offset();			
			var currSpellOffset     = talent.ele.offset();
	
			var reqArw = { top: 0, left: 0, height: 0, width: 0 };
			
			// Vertical arrow
			if(currSpellOffset.left == requiredSpellOffset.left) {
				reqArw.top    = (requiredSpellOffset.top + 36) - parentOffset.top;
				reqArw.left   = requiredSpellOffset.left - parentOffset.left + 8;
				reqArw.height = currSpellOffset.top - requiredSpellOffset.top - 33;
				reqArw.width  = 21;

				var arrow = makeReqArrow(reqArw.top, reqArw.left, reqArw.height, reqArw.width, talentVars.talHolder, "vArrow disabledArrow");
				talent.reqArrows.push(arrow);
				tree.reqArrows.push(arrow);
			}
	
			// Horizontal arrow
			else if(currSpellOffset.top == requiredSpellOffset.top)	{
	
				// Right
				if(currSpellOffset.left > requiredSpellOffset.left) {
					reqArw.top    = (requiredSpellOffset.top + 11) - parentOffset.top;
					reqArw.left   = currSpellOffset.left - 17 - parentOffset.left;
					reqArw.height = 21;
					reqArw.width  = currSpellOffset.left - requiredSpellOffset.left - 31;
					arrowClass    = "hArrow arrowRight disabledArrow";
	
				// Left
				} else {
					reqArw.top    = (requiredSpellOffset.top + 11) - parentOffset.top;
					reqArw.left   = requiredSpellOffset.left - 17 - parentOffset.left;
					reqArw.height = 21;
					reqArw.width  = requiredSpellOffset.left - currSpellOffset.left - 33;					
					arrowClass    = "hArrow arrowLeft disabledArrow";

				}
				
				var arrow = makeReqArrow(reqArw.top, reqArw.left, reqArw.height, reqArw.width, talentVars.talHolder, arrowClass);
				talent.reqArrows.push(arrow);
				tree.reqArrows.push(arrow);
	
			// Angle arrow
			} else {
	
				// Vertical line needs to go on bottom in dom for arrow bracket
				reqArw.top    = (requiredSpellOffset.top + 17) - parentOffset.top;
				reqArw.left   = currSpellOffset.left + 8 - parentOffset.left;
				reqArw.height = currSpellOffset.top - requiredSpellOffset.top - 13;
				reqArw.width  = 21;		
	
				var arrow = makeReqArrow(reqArw.top, reqArw.left, reqArw.height, reqArw.width, talentVars.talHolder, "vArrow disabledArrow");
				talent.reqArrows.push(arrow);
				tree.reqArrows.push(arrow);
	
				reqArw.top = reqArw.top - 8;
	
				// Horizontal line				
				if(currSpellOffset.left > requiredSpellOffset.left) {
	
					// Right					
					reqArw.left   = currSpellOffset.left - 15 - parentOffset.left;
					reqArw.height = 21;
					reqArw.width  = currSpellOffset.left - requiredSpellOffset.left - 13;
					arrowClass    = "hArrow arrowRight plain disabledArrow";					
				} else {
	
					// Left
					reqArw.left   = requiredSpellOffset.left - 15 - parentOffset.left - 21;
					reqArw.height = 21;
					reqArw.width  = requiredSpellOffset.left - currSpellOffset.left -14;
					arrowClass    = "hArrow arrowLeft plain disabledArrowL";
				}

				var arrow = makeReqArrow(reqArw.top, reqArw.left, reqArw.height, reqArw.width, talentVars.talHolder, arrowClass);
				talent.reqArrows.push(arrow);
				tree.reqArrows.push(arrow);
			}
		}
	}
}

// Creates an arrow
function makeReqArrow(top, left, height, width, parentDiv, arrowClass) {

	// Add to parent, and return the element so that it can be stored for later use
	return $(
			'<div class="requiredArrow ' + arrowClass +
			'" style="top: ' + top +
			'px; left: '     + left +
			'px; height: '   + height +
			'px; width: '    + width +
			'px;"></div>'
	).appendTo(parentDiv);	
}

// When a talent is clicked on
function addTalent(id, e) {	

	if(pageMode != "calc") return; // Calculator mode only

	var talent    = talentLookup[id];
	var tree      = talentTrees[talent.tree];
	var runChecks = true;

	// Subtract a point
	if(e.which == 3 || e.button == 2 || e.ctrlKey) {

		if(talent.pts > 0) {
			
			// Figure out if we can subtract or not			
			var canSubtract = true;
			var tierTotal = 0;
			
			// Decrement and test
			tree.tierVals[talent.tier]--;

			// Go through tiers and add up points
			for(var tierNum = 0; tierNum < talentVars.maxTiers; ++tierNum) {
				
				tierTotal += tree.tierVals[tierNum];

				var nextTierNum = tierNum + 1;

				if(tree.tierVals[nextTierNum] > 0) { // Ignore tiers with no points in them					
					if(tierTotal < (nextTierNum * talentVars.pointsPerTier)) {
						canSubtract = false;
						break;
					}
				}
			}

			// Make sure the talent we're clicking on is not needed by other talents
			if(canSubtract) {
				if(talent.dependencies && talent.dependencies.length > 0) {
					for(var i = 0; i < talent.dependencies.length; ++i) {

						var dependentTalent = talent.dependencies[i];
						if(dependentTalent.pts > 0) {
							canSubtract = false; // If a dependent talent has points in it, we can't subtract.
							break;
						}
					}
				}
			}
			
			if(canSubtract) {
				talent.pts--;
				tree.pts--;
				talentVars.pts--;
				//tree.tierVals[talent.tier]--; (Already done earlier)

				talent.ele.removeClass("talentMax"); // Certainly no longer maxed if we're subtracting
				
				// If we're coming from being at max points, check all the trees
				if((talentVars.pts + 1) >= talentVars.maxPts) {
					checkAllTrees();	
				}
				
			} else { // Cannot substract? Undo what was done.
				tree.tierVals[talent.tier]++;
			}
		} else {
			runChecks = false;
		}

	// Add a point
	} else {

		// Make sure talent isn't maxed out
		if(talent.pts < talent.maxPts && talentVars.pts < talentVars.maxPts) {

			// Prevent from adding points above where is allowed
			if(tree.pts >= (talent.tier * talentVars.pointsPerTier) && checkDependentTalent(talent)) {				
				talent.pts++;
				tree.pts++;
				talentVars.pts++;
				tree.tierVals[talent.tier]++;

				if(talent.pts >= talent.maxPts) {
					talent.ele.addClass("talentMax");
				}

			} else {
				runChecks = false;
			}
		} else {
			runChecks = false;
		}
	}

	if(runChecks)
	{
		// Update counters
		talent.ctr.text(talent.pts);
		tree.ctr.text(tree.pts);

		makeTalentTooltip(id);

		checkEnabled(tree.num);
	}
}

// Verify if the dependent talent has enough points in it (if any)
function checkDependentTalent(talent) {

	if(talent.requires) {
		
		var reqTalent = talentLookup[talent.requires];
		if(reqTalent && reqTalent.pts < reqTalent.maxPts) {
			return false;
		}
	}		

	return true;
}

function checkAllTrees() {
	
	calcTreePts();
	
	for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum) {			
		checkEnabled(treeNum);	
	}
}

function checkEnabled(treeNum) {

	calcTreePts();
	
	var tree = talentTrees[treeNum];
	for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) {

		var talent = tree.talents[talentNum];
		var enabled = (talent.tier == 0 || tree.pts >= (talent.tier * talentVars.pointsPerTier));

		if(enabled && talent.pts == 0 && (talentVars.pts >= talentVars.maxPts || pageMode != "calc"))
			enabled = false;
			
		// Dependent talents have special cases
		if(enabled && !checkDependentTalent(talent))
			enabled = false;

		if(enabled) {
			enableTalent(talent);
			enableArrows(talent);

		} else {
			disableTalent(talent);
			disableArrows(talent);
		}
	}
}

// Generate the talent tooltip and display it
function makeTalentTooltip(id) {

	var talent = talentLookup[id];
	if(!talent) return;

	var currRankNum = talent.pts;
	var maxRankNum  = talent.maxPts;

	// Name
	var talentTipStr = "<b>" + talent.name + "</b><br />";
	
	// Rank
	talentTipStr += sprintf(textTalentRank, currRankNum, maxRankNum) + "<br />";

	if(talent.spellInfo) {
		talentTipStr += talent.spellInfo + "<br />";			
	}
		
	// Show if the talent has a required talent
	if(talent.requires) {

		var reqTalent = talentLookup[talent.requires];
		
		if(reqTalent.pts < reqTalent.maxPts) { // Only if prereq. talent isn't maxed out				
		
			talentTipStr += '<span style="color: red">';

			if(reqTalent.maxPts == 1) {
				talentTipStr += sprintf(textTalentStrSingle, reqTalent.maxPts, reqTalent.name);
			} else {
				talentTipStr += sprintf(textTalentStrPlural, reqTalent.maxPts, reqTalent.name);				
			}
			talentTipStr += "</span><br />";
		}
	}
	
	// Show how many points is required in the tree (if not enough points)
	if(talent.tier > 0 && (talent.tier * talentVars.pointsPerTier) > talentTrees[talent.tree].pts) {
		talentTipStr += '<span style="color: red">'
		talentTipStr += sprintf(textTalentReqTreeTalents, talent.tier * talentVars.pointsPerTier, talentTrees[talent.tree].name) + "<br />";
		talentTipStr += '</span>'
	}

	// Current rank
	if(currRankNum != 0) {
		talentTipStr += "<span style='color: #ffd200'>" + talent.ranks[currRankNum - 1] + "</span>";
	}

	//  Next Rank
	if((currRankNum + 1) <= maxRankNum){
		if((maxRankNum > 1) && (currRankNum > 0)){
			talentTipStr += "<br /><br />" + textTalentNextRank + ":<br />";
		}
		talentTipStr += "<span style='color: #ffd200'>" + talent.ranks[currRankNum] + "</span>";
	}

	// IE6: Set maximum width by wrapping tooltip 
	if($.browser.msie && $.browser.version == "6.0"){
		talentTipStr = '<div style="width: 300px">' + talentTipStr + '</div>';
	}

	setTipText(talentTipStr);
}

function enableArrows(talent) {

	if(!talent.requires || !talent.reqArrows) return;
	
	for(var x = 0; x < talent.reqArrows.length; ++x) {
		$(talent.reqArrows[x]).removeClass("disabledArrow");
		$(talent.reqArrows[x]).removeClass("disabledArrowL");
	}
}

function disableArrows(talent) {

	if(!talent.requires || !talent.reqArrows) return;
	
	for(var x = 0; x < talent.reqArrows.length; ++x) {

		if($(talent.reqArrows[x]).hasClass("arrowLeft")) {
			$(talent.reqArrows[x]).addClass("disabledArrowL");
		} else {
			$(talent.reqArrows[x]).addClass("disabledArrow");
		}
	}
}

function enableTalent(talent) {
	talent.ele.removeClass("disabled");
	talent.iconEle.css("background-image", "url('http://www.wowarmory.com/" + ICON_PREFIX + talent.icon + ".jpg')");
}

function disableTalent(talent) {
	talent.ele.addClass("disabled");
	talent.iconEle.css("background-image", "url('http://www.wowarmory.com/" + ICON_PREFIX_GREY + talent.icon + ".jpg')");		
}

function showTalent(talent) {
	talent.iconEle.css('display', '');
	talent.hidden = false;
}

function hideTalent(talent) {
	talent.iconEle.css('display', 'none');
	talent.hidden = true;
}

// Parses a talent build string
function applyTalents(build) {
	
	resetAllTalents(); // Reset all the talents first

	// Don't do anything if the build string is blank
	if(!build) {
		checkAllTrees();
		return false;
	}

	// Pet Talents
	if(petMode)	{

		// Calculator: Enable Beast Mastery if '&bm' is present in the URL
		if(pageMode == 'calc') {
			if(location.search && location.search.indexOf('&bm') != -1) {
				toggleBeastMastery();
			}

		// Otherwise: Enable Beast Mastery as needed.
		} else {
			var nPts = 0;
			for(var x = 0; x < build.length; ++x) {
				nPts += parseInt(build.charAt(x)) | 0;
			}

			if(nPts > talentVars.basePts) {
				enableBeastMastery();
			} else {
				disableBeastMastery();
			}
		}
	}

	var treeNums = getVisibleTrees();
	var nPointsLeft = talentVars.maxPts;
	var ctr = 0;

	for(var i = 0; i < treeNums.length; ++i) {

		var treeNum = treeNums[i];
		var tree    = talentTrees[treeNum];

		for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) {		
	
			var
				talent = tree.talents[talentNum];
				nPoints = parseInt(build.charAt(ctr)) | 0;			

			if(nPoints > 0) {

				if(nPoints > talent.maxPts)
					nPoints = talent.maxPts;
				if(nPoints > nPointsLeft)
					nPoints = nPointsLeft;

				talent.pts = nPoints;
				talent.ctr.text(talent.pts);

				if(talent.pts >= talent.maxPts) {
					talent.ele.addClass("talentMax");
				}
				
				nPointsLeft -= nPoints;

			} else {
				talent.pts = 0;
				talent.ctr.text('0');		
			}

			++ctr;
		}
	}

	checkAllTrees();
	
	return true;
}

function resetAllTalents(){	

	for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum) {
		resetTalents(treeNum, false);
	}

	checkAllTrees();
}

// Reset talent points back to zero
function resetTalents(treeNum, check) {

	var tree = talentTrees[treeNum];

	for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) {
		var talent = tree.talents[talentNum];

		talent.pts = 0;
		talent.ctr.text('0');
		talent.ele.removeClass("talentMax");
		
		if(talent.tier > 0) {
			disableTalent(talent);
		} else {
			talent.iconEle.css("background-image", "url('http://www.wowarmory.com/" + ICON_PREFIX + talent.icon + ".jpg')");	
		}
		
		if(talent.requires){
			disableArrows(talent);
		}	
	}

	// We do not need to calculate tree points if we're resetting all the talents.
	if(check) {
		checkAllTrees();
	}
}

function getCurrentTalentBuild() {

	var build = '';
	var treeNums = getVisibleTrees();

	for(var i = 0; i < treeNums.length; ++i) {

		var treeNum = treeNums[i];
		var tree = talentTrees[treeNum];

		for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum)	{
			var	talent = tree.talents[talentNum];

			build += talent.pts;
		}
	}

	return build;
}

// Returns which trees are currently visible
function getVisibleTrees()
{
	var treeNums;
	var cache;

	if(!getVisibleTrees.cache) {
		getVisibleTrees.cache = [];
	}

	cache = getVisibleTrees.cache;
	
	// Pet Talent Calculator: only return the currently visible tree
	if(petMode) {

		if(cache.length) { // Use cache if available
			cache[0] = currentPetTree;
		}
		else {
			cache.push(currentPetTree);
		}

	// Talent Calculator: return all the trees
	} else {

		if(cache.length) { // Use cache if available
			;
		}
		else {
			for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum) {
				cache.push(treeNum);
			}
		}
	}
	
	return cache;
}

// Adds up the points in the tree and its tiers
function calcTreePts(){

	talentVars.pts = 0;

	for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum) {
		var tree = talentTrees[treeNum];

		tree.pts = 0;
		for(var tierNum = 0; tierNum < talentVars.maxTiers; ++tierNum) {
			tree.tierVals[tierNum] = 0;
		}

		for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum)	{
			var talent = tree.talents[talentNum];

			tree.pts += talent.pts;
			tree.tierVals[talent.tier] += talent.pts;
		}
		
		talentVars.pts += tree.pts;

		tree.ctr.text(tree.pts);		
	}

	// After running out of talent points, disable talents with no points in them
	if(talentVars.pts >= talentVars.maxPts) {
		for(var talId in talentLookup){

			var talent = talentLookup[talId];
			
			if(!talent.ele.hasClass("talentMax")) {
				if(talent.pts == 0) {
					disableTalent(talent);
					disableArrows(talent);
				}
			}
		}
	}

	updatePointsLeftDisplay();
}

function getRequiredLevel() {

	var reqLevel = 0;

	// Pet Mode
	if(petMode) {
		if(talentVars.pts > 0) {
			reqLevel = 20 + (talentVars.pts - talentVars.extraPts - 1) * 4;
		}

		// Minimum level requirement for Beast Mastery
		if(talentVars.extraPts > 0) {
			reqLevel = Math.max(reqLevel, talentVars.beastMasteryReqLevel);
		}

	// Normal
	} else {
		if(talentVars.pts > 0) {
			reqLevel = talentVars.pts + 9;
		}
	}

	return reqLevel;
}

function getPointsSpent() {

	var ptsSpent;

	// Pet Talent Calculator: total number of points spent
	if(petMode) {
		ptsSpent = talentVars.pts;

	// Talent Calculator: number of points spent per tree
	} else {
		ptsSpent = '';
		for(var treeNum = 0; treeNum < talentVars.maxTrees; ++treeNum)
		{
			if(treeNum > 0)
				ptsSpent += '/';

			ptsSpent += talentTrees[treeNum].pts;
		}
	}

	return ptsSpent;
}

// Updates UI to show what points are left, etc.
function updatePointsLeftDisplay() {

	if(pageMode == 'calc') {
		
		var ptsSpent = getPointsSpent();

		$(talentVars.pointsSpent).text(ptsSpent);
		$(talentVars.pointsLeft).text(talentVars.maxPts - talentVars.pts);

		var reqLevel = getRequiredLevel();	
		$(talentVars.reqLevel).text(reqLevel == 0 ? '-' : reqLevel);
	}

	var url;
	// Pet Talent Calculator
	if(petMode) {
		url = "/talent-calc.xml?pid=" + whichClass + "&tal=" + getCurrentTalentBuild();
		if(talentVars.extraPts > 0) {
			url += '&bm';
		}

	// Talent Calculator
	} else {
		url = "/talent-calc.xml?cid=" + whichClass + "&tal=" + getCurrentTalentBuild();
	}

	$(talentVars.talentPtsStr).attr('href', url);
}

// Prevents event from propagating
function blockEvent(event) {
	event = event || window.event;

	if(event.stopPropagation) event.stopPropagation();	
	event.cancelBubble = true;

	return false;
}

// Unhides the arrows in the specified talent tree
function showTreeArrows(treeNum) {
	
	var tree = talentTrees[treeNum];

	$.each(tree.reqArrows, function() {
		this.css('display', '');
	});
}

// Hides the arrows in the specified talent tree
function hideTreeArrows(treeNum) {
	
	var tree = talentTrees[treeNum];

	$.each(tree.reqArrows, function() {
		this.css('display', 'none');
	});
}

// Used in the Pet Talent Calculator
function changePetTree(treeNum, familyId, e)
{
	var changed = false;

	// Allows for calling the function with only a family ID
	if(!treeNum && familyId && petFamilies[familyId]) {
		treeNum = petFamilies[familyId].tree;		
	}

	// Tree change
	if(currentPetTree != treeNum) {
		changed = true;

		var previousPetTree = currentPetTree;
		currentPetTree = treeNum;
	
		// Talent tree
		if(previousPetTree != null)
			$('#' + getUniqueId(talentTrees[previousPetTree].id + '_treeContainer')).css('display', 'none');
		$('#' + getUniqueId(talentTrees[currentPetTree].id + '_treeContainer')).css('display', '');

		// Arrows
		drawRequiredArrows();
		if(previousPetTree != null)
			hideTreeArrows(previousPetTree);
		showTreeArrows(currentPetTree);

		if(pageMode == 'calc') {

			// Subtab
			if(previousPetTree != null)
				$('#' + talentTrees[previousPetTree].id + '_subTab').removeClass('selected-subTab');
			$('#' + talentTrees[currentPetTree].id + '_subTab').addClass('selected-subTab');

			// Pet family group
			$('#' + currentPetTree + '_group').parent().children().removeClass('selectedPetGroup');
			$('#' + currentPetTree + '_group').addClass('selectedPetGroup');

			if(!familyId) { // Chooses the first family in the group
				familyId = parseInt($('#' + treeNum + '_group .petFamily:first').attr('id'));
			}
		}
	}

	// Family change
	if(familyId > 0)
	{
		if(familyId != whichClass)
		{
			changed = true;

			whichClass = familyId; 
	
			// Pet Talent Calculator
			if(pageMode == 'calc') {

				// Highlight family icon
				$('#petFamilies .petFrameSelected').removeClass('petFrameSelected');
				$('#' + familyId + '_family .petFrame:first').addClass('petFrameSelected');

				// Update bottom section with family name and icon
				var name = petFamilies[whichClass].name;
				var maxLength = 9;

				if(name.length > (maxLength + 3)) {
					name = name.substr(0, maxLength) + '...';
				}

				talentTrees[currentPetTree].nameLbl.text(name);
				talentTrees[currentPetTree].iconDiv.css('background-image', 'url(http://www.wowarmory.com/' + ICON_TREE_PREFIX + petFamilies[whichClass].icon + '.png)');
			}
		}
	}

	if(changed)
	{
		resetAllTalents();
		validatePetTalents(); // Support for birds
	}

	if(e) blockEvent(e);
}

function validatePetTalents() {

	var	catId = petFamilies[whichClass].catId;
	var mask;

	if(catId < 32) {
		mask = '0';
	} else {
		catId -= 32;
		mask = '1';
	}

	for(var talentNum = 0, len = talentTrees[currentPetTree].talents.length; talentNum < len; ++talentNum) {

		var talent = talentTrees[currentPetTree].talents[talentNum];
		
		if(talent.categoryMask0 || talent.categoryMask1) {

			var valid = talent['categoryMask' + mask] & (1 << catId);

			if(!talent.hidden && !valid) {
				hideTalent(talent);
			} else if(talent.hidden && valid) {
				showTalent(talent);
			}
		}
	}
}

function enableBeastMastery() {
	talentVars.extraPts = talentVars.beastMasteryExtraPts;
	talentVars.maxPts   = talentVars.basePts + talentVars.extraPts;
}

function disableBeastMastery() {
	talentVars.extraPts = 0;
	talentVars.maxPts   = talentVars.basePts + talentVars.extraPts;
}

function toggleBeastMastery() {

	var ele = $('#beastMasteryToggler');

	// Disable BM
	if(talentVars.extraPts)
	{
		if(talentVars.pts > talentVars.basePts)
		{
			// TODO: Permit the operation by removing points from the end of the tree.
			return;
		}

		disableBeastMastery();
		
		ele.text('+' + talentVars.beastMasteryExtraPts);
		ele.removeClass('petBeastMastery-on');
	}

	// Enable BM
	else
	{
		enableBeastMastery();

		ele.text('-' + talentVars.beastMasteryExtraPts);
		ele.addClass('petBeastMastery-on');
	}

	displayBeastMasteryTooltip();
	checkAllTrees();
}

function displayBeastMasteryTooltip() {
	var tt = '';
	
	tt += '<b>' + textTalentBeastMasteryName + '</b><br />';
	tt += '<span style="color: #ffd200">' + textTalentBeastMasteryDesc + '</span>';

	setTipText(tt);
}

function displayPetFamilyTooltip(id) {
	setTipText(petFamilies[id].name);	
}

function showPrintableVersion() {

	var html = '';

	var className;
	if(petMode) {
		className = petFamilies[whichClass].name;
	} else {
		className = window['text' + whichClass + 'class'];
	}
	var reqLevel = getRequiredLevel();
	var title = sprintf(textPrintableClassTalents, className);
	
	html += '<html><head>';
	html += '<title>' + title + '</title>';
	html += '</head><body style="font-family: Verdana">';

	html += '<h3>' + title + '</h3>';
	html += sprintf(textPrintableMinReqLevel, reqLevel) + '<br />';
	html += sprintf(textPrintableReqTalentPts, talentVars.pts) + '<br /><br />';

	var treeNums = getVisibleTrees();
	for(var i = 0; i < treeNums.length; ++i) {

		var treeNum = treeNums[i];
		var tree    = talentTrees[treeNum];
	
		if(tree.pts > 0) {

			html += '<b><u>' + sprintf(textPrintableTreeTalents, tree.name) + '</u></b> - ';
			html += sprintf(textPrintablePtsPerTree, tree.pts) + '</h3>';
			html += '<ul>';

			for(var talentNum = 0, len = tree.talents.length; talentNum < len; ++talentNum) {		
			
				var talent = tree.talents[talentNum];
	
				if(talent.pts > 0) {
					html += '<li><b>' + talent.name + '</b> - ' + sprintf(textTalentRank, talent.pts, talent.maxPts) + '</li>';
				}
			}
			html += '</ul>';
		}
	}

	if(!talentVars.pts)
		html += textPrintableDontWastePaper;

	html += '</body></html>';
	
	var win;
	win = window.open('', '', 'menubar=yes,status=yes,scrollbars=yes,resizable=yes,toolbar=no'),
	win.document.open();
	win.document.write(html);
	win.document.close();

	if(talentVars.pts)
		win.print();
}

}

var talentData_wenld36 = [
		
			{
				id:   "Holy",
				name: "Holy",
				talents: [
				
					{
						id:     1432,
						tier:   0,
						column: 1,
						name:  "Spiritual Focus",
						icon:  "spell_arcane_blink",
						
						ranks: [
						
							"Reduces the pushback suffered from damaging attacks while casting Flash of Light and Holy Light by 14%."
							,
							"Reduces the pushback suffered from damaging attacks while casting Flash of Light and Holy Light by 28%."
							,
							"Reduces the pushback suffered from damaging attacks while casting Flash of Light and Holy Light by 42%."
							,
							"Reduces the pushback suffered from damaging attacks while casting Flash of Light and Holy Light by 56%."
							,
							"Reduces the pushback suffered from damaging attacks while casting Flash of Light and Holy Light by 70%."
							
						]
					}
					,
					{
						id:     1463,
						tier:   0,
						column: 2,
						name:  "Seals of the Pure",
						icon:  "ability_thunderbolt",
						
						ranks: [
						
							"Increases the damage done by your Seal of Righteousness, Seal of Vengeance and Seal of Corruption and their Judgement effects by 3%."
							,
							"Increases the damage done by your Seal of Righteousness, Seal of Vengeance and Seal of Corruption and their Judgement effects by 6%."
							,
							"Increases the damage done by your Seal of Righteousness, Seal of Vengeance and Seal of Corruption and their Judgement effects by 9%."
							,
							"Increases the damage done by your Seal of Righteousness, Seal of Vengeance and Seal of Corruption and their Judgement effects by 12%."
							,
							"Increases the damage done by your Seal of Righteousness, Seal of Vengeance and Seal of Corruption and their Judgement effects by 15%."
							
						]
					}
					,
					{
						id:     1444,
						tier:   1,
						column: 0,
						name:  "Healing Light",
						icon:  "spell_holy_holybolt",
						
						ranks: [
						
							"Increases the amount healed by your Holy Light, Flash of Light and the effectiveness of Holy Shock spells by 4%."
							,
							"Increases the amount healed by your Holy Light, Flash of Light and the effectiveness of Holy Shock spells by 8%."
							,
							"Increases the amount healed by your Holy Light, Flash of Light and the effectiveness of Holy Shock spells by 12%."
							
						]
					}
					,
					{
						id:     1449,
						tier:   1,
						column: 1,
						name:  "Divine Intellect",
						icon:  "spell_nature_sleep",
						
						ranks: [
						
							"Increases your total Intellect by 2%."
							,
							"Increases your total Intellect by 4%."
							,
							"Increases your total Intellect by 6%."
							,
							"Increases your total Intellect by 8%."
							,
							"Increases your total Intellect by 10%."
							
						]
					}
					,
					{
						id:     1628,
						tier:   1,
						column: 2,
						name:  "Unyielding Faith",
						icon:  "spell_holy_unyieldingfaith",
						
						ranks: [
						
							"Reduces the duration of all Fear and Disorient effects by 15%."
							,
							"Reduces the duration of all Fear and Disorient effects by 30%."
							
						]
					}
					,
					{
						id:     1435,
						tier:   2,
						column: 0,
						name:  "Aura Mastery",
						icon:  "spell_holy_auramastery",
						
						ranks: [
						
							"Causes your Concentration Aura to make all affected targets immune to Silence and Interrupt effects and improve the effect of all other auras by 100%.  Lasts 10 sec."
							
						]
					}
					,
					{
						id:     1461,
						tier:   2,
						column: 1,
						name:  "Illumination",
						icon:  "spell_holy_greaterheal",
						
						ranks: [
						
							"After getting a critical effect from your Flash of Light, Holy Light, or Holy Shock heal spell you have a 20% chance to gain mana equal to 30% of the base cost of the spell."
							,
							"After getting a critical effect from your Flash of Light, Holy Light, or Holy Shock heal spell you have a 40% chance to gain mana equal to 30% of the base cost of the spell."
							,
							"After getting a critical effect from your Flash of Light, Holy Light, or Holy Shock heal spell you have a 60% chance to gain mana equal to 30% of the base cost of the spell."
							,
							"After getting a critical effect from your Flash of Light, Holy Light, or Holy Shock heal spell you have a 80% chance to gain mana equal to 30% of the base cost of the spell."
							,
							"After getting a critical effect from your Flash of Light, Holy Light, or Holy Shock heal spell you have a 100% chance to gain mana equal to 30% of the base cost of the spell."
							
						]
					}
					,
					{
						id:     1443,
						tier:   2,
						column: 2,
						name:  "Improved Lay on Hands",
						icon:  "spell_holy_layonhands",
						
						ranks: [
						
							"Grants the target of your Lay on Hands spell 10% reduced physical damage taken for 15 sec.  In addition, the cooldown for your Lay on Hands spell is reduced by 2 min."
							,
							"Grants the target of your Lay on Hands spell 20% reduced physical damage taken for 15 sec.  In addition, the cooldown for your Lay on Hands spell is reduced by 4 min."
							
						]
					}
					,
					{
						id:     1450,
						tier:   3,
						column: 0,
						name:  "Improved Concentration Aura",
						icon:  "spell_holy_mindsooth",
						
						ranks: [
						
							"Increases the effect of your Concentration Aura by an additional 5% and while any Aura is active reduces the duration of any Silence or Interrupt effect used against an affected group member by 10%.  The duration reduction does not stack with any other effects."
							,
							"Increases the effect of your Concentration Aura by an additional 10% and while any Aura is active reduces the duration of any Silence or Interrupt effect used against an affected group member by 20%.  The duration reduction does not stack with any other effects."
							,
							"Increases the effect of your Concentration Aura by an additional 15% and while any Aura is active reduces the duration of any Silence or Interrupt effect used against an affected group member by 30%.  The duration reduction does not stack with any other effects."
							
						]
					}
					,
					{
						id:     1446,
						tier:   3,
						column: 2,
						name:  "Improved Blessing of Wisdom",
						icon:  "spell_holy_sealofwisdom",
						
						ranks: [
						
							"Increases the effect of your Blessing of Wisdom spell by 10%."
							,
							"Increases the effect of your Blessing of Wisdom spell by 20%."
							
						]
					}
					,
					{
						id:     2198,
						tier:   3,
						column: 3,
						name:  "Blessed Hands",
						icon:  "ability_paladin_blessedhands",
						
						ranks: [
						
							"Reduces the mana cost of Hand of Freedom, Hand of Sacrifice and Hand of Salvation by 15%, increases the effectiveness of Hand of Salvation by 50% and the effectiveness of Hand of Sacrifice by an additional 5%."
							,
							"Reduces the mana cost of Hand of Freedom, Hand of Sacrifice and Hand of Salvation by 30%, increases the effectiveness of Hand of Salvation by 100% and the effectiveness of Hand of Sacrifice by an additional 10%."
							
						]
					}
					,
					{
						id:     1742,
						tier:   4,
						column: 0,
						name:  "Pure of Heart",
						icon:  "spell_holy_pureofheart",
						
						ranks: [
						
							"Reduces the duration of Curse, Disease and Poison effects by 15%."
							,
							"Reduces the duration of Curse, Disease and Poison effects by 30%."
							
						]
					}
					,
					{
						id:     1433,
						tier:   4,
						column: 1,
						name:  "Divine Favor",
						icon:  "spell_holy_heal",
						
							requires: 1461,
						
						ranks: [
						
							"When activated, gives your next Flash of Light, Holy Light, or Holy Shock spell a 100% critical effect chance."
							
						]
					}
					,
					{
						id:     1465,
						tier:   4,
						column: 2,
						name:  "Sanctified Light",
						icon:  "spell_holy_healingaura",
						
						ranks: [
						
							"Increases the critical effect chance of your Holy Light and Holy Shock spells by 2%."
							,
							"Increases the critical effect chance of your Holy Light and Holy Shock spells by 4%."
							,
							"Increases the critical effect chance of your Holy Light and Holy Shock spells by 6%."
							
						]
					}
					,
					{
						id:     1743,
						tier:   5,
						column: 0,
						name:  "Purifying Power",
						icon:  "spell_holy_purifyingpower",
						
						ranks: [
						
							"Reduces the mana cost of your Cleanse, Purify and Consecration spells by 5% and reduces the cooldown of your Exorcism and Holy Wrath spells by 17%."
							,
							"Reduces the mana cost of your Cleanse, Purify and Consecration spells by 10% and reduces the cooldown of your Exorcism and Holy Wrath spells by 33%."
							
						]
					}
					,
					{
						id:     1627,
						tier:   5,
						column: 2,
						name:  "Holy Power",
						icon:  "spell_holy_power",
						
						ranks: [
						
							"Increases the critical effect chance of your Holy spells by 1%."
							,
							"Increases the critical effect chance of your Holy spells by 2%."
							,
							"Increases the critical effect chance of your Holy spells by 3%."
							,
							"Increases the critical effect chance of your Holy spells by 4%."
							,
							"Increases the critical effect chance of your Holy spells by 5%."
							
						]
					}
					,
					{
						id:     1745,
						tier:   6,
						column: 0,
						name:  "Light's Grace",
						icon:  "spell_holy_lightsgrace",
						
						ranks: [
						
							"Gives your Holy Light spell a 33% chance to reduce the cast time of your next Holy Light spell by 0.5 sec.  This effect lasts 15 sec."
							,
							"Gives your Holy Light spell a 66% chance to reduce the cast time of your next Holy Light spell by 0.5 sec.  This effect lasts 15 sec."
							,
							"Gives your Holy Light spell a 100% chance to reduce the cast time of your next Holy Light spell by 0.5 sec.  This effect lasts 15 sec."
							
						]
					}
					,
					{
						id:     1502,
						tier:   6,
						column: 1,
						name:  "Holy Shock",
						icon:  "spell_holy_searinglight",
						
							requires: 1433,
						
						ranks: [
						
							"Blasts the target with Holy energy, causing 314 to 340 Holy damage to an enemy, or 481 to 519 healing to an ally."
							
						]
					}
					,
					{
						id:     1744,
						tier:   6,
						column: 2,
						name:  "Blessed Life",
						icon:  "spell_holy_blessedlife",
						
						ranks: [
						
							"All attacks against you have a 4% chance to cause half damage."
							,
							"All attacks against you have a 7% chance to cause half damage."
							,
							"All attacks against you have a 10% chance to cause half damage."
							
						]
					}
					,
					{
						id:     2190,
						tier:   7,
						column: 0,
						name:  "Sacred Cleansing",
						icon:  "ability_paladin_sacredcleansing",
						
						ranks: [
						
							"Your Cleanse spell has a 10% chance to increase the target's resistance to Disease, Magic and Poison by 30% for 10 sec."
							,
							"Your Cleanse spell has a 20% chance to increase the target's resistance to Disease, Magic and Poison by 30% for 10 sec."
							,
							"Your Cleanse spell has a 30% chance to increase the target's resistance to Disease, Magic and Poison by 30% for 10 sec."
							
						]
					}
					,
					{
						id:     1746,
						tier:   7,
						column: 2,
						name:  "Holy Guidance",
						icon:  "spell_holy_holyguidance",
						
						ranks: [
						
							"Increases your spell power by 4% of your total Intellect."
							,
							"Increases your spell power by 8% of your total Intellect."
							,
							"Increases your spell power by 12% of your total Intellect."
							,
							"Increases your spell power by 16% of your total Intellect."
							,
							"Increases your spell power by 20% of your total Intellect."
							
						]
					}
					,
					{
						id:     1747,
						tier:   8,
						column: 0,
						name:  "Divine Illumination",
						icon:  "spell_holy_divineillumination",
						
						ranks: [
						
							"Reduces the mana cost of all spells by 50% for 15 sec."
							
						]
					}
					,
					{
						id:     2199,
						tier:   8,
						column: 2,
						name:  "Judgements of the Pure",
						icon:  "ability_paladin_judgementofthepure",
						
						ranks: [
						
							"Increases the damage done by your Seal and Judgement spells by 5%, and your Judgement spells increase your casting and melee haste by 3% for 1 min."
							,
							"Increases the damage done by your Seal and Judgement spells by 10%, and your Judgement spells increase your casting and melee haste by 6% for 1 min."
							,
							"Increases the damage done by your Seal and Judgement spells by 15%, and your Judgement spells increase your casting and melee haste by 9% for 1 min."
							,
							"Increases the damage done by your Seal and Judgement spells by 20%, and your Judgement spells increase your casting and melee haste by 12% for 1 min."
							,
							"Increases the damage done by your Seal and Judgement spells by 25%, and your Judgement spells increase your casting and melee haste by 15% for 1 min."
							
						]
					}
					,
					{
						id:     2193,
						tier:   9,
						column: 1,
						name:  "Infusion of Light",
						icon:  "ability_paladin_infusionoflight",
						
							requires: 1502,
						
						ranks: [
						
							"Your Holy Shock critical hits reduce the cast time of your next Flash of Light by 0.75 sec or increase the critical chance of your next Holy Light by 10%."
							,
							"Your Holy Shock critical hits reduce the cast time of your next Flash of Light by 1.5 sec or increase the critical chance of your next Holy Light by 20%."
							
						]
					}
					,
					{
						id:     2191,
						tier:   9,
						column: 2,
						name:  "Enlightened Judgements",
						icon:  "ability_paladin_enlightenedjudgements",
						
						ranks: [
						
							"Increases the range of your Judgement of Light and Judgement of Wisdom spells by 15 yards and increases your chance to hit by 2%."
							,
							"Increases the range of your Judgement of Light and Judgement of Wisdom spells by 30 yards and increases your chance to hit by 4%."
							
						]
					}
					,
					{
						id:     2192,
						tier:   10,
						column: 1,
						name:  "Beacon of Light",
						icon:  "ability_paladin_beaconoflight",
						
						ranks: [
						
							"The target becomes a Beacon of Light to all targets within a 60 yard radius.  Any heals you cast on those targets will also heal the Beacon for 100% of the amount healed.  Only one target can be the Beacon of Light at a time. Lasts 1 min."
							
						]
					}
					
				]
			}
			,
			{
				id:   "Protection",
				name: "Protection",
				talents: [
				
					{
						id:     1442,
						tier:   0,
						column: 1,
						name:  "Divinity",
						icon:  "spell_holy_blindingheal",
						
						ranks: [
						
							"Increases all healing done by you and all healing effects on you by 1%."
							,
							"Increases all healing done by you and all healing effects on you by 2%."
							,
							"Increases all healing done by you and all healing effects on you by 3%."
							,
							"Increases all healing done by you and all healing effects on you by 4%."
							,
							"Increases all healing done by you and all healing effects on you by 5%."
							
						]
					}
					,
					{
						id:     2185,
						tier:   0,
						column: 2,
						name:  "Divine Strength",
						icon:  "ability_golemthunderclap",
						
						ranks: [
						
							"Increases your total Strength by 3%."
							,
							"Increases your total Strength by 6%."
							,
							"Increases your total Strength by 9%."
							,
							"Increases your total Strength by 12%."
							,
							"Increases your total Strength by 15%."
							
						]
					}
					,
					{
						id:     1748,
						tier:   1,
						column: 0,
						name:  "Stoicism",
						icon:  "spell_holy_stoicism",
						
						ranks: [
						
							"Reduces the duration of all Stun effects by an additional 10% and reduces the chance your helpful spells and damage over time effects will be dispelled by an additional 10%."
							,
							"Reduces the duration of all Stun effects by an additional 20% and reduces the chance your helpful spells and damage over time effects will be dispelled by an additional 20%."
							,
							"Reduces the duration of all Stun effects by an additional 30% and reduces the chance your helpful spells and damage over time effects will be dispelled by an additional 30%."
							
						]
					}
					,
					{
						id:     1425,
						tier:   1,
						column: 1,
						name:  "Guardian's Favor",
						icon:  "spell_holy_sealofprotection",
						
						ranks: [
						
							"Reduces the cooldown of your Hand of Protection by 60 sec and increases the duration of your Hand of Freedom by 0 min."
							,
							"Reduces the cooldown of your Hand of Protection by 2 min and increases the duration of your Hand of Freedom by 4 sec."
							
						]
					}
					,
					{
						id:     1629,
						tier:   1,
						column: 2,
						name:  "Anticipation",
						icon:  "spell_magic_lesserinvisibilty",
						
						ranks: [
						
							"Increases your chance to dodge by 1%."
							,
							"Increases your chance to dodge by 2%."
							,
							"Increases your chance to dodge by 3%."
							,
							"Increases your chance to dodge by 4%."
							,
							"Increases your chance to dodge by 5%."
							
						]
					}
					,
					{
						id:     2280,
						tier:   2,
						column: 0,
						name:  "Divine Sacrifice",
						icon:  "spell_holy_powerwordbarrier",
						
						ranks: [
						
							"30% of all damage taken by party or raid members within 30 yards is redirected to the Paladin (up to a maximum of 150% of the Paladin's health).  Lasts 10 sec."
							
						]
					}
					,
					{
						id:     1501,
						tier:   2,
						column: 1,
						name:  "Improved Righteous Fury",
						icon:  "spell_holy_sealoffury",
						
						ranks: [
						
							"While Righteous Fury is active, all damage taken is reduced by 2%."
							,
							"While Righteous Fury is active, all damage taken is reduced by 4%."
							,
							"While Righteous Fury is active, all damage taken is reduced by 6%."
							
						]
					}
					,
					{
						id:     1423,
						tier:   2,
						column: 2,
						name:  "Toughness",
						icon:  "spell_holy_devotion",
						
						ranks: [
						
							"Increases your armor value from items by 2% and reduces the duration of all movement slowing effects by 6%."
							,
							"Increases your armor value from items by 4% and reduces the duration of all movement slowing effects by 12%."
							,
							"Increases your armor value from items by 6% and reduces the duration of all movement slowing effects by 18%."
							,
							"Increases your armor value from items by 8% and reduces the duration of all movement slowing effects by 24%."
							,
							"Increases your armor value from items by 10% and reduces the duration of all movement slowing effects by 30%."
							
						]
					}
					,
					{
						id:     2281,
						tier:   3,
						column: 0,
						name:  "Divine Guardian",
						icon:  "spell_holy_powerwordbarrier",
						
							requires: 2280,
						
						ranks: [
						
							"Improves the effectiveness of your Divine Sacrifice spell by an additional 5% and increases the duration of your Sacred Shield by 50% and the amount absorbed by 10%."
							,
							"Improves the effectiveness of your Divine Sacrifice spell by an additional 10% and increases the duration of your Sacred Shield by 100% and the amount absorbed by 20%."
							
						]
					}
					,
					{
						id:     1521,
						tier:   3,
						column: 1,
						name:  "Improved Hammer of Justice",
						icon:  "spell_holy_sealofmight",
						
						ranks: [
						
							"Decreases the cooldown of your Hammer of Justice spell by 10 sec."
							,
							"Decreases the cooldown of your Hammer of Justice spell by 20 sec."
							
						]
					}
					,
					{
						id:     1422,
						tier:   3,
						column: 2,
						name:  "Improved Devotion Aura",
						icon:  "spell_holy_devotionaura",
						
						ranks: [
						
							"Increases the armor bonus of your Devotion Aura by 17% and increases the amount healed on any target affected by any of your Auras by 2%."
							,
							"Increases the armor bonus of your Devotion Aura by 34% and increases the amount healed on any target affected by any of your Auras by 4%."
							,
							"Increases the armor bonus of your Devotion Aura by 50% and increases the amount healed on any target affected by any of your Auras by 6%."
							
						]
					}
					,
					{
						id:     1431,
						tier:   4,
						column: 1,
						name:  "Blessing of Sanctuary",
						icon:  "spell_nature_lightningshield",
						
						ranks: [
						
							"Places a Blessing on the friendly target, reducing damage taken from all sources by 3% for 10 min and increasing stamina by 10%.  In addition, when the target blocks, parries, or dodges a melee attack the target will gain 2% of maximum displayed mana.  Players may only have one Blessing on them per Paladin at any one time."
							
						]
					}
					,
					{
						id:     1426,
						tier:   4,
						column: 2,
						name:  "Reckoning",
						icon:  "spell_holy_blessingofstrength",
						
						ranks: [
						
							"Gives you a 2% chance after being hit by any damaging attack that the next 4 weapon swings within 8 sec will generate an additional attack."
							,
							"Gives you a 4% chance after being hit by any damaging attack that the next 4 weapon swings within 8 sec will generate an additional attack."
							,
							"Gives you a 6% chance after being hit by any damaging attack that the next 4 weapon swings within 8 sec will generate an additional attack."
							,
							"Gives you a 8% chance after being hit by any damaging attack that the next 4 weapon swings within 8 sec will generate an additional attack."
							,
							"Gives you a 10% chance after blocking or being hit by any damaging attack that the next 4 weapon swings within 8 sec will generate an additional attack."
							
						]
					}
					,
					{
						id:     1750,
						tier:   5,
						column: 0,
						name:  "Sacred Duty",
						icon:  "spell_holy_divineintervention",
						
						ranks: [
						
							"Increases your total Stamina by 4%, reduces the cooldown of your Divine Shield and Divine Protection spells by 30 sec."
							,
							"Increases your total Stamina by 8%, reduces the cooldown of your Divine Shield and Divine Protection spells by 60 sec."
							
						]
					}
					,
					{
						id:     1429,
						tier:   5,
						column: 2,
						name:  "One-Handed Weapon Specialization",
						icon:  "inv_sword_20",
						
						ranks: [
						
							"Increases all damage you deal when a one-handed melee weapon is equipped by 4%."
							,
							"Increases all damage you deal when a one-handed melee weapon is equipped by 7%."
							,
							"Increases all damage you deal when a one-handed melee weapon is equipped by 10%."
							
						]
					}
					,
					{
						id:     2282,
						tier:   6,
						column: 0,
						name:  "Spiritual Attunement",
						icon:  "spell_holy_revivechampion",
						
						ranks: [
						
							"A passive ability that gives the Paladin mana when healed by other friendly targets' spells.  The amount of mana gained is equal to 5% of the amount healed."
							,
							"A passive ability that gives the Paladin mana when healed by other friendly targets' spells.  The amount of mana gained is equal to 10% of the amount healed."
							
						]
					}
					,
					{
						id:     1430,
						tier:   6,
						column: 1,
						name:  "Holy Shield",
						icon:  "spell_holy_blessingofprotection",
						
							requires: 1431,
						
						ranks: [
						
							"Increases chance to block by 30% for 10 sec and deals 79 Holy damage for each attack blocked while active.  Each block expends a charge.  8 charges."
							
						]
					}
					,
					{
						id:     1751,
						tier:   6,
						column: 2,
						name:  "Ardent Defender",
						icon:  "spell_holy_ardentdefender",
						
						ranks: [
						
							"Damage that takes you below 35% health is reduced by 10%.  In addition, attacks which would otherwise kill you cause you to be healed by up to 10% of your maximum health (amount healed based on defense).  This healing effect cannot occur more often than once every 2 min."
							,
							"Damage that takes you below 35% health is reduced by 20%.  In addition, attacks which would otherwise kill you cause you to be healed by up to 20% of your maximum health (amount healed based on defense).  This healing effect cannot occur more often than once every 2 min."
							,
							"Damage that takes you below 35% health is reduced by 30%.  In addition, attacks which would otherwise kill you cause you to be healed by up to 30% of your maximum health (amount healed based on defense).  This healing effect cannot occur more often than once every 2 min."
							
						]
					}
					,
					{
						id:     1421,
						tier:   7,
						column: 0,
						name:  "Redoubt",
						icon:  "ability_defend",
						
						ranks: [
						
							"Increases your block value by 10% and damaging melee and ranged attacks against you have a 10% chance to increase your chance to block by 10%.  Lasts 10 sec or 5 blocks."
							,
							"Increases your block value by 20% and damaging melee and ranged attacks against you have a 10% chance to increase your chance to block by 20%.  Lasts 10 sec or 5 blocks."
							,
							"Increases your block value by 30% and damaging melee and ranged attacks against you have a 10% chance to increase your chance to block by 30%.  Lasts 10 sec or 5 blocks."
							
						]
					}
					,
					{
						id:     1753,
						tier:   7,
						column: 2,
						name:  "Combat Expertise",
						icon:  "spell_holy_weaponmastery",
						
						ranks: [
						
							"Increases your expertise by 2, total Stamina and chance to critically hit by 2%."
							,
							"Increases your expertise by 4, total Stamina and chance to critically hit by 4%."
							,
							"Increases your expertise by 6, total Stamina and chance to critically hit by 6%."
							
						]
					}
					,
					{
						id:     2195,
						tier:   8,
						column: 0,
						name:  "Touched by the Light",
						icon:  "ability_paladin_touchedbylight",
						
						ranks: [
						
							"Increases your spell power by an amount equal to 10% of your Stamina and increases the amount healed by your critical heals by 10%."
							,
							"Increases your spell power by an amount equal to 20% of your Stamina and increases the amount healed by your critical heals by 20%."
							,
							"Increases your spell power by an amount equal to 30% of your Stamina and increases the amount healed by your critical heals by 30%."
							
						]
					}
					,
					{
						id:     1754,
						tier:   8,
						column: 1,
						name:  "Avenger's Shield",
						icon:  "spell_holy_avengersshield",
						
							requires: 1430,
						
						ranks: [
						
							"Hurls a holy shield at the enemy, dealing 442 to 538 Holy damage, Dazing them and then jumping to additional nearby enemies.  Affects 3 total targets.  Lasts 10 sec."
							
						]
					}
					,
					{
						id:     2194,
						tier:   8,
						column: 2,
						name:  "Guarded by the Light",
						icon:  "ability_paladin_gaurdedbythelight",
						
						ranks: [
						
							"Reduces spell damage taken by 3% and gives a 50% chance to refresh the duration of your Divine Plea when you hit an enemy.  In addition, your Divine Plea spell is 50% less likely to be dispelled."
							,
							"Reduces spell damage taken by 6% and gives a 100% chance to refresh the duration of your Divine Plea when you hit an enemy.  In addition, your Divine Plea spell is 100% less likely to be dispelled."
							
						]
					}
					,
					{
						id:     2204,
						tier:   9,
						column: 1,
						name:  "Shield of the Templar",
						icon:  "ability_paladin_shieldofthetemplar",
						
							requires: 1754,
						
						ranks: [
						
							"Reduces all damage taken by 1% and grants your Avenger's Shield a 33% chance to silence your targets for 3 sec."
							,
							"Reduces all damage taken by 2% and grants your Avenger's Shield a 66% chance to silence your targets for 3 sec."
							,
							"Reduces all damage taken by 3% and grants your Avenger's Shield a 100% chance to silence your targets for 3 sec."
							
						]
					}
					,
					{
						id:     2200,
						tier:   9,
						column: 2,
						name:  "Judgements of the Just",
						icon:  "ability_paladin_judgementsofthejust",
						
						ranks: [
						
							"Reduces the cooldown of your Hammer of Justice by 10 sec, increases the duration of your Seal of Justice effect by 0.5 sec and your Judgement spells also reduce the melee attack speed of the target by 10%."
							,
							"Reduces the cooldown of your Hammer of Justice by 20 sec, increases the duration of your Seal of Justice effect by 1 sec and your Judgement spells also reduce the melee attack speed of the target by 20%."
							
						]
					}
					,
					{
						id:     2196,
						tier:   10,
						column: 1,
						name:  "Hammer of the Righteous",
						icon:  "ability_paladin_hammeroftherighteous",
						
						ranks: [
						
							"Hammer the current target and up to 2 additional nearby targets, causing 4 times your main hand damage per second as Holy damage."
							
						]
					}
					
				]
			}
			,
			{
				id:   "Retribution",
				name: "Retribution",
				talents: [
				
					{
						id:     1403,
						tier:   0,
						column: 1,
						name:  "Deflection",
						icon:  "ability_parry",
						
						ranks: [
						
							"Increases your Parry chance by 1%."
							,
							"Increases your Parry chance by 2%."
							,
							"Increases your Parry chance by 3%."
							,
							"Increases your Parry chance by 4%."
							,
							"Increases your Parry chance by 5%."
							
						]
					}
					,
					{
						id:     1407,
						tier:   0,
						column: 2,
						name:  "Benediction",
						icon:  "spell_frost_windwalkon",
						
						ranks: [
						
							"Reduces the mana cost of all instant cast spells by 2%."
							,
							"Reduces the mana cost of all instant cast spells by 4%."
							,
							"Reduces the mana cost of all instant cast spells by 6%."
							,
							"Reduces the mana cost of all instant cast spells by 8%."
							,
							"Reduces the mana cost of all instant cast spells by 10%."
							
						]
					}
					,
					{
						id:     1631,
						tier:   1,
						column: 0,
						name:  "Improved Judgements",
						icon:  "spell_holy_righteousfury",
						
						ranks: [
						
							"Decreases the cooldown of your Judgement spells by 1 sec."
							,
							"Decreases the cooldown of your Judgement spells by 2 sec."
							
						]
					}
					,
					{
						id:     1464,
						tier:   1,
						column: 1,
						name:  "Heart of the Crusader",
						icon:  "spell_holy_holysmite",
						
						ranks: [
						
							"In addition to the normal effect, your Judgement spells will also increase the critical strike chance of all attacks made against that target by an additional 1%."
							,
							"In addition to the normal effect, your Judgement spells will also increase the critical strike chance of all attacks made against that target by an additional 2%."
							,
							"In addition to the normal effect, your Judgement spells will also increase the critical strike chance of all attacks made against that target by an additional 3%."
							
						]
					}
					,
					{
						id:     1401,
						tier:   1,
						column: 2,
						name:  "Improved Blessing of Might",
						icon:  "spell_holy_fistofjustice",
						
						ranks: [
						
							"Increases the attack power bonus of your Blessing of Might by 12%."
							,
							"Increases the attack power bonus of your Blessing of Might by 25%."
							
						]
					}
					,
					{
						id:     1633,
						tier:   2,
						column: 0,
						name:  "Vindication",
						icon:  "spell_holy_vindication",
						
						ranks: [
						
							"Gives the Paladin's damaging attacks a chance to reduce the target's attack power by 23 for 10 sec."
							,
							"Gives the Paladin's damaging attacks a chance to reduce the target's attack power by 46 for 10 sec."
							
						]
					}
					,
					{
						id:     1411,
						tier:   2,
						column: 1,
						name:  "Conviction",
						icon:  "spell_holy_retributionaura",
						
						ranks: [
						
							"Increases your chance to get a critical strike with all spells and attacks by 1%."
							,
							"Increases your chance to get a critical strike with all spells and attacks by 2%."
							,
							"Increases your chance to get a critical strike with all spells and attacks by 3%."
							,
							"Increases your chance to get a critical strike with all spells and attacks by 4%."
							,
							"Increases your chance to get a critical strike with all spells and attacks by 5%."
							
						]
					}
					,
					{
						id:     1481,
						tier:   2,
						column: 2,
						name:  "Seal of Command",
						icon:  "ability_warrior_innerrage",
						
						ranks: [
						
							"All melee attacks deal 3 to 4 additional Holy damage.  Lasts 30 min.<br/><br/>Unleashing this Seal's energy will judge an enemy, instantly causing 4 to 4 Holy damage."
							
						]
					}
					,
					{
						id:     1634,
						tier:   2,
						column: 3,
						name:  "Pursuit of Justice",
						icon:  "spell_holy_persuitofjustice",
						
						ranks: [
						
							"Reduces the duration of all Disarm effects by 25% and increases movement and mounted movement speed by 8%.  This does not stack with other movement speed increasing effects."
							,
							"Reduces the duration of all Disarm effects by 50% and increases movement and mounted movement speed by 15%.  This does not stack with other movement speed increasing effects."
							
						]
					}
					,
					{
						id:     1632,
						tier:   3,
						column: 0,
						name:  "Eye for an Eye",
						icon:  "spell_holy_eyeforaneye",
						
						ranks: [
						
							"All criticals against you cause 5% of the damage taken to the attacker as well.  The damage caused by Eye for an Eye will not exceed 50% of the Paladin's total health."
							,
							"All criticals against you cause 10% of the damage taken to the attacker as well.  The damage caused by Eye for an Eye will not exceed 50% of the Paladin's total health."
							
						]
					}
					,
					{
						id:     1761,
						tier:   3,
						column: 2,
						name:  "Sanctity of Battle",
						icon:  "spell_holy_holysmite",
						
						ranks: [
						
							"Increases your chance to critically hit with all spells and attacks by 1% and increases the damage caused by Exorcism and Crusader Strike by 5%."
							,
							"Increases your chance to critically hit with all spells and attacks by 2% and increases the damage caused by Exorcism and Crusader Strike by 10%."
							,
							"Increases your chance to critically hit with all spells and attacks by 3% and increases the damage caused by Exorcism and Crusader Strike by 15%."
							
						]
					}
					,
					{
						id:     1755,
						tier:   3,
						column: 3,
						name:  "Crusade",
						icon:  "spell_holy_crusade",
						
						ranks: [
						
							"Increases all damage caused by 1% and all damage caused against Humanoids, Demons, Undead and Elementals by an additional 1%."
							,
							"Increases all damage caused by 2% and all damage caused against Humanoids, Demons, Undead and Elementals by an additional 2%."
							,
							"Increases all damage caused by 3% and all damage caused against Humanoids, Demons, Undead and Elementals by an additional 3%."
							
						]
					}
					,
					{
						id:     1410,
						tier:   4,
						column: 0,
						name:  "Two-Handed Weapon Specialization",
						icon:  "inv_hammer_04",
						
						ranks: [
						
							"Increases the damage you deal with two-handed melee weapons by 2%."
							,
							"Increases the damage you deal with two-handed melee weapons by 4%."
							,
							"Increases the damage you deal with two-handed melee weapons by 6%."
							
						]
					}
					,
					{
						id:     1756,
						tier:   4,
						column: 2,
						name:  "Sanctified Retribution",
						icon:  "spell_holy_mindvision",
						
						ranks: [
						
							"Increases the damage caused by Retribution Aura by 50% and all damage caused by friendly targets affected by any of your Auras is increased by 3%."
							
						]
					}
					,
					{
						id:     1402,
						tier:   5,
						column: 1,
						name:  "Vengeance",
						icon:  "ability_racial_avatar",
						
							requires: 1411,
						
						ranks: [
						
							"Gives you a 1% bonus to Physical and Holy damage you deal for 30 sec after dealing a critical strike from a weapon swing, spell, or ability.  This effect stacks up to 3 times."
							,
							"Gives you a 2% bonus to Physical and Holy damage you deal for 30 sec after dealing a critical strike from a weapon swing, spell, or ability.  This effect stacks up to 3 times."
							,
							"Gives you a 3% bonus to Physical and Holy damage you deal for 30 sec after dealing a critical strike from a weapon swing, spell, or ability.  This effect stacks up to 3 times."
							
						]
					}
					,
					{
						id:     1757,
						tier:   5,
						column: 2,
						name:  "Divine Purpose",
						icon:  "spell_holy_divinepurpose",
						
						ranks: [
						
							"Reduces your chance to be hit by spells and ranged attacks by 2% and gives your Hand of Freedom spell a 50% chance to remove any Stun effects on the target."
							,
							"Reduces your chance to be hit by spells and ranged attacks by 4% and gives your Hand of Freedom spell a 100% chance to remove any Stun effects on the target."
							
						]
					}
					,
					{
						id:     2176,
						tier:   6,
						column: 0,
						name:  "The Art of War",
						icon:  "ability_paladin_artofwar",
						
						ranks: [
						
							"Increases the damage of your Judgement, Crusader Strike and Divine Storm abilities by 5% and when your melee attacks critically hit the cast time of your next Flash of Light or Exorcism is reduced by 0.75 sec."
							,
							"Increases the damage of your Judgement, Crusader Strike and Divine Storm abilities by 10% and when your melee attacks critically hit your next Flash of Light  or Exorcism spell becomes instant cast."
							
						]
					}
					,
					{
						id:     1441,
						tier:   6,
						column: 1,
						name:  "Repentance",
						icon:  "spell_holy_prayerofhealing",
						
						ranks: [
						
							"Puts the enemy target in a state of meditation, incapacitating them for up to 1 min.  Any damage caused will awaken the target.  Usable against Demons, Dragonkin, Giants, Humanoids and Undead."
							
						]
					}
					,
					{
						id:     1758,
						tier:   6,
						column: 2,
						name:  "Judgements of the Wise",
						icon:  "ability_paladin_judgementofthewise",
						
						ranks: [
						
							"Your damaging Judgement spells have a 33% chance to grant the Replenishment effect to up to 10 party or raid members mana regeneration equal to 1% of their maximum mana per 5 sec for 15 sec, and to immediately grant you 25% of your base mana."
							,
							"Your damaging Judgement spells have a 66% chance to grant the Replenishment effect to up to 10 party or raid members mana regeneration equal to 1% of their maximum mana per 5 sec for 15 sec, and to immediately grant you 25% of your base mana."
							,
							"Your damaging Judgement spells have a 100% chance to grant the Replenishment effect to up to 10 party or raid members mana regeneration equal to 1% of their maximum mana per 5 sec for 15 sec, and to immediately grant you 25% of your base mana."
							
						]
					}
					,
					{
						id:     1759,
						tier:   7,
						column: 1,
						name:  "Fanaticism",
						icon:  "spell_holy_fanaticism",
						
							requires: 1441,
						
						ranks: [
						
							"Increases the critical strike chance of all Judgements capable of a critical hit by 6% and reduces threat caused by all actions by 10% except when under the effects of Righteous Fury."
							,
							"Increases the critical strike chance of all Judgements capable of a critical hit by 12% and reduces threat caused by all actions by 20% except when under the effects of Righteous Fury."
							,
							"Increases the critical strike chance of all Judgements capable of a critical hit by 18% and reduces threat caused by all actions by 30% except when under the effects of Righteous Fury."
							
						]
					}
					,
					{
						id:     2147,
						tier:   7,
						column: 2,
						name:  "Sanctified Wrath",
						icon:  "ability_paladin_sanctifiedwrath",
						
						ranks: [
						
							"Increases the critical strike chance of Hammer of Wrath by 25%, reduces the cooldown of Avenging Wrath by 30 secs and while affected by Avenging Wrath 25% of all damage caused bypasses damage reduction effects."
							,
							"Increases the critical strike chance of Hammer of Wrath by 50%, reduces the cooldown of Avenging Wrath by 60 secs and while affected by Avenging Wrath 50% of all damage caused bypasses damage reduction effects."
							
						]
					}
					,
					{
						id:     2148,
						tier:   8,
						column: 0,
						name:  "Swift Retribution",
						icon:  "ability_paladin_swiftretribution",
						
						ranks: [
						
							"Your auras also increase casting, ranged and melee attack speeds by 1%."
							,
							"Your auras also increase casting, ranged and melee attack speeds by 2%."
							,
							"Your auras also increase casting, ranged and melee attack speeds by 3%."
							
						]
					}
					,
					{
						id:     1823,
						tier:   8,
						column: 1,
						name:  "Crusader Strike",
						icon:  "spell_holy_crusaderstrike",
						
						ranks: [
						
							"An instant strike that causes 75% weapon damage."
							
						]
					}
					,
					{
						id:     2179,
						tier:   8,
						column: 2,
						name:  "Sheath of Light",
						icon:  "ability_paladin_sheathoflight",
						
						ranks: [
						
							"Increases your spell power by an amount equal to 10% of your attack power and your critical healing spells heal the target for 20% of the healed amount over 12 seconds."
							,
							"Increases your spell power by an amount equal to 20% of your attack power and your critical healing spells heal the target for 40% of the healed amount over 12 seconds."
							,
							"Increases your spell power by an amount equal to 30% of your attack power and your critical healing spells heal the target for 60% of the healed amount over 12 seconds."
							
						]
					}
					,
					{
						id:     2149,
						tier:   9,
						column: 1,
						name:  "Righteous Vengeance",
						icon:  "ability_paladin_righteousvengeance",
						
						ranks: [
						
							"When your Judgement, Crusader Strike and Divine Storm spells deal a critical strike, your target will take 10% additional damage over 8 sec."
							,
							"When your Judgement, Crusader Strike and Divine Storm spells deal a critical strike, your target will take 20% additional damage over 8 sec."
							,
							"When your Judgement, Crusader Strike and Divine Storm spells deal a critical strike, your target will take 30% additional damage over 8 sec."
							
						]
					}
					,
					{
						id:     2150,
						tier:   10,
						column: 1,
						name:  "Divine Storm",
						icon:  "ability_paladin_divinestorm",
						
						ranks: [
						
							"An instant weapon attack that causes 110% of weapon damage to up to 4 enemies within 8 yards.  The Divine Storm heals up to 3 party or raid members totaling 25% of the damage caused."
							
						]
					}
					
				]
			}
			
		];

		var petData_wenld36 = null;
		
	
		var textTalentStrSingle = "Requires {0} point in {1}.";
		var textTalentStrPlural = "Requires {0} points in {1}.";
		var textTalentRank = "Rank {0}/{1}";
		var textTalentNextRank = "Next Rank";
		var textTalentReqTreeTalents = "Requires {0} points in {1} Talents.";
		var textPrintableClassTalents = "{0} Talents";
		var textPrintableMinReqLevel = "Minimum Required Level: {0}";
		var textPrintableReqTalentPts = "Required Talent Points: {0}";
		var textPrintableTreeTalents = "{0} Talents";
		var textPrintablePtsPerTree = "{0} point(s)";
		var textPrintableDontWastePaper = "Don't waste paper!";

