var breadcrumbs = new Array();
if (document.implementation && document.implementation.createDocument) {
//
// Define extras for FireFox to supoort .xml and loadXML
//
try {
Document.prototype.__defineGetter__("xml",function() {
return (new XMLSerializer()).serializeToString(this);
}
)
} catch (e) {
}
try {
Document.prototype.loadXML = function(s) {
var domParser = new DOMParser();
var doc2 = domParser.parseFromString(s,"text/xml");
while (this.hasChildNodes()){
this.removeChild(this.lastChild);
}
for (var i = 0; i != doc2.childNodes.length; ++i){
this.appendChild(this.importNode(doc2.childNodes[i],true));
}
return true;
}
} catch (e) {
}
}
function CreateDOM() {
var dom = null;
if (document.implementation && document.implementation.createDocument) {
dom = document.implementation.createDocument("", "", null);
} else if (window.ActiveXObject) {
dom = new ActiveXObject("Microsoft.XMLDOM");
}
return dom;
}
var submenuItems = new Array();
//
// AddSubmenuItem
////////////////////////////////////////////////////////////////////////////////////
function AddSubmenuItem(name, url, isAdmin) {
var o = new Object();
o.name = name;
o.url = url;
o.isAdmin = (isAdmin == true || isAdmin > 0)? true : false;
submenuItems[submenuItems.length] = o;
}
var overlaySeed = parseInt(Math.random() * 3);
//
// RenderBreadcrumbs
////////////////////////////////////////////////////////////////////////////////////
function RenderBreadcrumbs() {
var isIE = false;
if (!document.implementation || !document.implementation.createDocument) {
isIE = true;
}
var e = document.getElementById("breadcrumbsTwo");
if (!e) {
alert("Failed to locate breadcrumbsTwo");
return;
}
if (!breadcrumbs.length) {
e.style.display = 'none';
// try { urchinTracker(""); } catch (e) {;}
return;
}
var width = (isIE)? 565 : 545;
var name = breadcrumbs[breadcrumbs.length - 1].name;
if (name.length > 30) {
name = name.substring(0, 27) + '...';
}
var s = '';
var r = overlaySeed;
if (r == 0) {
s += '

';
} else if (r == 1) {
s += '
';
} else {
s += '
';
}
s += '
';
s += '';
s += name;
s += '
';
s += '';
s += '
';
if (breadcrumbs.length > 1 || submenuItems.length > 0) {
s += '';
var bcs = "";
for (var i = 0; i < breadcrumbs.length; ++i) {
var bc = breadcrumbs[i];
if (bc.url) {
s += '
' + bc.name + '';
bcs += bc.name;
} else {
s += bc.name;
bcs += bc.name;
}
if (i != breadcrumbs.length - 1) {
s += ' / ';
bcs += ' / ';
}
}
// try { urchinTracker(bcs); } catch (e2) {;}
s += '
';
s += '';
for (var i = 0; i < submenuItems.length; ++i) {
var si = submenuItems[i];
if (i) {
s += ' | ';
}
if (si.url) {
if (si.url.indexOf("javascript:") != 0) {
url = 'javascript:GoTo(\'' + si.url + '\');';
} else {
url = si.url;
}
s += '
' + si.name + '';
} else {
s += '
' + si.name + '';
}
}
s += '
';
s += '
';
}
s += '';
s += '
';
s += '
';
e.innerHTML = s;
e.style.marginLeft = '-20px';
e.style.marginTop = '-29px';
if (isIE) {
e.style.position = 'relative';
e.style.marginTop = '-32px';
e.style.width = '565px';
}
e.style.display = 'block';
}
//
// XMLRequest
// cross browser XMLHTTPRequest
////////////////////////////////////////////////////////////////////////////////////
var __pendingRequests = new Array();
var __xmlRequest = null;
function ProcessPendingRequests() {
if (__pendingRequests.length) {
if (!__xmlRequest) {
__xmlRequest = __pendingRequests[0];
__xmlRequest.request.onreadystatechange = XMLRequestReadyStateChange;
__xmlRequest.request.send(__xmlRequest.postData);
var n = new Array();
for (var i = 1; i < __pendingRequests.length; ++i) {
n[n.length] = __pendingRequests[i];
}
__pendingRequests = n;
}
setTimeout("ProcessPendingRequests()", 100);
}
}
function XMLRequest(url, callback, errorCallback, additionalRequestData) {
var q = url.indexOf("?");
var pageUrl = (q != -1)? url.substring(0, q) : url;
var postData = (q != -1)? url.substring(q + 1, url.length) : "";
var postVariables = new Array();
postData = postData.split("&");
for (var i = 0; i < postData.length; ++i) {
if (postData[i].indexOf("=") != -1) {
var nameAndValue = postData[i].split("=");
postVariables[nameAndValue[0]] = nameAndValue[1];
}
}
if (additionalRequestData) {
for (a in additionalRequestData) {
postVariables[a] = additionalRequestData[a];
}
}
var boundary = "d4wnsp1r3XMLHttpRequest";
var xmlRequest = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xmlRequest.open("POST", pageUrl, (callback)? true : false);
xmlRequest.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
var postData = "";
for (a in postVariables) {
if (a.indexOf("_") == 0) { continue; }
postData += '--' + boundary + '\r\n';
postData += 'Content-Disposition: form-data; name="' + a + '"\r\n\r\n';
postData += postVariables[a] + '\r\n';
}
postData += '--' + boundary;
if (callback) {
var r = new Object();
r.url = url;
r.request = xmlRequest;
r.callback = callback;
r.errorCallback = errorCallback;
r.postData = postData;
__pendingRequests[__pendingRequests.length] = r;
ProcessPendingRequests();
} else {
xmlRequest.send(postData);
if (xmlRequest.status != 200) {
alert("Error executing XMLRequest : " + xmlRequest.statusText + " (" + url + ")");
return '';
}
return xmlRequest.responseText;
}
}
function XMLRequestReadyStateChange() {
var r = __xmlRequest.request;
if (r.readyState == 4) {
if (r.status == 200) {
__xmlRequest.callback(r.responseText);
__xmlRequest = null;
} else {
if (__xmlRequest.errorCallback) {
__xmlRequest.errorCallback(r.status, r.statusText)
} else {
alert("Error executing XMLRequest : " + r.statusText + " (" + __xmlRequest.url + ")");
}
__xmlRequest = null;
}
}
}
//
// MBEvent
// cross browser event
////////////////////////////////////////////////////////////////////////////////////
function MBEvent(e) {
if (!e) { e = window.event; }
if (e.keyCode) {
this.keyCode = e.keyCode;
} else if (e.which) {
this.keyCode = e.which
}
this.event = e;
this.character = String.fromCharCode(this.keyCode);
this.ctrlKey = e.ctrlKey;
this.sourceElement = (e.srcElement)? e.srcElement : e.target;
this.mouse = new Object();
this.mouse.button = e.button;
if (e.pageX || e.pageY) {
this.mouse.x = e.pageX;
this.mouse.y = e.pageY;
} else if (e.clientX || e.clientY) {
if (document.documentElement && document.documentElement.scrollTop) {
this.mouse.x = e.clientX + document.documentElement.scrollLeft;
this.mouse.y = e.clientY + document.documentElement.scrollTop;
} else {
this.mouse.x = e.clientX + document.body.scrollLeft;
this.mouse.y = e.clientY + document.body.scrollTop;
}
}
this.CancelBubble = MBEvent_CancelBubble;
}
function MBEvent_CancelBubble() {
this.event.cancelBubble = true;
}
function Replace(sIn, lookfor, replacewith) {
var done = false;
var out = '';
var at = null;
while (!done) {
at = sIn.indexOf(lookfor);
if (at != -1) {
out += sIn.substring(0, at) + replacewith
sIn = sIn.substring(at + lookfor.length, sIn.length)
} else {
out += sIn
done = true
}
}
return out;
}
//
// Code for Skill Table Creation
// var definition = "Casting Time:castingTime:%i|Mana Cost:manaCost:%i|Range:range:%i m|Damage Reduction:percentDamageReduction:%p%";
// CreateTable(definition, "enfeeble.xml");
////////////////////////////////////////////////////////////////////////////////////
function DefinitionVariable(s) {
s = s.split(":");
this.name = s[0];
this.attribute = s[1];
this.format = s[2];
this.Render = DefinitionVariable_Render;
}
function DefinitionVariable_Render(node) {
var value = node.attributes.getNamedItem(this.attribute).nodeValue;
var i = parseInt(value);
var p = parseInt(parseFloat(value) * 100);
return Replace(Replace(this.format, "%i", i), "%p", p);
}
function CreateTable(definition, file) {
definition = definition.split("|");
var variables = new Array();
for (var i = 0; i < definition.length; ++i) {
variables[variables.length] = new DefinitionVariable(definition[i]);
}
var dom = CreateDOM();
dom.async = false;
if (!dom.load(file)) {
alert("failed to load " + file + ", it might not exist, or the XML isn't good");
return;
}
var s = '';
s += '';
for (var j = 0; j < variables.length; ++j) {
s += '| ' + variables[j].name + ' | ';
}
s += '
';
var levels = dom.getElementsByTagName("level");
for (var i = 0; i < levels.length; ++i) {
var level = levels.item(i);
s += '';
for (var j = 0; j < variables.length; ++j) {
s += '| ' + variables[j].Render(level) + ' | ';
}
s += '
';
}
s += '
';
document.write(s);
}
//
// XMLRequestToDOM
////////////////////////////////////////////////////////////////////////////////////
function XMLRequestToDOM(url) {
var responseText = XMLRequest(url);
dom = CreateDOM();
dom.loadXML(responseText);
return dom;
}
//
// Breadcrumb
////////////////////////////////////////////////////////////////////////////////////
function Breadcrumb(name, url) {
this.name = name;
this.url = url;
}
//
// AddBreadcrumb
////////////////////////////////////////////////////////////////////////////////////
function AddBreadcrumb(name, url) {
document.title = document.title + ' - ' + name;
if (url) {
url = Replace(url, "index.php?page=", "");
}
breadcrumbs[breadcrumbs.length] = new Breadcrumb(name, url);
}
//
// RenderBreadcrumbs
////////////////////////////////////////////////////////////////////////////////////
/*
function RenderBreadcrumbs() {
var s = '';
for (var i = 0; i < breadcrumbs.length; ++i) {
var bc = breadcrumbs[i];
if (bc.url) {
s += '' + bc.name + ' / ';
} else {
s += bc.name;
}
}
var e = document.getElementById("breadcrumbsDiv");
e.innerHTML = s;
}
*/
//
// Table
////////////////////////////////////////////////////////////////////////////////////
function Table(globalVariable) {
this.globalVariable = globalVariable;
this.cells = new Array();
this.rows = new Array();
this.renderElement = null;
this.sortBy = '';
this.sortOrder = 'asc';
this.width = '';
this.AddCell = Table_AddCell;
this.AddRow = Table_AddRow;
this.Render = Table_Render;
this.Sort = Table_Sort;
this.SortBy = Table_SortBy;
}
function Table_SortBy(sortBy, sortOrder) {
if (this.sortBy == sortBy) {
if (this.sortOrder == 'asc') {
this.sortOrder = 'desc';
} else {
this.sortOrder = 'asc';
}
} else {
this.sortOrder = sortOrder;
}
this.sortBy = sortBy;
this.Render();
}
function Table_Sort() {
switched = true;
while (switched) {
switched = false;
for (var i = 0; i < this.rows.length - 1; ++i) {
if ((this.sortOrder == 'asc' && this.rows[i][this.sortBy] > this.rows[i + 1][this.sortBy]) ||
(this.sortOrder == 'desc' && this.rows[i][this.sortBy] < this.rows[i + 1][this.sortBy])) {
temp = this.rows[i + 1];
this.rows[i + 1] = this.rows[i];
this.rows[i] = temp;
switched = true;
}
}
}
}
function Table_AddCell(header, row, sortBy, sortOrder) {
this.cells[this.cells.length] = new Cell(header, row, sortBy, sortOrder);
}
function Table_AddRow(row) {
this.rows[this.rows.length] = row;
}
function Table_Render(element) {
if (element) {
this.renderElement = element;
}
this.Sort();
var s = '';
for (var i = 0; i < this.cells.length; ++i) {
var cell = this.cells[i];
var width = (cell.width != '')? ' width="' + cell.width + '"' : '';
s += '| ' + cell.header + ' | ';
}
s += '
';
for (var i = 0; i < this.rows.length; ++i) {
s += '';
for (var j = 0; j < this.cells.length; ++j) {
var sc = this.cells[j].row;
for (a in this.rows[i]) {
sc = Replace(sc, '%' + a + '%', this.rows[i][a]);
}
var style = '';
if (this.rows[i].cssStyle) {
style = ' style="' + this.rows[i].cssStyle + '" ';
}
s += '| ' + sc + ' | ';
}
s += '
';
}
s += '
';
this.renderElement.innerHTML = s;
}
function Cell(header, row, sortBy, sortOrder) {
this.header = header;
this.row = row;
this.sortBy = sortBy;
this.sortOrder = (sortOrder)? sortOrder : 'asc';
}
//
// CBEvent
// cross browser event
////////////////////////////////////////////////////////////////////////////////////
function CBEvent(e) {
if (!e) { e = window.event; }
if (e.keyCode) {
this.keyCode = e.keyCode;
} else if (e.which) {
this.keyCode = e.which
}
this.event = e;
this.character = String.fromCharCode(this.keyCode);
this.ctrlKey = e.ctrlKey;
this.sourceElement = (e.srcElement)? e.srcElement : e.target;
this.mouse = new Object();
this.mouse.button = e.button;
if (window.event && document.all) {
this.mouse.button -= 1;
}
if (e.pageX || e.pageY) {
this.mouse.x = e.pageX;
this.mouse.y = e.pageY;
} else if (e.clientX || e.clientY) {
if (document.documentElement && document.documentElement.scrollTop) {
this.mouse.x = e.clientX + document.documentElement.scrollLeft;
this.mouse.y = e.clientY + document.documentElement.scrollTop;
} else {
this.mouse.x = e.clientX + document.body.scrollLeft;
this.mouse.y = e.clientY + document.body.scrollTop;
}
}
this.CancelBubble = CBEvent_CancelBubble;
}
function CBEvent_CancelBubble() {
this.event.cancelBubble = true;
}
function LoadDynamicScript(id, src, callback) {
loadDynamicScriptCallback = callback;
var script = document.createElement('script');
script.id = id;
script.type = 'text/javascript';
script.src = 'script.php?file=' + src;
document.getElementsByTagName('head')[0].appendChild(script);
}
function UnloadDynamicScript(id) {
var script = document.getElementById(id);
document.getElementsByTagName('head')[0].removeChild(script);
}
function Rectangle(t, l, b, r) {
this.t = (t)? t : 0;
this.l = (l)? l : 0;
this.b = (b)? b : 0;
this.r = (r)? r : 0;
this.CollidesWithRect = Rectangle_CollidesWithRect;
this.FromObject = Rectangle_FromObject;
this.toString = Rectangle_ToString;
}
function Rectangle_ToString() {
return 'Rectangle(' + this.l + ', ' + this.t + ', ' + this.r + ', ' + this.b + ')';
}
function Rectangle_FromObject(o) {
var position = GetObjectPosition(o);
this.l = position.x;
this.t = position.y;
this.r = this.l + o.offsetWidth;
this.b = this.t + o.offsetHeight;
}
function Rectangle_CollidesWithRect(rectangle) {
if (this.l > rectangle.r || this.r < rectangle.l || this.t > rectangle.b || this.b < rectangle.t) {
return false;
}
return true;
}
function Point(x, y) {
this.x = (x)? x : 0;
this.y = (y)? y : 0;
this.toString = Point_ToString;
}
function Point_ToString() {
return 'Point(' + this.x + ', ' + this.y + ')';
}
function GetObjectPosition(object) {
var point = new Point();
if (object.offsetParent) {
while (object.offsetParent) {
point.x += object.offsetLeft;
point.y += object.offsetTop;
object = object.offsetParent;
}
} else if (object.x || object.y) {
point.x = object.x;
point.y = object.y;
}
return point;
}
function ModalOn() {
var modal = document.getElementById("modal");
if (!modal) {
return;
}
modal.style.display = 'block';
modal.style.zIndex = 100;
var rectangle = new Rectangle();
var bottomRight = document.getElementById("bottomRight");
rectangle.FromObject(bottomRight);
modal.style.width = rectangle.r;
modal.style.height = rectangle.b;
}
function ModalOff() {
var modal = document.getElementById("modal");
if (!modal) {
return;
}
modal.style.display = 'none';
}
function GetCookie(name) {
var dc = document.cookie;
var b = (dc + '').indexOf(name + "=");
if (b != -1) {
b += name.length + 1;
e = dc.substring(b, dc.length).indexOf(";");
if (e == -1) { e = dc.length } else { e += b; }
return dc.substring(b, e);
} else {
return null;
}
}
function SetCookie(name, value, expires) {
expires = (expires)? "; expires=" + expires.toGMTString() : ""
document.cookie = name + "=" + value + expires
}
function DeleteCookie(name) {
document.cookie = name + "=null;expires=1970;"
}
function XMLGetAttribute(node, name) {
if (!node) { return ""; }
var ni = node.attributes.getNamedItem(name);
if (!ni) { return ""; }
return ni.nodeValue;
}
var scrollToElement = "";
function ScrollToElement(id) {
scrollToElement = id;
}
function DoScrollTo() {
if (scrollToElement != "") {
try {
var rect = new Rectangle();
rect.FromObject(document.getElementById(scrollToElement));
window.scrollTo(0, rect.t);
} catch (e) {
}
scrollToElement = "";
} else {
window.scrollTo(0,0);
}
}
var skillTranslationInited = false;
var skillTranslation = new Array();
function GetSkillTranslation(id) {
if (!skillTranslationInited) {
skillTranslationInited = true;
var dom = CreateDOM();
dom.async = false;
dom.load("languages/en_skills.xml");
var es = dom.getElementsByTagName("string");
for (var i = 0; i < es.length; ++i) {
var e = es.item(i);
skillTranslation[(e.attributes.getNamedItem("id").nodeValue + "").toLowerCase()] = e.firstChild.nodeValue;
}
}
var idL = (id + "").toLowerCase();
if (skillTranslation[idL]) {
return skillTranslation[idL];
} else {
return idL;
}
}