// Copyright (c) 2005 - 2008 Joseph Huckaby.
// All rights reserved.  Patent Pending.
var vb = "\t";var Oo = '<?xml version="1.0"?>';var Nu = null;var _s = /^\w[\w\-\:]*$/;function XML(dh) {if (!dh) dh = '';if (isa_hash(dh)) {for (var Sp in dh) this[Sp] = dh[Sp];}else this.text = dh || '';this.Ev = {};this.errors = [];this.piNodeList = [];this.dtdNodeList = [];this.documentNodeName = '';this.patTag.lastIndex = 0;if (this.text) this.parse();}XML.prototype.preserveAttributes = false;XML.prototype.patTag = /([^<]*?)<([^>]+)>/g;XML.prototype.patSpecialTag = /^\s*([\!\?])/;XML.prototype.patPITag = /^\s*\?/;XML.prototype.patCommentTag = /^\s*\!--/;XML.prototype.patDTDTag = /^\s*\!DOCTYPE/;XML.prototype.patCDATATag = /^\s*\!\s*\[\s*CDATA/;XML.prototype.patStandardTag = /^\s*(\/?)([\w\-\:\.]+)\s*(.*)$/;XML.prototype.patSelfClosing = /\/\s*$/;XML.prototype.patAttrib = new RegExp("([\\w\\-\\:\\.]+)\\s*=\\s*([\\\"\\'])([^\\2]*?)\\2", "g");XML.prototype.patPINode = /^\s*\?\s*([\w\-\:]+)\s*(.*)$/;XML.prototype.patEndComment = /--$/;XML.prototype.patNextClose = /([^>]*?)>/g;XML.prototype.patExternalDTDNode = new RegExp("^\\s*\\!DOCTYPE\\s+([\\w\\-\\:]+)\\s+SYSTEM\\s+\\\"([^\\\"]+)\\\"");XML.prototype.patInlineDTDNode = /^\s*\!DOCTYPE\s+([\w\-\:]+)\s+\[/;XML.prototype.patEndDTD = /\]$/;XML.prototype.patDTDNode = /^\s*\!DOCTYPE\s+([\w\-\:]+)\s+\[(.*)\]/;XML.prototype.patEndCDATA = /\]\]$/;XML.prototype.patCDATANode = /^\s*\!\s*\[\s*CDATA\s*\[(.*)\]\]/;XML.prototype.attribsKey = '_Attribs';
XML.prototype.dataKey = '_Data';XML.prototype.parse = function(xD, name) {if (!xD) xD = this.Ev;if (!name) name = null;var LD = false;var Pv = null;while ( Pv = this.patTag.exec(this.text) ) {var vi = Pv[1];var EG = Pv[2];if (vi.match(/\S/)) {if (typeof(xD[this.dataKey]) != 'undefined') xD[this.dataKey] += ' '; else xD[this.dataKey] = '';xD[this.dataKey] += trim(decode_entities(vi));}if (EG.match(this.patSpecialTag)) {if (EG.match(this.patPITag)) EG = this.parsePINode(EG);else if (EG.match(this.patCommentTag)) EG = this.parseCommentNode(EG);else if (EG.match(this.patDTDTag)) EG = this.parseDTDNode(EG);else if (EG.match(this.patCDATATag)) {EG = this.parseCDATANode(EG);if (typeof(xD[this.dataKey]) != 'undefined') xD[this.dataKey] += ' '; else xD[this.dataKey] = '';xD[this.dataKey] += trim(decode_entities(EG));} else {this.throwParseError( "Malformed special EG", EG );break;} if (EG == null) break;continue;} else {var Pv = EG.match(this.patStandardTag);if (!Pv) {this.throwParseError( "Malformed EG", EG );break;}var Xv = Pv[1];var HR = Pv[2];var DD = Pv[3];if (Xv) {if (HR == (name || '')) {
LD = 1;break;}else {this.throwParseError( "Mismatched Xv EG (expected </" + name + ">)", EG );break;}} else {var Wo = !!DD.match(this.patSelfClosing);var _N = {};var zI = _N;if (this.preserveAttributes) {_N[this.attribsKey] = {};zI = _N[this.attribsKey];}this.patAttrib.lastIndex = 0;while ( Pv = this.patAttrib.exec(DD) ) {zI[ Pv[1] ] = decode_entities( Pv[3] );} if (!Wo) {this.parse( _N, HR );if (this.error()) break;}var sW = num_keys(_N);if ((typeof(_N[this.dataKey]) != 'undefined') && (sW == 1)) {_N = _N[this.dataKey];}else if (!sW) {_N = '';}if (typeof(xD[HR]) != 'undefined') {if (isa_array(xD[HR])) {array_push( xD[HR], _N );}else {var OM = xD[HR];xD[HR] = [ OM, _N ];}}
else {xD[HR] = _N;}if (this.error() || (xD == this.Ev)) break;} } } if (name && !LD) {this.throwParseError( "Missing Xv EG (expected </" + name + ">)", name );}if (xD == this.Ev) {if (typeof(this.Ev[this.dataKey]) != 'undefined') delete this.Ev[this.dataKey];if (num_keys(this.Ev) > 1) {this.throwParseError( 'Only one top-level qD is allowed in document', first_key(this.Ev) );return;}this.documentNodeName = first_key(this.Ev);if (this.documentNodeName) {this.Ev = this.Ev[this.documentNodeName];}}};XML.prototype.throwParseError = function(Sp, EG) {var fJ = this.text.substring(0, this.patTag.lastIndex);var wY = fJ.match(/\n/g).length + 1;wY -= EG.match(/\n/g).length;array_push(this.errors, {type: 'Parse',Sp: Sp,text: '<' + EG + '>',line: wY});};XML.prototype.error = function() {return this.errors.length;};XML.prototype.getError = function(error) {var text = '';if (!error) return '';text = (error.type || 'General') + ' Error';
if (error.code) text += ' ' + error.code;text += ': ' + error.Sp;if (error.line) text += ' on line ' + error.line;if (error.text) text += ': ' + error.text;return text;};XML.prototype.getLastError = function() {if (!this.error()) return '';return this.getError( this.errors[this.errors.length - 1] );};XML.prototype.parsePINode = function(EG) {if (!EG.match(this.patPINode)) {this.throwParseError( "Malformed processor instruction", EG );return null;}array_push( this.piNodeList, EG );return EG;};XML.prototype.parseCommentNode = function(EG) {var Pv = null;this.patNextClose.lastIndex = this.patTag.lastIndex;while (!EG.match(this.patEndComment)) {if (Pv = this.patNextClose.exec(this.text)) {EG += '>' + Pv[1];}else {this.throwParseError( "Unclosed comment EG", EG );return null;}}this.patTag.lastIndex = this.patNextClose.lastIndex;return EG;};XML.prototype.parseDTDNode = function(EG) {var Pv = null;if (EG.match(this.patExternalDTDNode)) {array_push( this.dtdNodeList, EG );}else if (EG.match(this.patInlineDTDNode)) {this.patNextClose.lastIndex = this.patTag.lastIndex;
while (!EG.match(this.patEndDTD)) {if (Pv = this.patNextClose.exec(this.text)) {EG += '>' + Pv[1];}else {this.throwParseError( "Unclosed DTD EG", EG );return null;}}this.patTag.lastIndex = this.patNextClose.lastIndex;if (EG.match(this.patDTDNode)) {array_push( this.dtdNodeList, EG );}else {this.throwParseError( "Malformed DTD EG", EG );return null;}}else {this.throwParseError( "Malformed DTD EG", EG );return null;}return EG;};XML.prototype.parseCDATANode = function(EG) {var Pv = null;this.patNextClose.lastIndex = this.patTag.lastIndex;while (!EG.match(this.patEndCDATA)) {if (Pv = this.patNextClose.exec(this.text)) {EG += '>' + Pv[1];}else {this.throwParseError( "Unclosed CDATA EG", EG );return null;}}this.patTag.lastIndex = this.patNextClose.lastIndex;if (Pv = EG.match(this.patCDATANode)) {return Pv[1];}
else {this.throwParseError( "Malformed CDATA EG", EG );return null;}};XML.prototype.getTree = function() {return this.Ev;};XML.prototype.compose = function() {var yG = compose_xml( this.documentNodeName, this.Ev );var body = yG.substring( yG.indexOf("\n") + 1, yG.length );var xml = '';if (this.piNodeList.length) {for (var ah = 0, it = this.piNodeList.length; ah < it; ah++) {xml += '<' + this.piNodeList[ah] + '>' + "\n";}}else {xml += Oo + "\n";}if (this.dtdNodeList.length) {for (var ah = 0, it = this.dtdNodeList.length; ah < it; ah++) {xml += '<' + this.dtdNodeList[ah] + '>' + "\n";}}xml += body;return xml;};function parse_xml(text) {var dn = new XML(text);return dn.error() ? dn.getLastError() : dn.getTree();}function trim(text) {if (text == null) return '';if (text && text.replace) {text = text.replace(/^\s+/, "");text = text.replace(/\s+$/, "");}return text;}
function encode_entities(text) {if (text == null) return '';if (text && text.replace) {text = text.replace(/\&/g, "&amp;");text = text.replace(/</g, "&lt;");text = text.replace(/>/g, "&gt;");}return text;}function encode_attrib_entities(text) {if (text == null) return '';if (text && text.replace) {text = text.replace(/\&/g, "&amp;");text = text.replace(/</g, "&lt;");text = text.replace(/>/g, "&gt;");text = text.replace(/\"/g, "&quot;");text = text.replace(/\'/g, "&apos;");}return text;}function decode_entities(text) {if (text == null) return '';if (text && text.replace) {text = text.replace(/\&amp\;/g, "&");text = text.replace(/\&lt\;/g, "<");text = text.replace(/\&gt\;/g, ">");text = text.replace(/\&quot\;/g, '"');text = text.replace(/\&apos\;/g, "'");}return text;}function compose_xml(name, qD, cM) {var xml = "";if (!cM) {cM = 0;xml = Oo + "\n";}var SC = "";for (var k = 0; k < cM; k++) SC += vb;if ((typeof(qD) == 'object') && (qD != null)) {
if (!qD.length) { xml += SC + "<" + name;var num_keys = 0;var Ps = 0;for (var Sp in qD) num_keys++; if (qD["_Attribs"]) {Ps = 1;var fF = hash_keys_to_array(qD["_Attribs"]).sort();for (var ah = 0, it = fF.length; ah < it; ah++) {var Sp = fF[ah];xml += " " + Sp + "=\"" + encode_attrib_entities(qD["_Attribs"][Sp]) + "\"";}} if (num_keys > Ps) {xml += ">";if (qD["_Data"]) {xml += encode_entities(qD["_Data"]) + "</" + name + ">\n";} else {xml += "\n";var fF = hash_keys_to_array(qD).sort();for (var ah = 0, it = fF.length; ah < it; ah++) {var Sp = fF[ah]; if ((Sp != "_Attribs") && Sp.match(_s)) {xml += compose_xml( Sp, qD[Sp], cM + 1 );} } xml += SC + "</" + name + ">\n";} }else {xml += "/>\n";}} else {for (var ah = 0; ah < qD.length; ah++) {xml += compose_xml( name, qD[ah], cM );}} } 
else {xml += SC + "<" + name + ">" + encode_entities(qD) + "</" + name + ">\n";} return xml;}function find_object(obj, PS) {var CW = 0;for (var a in PS) CW++;obj = always_array(obj);for (var a = 0; a < obj.length; a++) {var Pv = 0;for (var b in PS) {if (obj[a][b] && (obj[a][b] == PS[b])) Pv++;else if (obj[a]["_Attribs"] && obj[a]["_Attribs"][b] && (obj[a]["_Attribs"][b] == PS[b])) Pv++;}if (Pv >= CW) return obj[a];}return null;}function find_objects(obj, PS) {var tL = new Array();var CW = 0;for (var a in PS) CW++;obj = always_array(obj);for (var a = 0; a < obj.length; a++) {var Pv = 0;for (var b in PS) {if (obj[a][b] && obj[a][b] == PS[b]) Pv++;else if (obj[a]["_Attribs"] && obj[a]["_Attribs"][b] && (obj[a]["_Attribs"][b] == PS[b])) Pv++;}if (Pv >= CW) array_push( tL, obj[a] );}return tL;}function find_object_idx(obj, PS) {var CW = 0;for (var a in PS) CW++;obj = always_array(obj);for (var ah = 0; ah < obj.length; ah++) {var Pv = 0;
for (var b in PS) {if (obj[ah][b] && (obj[ah][b] == PS[b])) Pv++;else if (obj[ah]["_Attribs"] && obj[ah]["_Attribs"][b] && (obj[ah]["_Attribs"][b] == PS[b])) Pv++;}if (Pv >= CW) return ah;}return -1;}function delete_object(obj, PS) {var ah = find_object_idx(obj, PS);if (ah > -1) {array_splice( obj, ah, 1 );return true;}return false;}function delete_objects(obj, PS) {while (delete_object(obj, PS)) ;}function insert_object_before(obj, PS, EI) {var ah = find_object_idx(obj, PS);if (ah > -1) {array_splice( obj, ah, 0, EI );return true;}return false;}function always_array(obj, Sp) {if (Sp) {if ((typeof(obj[Sp]) != 'object') || (typeof(obj[Sp].length) == 'undefined')) {var OM = obj[Sp];delete obj[Sp];obj[Sp] = new Array();obj[Sp][0] = OM;}return null;}else {if ((typeof(obj) != 'object') || (typeof(obj.length) == 'undefined')) { return [ obj ]; }else return obj;
}}function hash_keys_to_array(XK) {var array = [];for (var Sp in XK) array_push(array, Sp);return array;}function serialize(Of, VL) {if (!VL) VL = ':'; var lR = '';if (typeof(Of) == 'number') {lR += Of;}else if (typeof(Of) == 'string') {lR += '"' + Of.replace(/([\"\\])/g, '\\$1').replace(/\r/g, "\\r").replace(/\n/g, "\\n") + '"';}else if (isa_hash(Of)) {lR += '{';for (var Sp in Of) {lR += Sp + VL + serialize(Of[Sp], VL) + ',';}lR = lR.substring( 0, lR.length - 1); lR += '}';}else if (isa_array(Of)) {lR += '[';for (var ah = 0, it = Of.length; ah < it; ah++) {lR += serialize(Of[ah], VL);if (ah < it - 1) lR += ',';}lR += ']';}else {lR += '0';}return lR;}function ue(wC) {return unescape(wC);}
function custom_sort(a, b) {var qT = a[ Nu.sort_by ];if (!qT && a["_Attribs"]) qT = a["_Attribs"][ Nu.sort_by ];var XR = b[ Nu.sort_by ];if (!XR && b["_Attribs"]) XR = b["_Attribs"][ Nu.sort_by ];var Vr = (XR < qT) ? 1 : -1;return Vr * Nu.sort_dir;}function sort_array(obj, dh) {var oe = always_array(obj);Nu = dh;return oe.sort( custom_sort );}function merge_objects(a, b) {if (!a) a = {};if (!b) b = {};var c = {};if (typeof(a) != 'object') eval( "a = " + a );if (typeof(b) != 'object') eval( "b = " + b );for (var Sp in a) c[Sp] = a[Sp];for (var Sp in b) c[Sp] = b[Sp];return c;}function copy_object(obj) {var gf = {};for (var Sp in obj) gf[Sp] = obj[Sp];return gf;}function deep_copy_object(obj) {var gf = {};if (typeof(obj.length) != 'undefined') gf = [];for (var Sp in obj) {if (typeof(obj[Sp]) == 'object') gf[Sp] = deep_copy_object( obj[Sp] );else gf[Sp] = obj[Sp];}return gf;}function deep_copy_object_lc_keys(obj) {var gf = {};if (obj.length) gf = [];
for (var Sp in obj) {var bK = Sp.toLowerCase ? Sp.toLowerCase() : Sp;if (typeof(obj[Sp]) == 'object') gf[bK] = deep_copy_object_lc_keys( obj[Sp] );else gf[bK] = obj[Sp];}return gf;}function copy_into_object(a, b) {for (var Sp in b) a[Sp] = b[Sp];}function deep_copy_into_object(a, b) {for (var Sp in b) {if (typeof(b[Sp]) == 'object') {if (typeof(a[Sp]) == 'undefined') {if (b[Sp].length) a[Sp] = []; else a[Sp] = {};}deep_copy_into_object( a[Sp], b[Sp] );}else a[Sp] = b[Sp];}}function num_keys(XK) {var Rk = 0;for (var a in XK) Rk++;return Rk;}function deep_diff_object(a, b) {if ((typeof(a) != 'object') && (typeof(a) != 'array')) {if (typeof(a) == 'string') {a = a.replace(/\r\n/g, "\n");a = a.replace(/\r/g, "\n");}if (typeof(b) == 'string') {b = b.replace(/\r\n/g, "\n");b = b.replace(/\r/g, "\n");}if (a != b) return 1; else return 0;}if (typeof(a) != typeof(b)) return 1; 
if (typeof(a.length) == 'undefined') {if (num_keys(a) != num_keys(b)) return 1; for (var VN in a) {if (typeof(b[VN]) == 'undefined') return 1; if (deep_diff_object( a[VN], b[VN] )) return 1; }for (var ls in b) {if (typeof(a[ls]) == 'undefined') return 1; }}else {if (a.length != b.length) return 1; for (var ah = 0; ah < a.length; ah++) {if (deep_diff_object( a[ah], b[ah] )) return 1; }}return 0;}function lookup_path(nH, obj) {while (/\/\w+/.test(nH) && (typeof(obj) == 'object')) {var ME = nH.indexOf('/');nH = nH.substring( ME + 1 );ME = nH.indexOf('/');if (ME == -1) ME = nH.length;var name = nH.substring(0, ME);if (typeof(obj.length) == 'undefined') {if (typeof(obj[name]) != 'undefined') obj = obj[name];else return null;}else {var ah = parseInt(name);if (isNaN(ah)) return null;if (typeof(obj[ah]) != 'undefined') obj = obj[ah];else return null;}} return obj;}function set_path_value(nH, obj, value) {var PH = nH.lastIndexOf('/');
var tP = nH.substring( PH + 1, nH.length );nH = nH.substring( 0, PH );while (/\/\w+/.test(nH)) {var ME = nH.indexOf('/');nH = nH.substring( ME + 1 );ME = nH.indexOf('/');if (ME == -1) ME = nH.length;var name = nH.substring(0, ME);if (typeof(obj.length) == 'undefined') {if (typeof(obj[name]) == 'undefined') obj[name] = {}; obj = obj[name];}else {var ah = parseInt(name);if (isNaN(ah)) return null;if (typeof(obj[ah]) != 'undefined') obj[ah] = {}; obj = obj[ah];}} obj[tP] = value;}function delete_path_value(nH, obj) {var PH = nH.lastIndexOf('/');var tP = nH.substring( PH + 1, nH.length );nH = nH.substring( 0, PH );while (/\/\w+/.test(nH) && (typeof(obj) == 'object')) {var ME = nH.indexOf('/');nH = nH.substring( ME + 1 );ME = nH.indexOf('/');if (ME == -1) ME = nH.length;var name = nH.substring(0, ME);if (typeof(obj.length) == 'undefined') {if (typeof(obj[name]) != 'undefined') obj = obj[name];else return null;}else {var ah = parseInt(name);if (isNaN(ah)) return null;if (typeof(obj[ah]) != 'undefined') obj = obj[ah];else return null;
}} delete obj[tP];return true;}function set_all(obj, dh) {for (var ah = 0; ah < obj.length; ah++) {for (var a in dh) {obj[ah][a] = dh[a];} } }function delete_all(obj, Sp) {for (var ah = 0; ah < obj.length; ah++) {if (typeof(obj[ah][Sp]) != 'undefined') delete obj[ah][Sp];}}function compose_attribs(zI) {var html = '';if (zI) {for (var Sp in zI) {html += " " + Sp + "=\"" + zI[Sp] + "\"";}}return html;}function isa_hash(yv) {return( !!yv && (typeof(yv) == 'object') && (typeof(yv.length) == 'undefined') );}function isa_array(yv) {if (typeof(yv) == 'array') return true;return( !!yv && (typeof(yv) == 'object') && (typeof(yv.length) != 'undefined') );}function first_key(XK) {for (var Sp in XK) return Sp;}function xml_index_by( xml, element, Sp, DF, Cr ) {if (!xml || !Sp || !element) return 0;if (isa_hash(xml) && isa_hash(xml[element]) && xml[element][Sp])always_array( xml, element );
if (isa_hash(xml) && isa_array(xml[element])) {var Cc = 0;for (var ah = xml[element].length - 1; ah >= 0; ah--) {var Sf = xml[element][ah];if (Sf[Sp]) {Cc = 1;var cX = Sf[Sp];delete Sf[Sp];if (Cr && (num_keys(Sf) == 1) && (typeof(Sf[ first_key(Sf) ]) != 'object')) {Sf = Sf[ first_key(Sf) ];} if (typeof(xml[cX]) != 'undefined') {always_array( xml, cX );array_unshift( xml[cX], Sf );}else {xml[cX] = Sf;}} } if (Cc) {delete xml[element];}} if (DF) {if (xml && (typeof(xml) == 'object')) { if (typeof(xml.length) != 'undefined') {for (var ah = 0; ah < xml.length; ah++) {xml_index_by( xml[ah], element, Sp, DF, Cr );} }else {for (var Sp in xml) {xml_index_by( xml[Sp], element, Sp, DF, Cr );} }} } }function expand_parameter_nodes(Ev) {
xml_index_by( Ev, 'ParameterGroup', 'Name', true, false );xml_index_by( Ev, 'Parameter', 'Name', true, true );}function make_parameter_nodes(Ev, AN) {var Ni = {};if (typeof(AN) == 'undefined') { AN = -1; } if (!AN) { return {}; } for (var Sp in Ev) {if (isa_hash(Ev[Sp])) {var gF = merge_objects({ "_Attribs": { Name: Sp } },make_parameter_nodes(Ev[Sp], AN - 1) );if (Ni['ParameterGroup']) {if (isa_array(Ni['ParameterGroup'])) {array_push( Ni['ParameterGroup'], gF );}else {Ni['ParameterGroup'] = [ Ni['ParameterGroup'], gF ];}}else {Ni['ParameterGroup'] = gF;}}else if (isa_array(Ev[Sp])) {for (var ah = 0; ah < Ev[Sp].length; ah++) {var Sf = Ev[Sp][ah];if (isa_hash(Sf)) {var gF = merge_objects({ "_Attribs": { Name: Sp } },make_parameter_nodes(Sf, AN - 1) );if (Ni['ParameterGroup']) {if (isa_array(Ni['ParameterGroup'])) {array_push( Ni['ParameterGroup'], gF );}else {Ni['ParameterGroup'] = [ Ni['ParameterGroup'], gF ];}}else {Ni['ParameterGroup'] = gF;}
} else {var qD = { "_Attribs": { Name: Sp } };if (/[\n\"]/.test(Sf)) {qD['content'] = Sf;}else {qD['_Attribs']['Value'] = Sf;}if (Ni['Parameter']) {if (isa_array(Ni['Parameter'])) {array_push( Ni['Parameter'], qD );}else {Ni['Parameter'] = [ Ni['Parameter'], qD ];}}else {Ni['Parameter'] = qD;}} } }else {var qD = { "_Attribs": { Name: Sp } };if (/[\n\"]/.test(Ev[Sp])) {qD['content'] = Ev[Sp];}else {qD['_Attribs']['Value'] = Ev[Sp];}if (Ni['Parameter']) {if (isa_array(Ni['Parameter'])) {array_push( Ni['Parameter'], qD );}else {Ni['Parameter'] = [ Ni['Parameter'], qD ];}}else {
Ni['Parameter'] = qD;}}}return Ni;}function array_push(array, fO) {array[ array.length ] = fO;}function array_pop(array) {if (array.length > 0) {var OM = array[ array.length - 1 ];delete array[ array.length - 1 ];array.length--;return OM;}else return null;}function array_unshift(array, fO) {if (array.length > 0) {for (var ah = array.length - 1; ah >= 0; ah--) {array[ah + 1] = array[ah];}}array[0] = fO;}function array_shift(array) {if (array.length > 0) {var OM = array[0];if (array.length > 1) {for (var ah = 0; ah < array.length - 1; ah++) {array[ah] = array[ah + 1];}}array_pop(array);return OM;}else return null;}function array_splice(array, gt, xZ, fO) {
var vV = [];while (xZ) {array_push(vV, array[gt]);if (array.length > gt + 1) {for (var ah = gt; ah < array.length - 1; ah++) {array[ah] = array[ah + 1];}}array_pop(array);xZ--;}if (typeof(fO) != 'undefined') {for (var ah = array.length - 1; ah >= gt; ah--) {array[ah + 1] = array[ah];}array[gt] = fO;}return vV;}function array_slice(array, start, end) {if (!end) end = array.length;var Dw = [];for (var ah = start; ah < end; ah++) {if (ah < array.length) array_push( Dw, array[ah] );}return Dw;}function array_cat(a, b) {var c = [];for (var ah = 0; ah < a.length; ah++) array_push( c, a[ah] );for (var ah = 0; ah < b.length; ah++) array_push( c, b[ah] );return c;};var VH = navigator.userAgent;var safari = !!VH.match(/Safari/);var Cf = safari && !!VH.match(/Version\D[3456789]/);var JI = safari && !Cf;var bu = !!VH.match(/MSIE/);var Ik = bu && !!VH.match(/MSIE\s+7/);
var pF = bu && !Ik;var jp = !safari && !bu;var ut = !!window.opera;var yT = !!VH.match(/Mac/i);var XG = !!VH.match(/Firefox/);var dK = !!VH.match(/Firefox\D+3/);var protocol = location.protocol.match(/https/i) ? 'https' : 'http';function parse_query_string(j_) {var wy = {};j_ = j_.replace(/^.*\?(.+)$/,'$1');while ((pair = j_.match(/([^=]+)=\'?([^\&\']*)\'?\&?/)) && pair[0].length) {j_ = j_.substring( pair[0].length );if (/^\-?\d+$/.test(pair[2])) pair[2] = parseInt(pair[2]);wy[pair[1]] = unescape(pair[2]);}return wy;}var query = parse_query_string( location.search );var yZ = 772;function get_unique_id() {yZ++;return yZ;}function compose_style(zI) {var html = '';if (zI) {for (var Sp in zI) {if (html.length) html += ';';html += Sp + ":" + zI[Sp];}}return html;}function now_epoch() {var cH = new Date();return cH.getTime() / 1000;}function get_short_time(NP, Lj) {var cH;if (NP) cH = new Date( NP * 1000 );
else cH = new Date();var mn = 'AM';var XK = cH.getHours();if (XK >= 12) { mn = 'PM'; XK -=12; }if (XK == 0) XK = 12;var ZQ = cH.getMinutes(); if (ZQ < 10) ZQ = "0" + ZQ;var BO = cH.getSeconds(); if (BO < 10) BO = "0" + BO;var oX = cH.getMilliseconds();if (oX < 10) oX = "00" + oX;else if (oX < 100) oX = "0" + oX;var wC = XK+':'+ZQ;if (Lj) wC += ':'+BO+'.'+oX;wC += '&nbsp;'+mn;return wC;}function append_to_callback(hd, code) {var Lk = '';if (window[hd]) {var Dm = window[hd].toString();Lk = code + ";\r" + Dm.substring(Dm.indexOf("{")+1, Dm.lastIndexOf("}") ) + "\r;";}else {Lk = code + ";";}window[hd] = new Function( Lk );}function get_mouse_coords(e, obj) {var bi = new Point();if (document.all) {bi.x = e.clientX;bi.y = e.clientY;}else {bi.x = e.pageX;bi.y = e.pageY;}if (obj) {var tU = get_dom_object_info(obj);bi.x -= tU.left;
bi.y -= tU.top;}return bi;}function get_dom_object_info(obj) {var tU = {left: 0, top: 0, width: obj.width ? obj.width : obj.offsetWidth, height: obj.height ? obj.height : obj.offsetHeight};while (obj) {tU.left += obj.offsetLeft;tU.top += obj.offsetTop;obj = obj.offsetParent;}return tU;}function find_iframe_doc(id) {var uE = el(id);if (!uE) return null;var xP = null;if (uE.contentDocument) xP = uE.contentDocument; else if (uE.contentWindow) xP = uE.contentWindow.document; else if (uE.document) xP = eval(uE.id+".document"); return xP;}function easeOutInt(value, Vl) {if (!Vl) Vl = 2;if (!parseInt(value / Vl)) {if ((value < 1) && (value > -1)) value = 0;else if (value < 0) value++;else if (value > 0) value--;}else value -= parseInt( value / Vl );return value;}function easeFloat(value, Vl, Rt, Rv) {if (!Vl) Vl = 2;if (!Rt) Rt = -1;
if (!Rv) Rv = 0.5;value += ((value / Vl) * Rt);if (Math.abs(value) < Rv) value = (Rt < 0) ? 0 : Rv;return value;}function make_2d_array(cols, rows, value) {var data = [];for (var x=0; x<cols; x++) {data[x] = [];for (var y=0; y<rows; y++) data[x][y] = value;} return data;}function rand_array(MJ, min, qw) {if (!min) min = 0;if (!qw) qw = MJ.length;return MJ[ min + parseInt(Math.random() * (qw - min)) ];}function probably(value) {if (typeof(value) == 'undefined') { return 1; }return ( Math.random() < value ) ? 1 : 0;}function pad_int(value, it) {var wC = '' + value;while (wC.length < it) wC = '0' + wC;return wC;}function set_opacity(obj, opacity) {if (opacity == 0.0) {obj.style.opacity = 1.0;if (jp) obj.style.MozOpacity = 1.0;else if (bu) obj.style.filter = "";obj.style.visibility = 'hidden';}else if (opacity == 1.0) {obj.style.opacity = 1.0;if (jp) obj.style.MozOpacity = 1.0;else if (bu) obj.style.filter = "";obj.style.visibility = 'visible';}
else {obj.style.opacity = opacity;if (jp) obj.style.MozOpacity = opacity;else if (bu) obj.style.filter = "alpha(opacity=" + parseInt(opacity * 100) + ")";obj.style.visibility = 'visible';}}function el(id) {return document.getElementById(id);}function JH() {}JH.prototype.setHandler = function(name, hm) {if (!this.HD) this.HD = {};if (!this.HD[name]) this.HD[name] = [];array_push( this.HD[name], hm );};JH.prototype.clearHandler = function(name) {if (!this.HD) this.HD = {};if (this.HD[name]) this.HD[name] = [];};JH.prototype.fireHandler = function(name) {if (!this.HD) this.HD = {};var dh = array_slice( arguments, 1 );if (this.HD[name]) {var HD = always_array( this.HD[name] );for (var ah = 0, it = HD.length; ah < it; ah++) {var bN = false;var si = HD[ah];if (typeof(si) == 'function') bN = si.apply(window, dh);else if (isa_array(si)) {if (typeof(si[1]) == 'function') bN = si[1].apply(si[0], dh);else bN = si[0][ si[1] ](dh);}else if (window[si]) bN = window[si].apply(window, dh);else return throwError("Unsupported si type: " + name + ": " + si);if (!bN) return bN;} }return true;
};window.EaseAlgos = {Linear: function(Vl) { return Vl; },Quadratic: function(Vl) { return Math.pow(Vl, 2); },Cubic: function(Vl) { return Math.pow(Vl, 3); },Quartetic: function(Vl) { return Math.pow(Vl, 4); },Quintic: function(Vl) { return Math.pow(Vl, 5); },Sine: function(Vl) { return 1 - Math.sin((1 - Vl) * Math.PI / 2); },Circular: function(Vl) { return 1 - Math.sin(Math.acos(Vl)); }};window.EaseModes = {EaseIn: function(Vl, YX) { return window.EaseAlgos[YX](Vl); },EaseOut: function(Vl, YX) { return 1 - window.EaseAlgos[YX](1 - Vl); },EaseInOut: function(Vl, YX) {return (Vl <= 0.5) ? window.EaseAlgos[YX](2 * Vl) / 2 : (2 - window.EaseAlgos[YX](2 * (1 - Vl))) / 2;}};function ease(Vl, mode, YX) {return window.EaseModes[mode]( Vl, YX );}function uW() {this.ho = {};};uW.prototype.begin = function(id) {if (!id) id = 't';if (!this.ho[id]) this.ho[id] = { elapsed: 0 };var cH = new Date();this.ho[id].start = cH.getTime();};uW.prototype.Rk = function(id, Vl) {if (!Vl) Vl = 1;if (!id) return 0;if (!this.ho[id]) this.ho[id] = { start: 1, end: 1, elapsed: 0 };this.ho[id].elapsed += Vl;};uW.prototype.end = function(id) {if (!id) id = 't';if (!this.ho[id]) return;var cH = new Date();this.ho[id].end = cH.getTime();
var elapsed = this.ho[id].end - this.ho[id].start;if (elapsed < 0) elapsed = 0;this.ho[id].elapsed = elapsed;};uW.prototype.summarize = function() {var Oh = '';for (var id in this.ho) {if (!this.ho[id].end) this.end(id);if (Oh) Oh += '; ';Oh += id + '=' + this.ho[id].elapsed;}return Oh;};uW.prototype.reset = function() {this.ho = {};};var Qh = new uW();function RADIANS_TO_DECIMAL(rt) { return rt * 180.0 / Math.PI; }function DECIMAL_TO_RADIANS(xK) { return xK * Math.PI / 180.0; }function Point(YA, yz) {this.x = YA ? YA : 0;this.y = yz ? yz : 0;};Point.prototype.set = function() {if (arguments.length == 1) {this.x = arguments[0].x;this.y = arguments[0].y;}else {this.x = arguments[0];this.y = arguments[1];}return this;};Point.prototype.offset = function() {if (arguments.length == 1) {this.x += arguments[0].x;this.y += arguments[0].y;}else {
this.x += arguments[0];this.y += arguments[1];}return this;};Point.prototype.floor = function() {this.x = Math.floor(this.x);this.y = Math.floor(this.y);return this;};Point.prototype.getPointFromOffset = function() {if (arguments.length == 1) {return new Point( this.x + arguments[0].x, this.y + arguments[0].y );}else {return new Point( this.x + arguments[0], this.y + arguments[1] );}};Point.prototype.getDistance = function() {var bi;if (arguments.length == 1) bi = arguments[0];else bi = new Point(arguments[0], arguments[1]);if ((bi.x == this.x) && (bi.y == this.y)) return 0;return Math.sqrt( Math.pow(Math.abs(bi.x - this.x), 2) + Math.pow(Math.abs(bi.y - this.y), 2) );};Point.prototype.getAngle = function() {var bi;if (arguments.length == 1) bi = arguments[0];else bi = new Point(arguments[0], arguments[1]);if (this.x == bi.x && this.y == bi.y) return 0;var tl;var aO;if (bi.y < this.y && bi.x >= this.x) { aO = 0.0; tl = Math.abs(bi.y - this.y); }else if (bi.y < this.y && bi.x < this.x) { aO = 90.0; tl = Math.abs(bi.x - this.x); }else if (bi.y >= this.y && bi.x < this.x) { aO = 180.0; tl = Math.abs(bi.y - this.y); }else { aO = 270.0; tl = Math.abs(bi.x - this.x); }var fQ = aO + RADIANS_TO_DECIMAL( Math.asin( tl / this.getDistance(bi) ) );if (fQ >= 360.0) fQ -= 360.0;return fQ;};
Point.prototype.getPointFromProjection = function(fQ, UR) {return this.clone().project(fQ, UR);};Point.prototype.project = function(fQ, UR) {fQ = fQ % 360;var dP = ((fQ == 90) || (fQ == 270)) ? 0 : Math.cos( DECIMAL_TO_RADIANS(fQ) );var wW = ((fQ == 0) || (fQ == 180)) ? 0 : Math.sin( DECIMAL_TO_RADIANS(fQ) );this.x += (dP * UR);this.y -= (wW * UR);return this;};Point.prototype.getMidPoint = function(bi) {return new Point(this.x + ((bi.x - this.x) / 2),this.y + ((bi.y - this.y) / 2));};Point.prototype.clone = function() {return new Point(this.x, this.y);};function Rect(mk, Zm, ZG, dp) {this.left = mk ? mk : 0;this.top = Zm ? Zm : 0;this.right = ZG ? ZG : 0;this.bottom = dp ? dp : 0;};Rect.prototype.set = function() {if (arguments.length == 1) {this.left = arguments[0].left;this.top = arguments[0].top;this.right = arguments[0].right;this.bottom = arguments[0].bottom;}else {this.left = arguments[0];this.top = arguments[1];this.right = arguments[2];this.bottom = arguments[3];}return this;
};Rect.prototype.offset = function() {if (arguments.length == 1) {this.left += arguments[0].x;this.top += arguments[0].y;this.right += arguments[0].x;this.bottom += arguments[0].y;}else {this.left += arguments[0];this.top += arguments[1];this.right += arguments[0];this.bottom += arguments[1];}return this;};Rect.prototype.moveTo = function(mk, Zm) {return this.offset( mk - this.left, Zm - this.top );};Rect.prototype.width = function() {return (this.right - this.left);};Rect.prototype.height = function() {return (this.bottom - this.top);};Rect.prototype.centerPointX = function() {return ((this.left + this.right) / 2);};Rect.prototype.centerPointY = function() {return ((this.top + this.bottom) / 2);};Rect.prototype.ptIn = function(px, Ww) {return((px >= this.left) && (Ww >= this.top) && (px < this.right) && (Ww < this.bottom));};Rect.prototype.pointIn = function(bi) {return((bi.x >= this.left) && (bi.y >= this.top) && 
(bi.x < this.right) && (bi.y < this.bottom));};Rect.prototype.rectIn = function(rect) {var Ep = 0, vertTest = 0;if (this.left >= rect.left && this.left <= rect.right) Ep = 1;else if (this.right >= rect.left && this.right <= rect.right) Ep = 1;else if (this.left < rect.left && this.right > rect.right) Ep = 1;if (this.top >= rect.top && this.top <= rect.bottom) vertTest = 1;else if (this.bottom >= rect.top && this.bottom <= rect.bottom) vertTest = 1;else if (this.top < rect.top && this.bottom > rect.bottom) vertTest = 1;return (Ep && vertTest);};Rect.prototype.clone = function() {return new Rect(this.left, this.top, this.right, this.bottom);};Rect.prototype.morph = function(of, tS) {this.left += ((of.left - this.left) * tS);this.top += ((of.top - this.top) * tS);this.right += ((of.right - this.right) * tS);this.bottom += ((of.bottom - this.bottom) * tS);return this;};;var Sa = false;var Ig = null;var eB = 0;var iz = '<font style="font-family:courier,sans-serif; font-size:11px;">';var CK = '</font>';var _W = [];var oE = 100;function debug_startup() {if (Sa) {show_debug_window();Ig.blur();window.focus();}}function debug_onload() {}function do_dump_session() {
if (Sa) ;else alert( dumper( session ) );}function do_onerror(e) {;}window.debugstr = function(s) {if (!Sa) return false;array_push( _W, s );if (_W.length > oE) array_shift(_W);if (is_debug_window_open()) {while ( s = array_shift(_W) ) {var Ez = now_epoch();var elapsed = '' + (Ez - eB);var JA = '[' + elapsed.replace(/^(\-?\d+\.[0]*\d{2}).*$/, '$1') + '] ';eB = Ez;var SF = "";for (var k=0; k<JA.length; k++) SF += "&nbsp;";s = s.replace(/\t/g, " ");s = s.replace(/ /g, "&nbsp;");s = s.replace(/</g, "&lt;");s = s.replace(/>/g, "&gt;");s = s.replace(/\n/g, "<br>\n" + SF);if (Ig.document.createElement) {var div = Ig.document.createElement('div');div.innerHTML = iz + JA + s + CK;Ig.document.getElementById('debug_log').appendChild(div);}else Ig.document.getElementById('debug_log').innerHTML += iz + JA + s + CK + "<br>\n";}Ig.scrollTo(0, 99999);}return true;};function show_debug_window() {Sa = true;if (!Ig || Ig.closed) {Ig = window.open('', 'Ig', 'width=800,height=400,left=50,top=50,toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0,scrollbars=1,resizable=1');Ig.document.open();Ig.document.writeln('<html><head><title>Debug Window</title></head><body onLoad="window.opener.;"><div id="debug_log"></div><form><input type=button value="Clear" onClick="document.getElementById(\'debug_log\').innerHTML = \'\';"></form></body></html>');
Ig.document.close();}if (typeof(Ig.closed) == 'undefined') Ig.closed = false;if (typeof(Ig.opener) == 'undefined') Ig.opener = window;}function is_debug_window_open() {return (Ig != null && !Ig.closed && Ig.document && Ig.document.getElementById('debug_log'));}function hide_debug_window() {if (is_debug_window_open()) {Ig.close();Ig = null;}}function dump(obj, cM) {var text = '';if (!Sa) return(0);if (!cM) {text = "var obj = ";if (typeof(obj) == 'object' && typeof(obj.length) != 'undefined') text += "[\n";else if (typeof(obj) == 'object') text += "{\n";cM = 1;}var YW = '';for (var k=0; k<cM; k++) YW += "\t";if (typeof(obj) == 'undefined') {text += "( undefined )";}else if (typeof(obj) == 'function') {text += obj.toString();}else {if (typeof(obj.length) != 'undefined') {for (var a = 0; a < obj.length; a++) {text += YW;if (typeof(obj[a]) == 'object') {if (typeof(obj[a].length) != 'undefined') {text += "[\n" + dump( obj[a], cM + 1) + YW + "],\n";}else {
text += "{\n" + dump( obj[a], cM + 1) + YW + "},\n";}}else if (typeof(obj[a]) == 'number') text += obj[a] + ",\n";else text += '"' + obj[a] + '",' + "\n";}} else {for (var a in obj) {text += YW + a + ": ";if (typeof(obj[a]) == 'object') {if (typeof(obj[a].length) != 'undefined') {text += "[\n" + dump( obj[a], cM + 1) + YW + "],\n";}else {text += "{\n" + dump( obj[a], cM + 1) + YW + "},\n";}}else if (typeof(obj[a]) == 'number') text += obj[a] + ",\n";else text += '"' + obj[a] + '",' + "\n";}} }if (cM == 1) {if (typeof(obj) == 'object' && typeof(obj.length) != 'undefined') text += "];\n";else if (typeof(obj) == 'object') text += "};\n";;}return text;}function dumper(obj, cM, AN) {if (typeof(AN) == 'undefined') AN = 100;var text = '';if (!cM) {text = "var obj = ";if (typeof(obj) == 'object' && typeof(obj.length) != 'undefined') text += "[\n";else text += "{\n";cM = 1;}var YW = '';
for (var k=0; k<cM; k++) YW += "\t";if (typeof(obj) == 'object' && typeof(obj.length) != 'undefined') {for (var a = 0; a < obj.length; a++) {if (typeof(obj[a]) != 'function') {if (typeof(obj.length) != 'undefined') text += YW;else text += YW + a + ": ";if (typeof(obj[a]) == 'object') {if (obj[a] == null) {text += "null,\n";}else if (typeof(obj[a].length) != 'undefined') {if (AN) text += "[\n" + dumper( obj[a], cM + 1, AN - 1) + YW + "],\n";else text += "[...],\n";}else {if (AN) text += "{\n" + dumper( obj[a], cM + 1, AN - 1) + YW + "},\n";else text += "{...},\n";}}else if (typeof(obj[a]) == 'number') text += obj[a] + ",\n";else text += '"' + obj[a] + '",' + "\n";} } } else {for (var a in obj) {if (typeof(obj[a]) != 'function') {if (typeof(obj.length) != 'undefined') text += YW;else text += YW + a + ": ";if (typeof(obj[a]) == 'object') {if (obj[a] == null) {text += "null,\n";}else if (typeof(obj[a].length) != 'undefined') {if (AN) text += "[\n" + dumper( obj[a], cM + 1, AN - 1) + YW + "],\n";else text += "[...],\n";}else {if (AN) text += "{\n" + dumper( obj[a], cM + 1, AN - 1) + YW + "},\n";else text += "{...},\n";
}}else if (typeof(obj[a]) == 'number') text += obj[a] + ",\n";else text += '"' + obj[a] + '",' + "\n";} } } if (cM == 1) {if (typeof(obj) == 'object' && typeof(obj.length) != 'undefined') text += "];\n";else text += "};\n";}return text;}function diff_report(Cs, a, b, nH) {var kd = window.open('','diffwin','width=350,height=300,toolbar=0,location=0,directories=0,status=0,menubar=0,copyhistory=0,scrollbars=1,resizable=1');if (kd) {kd.document.open();kd.document.write("<html><body><pre>" + Cs + "\nPath: " + nH + "\n\nA: " + a + "\n\nB: " + b + "\n");if (Cs.indexOf("Strings differ") == 0) {var Jf = (a.length < b.length) ? a.length : b.length;for (var ah=0; ah<Jf; ah++) {if (a.charAt(ah) != b.charAt(ah)) break;}kd.document.write("\nOffset of first difference: " + ah + "\n");}kd.document.write("</pre></body></html>");kd.document.close();kd.focus();}else alert("Disable popup blocker and try again");return 1;}function deep_diff_analyze(a, b, nH) {if (!nH) nH = '';if ((typeof(a) != 'object') && (typeof(a) != 'array')) {if (typeof(a) == 'string') {a = a.replace(/\r\n/g, "\n");a = a.replace(/\r/g, "\n");}if (typeof(b) == 'string') {
b = b.replace(/\r\n/g, "\n");b = b.replace(/\r/g, "\n");}if (a != b) return diff_report("Strings differ", a.toString(), b.toString(), nH);else return 0;}if (typeof(a) != typeof(b)) return diff_report("Object types differ", typeof(a), typeof(b), nH);if (typeof(a.length) == 'undefined') {for (var VN in a) {if (typeof(b[VN]) == 'undefined') return diff_report("B missing Sp that A has", VN, '', nH);if (deep_diff_analyze( a[VN], b[VN], nH + '/' + VN )) return 1; }for (var ls in b) {if (typeof(a[ls]) == 'undefined') return diff_report("A missing Sp that B has", '', ls, nH);}}else {if (a.length != b.length) return diff_report("Array lengths differ", a.length, b.length, nH);for (var ah = 0; ah < a.length; ah++) {if (deep_diff_analyze( a[ah], b[ah], nH + '/' + ah )) return 1; }}return 0;}function throwError(Cs) {if (gProgress) gProgress.hide();if (gGame) gGame.stop();;alert("ERROR: " + Cs);return null;}window.assert = function(value, Cs) {if (!value) {if (gProgress) gProgress.hide();var B_ = stack_trace();if (B_) Cs += "\n\n" + B_;;if (confirm("Assert Failed: " + Cs + "\n\nDo you want to debug?")) {if (gGame) gGame.stop();
eval( "debugger;" );}}return value;};window.assertError = window.assert;function isset(value) {return (typeof(value) != 'undefined');}function stack_trace() {var bN = '';if (typeof(arguments.caller) != 'undefined') {for (var a = arguments.caller; a != null; a = a.caller) {var name = 'anonymous';if (a.callee && a.callee.toString) {var code = a.callee.toString();if (code.match) {var Pv = code.match(/function (\w*)/);if (Pv && Pv[1]) name = Pv[1];else alert("stack B_ no likey: " + code);}}bN += '> ' + name + '\n';if (a.caller == a) {bN += '*';break;}}}else {var e;try { foo.bar; }catch(e) {if (e.stack) bN = e.stack;}}return( bN );};var au = 0; 
var WI = ""; var by = 8; function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * by));}function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * by));}function hex_hmac_md5(Sp, data) { return binl2hex(core_hmac_md5(Sp, data)); }function b64_hmac_md5(Sp, data) { return binl2b64(core_hmac_md5(Sp, data)); }function calcMD5(s){ return binl2hex(core_md5(str2binl(s), s.length * by));}function md5_vm_test(){return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";}function core_md5(x, it){x[it >> 5] |= 0x80 << ((it) % 32);x[(((it + 64) >>> 9) << 4) + 14] = it;var a = 1732584193;var b = -271733879;var c = -1732584194;var d = 271733878;for(var i = 0; i < x.length; i += 16){var vt = a;var Lg = b;var Yy = c;var Uf = d;a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);c = md5_ff(c, d, a, b, x[i+10], 17, -42063);b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);a = safe_add(a, vt);b = safe_add(b, Lg);c = safe_add(c, Yy);d = safe_add(d, Uf);}return Array(a, b, c, d);}function md5_cmn(q, a, b, x, s, t){return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);}function md5_ff(a, b, c, d, x, s, t){return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);}function md5_gg(a, b, c, d, x, s, t){return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);}function md5_hh(a, b, c, d, x, s, t){return md5_cmn(b ^ c ^ d, a, b, x, s, t);}function md5_ii(a, b, c, d, x, s, t){return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);}function core_hmac_md5(Sp, data){var ls = str2binl(Sp);if(ls.length > 16) ls = core_md5(ls, Sp.length * by);
var Vj = Array(16), opad = Array(16);for(var i = 0; i < 16; i++) {Vj[i] = ls[i] ^ 0x36363636;opad[i] = ls[i] ^ 0x5C5C5C5C;}var XK = core_md5(Vj.concat(str2binl(data)), 512 + data.length * by);return core_md5(opad.concat(XK), 512 + 128);}function safe_add(x, y){var RR = (x & 0xFFFF) + (y & 0xFFFF);var Ic = (x >> 16) + (y >> 16) + (RR >> 16);return (Ic << 16) | (RR & 0xFFFF);}function bit_rol(yo, Bb){return (yo << Bb) | (yo >>> (32 - Bb));}function str2binl(wC){var FB = Array();var CF = (1 << by) - 1;for(var i = 0; i < wC.length * by; i += by)FB[i>>5] |= (wC.charCodeAt(i / by) & CF) << (i%32);return FB;}function binl2hex(wx){var UL = au ? "0123456789ABCDEF" : "0123456789abcdef";var wC = "";for(var i = 0; i < wx.length * 4; i++){wC += UL.charAt((wx[i>>2] >> ((i%4)*8+4)) & 0xF) +UL.charAt((wx[i>>2] >> ((i%4)*8 )) & 0xF);}return wC;}function binl2b64(wx){
var dv = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var wC = "";for(var i = 0; i < wx.length * 4; i += 3){var pi = (((wx[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)| (((wx[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )| ((wx[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);for(var j = 0; j < 4; j++){if(i * 8 + j * 6 > wx.length * 32) wC += WI;else wC += dv.charAt((pi >> 6*(3-j)) & 0x3F);}}return wC;};function nm(id) {this.lW = {};this.EL = 0;this.gA = 0;this.enabled = true;this.eb = false;this.gk = null;this.MQ = 1.0;this.zU = 1.0;this.fv = 0.0;this.vx = {sfx: {volume: 1.0,rate: 1.0,balance: 0.0},music: {volume: 1.0,rate: 1.0,balance: 0.0}}; };nm.prototype.gl = function(obj) {for (var Sp in obj) {
var WJ = obj[Sp];if (!this.lW[Sp]) {var track = new lH( merge_objects(WJ, { dG: Sp, yH: this }) );this.lW[ Sp ] = track;} } };nm.prototype._r = function() {if (!this.enabled) return 1.0;if ((num_keys(this.lW) - this.EL) == 0) return 1.0;return ((this.gA - this.EL) / (num_keys(this.lW) - this.EL));};nm.prototype.pp = function() {this.EL = num_keys(this.lW);};nm.prototype.ZL = function() {if (this._r() < 1.0) return throwError( "One or more audio tracks are still loading" );for (var Sp in this.lW) {this.lW[Sp].ZL();}};nm.prototype.setMasterVolume = function(Yq) {if (Yq < 0) Yq = 0;else if (Yq > 1.0) Yq = 1.0;this.MQ = Yq;this.ZL();};nm.prototype.setMasterRate = function(YF) {this.zU = YF;this.ZL();};nm.prototype.setMasterBalance = function(tK) {this.fv = tK;this.ZL();};nm.prototype.setCategoryVolume = function(Ws, Yq) {if (Yq < 0) Yq = 0;else if (Yq > 1.0) Yq = 1.0;var JE = this.vx[Ws];
assertError(JE, "Unknown audio category: " + Ws );JE.volume = Yq;this.ZL();};nm.prototype.setCategoryRate = function(Ws, YF) {var JE = this.vx[Ws];assertError(JE, "Unknown audio category: " + Ws );JE.rate = YF;this.ZL();};nm.prototype.setCategoryBalance = function(Ws, tK) {var JE = this.vx[Ws];assertError(JE, "Unknown audio category: " + Ws );JE.balance = tK;this.ZL();};nm.prototype.getTrack = function(id) {return this.lW[id];};nm.prototype.playSound = function(id) {var track = this.lW[id];assertError(track, "Could not locate track: " + id );track.playSound();};nm.prototype.quiet = function() {for (var Sp in this.lW) {this.lW[Sp].stop();}};nm.prototype.quietCategory = function(category) {for (var Sp in this.lW) {if (this.lW[Sp].category == category) this.lW[Sp].stop();}};nm.prototype.flashNotify = function(Ap, id, value) {switch (Ap) {case 'soundLoadComplete':if (value) {this.gA++;;
}else throwError("Failed to load audio track: " + id + ": " + track.mediaURL);break;case 'soundLoadError':throwError("Failed to load audio track: " + id + ": " + track.mediaURL + ": " + value);break;case 'flashLoadComplete':if (!this.flashLoadComplete) {this.flashLoadComplete = true;;setTimeout( function() { gAudio.Us(); }, 100 );}break;case 'debug':;break;}};nm.prototype.Us = function() {this.gk = el('audio_player');if (!this.gk || !this.gk._load) {this.uT = setTimeout( function() { gAudio.Us(); }, 100 );return;}if (this.Xi) clearTimeout( this.Xi );this.Xi = null;this.eb = true;;gGame.ge();};nm.prototype.FF = function() {if (!this.enabled || this.eb) return;;this.Xi = setTimeout( function() { gAudio.CG(); }, 10 * 1000 );var us = ( navigator.userAgent.match(/MSIE/) && navigator.userAgent.match(/Win/) );var html = '';if (us) {html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' + ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"' + 
' width="1" height="1" id="audio_player" align="middle">' + '<param name="allowScriptAccess" value="always" />' + '<param name="movie" value="' + gGame.homePath + '/audio.swf" />' + '<param name="quality" value="high" />' + '</object>';document.body.insertAdjacentHTML( "beforeEnd", html );}else {html = '<embed src="' + gGame.homePath + '/audio.swf" quality="high" swliveconnect="true" bgcolor="#ffffff"' + ' width="16" height="16" id="audio_player" name="player" align="middle" allowScriptAccess="always"' + ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">' + '</embed>';var div = document.createElement('DIV');div.style.position = 'absolute';div.style.width = '16px';div.style.height = '16px';div.style.left = '-4000px';div.style.top = '0px';div.style.visibility = 'hidden';div.innerHTML = html;document.body.appendChild(div);}};nm.prototype.CG = function() {if (this.uT) clearTimeout( this.uT );this.uT = null;;this.enabled = false;gGame.ge();};function lH(dh) {this.dG = 0;this.yH = null;for (var Sp in dh) this[Sp] = dh[Sp];;;if (!this.category) this.category = 'sfx';if (!this.yH.vx[this.category])return throwError( "Unknown audio category: " + this.category );if (!this.volume) this.volume = 1.0;
if (!this.rate) this.rate = 1.0;if (!this.balance) this.balance = 0.0;if (!this.loop) this.loop = false;this.load();}lH.prototype.ZL = function() {if (!this.yH.enabled) return;;this.yH.gk._set_volume( this.dG, Math.floor(this.uG() * 100) );this.yH.gk._set_balance( this.dG, Math.floor(this.IR() * 100) );};lH.prototype.uG = function() {return( Math.min(this.volume * this.yH.vx[ this.category ].volume *this.yH.MQ, 1.0));};lH.prototype.mi = function() {return(this.rate * this.yH.vx[ this.category ].rate *this.yH.zU);};lH.prototype.IR = function() {return this.balance;};lH.prototype.playSound = function() {if (!this.yH.enabled) return;this.yH.gk._play( this.dG );};lH.prototype.play = function() {if (!this.yH.enabled) return;this.yH.gk._play( this.dG );return this; };lH.prototype.stop = function() {if (!this.yH.enabled) return;this.yH.gk._stop( this.dG );
return this; };lH.prototype.rewind = function() {if (!this.yH.enabled) return;this.yH.gk._rewind( this.dG );return this; };lH.prototype.setRate = function(YF) {if (!this.yH.enabled) return;;};lH.prototype.setVolume = function(Yq) {if (!this.yH.enabled) return;if (Yq < 0) Yq = 0;else if (Yq > 1.0) Yq = 1.0;this.volume = Yq;var bh = this.uG();this.yH.gk._set_volume( this.dG, Math.floor(this.uG() * 100) );return this; };lH.prototype.setBalance = function(tK) {if (!this.yH.enabled) return;if (tK < -1.0) tK = -1.0;else if (tK > 1.0) tK = 1.0;this.balance = tK;var cx = this.IR();this.yH.gk._set_balance( this.dG, Math.floor(this.IR() * 100) );return this; };lH.prototype.load = function() {if (!this.yH.enabled) return '';;this.mediaURL = gGame.getGamePath() + '/' + gGame.audioPath + '/' + this.url;;this.yH.gk._load( this.dG, this.mediaURL, !!this.loop, Math.floor(this.uG() * 100), Math.floor(this.IR() * 100) );};;function Cq() {this.za = {};this.EL = 0;
this.fo = {};this.maxPriorityLevels = 4;this.maxLoadsPerFrame = 32;};Cq.prototype.loadImages = function(obj) {var oe = always_array(obj);var Az = gGame.getGamePath() + '/' + gGame.imagePath;for (var ah = 0; ah < oe.length; ah++) {var url = oe[ah];if (!this.za[url]) {var image = {loaded: false,img: new Image()};image.img.onerror = function() { throwError("Failed to load image: " + this.src); };image.img.src = Az + '/' + url;this.za[url] = image;} } };Cq.prototype.reloadAll = function() {var oe = hash_keys_to_array( this.za );this.za = {};this.EL = 0;this.fo = {};this.loadImages( oe );};Cq.prototype._r = function() {if ((num_keys(this.za) - this.EL) == 0) return 1.0;var Qe = 0;for (var url in this.za) {if (this.za[url].loaded) Qe++;else {var image = this.za[url];var img = image.img;if (typeof(img.complete) != 'undefined') {if (img.complete) {image.loaded = true;Qe++;}
}else {if (img.width > 0) {image.loaded = true;Qe++;}}}}return ((Qe - this.EL) / (num_keys(this.za) - this.EL));};Cq.prototype.pp = function() {this.EL = num_keys(this.za);};Cq.prototype.reset = function() {this.za = {};this.EL = 0;};Cq.prototype.lookupImage = function(url) {return this.za[url];};Cq.prototype.getImageTag = function(url, zI) {var image = this.lookupImage(url);if (!image || !image.loaded) return '';var img = image.img;return '<img src="'+img.src+'" width="'+img.width+'" height="'+img.height+'" border="0" '+compose_attribs(zI)+'/>';};Cq.prototype.getImageURL = function(url) {var image = this.lookupImage(url);if (!image || !image.loaded) return '';return image.img.src;};Cq.prototype.dynaLoad = function(BF, url, FN) {if (!FN) FN = 1.0;else if (FN > 1.0) FN = 1.0;else if (FN < 0.0) FN = 0.0;var ye = parseInt( FN * this.maxPriorityLevels );this.fo[BF] = [ ye, url ];};Cq.prototype.dynaIdle = function(fP) {
this.dynaTimeout = null;var Rk = 0;var Az = gGame.getGamePath() + '/' + gGame.imagePath;if (!num_keys(this.fo)) return;for (var ye = 0; ye <= this.maxPriorityLevels; ye++) {var SZ = [];for (var BF in this.fo) {if (this.fo[BF][0] == ye) {if (Rk < this.maxLoadsPerFrame) {var img = el(BF);;img.src = Az + '/' + this.fo[BF][1];Rk++;SZ.push( BF );}else {ye = this.maxPriorityLevels + 1;break;}} } for (var ah = 0; ah < SZ.length; ah++) {delete this.fo[ SZ[ah] ];}} if (fP && num_keys(this.fo) && !this.dynaTimeout) {this.dynaTimeout = setTimeout( 'gGame.gJ.dynaIdle(true)', 33 );}};Cq.prototype.dynaClear = function(wC) {var SZ = [];for (var BF in this.fo) {if (BF.indexOf(wC) == 0) SZ.push(BF);} for (var ah = 0; ah < SZ.length; ah++) {delete this.fo[ SZ[ah] ];}};;function Wn() {this.wv = {};
this.EL = 0;this.wK = 0;this.onLoad = null;};Wn.prototype.PJ = function(name, hd) {var Sp = name.replace(/\.js$/, "");if (!this.wv[Sp]) this.wv[Sp] = { loaded: false };this.wv[Sp].hd = hd;};Wn.prototype.Ud = function(D_, bC) {var MO = always_array(D_);if (!bC) bC = false;var Za = [];this.SN();for (var ah = 0; ah < MO.length; ah++) {var Sp = MO[ah].replace(/\.js$/, "");;if (this.wv[Sp] && this.wv[Sp].loaded && !bC) {array_push( Za, Sp );continue;}if (!this.wv[Sp]) this.wv[Sp] = {};this.wv[Sp].loaded = false;var iU = document.createElement('SCRIPT');var id = get_unique_id();iU.id = id;iU.type = "text/javascript";iU.src = gGame.getGamePath() + '/' + Sp + ".js";document.getElementsByTagName('head')[0].appendChild(iU);} if (Za.length) {for (var ah = 0; ah < Za.length; ah++) {var Sp = Za[ah];this.notifyLoad(Sp);}}this.TG();};Wn.prototype.notifyLoad = function(name) {;
var Sp = name.replace(/\.js$/, "");;var xI = this.wv[Sp];xI.loaded = true;xI.fired = false;if (xI.hd && !this.wK) {xI.fired = true;;if (xI.hd.indexOf('(') > -1) eval( xI.hd ); else window[ xI.hd ](); }if (!xI.hd) xI.fired = true;if (!this.wK) this.RY();};Wn.prototype._r = function() {if ((num_keys(this.wv) - this.EL) == 0) return 1.0;var Qe = 0;for (var Sp in this.wv) {if (this.wv[Sp].loaded) Qe++;}return ((Qe - this.EL) / (num_keys(this.wv) - this.EL));};Wn.prototype.pp = function() {this.EL = num_keys(this.wv);};Wn.prototype.SN = function() {this.wK++;};Wn.prototype.TG = function() {this.wK--;if (!this.wK) this.RY();};Wn.prototype.RY = function() {if (this.onLoad && (this._r() == 1.0)) {;var hm = this.onLoad;this.onLoad = null;if (hm.indexOf('(') > -1) eval( hm );else window[ hm ]();} 
for (var Sp in this.wv) {var xI = this.wv[Sp];if (xI.loaded && !xI.fired && xI.hd) {xI.fired = true;;if (xI.hd.indexOf('(') > -1) eval( xI.hd ); else window[ xI.hd ](); } } };;function Fb() {this.id = 'd_progress';this.width = 80;this.height = 68;this.zIndex = 99;this.div = null;this.parent = document.body;this.counter = 0;this.counterMax = 1;};Fb.prototype.nV = function(hd) {this.Lw = hd;this.images = [];for (var ah = 0; ah < 4; ah++) {this.images[ah] = new Image();this.images[ah].src = gGame.homePath + '/images/loading_' + ah + '.png';}this.GS();};Fb.prototype.GS = function() {var yo = 0;for (var ah = 0; ah < 4; ah++) {if (this.images[ah].complete || this.images[ah].width) yo++;}if (yo == 4) {eval( this.Lw );}else {setTimeout( 'gProgress.GS()', 100 );}
};Fb.prototype.setPosition = function() {var He = 0;var uU = null;if (gGame.lu) {for (var ah = 0; ah < gGame.lu.length; ah++) {var port = gGame.lu[ah];if (port.portWidth * port.portHeight > He) {He = port.portWidth * port.portHeight;uU = port;}}}if (uU) {this.parent = uU.div;this.left = parseInt( (this.parent.offsetWidth / 2) - (this.width / 2) );this.top = parseInt( (this.parent.offsetHeight / 2) - (this.height / 2) );}else {this.parent = document.body;this.left = parseInt( (document.body.clientWidth / 2) - (this.width / 2) );this.top = parseInt( (document.body.clientHeight / 3) - (this.height / 2) );}if (this.div) {this.div.style.left = this.left + 'px';this.div.style.top = this.top + 'px';}};Fb.prototype.show = function() {if (!this.div) {this.div = document.createElement('DIV');this.div.setAttribute( 'id', this.id );this.div.id = this.id;this.div.style.position = 'absolute';this.div.style.width = this.width + 'px';this.div.style.height = this.height + 'px';this.div.style.zIndex = this.zIndex;this.div.style.visibility = 'visible';this.setPosition();this.parent.appendChild(this.div);
var html = '<div style="position:relative; left:0px; top:0px; width:'+this.width+'px; height:'+this.height+'px;">';for (var ah = 0; ah < 4; ah++) {html += '<div id="'+this.id+'_'+ah+'" style="position:absolute; width:'+this.width+'px; height:'+this.height+'px; ';html += 'visibility:' + ((ah == 0) ? 'visible' : 'hidden') + '; ';if (pF) html += '">' + "<span "+ " style=\"" + "width:" + this.width + "px; height:" + this.height + "px;"+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+ "(src=\'" + this.images[ah].src + "\', sizingMethod='scale');\"></span>" + '</div>';else html += 'background-image:url('+this.images[ah].src+');"></div>';}html += '</div>';this.div.innerHTML = html;}else {this.RC();this.setPosition();this.div.style.visibility = 'visible';}};Fb.prototype.hide = function() {if (this.div) {this.div.style.left = '-4000px';this.div.style.visibility = 'hidden';try { this.parent.removeChild(this.div); } catch (e) {var div = el( this.id );try { this.parent.removeChild(div); } catch (e) { ; };};this.div = null;}};Fb.prototype.RC = function(hL, jw) {if (typeof(hL) != 'undefined') this.counter = hL;if (typeof(jw) != 'undefined') this.counterMax = jw;var Zx = [];for (var ah = 1; ah < 4; ah++) {Zx[ah] = el( this.id + '_' + ah );if (!Zx[ah]) return; }var value = this.counter / this.counterMax;if ((value >= 0.0) && (value < 0.33)) {
set_opacity( Zx[1], value / 0.33 );set_opacity( Zx[2], 0 );set_opacity( Zx[3], 0 );}else if ((value >= 0.33) && (value < 0.66)) {set_opacity( Zx[1], 1.0 );set_opacity( Zx[2], (value - 0.33) / 0.33 );set_opacity( Zx[3], 0 );}else if ((value >= 0.66) && (value < 1.0)) {set_opacity( Zx[1], 1.0 );set_opacity( Zx[2], 1.0 );set_opacity( Zx[3], (value - 0.66) / 0.33 );}else {set_opacity( Zx[1], 1.0 );set_opacity( Zx[2], 1.0 );set_opacity( Zx[3], 1.0 );}};;function Portal(id) {if (!id) return throwError("You must pass an ID");this.id = id;this.div = el(id);if (!this.div) return throwError("Cannot locate DOM element: " + id);this.style = this.div.style;if (!this.div.style.position) this.div.style.position = 'relative';this.div.style.overflow = 'hidden';this.Hf = [];this.hO = 1;this.portWidth = 0;this.portHeight = 0;this.virtualWidth = 0;this.virtualHeight = 0;this.scrollX = 0;this.scrollY = 0;this.cursor = true;this.hc = {div: null,last_x: 0,
last_y: 0,size: 192,padding: 64};};Portal.prototype.init = function() {if (!this.portWidth || !this.portHeight) return throwError("Portal size is not set.");var Iy = this.portWidth * this.hO;var hE = this.portHeight * this.hO;this.div.style.width = Iy + 'px';this.div.style.height = hE + 'px';for (var ah = 0; ah < this.Hf.length; ah++) {if (this.Hf[ah].init) this.Hf[ah].init();}this.setBackground();};Portal.prototype.setZoomLevel = function(nr) {this.hO = nr;gGame.imagePath = 'images/zoom_'+parseInt(nr)+'.0';};Portal.prototype.getZoomLevel = function() { return this.hO; };Portal.prototype.setBackgroundColor = function(wl) {this.div.style.backgroundImage = '';this.div.style.backgroundColor = wl;};Portal.prototype.setBackground = function(dh) {if (dh) this.background = copy_object( dh );if (!this.background) return;this.div.style.backgroundColor = this.background.color ? this.background.color : 'black';if (this.background.url) {var Az = gGame.getGamePath() + '/' + gGame.imagePath;this.div.style.backgroundImage = 'url(' + Az + '/' + this.background.url + ')';this.background.width = gGame.gJ.lookupImage( this.background.url ).img.width;this.background.height = gGame.gJ.lookupImage( this.background.url ).img.height;}else this.div.style.backgroundImage = '';var repeat = '';if (this.background.xMode && (this.background.xMode == 'infinite') && this.background.yMode && (this.background.yMode == 'infinite')) {repeat += ' repeat';
}else if (this.background.xMode && (this.background.xMode == 'infinite')) repeat += ' repeat-x';else if (this.background.yMode && (this.background.yMode == 'infinite')) repeat += ' repeat-y';if (repeat.length > 0) {try { this.div.style.backgroundRepeat = repeat; } catch(e) {this.div.setAttribute( "style", "background-repeat:" + repeat );};}if (!this.background.xDiv && this.background.xyDiv) this.background.xDiv = this.background.xyDiv;if (!this.background.xDiv) this.background.xDiv = 2;if (!this.background.yDiv && this.background.xyDiv) this.background.yDiv = this.background.xyDiv;if (!this.background.yDiv) this.background.yDiv = 2;};Portal.prototype.attach = function(obj) {obj.port = this;array_push( this.Hf, obj );if (obj.init) obj.init();};Portal.prototype.getPlane = function(id) {return find_object( this.Hf, { id: id } );};Portal.prototype.setSize = function(KY, ij) {this.portWidth = KY;this.portHeight = ij;};Portal.prototype.setVirtualSize = function(KY, ij) {this.virtualWidth = KY;this.virtualHeight = ij;};Portal.prototype.setScroll = function(PO, ed) {if (PO < 0) PO = 0;if (ed < 0) ed = 0;if (PO > this.virtualWidth - this.portWidth) PO = this.virtualWidth - this.portWidth;if (ed > this.virtualHeight - this.portHeight) ed = this.virtualHeight - this.portHeight;for (var ah = 0; ah < this.Hf.length; ah++) {if (this.Hf[ah].setScroll) this.Hf[ah].setScroll(PO,ed);}if (this.background && this.background.url) {var MU = 0, by = 0;if (this.background.xMode) {
if (this.background.xMode == 'infinite') {MU = 0 - parseInt( PO / this.background.xDiv );}else if (this.background.xMode == 'fit') {if (this.virtualWidth == this.portWidth) MU = 0;else {var Iy = this.portWidth * this.hO;var Vu = this.background.width - Iy;MU = 0 - parseInt( (PO * Vu) / (this.virtualWidth - this.portWidth) );}}} if (this.background.yMode) {if (this.background.yMode == 'infinite') {by = 0 - parseInt( ed / this.background.yDiv );}else if (this.background.yMode == 'fit') {if (this.virtualHeight == this.portHeight) by = 0;else {var hE = this.portHeight * this.hO;var aZ = this.background.height - hE;by = 0 - parseInt( (ed * aZ) / (this.virtualHeight - this.portHeight) );}}} this.div.style.backgroundPosition = MU + 'px ' + by + 'px';} this.scrollX = PO;this.scrollY = ed;};Portal.prototype.draw = function(_I) {if (!_I) _I = false;for (var ah = 0; ah < this.Hf.length; ah++) {this.Hf[ah].draw(_I);}if (!this.cursor && yT && !dK) {var bi = new Point( gGame.mousePt.x, gGame.mousePt.y );var tU = get_dom_object_info(this.div);bi.x -= tU.left;bi.y -= tU.top;
var jV = Math.floor(bi.x / this.hc.size);var uL = Math.floor(bi.y / this.hc.size);if ((jV != this.hc.last_x) || (uL != this.hc.last_y)) {var x = jV * this.hc.size;var y = uL * this.hc.size;var Iy = this.portWidth * this.hO;var hE = this.portHeight * this.hO;if ((bi.x < 0) || (bi.x >= Iy) || (bi.y < 0) || (bi.y >= hE)) {x = -4000; y = 0;}x -= (this.hc.padding / 2);y -= (this.hc.padding / 2);this.hc.div.style.left = x + 'px';this.hc.div.style.top = y + 'px';this.hc.last_x = jV;this.hc.last_y = uL;} }};Portal.prototype.logic = function() {for (var ah = 0; ah < this.Hf.length; ah++) {this.Hf[ah].logic();}};Portal.prototype.reset = function() {for (var ah = 0; ah < this.Hf.length; ah++) {if (this.Hf[ah].reset) this.Hf[ah].reset();}this.setBackgroundColor('black');};Portal.prototype.hide = function() {for (var ah = 0; ah < this.Hf.length; ah++) {if (this.Hf[ah].hide) this.Hf[ah].hide();}};Portal.prototype.show = function() {for (var ah = 0; ah < this.Hf.length; ah++) {if (this.Hf[ah].show) this.Hf[ah].show();}};
Portal.prototype.onLoadLevel = function() {for (var ah = 0; ah < this.Hf.length; ah++) {if (this.Hf[ah].onLoadLevel) this.Hf[ah].onLoadLevel();}};Portal.prototype.hideCursor = function() {if (!this.cursor) return; if (yT) {if (dK) {this.div.style.cursor = 'none';}else {if (!this.hc.div) {var Qq = this.hc.size + this.hc.padding;var div = document.createElement('DIV');div.style.position = 'absolute';div.style.width = Qq+'px';div.style.height = Qq+'px';div.style.left = '-4000px';div.style.top = '0px';div.style.zIndex = 999; div.innerHTML = '<embed src="'+gGame.homePath+'/hide_cursor.swf" quality="high" swliveconnect="true" bgcolor="#ffffff" width="'+Qq+'" height="'+Qq+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" />';this.div.appendChild(div);this.hc.div = div;}this.hc.div.style.visibility = 'visible';this.div.style.cursor = 'crosshair';} }else {if (dK) this.div.style.cursor = 'none';else this.div.style.cursor = 'url(' + gGame.homePath + '/transparent.cur), crosshair';}this.cursor = false;};Portal.prototype.showCursor = function() {if (this.cursor) return; if (yT) {if (this.hc.div) {this.div.removeChild( this.hc.div );
this.hc.div = null;}}this.div.style.cursor = 'default';this.cursor = true;};Portal.prototype.setHandler = function(name, hm) {if (name.match(/mouse/i)) {;this.div.captureMouse = this;}if (!this[name]) this[name] = [];array_push( this[name], hm );};Portal.prototype.clearHandler = function(name) {if (this[name]) this[name] = [];};Portal.prototype.getMouseCoords = function() {var Iy = this.portWidth * this.hO;var hE = this.portHeight * this.hO;var Ni = new Point(0, 0);var bi = new Point( gGame.mousePt.x, gGame.mousePt.y );var tU = get_dom_object_info(this.div);bi.x -= tU.left;bi.y -= tU.top;if ((bi.x >= 0) && (bi.x < Iy) && (bi.y >= 0) && (bi.y < hE)) {bi.x /= this.hO;bi.y /= this.hO;bi.x += this.scrollX;bi.y += this.scrollY;return bi;}else return null;};function tk() {};tk.prototype.scrollX = 0;tk.prototype.scrollY = 0;tk.prototype.scrollSpeed = 1.0;tk.prototype.zIndex = 1;
tk.prototype.setZIndex = function(ah) {this.zIndex = ah;};tk.prototype.init = function() {};tk.prototype.reset = function() {};tk.prototype.logic = function() {};tk.prototype.draw = function() {};tk.prototype.hide = function() {};tk.prototype.show = function() {};;function TilePlane(id) {if (!id) id = get_unique_id();this.id = id;this.tileSize = 16;this.tileExt = 'gif';this.data = [ [] ];this.tN = [];this.Zs = [];this.Fq = {};this.vY = {};this.pA = 0;this.xo = 0;this.CR = 0;this.gy = 0;this.bo = 4;this.Ji = 4;this.iu = false;this.zA = null;};TilePlane.prototype = new tk();TilePlane.prototype.setTileSize = function(value) { this.tileSize = parseInt(value); };TilePlane.prototype.setTilesPerDiv = function(Hs, nC) { this.bo = parseInt(Hs); this.Ji = parseInt(nC); };TilePlane.prototype.setInstantLoad = function(enabled) { this.iu = !!enabled; };TilePlane.prototype.setDrawTile = function(hm) { this.zA = hm; };TilePlane.prototype.init = function() {
;this.globalID = this.port.id + '_' + this.id;this.divWidth = this.tileSize * this.bo;this.divHeight = this.tileSize * this.Ji;this.pH = this.zoom(this.divWidth);this.PD = this.zoom(this.divHeight);var Ey = Math.ceil(this.port.portWidth / this.divWidth) + 1;var SY = Math.ceil(this.port.portHeight / this.divHeight) + 1;this.numDivs = Ey * SY;for (var ah = 0; ah < this.numDivs; ah++) {var eg = this.globalID + '_' + ah;var div = document.createElement('DIV');div.setAttribute('id', eg);div.id = eg;div.style.position = 'absolute';div.style.left = '-1000px';div.style.top = '0px';div.style.width = this.zoom(this.divWidth) + 'px';div.style.height = this.zoom(this.divHeight) + 'px';div.style.zIndex = this.zIndex;this.port.div.appendChild(div);var It = this.zoom(this.tileSize);var Ak = gGame.getGamePath() + '/' + gGame.imagePath + '/' + gGame.tileImagePath;var html = '';if (this.zA) html = '<table cellspacing="0" cellpadding="0" border="0">';for (var y = 0; y < this.Ji; y++) {if (this.zA) html += '<tr>';for (var x = 0; x < this.bo; x++) {if (this.zA) html += '<td width="' + It + '" height="' + It + '">';var BF = eg + '_' + x + '_' + y;if (this.zA) {html += '<div id="' + BF + '" width="' + It + '" height="' + It + '"></div>';}else {html += '<img id="' + BF + '" src="' + Ak + '/1.' + this.tileExt + '" width="' + It + '" height="' + It + '" border="0"/>';}if (this.zA) html += '</td>';} if (this.zA) html += '</tr>';
else html += '<br/>';} if (this.zA) html += '</table>';div.innerHTML = html;array_push( this.Zs, eg );this.Fq[ eg ] = div;this.vY[ eg ] = {id: eg,div: div,style: div.style,left: -1000,top: 0,data: make_2d_array( this.bo, this.Ji, 1 )};} };TilePlane.prototype.reset = function() {for (var eg in this.Fq) {try { this.port.div.removeChild(this.Fq[eg]); } catch (e) {var div = el( eg );try { this.port.div.removeChild(div); } catch (e) { ; };}}this.tN = [];this.Zs = [];this.Fq = {};this.vY = {};};TilePlane.prototype.draw = function(_I) {var nk = this.scrollX % this.divWidth;var Wd = this.scrollY % this.divHeight;var Iy = this.port.div.offsetWidth;var hE = this.port.div.offsetHeight;var pH = this.pH;var PD = this.PD;var qh = Iy;if (Iy % pH) qh += (pH - (Iy % pH));var qL = hE;if (hE % PD) qL += (PD - (hE % PD));var xd = this.zoom( this.scrollX - this.pA );
var yd = this.zoom( this.scrollY - this.xo );if (xd || yd) {for (var ah = 0; ah < this.tN.length; ah++) {var obj = this.vY[ this.tN[ah] ] ;var oq = obj.left - xd;var Me = obj.top - yd;if ((oq <= 0 - pH) || (oq >= qh) || (Me <= 0 - PD) || (Me >= qL)) {obj.style.left = '-1000px';obj.left = -1000;array_push( this.Zs, array_splice(this.tN, ah, 1)[0] );ah--;}else {obj.style.left = oq + 'px';obj.style.top = Me + 'px';obj.left = oq;obj.top = Me;}}} this.tempObjs = {};for (var ah = 0; ah < this.tN.length; ah++) {this.tempObjs[this.tN[ah]] = this.vY[ this.tN[ah] ];}var Ak = gGame.getGamePath() + '/' + gGame.imagePath + '/' + gGame.tileImagePath;for (var oq = 0; oq <= qh; oq += pH) {for (var Me = 0; Me <= qL; Me += PD) {if (!this.LV(oq, Me)) {if (!nk && (oq == qh)) continue;if (!Wd && (Me == qL)) continue;var id = array_pop( this.Zs );;array_push( this.tN, id );var obj = this.vY[id];var fA = oq - this.zoom( nk );var YY = Me - this.zoom( Wd );var HZ = parseInt( (this.unzoom(fA) + this.scrollX) / this.tileSize );var oW = parseInt( (this.unzoom(YY) + this.scrollY) / this.tileSize );for (var RR = 0; RR < this.Ji; RR++) {
for (var QB = 0; QB < this.bo; QB++) {var BF = obj.id + '_' + QB + '_' + RR;if (HZ + QB >= this.data.length) continue;var ea = this.data[ HZ + QB ][ oW + RR ];if (typeof(ea) == 'undefined') continue;if (obj.data[QB][RR] == ea) continue; obj.data[QB][RR] = ea;if (this.zA) {var VY = el(BF);;this.zA( VY, ea, HZ + QB, oW + RR );}else {var FN = 1.0;if (xd > 0) FN *= (QB / (this.bo - 1));else if (xd < 0) FN *= (((this.bo - 1) - QB) / (this.bo - 1));if (yd > 0) FN *= (RR / (this.Ji - 1));else if (yd < 0) FN *= (((this.Ji - 1) - RR) / (this.Ji - 1));if (_I || this.iu || !FN || (Math.abs(xd) >= pH) || (Math.abs(yd) >= PD)) {var img = el(BF);;img.src = Ak + '/' + ea + '.' + this.tileExt;delete gGame.gJ.fo[BF];}else {gGame.gJ.dynaLoad( BF, gGame.tileImagePath + '/' + ea + '.' + this.tileExt, FN );}} } } obj.style.left = fA + 'px';obj.style.top = YY + 'px';obj.left = fA;obj.top = YY;if (!_I) {oq = qh + 1;Me = qL + 1;}} } 
} if (gGame.inGame && this.objectData && (xd || yd)) this.OW();this.pA = this.scrollX;this.xo = this.scrollY;};TilePlane.prototype.OW = function() {var iP = 0;var XF = 0;var DE = 0;var Nj = 0;var LF = 0;if (this.scrollX > this.pA) {var NL = parseInt( (this.scrollX + this.port.portWidth - 1) / this.tileSize );var UY = parseInt( (this.pA + this.port.portWidth - 1) / this.tileSize );if (NL != UY) {var TZ = parseInt( this.scrollX / this.tileSize );XF = UY + 1;if (XF < TZ) XF = TZ;Nj = NL;DE = parseInt( this.scrollY / this.tileSize );LF = parseInt( (this.scrollY + this.port.portHeight - 1) / this.tileSize );iP = 1;} } else if (this.scrollX < this.pA) {var NL = parseInt( this.scrollX / this.tileSize );var UY = parseInt( this.pA / this.tileSize );if (NL != UY) {var ws = parseInt( (this.scrollX + this.port.portWidth - 1) / this.tileSize );XF = NL;Nj = UY - 1;if (Nj > ws) Nj = ws;DE = parseInt( this.scrollY / this.tileSize );LF = parseInt( (this.scrollY + this.port.portHeight - 1) / this.tileSize );iP = 1;} } if (iP) {for (var tx = XF; tx <= Nj; tx++) {for (var ty = DE; ty <= LF; ty++) {
var obj = this.lookupTile( tx, ty, 'objectData' );if (obj && obj.onScreen) obj.onScreen();} } iP = 0;} if (this.scrollY > this.xo) {var RE = parseInt( (this.scrollY + this.port.portHeight - 1) / this.tileSize );var Q_ = parseInt( (this.xo + this.port.portHeight - 1) / this.tileSize );if (RE != Q_) {var YV = parseInt( this.scrollY / this.tileSize );DE = Q_ + 1;if (DE < YV) DE = YV;LF = RE;XF = parseInt( this.scrollX / this.tileSize );Nj = parseInt( (this.scrollX + this.port.portWidth - 1) / this.tileSize );iP = 1;} } else if (this.scrollY < this.xo) {var RE = parseInt( this.scrollY / this.tileSize );var Q_ = parseInt( this.xo / this.tileSize );if (RE != Q_) {var db = parseInt( (this.scrollY + this.port.portHeight - 1) / this.tileSize );DE = RE;LF = Q_ - 1;if (LF > db) LF = db;XF = parseInt( this.scrollX / this.tileSize );Nj = parseInt( (this.scrollX + this.port.portWidth - 1) / this.tileSize );iP = 1;} } if (iP) {for (var tx = XF; tx <= Nj; tx++) {for (var ty = DE; ty <= LF; ty++) {var obj = this.lookupTile( tx, ty, 'objectData' );if (obj && obj.onScreen) obj.onScreen();} } } 
};TilePlane.prototype.activateScreenObjects = function() {var TZ = parseInt( this.scrollX / this.tileSize );var ws = parseInt( (this.scrollX + this.port.portWidth) / this.tileSize );var YV = parseInt( this.scrollY / this.tileSize );var db = parseInt( (this.scrollY + this.port.portHeight) / this.tileSize );for (var tx = TZ - 1; tx <= ws; tx++) {for (var ty = YV; ty <= db; ty++) {var obj = this.lookupTile( tx, ty, 'objectData' );if (obj && obj.onScreen) obj.onScreen();} } };TilePlane.prototype.LV = function(oq, Me) {for (var Sp in this.tempObjs) {var obj = this.tempObjs[Sp];if ((oq >= obj.left) && (oq < obj.left + this.pH) && (Me >= obj.top) && (Me < obj.top + this.PD)) {delete this.tempObjs[Sp];return this.Fq[Sp];}}return null;};TilePlane.prototype.xi = function(oq, Me) {for (var ah = 0; ah < this.tN.length; ah++) {var obj = this.vY[ this.tN[ah] ];if ((oq >= obj.left) && (oq < obj.left + this.pH) && (Me >= obj.top) && (Me < obj.top + this.PD)) {return this.Fq[ this.tN[ah] ];}} return null;};TilePlane.prototype.zoom = function(value) {return parseInt( value * this.port.hO );};TilePlane.prototype.unzoom = function(value) {return parseInt( value / this.port.hO );};
TilePlane.prototype.lookupTileFromScreen = function(oq, Me, Pj) {if (!Pj) Pj = 'data'; var tx = parseInt( (this.unzoom(oq) + this.scrollX) / this.tileSize );var ty = parseInt( (this.unzoom(Me) + this.scrollY) / this.tileSize );return this.lookupTile(tx, ty, Pj);};TilePlane.prototype.lookupTileFromGlobal = function(oq, Me, Pj) {if (!Pj) Pj = 'data'; var tx = parseInt( oq / this.tileSize );var ty = parseInt( Me / this.tileSize );return this.lookupTile(tx, ty, Pj);};TilePlane.prototype.lookupTile = function(tx, ty, Pj) {if (!Pj) Pj = 'data'; if ((tx < 0) || (ty < 0) || (tx >= this.CR) || (ty >= this.gy)) return 0;return this[Pj][tx][ty];};TilePlane.prototype.setTileFromScreen = function(oq, Me, ah, Pj) {if (!Pj) Pj = 'data'; var tx = parseInt( (this.unzoom(oq) + this.scrollX) / this.tileSize );var ty = parseInt( (this.unzoom(Me) + this.scrollY) / this.tileSize );return this.setTile(tx, ty, ah, Pj);};TilePlane.prototype.setTileFromGlobal = function(oq, Me, ah, Pj) {if (!Pj) Pj = 'data'; var tx = parseInt( oq / this.tileSize );var ty = parseInt( Me / this.tileSize );return this.setTile(tx, ty, ah, Pj);};TilePlane.prototype.setTile = function(tx, ty, ah, Pj) {if (!Pj) Pj = 'data'; var Ak = gGame.getGamePath() + '/' + gGame.imagePath + '/' + gGame.tileImagePath;if ((tx < 0) || (ty < 0) || (tx >= this.CR) || (ty >= this.gy)) return 0;this[Pj][tx][ty] = ah;if (Pj == 'data') {var oq = this.zoom( (tx * this.tileSize) - this.pA );var Me = this.zoom( (ty * this.tileSize) - this.xo );var div = this.xi(oq, Me);if (div) {var QB = parseInt( this.unzoom(oq - div.offsetLeft) / this.tileSize );
var RR = parseInt( this.unzoom(Me - div.offsetTop) / this.tileSize );var eg = div.id;this.vY[ eg ].data[QB][RR] = ah;var BF = eg + '_' + QB + '_' + RR;var img = el(BF);if (this.zA) {;this.zA( img, ah, tx, ty );}else {;img.src = Ak + '/' + ah + '.' + this.tileExt;}} } return 1;};TilePlane.prototype.setData = function(X_, Pj) {if (!Pj) Pj = 'data'; this[Pj] = X_;if (Pj == 'data') {this.CR = this.data.length;this.gy = this.data[0].length;for (var ah = 0; ah < this.tN.length; ah++) {var div = this.Fq[ this.tN[ah] ];div.style.left = '-1000px';array_push( this.Zs, array_splice(this.tN, ah, 1)[0] );ah--;}}else if (Pj == 'objectData') {for (var tx=0; tx<this.objectData.length; tx++) {var CN = this.objectData[tx];for (var ty=0; ty<CN.length; ty++) {if (CN[ty]) {if (typeof(CN[ty]) == 'string') {CN[ty] = eval("new " + CN[ty] + "();");}else {var bb = eval("new " + CN[ty].type + "();");
for (var Sp in CN[ty]) bb[Sp] = CN[ty][Sp];CN[ty] = bb;}CN[ty].plane = this;CN[ty].tx = tx;CN[ty].ty = ty;} } } }};TilePlane.prototype.setScroll = function(PO, ed) {this.scrollX = PO * this.scrollSpeed;this.scrollY = ed * this.scrollSpeed;};TilePlane.prototype.logic = function() {};TilePlane.prototype.hide = function() {for (var Sp in this.Fq) {this.Fq[Sp].style.visibility = 'hidden';}};TilePlane.prototype.show = function() {for (var Sp in this.Fq) {this.Fq[Sp].style.visibility = 'visible';}};TilePlane.prototype.linkSpritePlane = function(plane) {this.spritePlane = plane;};;function SpritePlane(id) {if (!id) id = get_unique_id();this.id = id;this.sprites = {};this.rS = 16; this.cb = 0.5;this.Ae = null;this.jL = 0.5;this.Ef = 8; this.offsetX = 0;
this.offsetY = 0;this.opacity = 1.0;};SpritePlane.prototype = new tk();SpritePlane.prototype.setMinSpriteSize = function(size) { this.rS = parseInt(size); };SpritePlane.prototype.setOffscreenDistance = function(value) { this.cb = parseFloat(value); };SpritePlane.prototype.setEtherDistance = function(value) { this.jL = parseFloat(value); };SpritePlane.prototype.setEtherCheckFreq = function(value) { this.Ef = parseInt(value); };SpritePlane.prototype.init = function() {;this.globalID = this.port.id + '_' + this.id;for (var Sp in this.sprites) {this.sprites[Sp].init();}};SpritePlane.prototype.reset = function() {for (var Sp in this.sprites) {this.sprites[Sp].reset();}};SpritePlane.prototype.deleteAll = function() {this.reset();this.sprites = {};};SpritePlane.prototype.createSprite = function(dh) {if (!dh.type) dh.type = Sprite;var dI = (typeof(dh.type) == 'string') ? eval('new ' + dh.type) : new dh.type;for (var Sp in dh) {if (Sp != 'type') dI[Sp] = dh[Sp];}if (!dh.zIndex) dI.zIndex = this.zIndex;this.attach(dI);return dI;};SpritePlane.prototype.attach = function(dI) {dI.plane = this;dI.port = this.port;dI.init();this.sprites[ dI.id ] = dI;}
SpritePlane.prototype.setOpacity = function(ac) {if (ac != this.opacity) {this.opacity = ac;this.EF = true;}};SpritePlane.prototype.draw = function(_I) {for (var Sp in this.sprites) {var dI = this.sprites[Sp];if (this.EF) dI.EF = true;dI.draw();if (dI.destroyed) delete this.sprites[Sp];}if (_I) this.MH(true);this.EF = false;};SpritePlane.prototype.logic = function() {if (this.soloSprite) {this.soloSprite.logic();}else {var Vw = [];for (var Sp in this.sprites) {var dI = this.sprites[Sp];if (dI.lateLogic) array_push( Vw, Sp );else {if (!dI.destroyed) dI.logic();if (dI.destroyed) delete this.sprites[Sp];}} if (Vw.length > 0) {for (var ah = 0; ah < Vw.length; ah++) {var Sp = Vw[ah];var dI = this.sprites[Sp];if (!dI.destroyed) dI.logic();if (dI.destroyed) delete this.sprites[Sp];} } } };
SpritePlane.prototype.setScroll = function(PO, ed) {this.scrollX = PO * this.scrollSpeed;this.scrollY = ed * this.scrollSpeed;this.MH(false);};SpritePlane.prototype.GF = function(x, y) {return '' + Math.floor(x / this.port.portWidth) + 'x' + Math.floor(y / this.port.portHeight);};SpritePlane.prototype.setupEther = function(ether) {this.Ae = {};for (var ah = 0; ah < ether.length; ah++) {var obj = ether[ah];;;if (!window[ obj.type ].prototype.width || !window[ obj.type ].prototype.height) return throwError("Object is not setup for ether (missing width/height in prototype)");obj.width = window[ obj.type ].prototype.width;obj.height = window[ obj.type ].prototype.height;var Sp = this.GF(obj.x, obj.y);if (!this.Ae[Sp]) this.Ae[Sp] = [];array_push( this.Ae[Sp], obj );} };SpritePlane.prototype.MH = function(_I) {if (this.Ae && (_I || (gGame.logicClock % this.Ef == 0))) {var Zh = new Rect(this.scrollX - (this.port.portWidth * this.jL), this.scrollY - (this.port.portHeight * this.jL),this.scrollX + this.port.portWidth + (this.port.portWidth * this.jL), this.scrollY + this.port.portHeight + (this.port.portHeight * this.jL));var yi = {};yi[ this.GF(Zh.left, Zh.top) ] = 1;yi[ this.GF(Zh.right, Zh.top) ] = 1;yi[ this.GF(Zh.left, Zh.bottom) ] = 1;yi[ this.GF(Zh.right, Zh.bottom) ] = 1;yi[ this.GF(Zh.centerPointX(), Zh.centerPointY()) ] = 1;for (var yA in yi) {if (this.Ae[yA]) {var Oi = this.Ae[yA];
for (var ah = 0; ah < Oi.length; ah++) {var va = Oi[ah];var cz = new Rect(va.x, va.y, va.x + va.width,va.y + va.height);if (Zh.rectIn(cz)) {var dI = this.createSprite( merge_objects(va, {type: window[ va.type ]}) );dI.Ae = va;array_splice( Oi, ah, 1 );ah--;} } } } } };SpritePlane.prototype.hide = function() {for (var Sp in this.sprites) {this.sprites[Sp].hide();}};SpritePlane.prototype.show = function() {for (var Sp in this.sprites) {this.sprites[Sp].show();}};SpritePlane.prototype.movePointX = function(oq, Me, fK, MM, tilePlane) {if (typeof(MM) == 'undefined') MM = true;if (typeof(tilePlane) == 'undefined') tilePlane = this.tilePlane;var Ss = oq + fK;if (parseInt(oq) == parseInt(Ss)) return null;while (oq != Ss) {if (fK > 0) {oq += this.rS;if (oq > Ss) oq = Ss;}else {oq -= this.rS;
if (oq < Ss) oq = Ss;}if (MM) {for (var Sp in this.sprites) {var dI = this.sprites[Sp];if (dI.collisions && !dI.destroyed && dI.ptIn(oq, Me)) {var Nn = Ss;if (dI.solid) {if (fK > 0) {if (dI.hitRect) Nn = (dI.x + dI.hitRect.left) - 1;else Nn = dI.x - 1;}else {if (dI.hitRect) Nn = (dI.x + dI.hitRect.right);else Nn = dI.x + dI.width;}}var event = {type: 'collision',targetType: 'dI',target: dI,correctedX: Nn,correctedY: Me};return event;} } } if (tilePlane && tilePlane.objectData) {var obj = tilePlane.lookupTileFromGlobal(oq, Me, 'objectData');if (obj && obj.collisions) {var Nn = oq;if (obj.solid) {var WN = oq % tilePlane.tileSize;if (fK > 0) Nn = (oq - WN) - 1;else Nn = oq + (tilePlane.tileSize - WN);}var event = {type: 'collision',targetType: 'tile',
target: obj,correctedX: Nn,correctedY: Me};return event;} } } return null;};SpritePlane.prototype.movePointY = function(oq, Me, QX, MM, tilePlane) {if (typeof(MM) == 'undefined') MM = true;if (typeof(tilePlane) == 'undefined') tilePlane = this.tilePlane;var Zv = Me + QX;if (parseInt(Me) == parseInt(Zv)) return null;while (Me != Zv) {if (QX > 0) {Me += this.rS;if (Me > Zv) Me = Zv;}else {Me -= this.rS;if (Me < Zv) Me = Zv;}if (MM) {for (var Sp in this.sprites) {var dI = this.sprites[Sp];if (dI.collisions && !dI.destroyed && dI.ptIn(oq, Me)) {var _y = Zv;if ((QX > 0) && (dI.ground || dI.solid)) {if (dI.hitRect) _y = (dI.y + dI.hitRect.top) - 1;else _y = dI.y - 1;}else if ((QX < 0) && dI.solid) {if (dI.hitRect) _y = dI.y + dI.hitRect.bottom;else _y = dI.y + dI.height;}var event = {type: 'collision',targetType: 'dI',
target: dI,correctedX: oq,correctedY: _y};return event;} } } if (tilePlane && tilePlane.objectData) {var obj = tilePlane.lookupTileFromGlobal(oq, Me, 'objectData');if (obj && obj.collisions) {var _y = Me;if ((((QX > 0) && (obj.ground || obj.solid)) || ((QX < 0) && obj.solid))) {var DS = Me % tilePlane.tileSize;if (QX > 0) _y = (Me - DS) - 1;else _y = Me + (tilePlane.tileSize - DS);}var event = {type: 'collision',targetType: 'tile',target: obj,correctedX: oq,correctedY: _y};return event;} } } return null;};SpritePlane.prototype.moveLineX = function(oq, top, bottom, fK, MM, tilePlane) {var events = [];for (var Me = top; Me < bottom; Me += this.rS) {var event = this.movePointX( oq, Me, fK, MM, tilePlane );if (event) array_push(events, event);}var Me = bottom - 1;var event = this.movePointX( oq, Me, fK, MM, tilePlane );if (event) array_push(events, event);if (!events.length) return null;
for (var ah = 0; ah < events.length; ah++) {if (events[ah].target.solid) return events[ah];}return events[0];};SpritePlane.prototype.moveLineY = function(Me, left, right, QX, MM, tilePlane) {var events = [];for (var oq = left; oq < right; oq += this.rS) {var event = this.movePointY( oq, Me, QX, MM, tilePlane );if (event) array_push(events, event);}var oq = right - 1;var event = this.movePointY( oq, Me, QX, MM, tilePlane );if (event) array_push(events, event);if (!events.length) return null;for (var ah = 0; ah < events.length; ah++) {if (events[ah].target.solid) return events[ah];}return events[0];};SpritePlane.prototype.checkFreeTile = function(tx, ty) {var s = this.tilePlane.tileSize;var x = tx * s;var y = ty * s;if (this.movePointX(x, y, 1)) return false;if (this.movePointY(x + s - 1, y, 1)) return false;if (this.movePointX(x + s - 1, y + s - 1, -1)) return false;if (this.movePointY(x, y + s - 1, -1)) return false;return true;};SpritePlane.prototype.findSprite = function(PS) {if (typeof(PS) != 'object') PS = { id: ''+PS };var CW = num_keys(PS);for (var Sp in this.sprites) {var dI = this.sprites[Sp];var Pv = 0;for (var b in PS) {if (dI[b] == PS[b]) Pv++;}if (Pv >= CW) return dI;
}return null;};SpritePlane.prototype.findSprites = function(PS) {var CW = num_keys(PS);var Sd = [];for (var Sp in this.sprites) {var dI = this.sprites[Sp];var Pv = 0;for (var b in PS) {if (dI[b] == PS[b]) Pv++;}if (Pv >= CW) array_push( Sd, dI );}return Sd;};SpritePlane.prototype.linkTilePlane = function(plane) {this.tilePlane = plane;};SpritePlane.prototype.tween = function(dh) {dh.target = this;gTween.addTween(dh);};SpritePlane.prototype.onTweenUpdate = function(tween) {var ZE = tween.properties;if (ZE.opacity) this.EF = true;};;function HUD(id) {if (!id) id = get_unique_id();this.id = id;this.x = 0;this.y = 0;this.scrollX = 0;this.scrollY = 0;this.zIndex = 99; };HUD.prototype = new tk();HUD.prototype.cols = 0;HUD.prototype.rows = 0;HUD.prototype.lf = 8;
HUD.prototype.QV = 8;HUD.prototype.font = '';HUD.prototype.ey = [ [] ];HUD.prototype.wO = {'-': 'dash','!': 'bang','+': 'plus'};HUD.prototype.setTableSize = function(uy, zc) {this.cols = uy;this.rows = zc;this.ey = [];for (var x=0; x<uy; x++) {this.ey[x] = [];for (var y=0; y<zc; y++) {this.ey[x][y] = '';} } };HUD.prototype.setCharSize = function(qS, hq) {this.lf = qS;this.QV = hq;};HUD.prototype.setPosition = function(px, Ww) {this.x = px;this.y = Ww;};HUD.prototype.setFont = function(tI) {if (!gGame.fonts[tI]) return throwError( "Font not found: " + tI );this.font = tI;this.setCharSize( gGame.fonts[tI].width, gGame.fonts[tI].height );};HUD.prototype.init = function() {;;var Az = gGame.getGamePath() + '/' + gGame.imagePath + '/' + gGame.fontImagePath;this.fontPath = Az + '/' + this.font;var Rf = this.lf * this.port.hO;var SS = this.QV * this.port.hO;var Hq = Rf * this.cols;
var gT = SS * this.rows;var gN = this.x * this.port.hO;var yh = this.y * this.port.hO;this.globalID = this.port.id + '_' + this.id;this.div = document.createElement('DIV');this.style = this.div.style;this.div.setAttribute('id', this.globalID);this.div.id = this.globalID;this.style.position = 'absolute';this.style.width = Hq + 'px';this.style.height = gT + 'px';this.style.left = gN + 'px';this.style.top = yh + 'px';this.style.zIndex = this.zIndex;this.port.div.appendChild(this.div);var html = '<table cellspacing="0" cellpadding="0" border="0" style="font-size:1pt">';for (var y=0; y<this.rows; y++) {html += '<tr>';for (var x=0; x<this.cols; x++) {html += '<td width="'+Rf+'" height="'+SS+'" id="'+this.globalID+'_'+x+'_'+y+'">';html += this.ZF( this.ey[x][y] );html += '</td>';} html += '</tr>';} html += '</table>';this.div.innerHTML = html;};HUD.prototype.reset = function() {try { this.port.div.removeChild(this.div); } catch (e) {var div = el( this.globalID );try { this.port.div.removeChild(div); } catch (e) { ; };}this.style = null;this.div = null;};HUD.prototype.ZF = function(Ht) {if (Ht == ' ') return '&nbsp;';var Az = gGame.getGamePath() + '/' + gGame.imagePath; var Rf = this.lf * this.port.hO;
var SS = this.QV * this.port.hO;var url = '';if (Ht) {if (this.wO[Ht]) Ht = this.wO[Ht];if (Ht.match && Ht.match(/\//)) url = Az + '/' + Ht;else url = this.fontPath+'/'+Ht+'.gif';}if (url) return '<img src="'+url+'" width="'+Rf+'" height="'+SS+'" border="0"/>';else return '&nbsp;';};HUD.prototype.setChar = function(x, y, Ht) {if ((x < 0) || (y < 0) || (x >= this.cols) || (y >= this.rows)) return;if (this.ey[x][y] != Ht) {this.ey[x][y] = Ht;var div = el( this.globalID+'_'+x+'_'+y );if (div) div.innerHTML = this.ZF(Ht);}};HUD.prototype.setString = function(x, y, wC) {if (wC.match && wC.match(/\//)) {this.setChar(x, y, wC); return;}if (typeof(wC) != 'string') wC = wC.toString();var it = wC.length;for (var ah=0; ah<it; ah++)this.setChar( x + ah, y, wC.substring(ah, ah + 1) );};HUD.prototype.setPadInt = function(x, y, value, ml) {var wC = '' + value;while (wC.length < ml) wC = '0' + wC;this.setString(x, y, wC);};HUD.prototype.logic = function() {};HUD.prototype.draw = function() {};HUD.prototype.hide = function() {this.div.style.visibility = 'hidden';};
HUD.prototype.show = function() {this.div.style.visibility = 'visible';};;function Sprite() {};Sprite.prototype.x = 0;Sprite.prototype.y = 0;Sprite.prototype.width = 0;Sprite.prototype.height = 0;Sprite.prototype.frameX = 0;Sprite.prototype.frameY = 0;Sprite.prototype.zIndex = 1;Sprite.prototype.opacity = 1.0;Sprite.prototype.url = '';Sprite.prototype.div = null;Sprite.prototype.visible = true;Sprite.prototype.offsetX = 0;Sprite.prototype.offsetY = 0;Sprite.prototype.By = 0;Sprite.prototype.sl = 0;Sprite.prototype.HI = -1000;Sprite.prototype.Xl = -1000;Sprite.prototype.dieOffscreen = 1;Sprite.prototype.init = function() {if (!this.id) this.id = get_unique_id();this.require('port', 'url', 'width', 'height');if (!this.offsetX) this.offsetX = 0;if (!this.offsetY) this.offsetY = 0;this.globalID = this.port.id + '_' + this.id;this.div = document.createElement('DIV');this.style = this.div.style;this.div.setAttribute('id', this.globalID);this.div.id = this.globalID;this.style.position = 'absolute';this.setImage();this.style.zIndex = this.zIndex;this.style.visibility = this.visible ? "visible" : "hidden";this.Uu();this.port.div.appendChild(this.div);};
Sprite.prototype.reset = function() {try { this.port.div.removeChild(this.div); } catch (e) {var div = el( this.globalID );try { this.port.div.removeChild(div); } catch (e) { ; };}this.style = null;this.div = null;};Sprite.prototype.setImage = function(url) {if (url) this.url = url;var image = gGame.gJ.lookupImage( this.url );;var img = image.img;if (!this.width) this.width = img.width;if (!this.height) this.height = img.height;this.style.width = img.width + 'px';this.style.height = img.height + 'px';this.style.clip = this.rq();this.style.left = this.dF() + 'px';this.style.top = this.tC() + 'px';if (bu && !Ik && this.url.match(/\.png$/i)) {this.div.innerHTML = "<span "+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;"+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";}else {this.div.innerHTML = '<img src="'+img.src+'" width="'+img.width+'" height="'+img.height+'" border="0"/>' + "\n";}};Sprite.prototype.setBackground = function(url) {if (bu && !Ik && url.match(/\.png$/i)) {this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader"+ "(src=\'" + gImageLoader.getImageURL(url) + "\', sizingMethod='scale')";}else {this.style.backgroundImage = 'url(' + gImageLoader.getImageURL(url) + ')';}};Sprite.prototype.setZIndex = function(jo) {
this.style.zIndex = jo;this.zIndex = jo;};Sprite.prototype.setOpacity = function(ac) {if (ac != this.opacity) {this.opacity = ac;this.EF = 1;}};Sprite.prototype.Uu = function() {var opacity = this.opacity * this.plane.opacity;this.style.visibility = (opacity && this.visible) ? "visible" : "hidden";if ((opacity > 0) && (opacity < 1.0)) {this.style.opacity = opacity;if (jp) this.style.MozOpacity = opacity;else if (bu) this.style.filter = "alpha(opacity=" + parseInt(opacity * 100) + ")";}else {this.style.opacity = 1.0;if (jp) this.style.MozOpacity = 1.0;else if (bu) this.style.filter = "";}};Sprite.prototype.rq = function() {this.clipX = parseInt( this.frameX * this.width );this.clipY = parseInt( this.frameY * this.height );return 'rect(' + this.zoom(this.clipY) + 'px ' + this.zoom(this.clipX + this.width) + 'px ' + this.zoom(this.clipY + this.height) + 'px ' + this.zoom(this.clipX) + 'px)';};Sprite.prototype.dF = function() {return this.zoom( ((Math.floor(this.x + this.offsetX) - this.clipX) - this.plane.scrollX) + this.plane.offsetX );};Sprite.prototype.tC = function() {return this.zoom( ((Math.floor(this.y + this.offsetY) - this.clipY) - this.plane.scrollY) + this.plane.offsetY );};Sprite.prototype.draw = function() {if (this.EF) {this.style.clip = this.rq();this.Uu();this.EF = 0;
}var mK = this.dF();var Pd = this.tC();if ((mK != this.HI) || (Pd != this.Xl)) {this.style.left = mK + 'px';this.style.top = Pd + 'px';if (this.dieOffscreen) {var mm = 0;if (this.x + this.width < this.port.scrollX - (this.port.portWidth * this.plane.cb)) mm = 1;else if (this.y + this.height < this.port.scrollY - (this.port.portHeight * this.plane.cb)) mm = 1;else if (this.x >= this.port.scrollX + this.port.portWidth + (this.port.portWidth * this.plane.cb)) mm = 1;else if (this.y >= this.port.scrollY + this.port.portHeight + (this.port.portHeight * this.plane.cb)) mm = 1;if (mm) this.destroy();} else if (this.Ae) {var mm = 0;if (this.x + this.width < this.port.scrollX - (this.port.portWidth * this.plane.jL)) mm = 1;else if (this.y + this.height < this.port.scrollY - (this.port.portHeight * this.plane.jL)) mm = 1;else if (this.x >= this.port.scrollX + this.port.portWidth + (this.port.portWidth * this.plane.jL)) mm = 1;else if (this.y >= this.port.scrollY + this.port.portHeight + (this.port.portHeight * this.plane.jL)) mm = 1;if (mm) {this.destroy();for (var Sp in this.Ae) {this.Ae[Sp] = this[Sp];} var yA = this.plane.GF(this.x, this.y);if (!this.plane.Ae[yA]) this.plane.Ae[yA] = [];array_push( this.plane.Ae[yA], this.Ae );} } else if (this.screenLoop) {if (this.x + this.width < this.port.scrollX) this.x = this.port.scrollX + this.port.portWidth;else if (this.y + this.height < this.port.scrollY) this.y = this.port.scrollY + this.port.portHeight;else if (this.x >= this.port.scrollX + this.port.portWidth) this.x = this.port.scrollX - this.width;else if (this.y >= this.port.scrollY + this.port.portHeight) this.y = this.port.scrollY - this.height;}this.HI = mK;this.Xl = Pd;} };
Sprite.prototype.logic = function() {};Sprite.prototype.destroy = function() {if (this.div && !this.destroyed) {try { this.port.div.removeChild(this.div); } catch (e) {this.style.left = "-1000px";this.style.visibility = "hidden";var div = el( this.globalID );try { this.port.div.removeChild(div); } catch (e) { ; };};this.destroyed = 1;}};Sprite.prototype.hide = function() {this.style.visibility = 'hidden';this.visible = false;};Sprite.prototype.show = function(state) {if (typeof(state) == 'undefined') state = true;this.style.visibility = state ? 'visible' : 'hidden';this.visible = state;};Sprite.prototype.setFrame = function(jz, Uw) {if (!jz) jz = 0;if (!Uw) Uw = 0;this.frameX = jz;this.frameY = Uw;if ((jz != this.By) || (Uw != this.sl))this.EF = 1; this.By = jz;this.sl = Uw;};Sprite.prototype.setFrameX = function(jz) {if (!jz) jz = 0;this.frameX = jz;if (jz != this.By)this.EF = 1; this.By = jz;};Sprite.prototype.setFrameY = function(Uw) {
if (!Uw) Uw = 0;this.frameY = Uw;if (Uw != this.sl)this.EF = 1; this.sl = Uw;};Sprite.prototype.zoom = function(value) {return parseInt( value * this.port.hO );};Sprite.prototype.unzoom = function(value) {return parseInt( value / this.port.hO );};Sprite.prototype.getRect = function() {var rect = new Rect();if (this.hitRect) rect.set(this.hitRect);else rect.set(0, 0, this.width, this.height);rect.offset(this.x, this.y);return rect;};Sprite.prototype.setPosFromRect = function(tH) {if (this.hitRect) {this.x = tH.left - this.hitRect.left;this.y = tH.top - this.hitRect.top;}else {this.x = tH.left;this.y = tH.top;}};Sprite.prototype.isMouseOver = function() {var bi = this.port.getMouseCoords();if (!bi) return false;return this.pointIn(bi);};Sprite.prototype.ptIn = function(px, Ww) {if (this.hitRect) {return ((px >= this.x + this.hitRect.left) && (Ww >= this.y + this.hitRect.top) && (px < this.x + this.hitRect.right) && (Ww < this.y + this.hitRect.bottom));
}else {return((px >= this.x) && (Ww >= this.y) && (px < this.x + this.width) && (Ww < this.y + this.height));}};Sprite.prototype.pointIn = function(bi) {if (this.hitRect)return ((bi.x >= this.x + this.hitRect.left) && (bi.y >= this.y + this.hitRect.top) && (bi.x < this.x + this.hitRect.right) && (bi.y < this.y + this.hitRect.bottom));elsereturn((bi.x >= this.x) && (bi.y >= this.y) && (bi.x < this.x + this.width) && (bi.y < this.y + this.height));};Sprite.prototype.rectIn = function(Ph) {return this.getRect().rectIn( Ph );};Sprite.prototype.centerPointX = function() {return (this.x + (this.width / 2));};Sprite.prototype.centerPointY = function() {return (this.y + (this.height / 2));};Sprite.prototype.centerPoint = function() {return new Point( this.centerPointX(), this.centerPointY() );};Sprite.prototype.move = function(CY) {if (!this.xd && !this.yd) return null;if (typeof(CY) == 'undefined') CY = this.plane;var hI = this.getRect();var of = hI.clone().offset(this.xd, this.yd);if (CY) {var bi = new Point(0, 0);var Mq = bi.getDistance( this.xd, this.yd );
if (!Mq) return null;var ah = 0;while (ah < Mq) {ah += CY.rS; if (ah > Mq) ah = Mq;var Ph = hI.clone().morph(of, ah / Mq);for (var Sp in CY.sprites) {var dI = CY.sprites[Sp];if ((dI.id != this.id) && dI.collisions && !dI.destroyed && dI.rectIn(Ph)) {var tH = of;if (dI.solid) {var vE = dI.getRect();var kQ = ah;var Eo = ah - CY.rS; if (Eo < 0) Eo = 0;for (var MP = kQ - 1; MP >= Eo; MP--) {var kr = hI.clone().morph(of, MP / Mq);if (!vE.rectIn(kr)) {tH = kr;MP = Eo - 1;}}}else if (dI.ground && (this.yd > 0)) {tH.moveTo( tH.left, dI.getRect().top - tH.height() );}this.setPosFromRect( tH );var event = {type: 'collision',targetType: 'dI',target: dI};return event;} } } } var tilePlane = CY ? CY.tilePlane : this.plane.tilePlane;if (tilePlane && tilePlane.objectData) {var Yj = ['x', 'y'];if (Math.abs(this.yd) > Math.abs(this.xd)) Yj = ['y', 'x'];for (var ah=0; ah<2; ah++) {
switch (Yj[ah]) {case 'x':if (this.xd < 0) {var uY = this.plane.moveLineX( hI.left, hI.top, hI.bottom, this.xd, false, tilePlane );if (uY) {if (this.hitRect) this.x = uY.correctedX - this.hitRect.left;else this.x = uY.correctedX;return uY;}}else if (this.xd > 0) {var uY = this.plane.moveLineX( hI.right - 1, hI.top, hI.bottom, this.xd, false, tilePlane );if (uY) {if (this.hitRect) this.x = (uY.correctedX - this.hitRect.right) + 1;else this.x = (uY.correctedX - this.width) + 1;return uY;}}hI.offset( this.xd, 0 );break;case 'y':if (this.yd < 0) {var uY = this.plane.moveLineY( hI.top, hI.left, hI.right, this.yd, false, tilePlane );if (uY) {if (this.hitRect) this.y = uY.correctedY - this.hitRect.top;else this.y = uY.correctedY;return uY;}}else if (this.yd > 0) {var uY = this.plane.moveLineY( hI.bottom - 1, hI.left, hI.right, this.yd, false, tilePlane );if (uY) {if (this.hitRect) this.y = (uY.correctedY - this.hitRect.bottom) + 1;else this.y = (uY.correctedY - this.height) + 1;return uY;}}hI.offset( 0, this.yd );break;} 
} } this.setPosFromRect( of );return null;};Sprite.prototype.require = function() {for (var ah = 0, it = arguments.length; ah < it; ah++) {if (typeof(this[arguments[ah]]) == 'undefined') {return throwError(this.type + " " + this.id + ": Missing required parameter: " + arguments[ah]);} }return true;};Sprite.prototype.tween = function(dh) {dh.target = this;gTween.addTween(dh);};Sprite.prototype.onTweenUpdate = function(tween) {var ZE = tween.properties;if (ZE.zIndex) this.setZIndex( this.zIndex );if (ZE.opacity || ZE.frameX || ZE.frameY) this.EF = true;};;function MultiSprite() {};MultiSprite.prototype = new Sprite();MultiSprite.prototype.init = function() {if (!this.id) this.id = get_unique_id();this.require('port');if (!this.offsetX) this.offsetX = 0;if (!this.offsetY) this.offsetY = 0;this.globalID = this.port.id + '_' + this.id;};MultiSprite.prototype.reset = function() {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];dI.reset();}this.sprites = [];};MultiSprite.prototype.logic = function() {
for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];dI.logic();}};MultiSprite.prototype.draw = function() {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];dI.draw();}if (this.dieOffscreen) {var mm = 0;if (this.x + this.width < this.port.scrollX - (this.port.portWidth * this.plane.cb)) mm = 1;else if (this.y + this.height < this.port.scrollY - (this.port.portHeight * this.plane.cb)) mm = 1;else if (this.x >= this.port.scrollX + this.port.portWidth + (this.port.portWidth * this.plane.cb)) mm = 1;else if (this.y >= this.port.scrollY + this.port.portHeight + (this.port.portHeight * this.plane.cb)) mm = 1;if (mm) this.destroy();} };MultiSprite.prototype.destroy = function() {if (!this.destroyed) {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];dI.destroy();}this.destroyed = 1;if (this.Ae) this.Ae.destroyed = 1;}};MultiSprite.prototype.hide = function() {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];dI.hide();}};MultiSprite.prototype.show = function() {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];dI.show();}
};MultiSprite.prototype.ptIn = function(px, Ww) {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];if (dI.ptIn(px, Ww)) return true;}return false;};MultiSprite.prototype.rectIn = function(Ph) {for (var ah=0; ah<this.sprites.length; ah++) {var dI = this.sprites[ah];if (dI.rectIn(Ph)) return true;}return false;};;function TextSprite(id) {this.text = '';};TextSprite.prototype = merge_objects( new HUD(), new Sprite() );TextSprite.prototype.type = 'TextSprite';TextSprite.prototype.init = function() {if (!this.id) this.id = get_unique_id();this.require('font');this.setFont( this.font );this.require('cols', 'rows');this.setTableSize( this.cols, this.rows );this.width = this.lf * this.cols;this.height = this.QV * this.rows;this.rq();if (this.text) this.setString(0, 0, this.text);HUD.prototype.init.call(this);this.style.left = this.dF() + 'px';this.style.top = this.tC() + 'px';};;function CustomSprite(id) {};CustomSprite.prototype = new Sprite;CustomSprite.prototype.type = 'CustomSprite';CustomSprite.prototype.init = function() {if (!this.id) this.id = get_unique_id();
this.require('port', 'width', 'height');if (!this.offsetX) this.offsetX = 0;if (!this.offsetY) this.offsetY = 0;this.globalID = this.port.id + '_' + this.id;this.div = document.createElement('DIV');this.style = this.div.style;this.div.setAttribute('id', this.globalID);this.div.id = this.globalID;this.style.position = 'absolute';this.style.width = this.width + 'px';this.style.height = this.height + 'px';this.style.clip = this.rq();this.style.left = this.dF() + 'px';this.style.top = this.tC() + 'px';this.style.zIndex = this.zIndex;this.style.visibility = this.visible ? "visible" : "hidden";this.Uu();if (this.className) this.div.className = this.className;if (this.html) this.div.innerHTML = this.html;this.port.div.appendChild(this.div);};;function Tile() {};Tile.prototype.type = '';Tile.prototype.solid = false;Tile.prototype.ground = false;Tile.prototype.collisions = false;Tile.prototype.climb = false;Tile.prototype.requires = null;;var Mm = {};Mm.RD = function() {this.Jt = false;this.oY = null;this.pZ = 50;this.Td = 30 * 1000;this.VA = ['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
try {this.oY = new XMLHttpRequest();}catch (e) {for (var ah = 0; ah < this.VA.length; ah++) {try {this.oY = new ActiveXObject( this.VA[ah] );break;}catch (e) {}} } };Mm.RD.prototype.send = function(tx) {this.tx = tx;if (this.tx.request.url.toLowerCase().match(/^(\w+)\:\/\/([\w\-\.]+)/)) {if ((RegExp.$1 != 'xI') && (RegExp.$2.toLowerCase() != location.hostname.toLowerCase())) {this.tx.response.code = 500;this.tx.response.data = "Cannot perform cross-domain AJAX calls";this.tx.Fn();return;}}if (!this.tx.request.ag['Content-Type'])this.tx.request.ag['Content-Type'] = 'text/xml';try {this.oY.open(this.tx.request.method, this.tx.request.url, true);}catch (e) {this.tx.response.code = 500;this.tx.response.data = e.toString();this.tx.Fn();return;}for (var Sp in this.tx.request.ag)this.oY.setRequestHeader( Sp, this.tx.request.ag[Sp] );try {this.oY.send( this.tx.request.data.length ? this.tx.request.data : null );}catch (e) {
this.tx.response.code = 500;this.tx.response.data = e.toString();this.tx.Fn();return;}this.Jt = true;var gq = this;this.rm = setTimeout( function() { gq.callTimeout(); }, this.Td );this._x = setInterval( function() { gq.pollControl(); }, this.pZ );};Mm.RD.prototype.callTimeout = function() {this.oY.abort();clearInterval( this._x );this.Jt = false;this.tx.response.code = 500;this.tx.response.data = 'Socket Timeout';this.tx.Fn();};Mm.RD.prototype.pollControl = function() {if (this.oY && (this.oY.readyState == 4)) {clearInterval( this._x );clearTimeout( this.rm );this.complete();} };Mm.RD.prototype.complete = function() {this.Jt = false;if (!this.oY.status && this.oY.responseText.length) {this.tx.response.code = 200;}else {try {if ((typeof(this.oY.status) != "undefined") && (this.oY.status != 0)) {this.tx.response.code = this.oY.status;}else {this.tx.response.code = 500;this.tx.response.data = 'Could not determine HTTP Status Code';}}
catch(e) {this.tx.response.code = 500;this.tx.response.data = 'Could not determine HTTP Status Code';}try {this.tx.response.headersRaw = this.oY.getAllResponseHeaders();var ag = this.tx.response.headersRaw.split('\n');for (var ah = 0; ah < ag.length; ah++){var QD = ag[ah].indexOf(':');if (QD != -1) {this.tx.response.ag[ag[ah].substring(0, QD)] = ag[ah].substring(QD + 2);}}}catch(e) {}}this.tx.response.data = '' + this.oY.responseText;this.tx.response.xml = this.oY.responseXML ? this.oY.responseXML : null;this.tx.response.statusLine = this.oY.statusText ? this.oY.statusText : '';this.tx.Fn();};Mm._Request = function() {this.method = 'POST';this.url = '';this.data = '';this.ag = {};};Mm._Response = function() {this.code = 0;this.data = '';this.ag = {};this.xml = null;this.statusLine = '';};Mm.WV = function() {this.request = new Mm._Request();this.response = new Mm._Response();this.hd = null;this.connection = null;
};Mm.WV.prototype.Fn = function() {if (typeof(this.hd) == 'function') this.hd( this );else if (window[this.hd]) window[this.hd]( this );};Mm.US = function() {this.gg = [];};Mm.US.prototype.cV = function() {var obj = new Mm.RD();this.gg[ this.gg.length ] = obj;return obj;};Mm.US.prototype.eo = function() {for (var ah = 0; ah < this.gg.length; ah++) {var fY = this.gg[ah];if (!fY.Jt) return fY;}return this.cV();};Mm.US.prototype.send = function(TW) {var tx = new Mm.WV();for (var Sp in TW) tx.request[Sp] = TW[Sp];if (!TW.hd) return this.doError( "hd is not set" );if (!TW.url) return this.doError( "url is not set" );tx.hd = TW.hd;tx.connection = this.eo();tx.connection.send( tx );};Mm.US.prototype.get = function(url, hd) {return this.send({method: 'GET',url: url,hd: hd});};Mm.US.prototype.doError = function(Cs) {throwError(Cs);};Mm.controller = new Mm.US();;
function jM() {}jM.prototype.Do = {};jM.prototype.iC = 1;jM.prototype.addTween = function(dh) {var tween = new jI(dh);this.Do[ this.iC ] = tween;this.iC++;return tween;};jM.prototype.logic = function() {for (var id in this.Do) {var tween = this.Do[id];tween.logic();if (tween.destroyed) delete this.Do[id];}};function jI(dh) {for (var Sp in dh) this[Sp] = dh[Sp];if (!this.mode) this.mode = 'EaseIn';if (!this.algorithm) this.algorithm = 'Linear';this.require('target', 'duration', 'properties');if (typeof(this.target) != 'object') return throwError("Tween: Target is not an object");if (typeof(this.duration) != 'number') return throwError("Tween: Duration is not a number");if (typeof(this.properties) != 'object') return throwError("Tween: Properties is not an object");for (var Sp in this.properties) {var DN = this.properties[Sp];if (typeof(DN) == 'number') DN = this.properties[Sp] = { end: DN };if (typeof(DN) != 'object') return throwError("Tween: Property " + Sp + " is not the correct format");if (typeof(DN.start) == 'undefined') DN.start = this.target[Sp];if (typeof(DN.start) != 'number') return throwError("Tween: Property " + Sp + ": start is not a number");if (typeof(DN.end) != 'number') return throwError("Tween: Property " + Sp + ": end is not a number");if (DN.filter && (typeof(DN.filter) != 'function')) return throwError("Tween: Property " + Sp + ": filter is not a function");}if (!this.delay) this.start = gGame.logicClock;}jI.prototype.destroyed = false;jI.prototype.delay = 0;jI.prototype.require = function() {for (var ah = 0, it = arguments.length; ah < it; ah++) {
if (typeof(this[arguments[ah]]) == 'undefined') {return throwError("Tween: Missing required parameter: " + arguments[ah]);}}return true;};jI.prototype.logic = function() {if (this.target.destroyed) {this.destroyed = true;return;}if (this.delay > 0) {this.delay--;if (this.delay <= 0) this.start = gGame.logicClock;else return;}this.Vl = (gGame.logicClock - this.start) / this.duration;if (this.Vl >= 1.0) {this.Vl = 1.0;this.destroyed = true;}for (var Sp in this.properties) {var DN = this.properties[Sp];this.target[Sp] = DN.start + (ease(this.Vl, this.mode, this.algorithm) * (DN.end - DN.start));if (DN.filter) this.target[Sp] = DN.filter( this.target[Sp] );}if (this.target.onTweenUpdate) this.target.onTweenUpdate(this);if (this.destroyed) {if (this.onTweenComplete) this.onTweenComplete(this);else if (this.target.onTweenComplete) this.target.onTweenComplete(this);}};;function So() {this.KW = {};this.TH = 'EffectSocket.swf';this.iC = 1;}So.prototype = {QB: function(id, Px) {this.KW[id] = Px;
},onLoad: function(id) {this.KW[id].onLoad();},onConnect: function(id) {this.KW[id].onConnect(id);},onError: function(id, Cs) {throwError("Socket Error: " + id + ": " + Cs);},onClose: function(id) {this.KW[id].onClose();delete this.KW[id];},onData: function(id, Pw) {this.KW[id].onData(Pw);}};var Vd = new So();function Socket_onLoad(id) { Vd.onLoad(id); }function Socket_onConnect(id) { Vd.onConnect(id); }function Socket_onError(id, Cs) { Vd.onError(id, Cs); }function Socket_onClose(id) { Vd.onClose(id); }function Socket_onData(id, Pw) { Vd.onData(id, Pw); }function FA(hd) {if (hd) this.setHandler( 'onLoad', hd );this.CJ = null;this.id = Vd.nextId++;;var div = document.createElement('div');div.id = 'd_socket_' + this.id;div.setAttribute('id', 'd_socket_'+this.id);var style = div.style;style.position = 'absolute';style.left = '-200px';style.top = '-200px';style.width = '1px';style.height = '1px';var html = '';if (bu) {
html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="1" height="1" id="swf_socket_'+this.id+'" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+Vd.movieURL+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="id='+this.id+'"/></object>';}else {html += '<embed id="swf_socket_'+this.id+'" src="'+Vd.movieURL+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="1" height="1" name="webcam_movie" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id='+this.id+'" />';}div.innerHTML = html;document.body.appendChild(div);Vd.add(this.id, this);}FA.prototype = merge_objects( JH.prototype, {UB: false,mC: false,gP: function(Ij, port) {;;this.CJ.connect(Ij, port);},UV: function(data) {;;;this.CJ.write(data);},QP: function() {;;;return this.CJ.read();},vm: function() {;;;this.CJ.close();},oP: function() {this.mC = false;this.CJ = null;setTimeout( function() {try { document.body.removeChild( document.getElementById('d_socket_'+this.id) ); } catch(e) {;}
}, 1 );},onLoad: function() {;this.UB = true;this.CJ = document.getElementById('swf_socket_' + this.id);if (!this.CJ) return throwError("ASSERT FAILURE: Cannot locate Px movie: swf_socket_" + this.id);this.fireHandler('onLoad');},onConnect: function() {;this.mC = true;this.fireHandler('onConnect');},onClose: function() {;this.mC = false;this.fireHandler('onClose');},onData: function(Pw) {;this.fireHandler('onData', Pw);}} );;function Gr() {this.enabled = false;this.Sw = this.ID;this.xz = '127.0.0.1'; this.cQ = '6201';this.hu = null;this.Di = {};this.Dx = {};this.VT = [];this.Mv = null;this.HQ = 0;this.WE = 0;this.E_ = 8;}Gr.prototype = new JH();
Gr.prototype.ID = 0;Gr.prototype.Wr = 1;Gr.prototype.wT = 2;Gr.prototype.HN = 3;Gr.prototype.sY = 4;Gr.prototype.FF = function() {if (this.Sw == this.ID) {this.Sw = this.Wr;this.Xi = setTimeout( 'BL.CG()', 1000 * 10 );this.ZH = new FA( [this, 'Qk'] );}};Gr.prototype.CG = function() {this.enabled = false;this.Sw = this.ID;return throwError("Multiplayer support failed to load. Please upgrade to the latest Adobe Flash Player and try again.");};Gr.prototype.Qk = function() {if (this.Sw == this.Wr) {;this.Sw = this.wT;if (this.Xi) clearTimeout( this.Xi );this.Xi = null;gGame.nM();}};Gr.prototype.gP = function() {if (this.Sw == this.wT) {this.Sw = this.HN;this.xV = setTimeout( 'BL.Fs()', 1000 * 10 );this.ZH.setHandler( 'onConnect', [this, 'rh'] );this.ZH.gP( this.xz, this.cQ );}};Gr.prototype.Fs = function() {this.Sw = this.wT;Vd.onError( this.Px.id, "Connect Timeout -- Will Retry" );};Gr.prototype.rh = function() {;
this.Sw = this.sY;if (this.xV) clearTimeout( this.xV );this.xV = null;Px.setHandler( 'onData', [this, 'ro'] );};Gr.prototype.logic = function() {if (!this.enabled) return;if (this.Sw != this.sY) return this.gP();if (this.Mv) {var ts = this.Mv.Ap;if (ts && ts.length) {for (var ah = 0, it = ts.length; ah < it; ah++) {var Ap = ts[ah];if (Ap.hm && this[Ap.hm]) this[Ap.hm].apply(this, Ap.dh);} } var zT = this.Mv.Cs;if (zT && zT.length) {for (var ah = 0, it = zT.length; ah < it; ah++) {var Cs = zT[ah];} } var sa = this.Mv.Sv;if (sa) {for (var id in sa) {var Sv = sa[id];} } this.Mv = null;} var jZ = 1 / this.E_;var Ez = now_epoch();var QW = (this.HQ + jZ) - (this.HQ - this.WE);if (Ez >= QW) {this.ZH.UV( serialize({ Cs: this.VT, Sv: this.Dx }, '=>') );this.VT = [];this.WE = Ez;}};Gr.prototype.ro = function(Pw) {
var data = this.Px.QP();if (data) {try {this.Mv = eval(data);}catch (e) {;}}else {;}this.HQ = now_epoch();};Gr.prototype.SA = function(dI) {this.Di[ dI.id ] = dI;};Gr.prototype.broadcastEvent = function(obj) {};Gr.prototype.sendPrivateEvent = function(Mb, obj) {};Gr.prototype.saveUserData = function(obj) {};var BL = new Gr();;var gGame = null;var gAudio = null;var gImageLoader = null;var gCodeLoader = null;var gProgress = null;var gAjax = null;var gTween = null;var level = null;function dw() {if (!gGame) gGame = this;if (!gAudio) gAudio = new nm();if (!gImageLoader) gImageLoader = new Cq();if (!gCodeLoader) gCodeLoader = new Wn();if (!gProgress) gProgress = new Fb();if (!gAjax) gAjax = Mm.controller;
if (!gTween) gTween = new jM();this.hB = gAudio;this.gJ = gImageLoader;this.Dc = gCodeLoader;this.br = gProgress;this.LH = gAjax;this.VQ = gTween;this.ZH = Vd;this.Xw = BL;this.homePath = 'http://www.effectgames.com/engine'; this.baseGamePath = '.';this.gameID = '.';this.objectCodePath = 'objects';this.imagePath = 'images'; this.audioPath = 'sounds';this.levelPath = 'levels';this.tileImagePath = 'tiles';this.tileExt = 'gif';this.fontImagePath = 'fonts';this.ZH.movieURL = this.homePath + '/' + this.ZH.movieURL;this.localPath = location.href.replace(/\?.*$/, '').replace(/\/[^\/]+$/, '');this.levels = {};this.level = null;this.levelName = '';this.fonts = {};this.keys = {move_left: { code: [37, 65, 178], down: false }, move_right: { code: [39, 68, 177], down: false }, move_up: { code: [38, 87, 175], down: false }, move_down: { code: [40, 83, 176], down: false }, button_1: { code: [90, 188, 187], down: false }, button_2: { code: [88, 32, 72, 171], down: false }, button_3: { code: [9, 53], down: false }, button_4: { code: [13, 27, 49], down: false } };this.autoKey = false; this.keysActive = true; this.mouseActive = true; this.mousePt = new Point(); this.lu = [];
this.logicClock = 0;this.drawClock = 0;this.targetFPS = 30;this.skipFrames = true;this.inGame = false;this.Mj = null;this.maxLogicsPerFrame = 2;this.We = {};this.Rc = {};this.state = 'loading';this.jP = {lG: 0,Iz: 0,UI: 0,el: 0,Mh: 0,RH: 0};this.onInit = null;this.onLoadGame = null;this.onLoadLevel = null;this.onKeyDown = null;this.onKeyUp = null;this.onMouseMove = null;this.onMouseDown = null;this.onMouseUp = null;this.onLogic = null;this.onDraw = null;if ((typeof(query.effect_audio) != 'undefined') && !query.effect_audio) gAudio.enabled = false;if (query.effect_debug) { Sa = true; debug_startup(); }};dw.prototype.keyMap = {8: 'Backspace',9: 'Tab',27: 'Escape', 32: 'Space',192: '~ (Tilde)',187: '= (Equals)',189: '- (Dash)',45: 'Insert',
36: 'Home',33: 'Page Up',144: 'Num Lock',111: '/ (Keypad)',106: '* (Keypad)',109: '- (Keypad)',219: '[ (Left Bracket)',221: '] (Right Bracket)',220: "\\ (Backslash)",46: 'Delete',35: 'End',34: 'Page Down',103: '7 (Keypad)',104: '8 (Keypad)',105: '9 (Keypad)',107: 'Plus (Keypad)',186: ': (Colon)',222: '\' (Quote)',13: 'Enter',100: '4 (Keypad)',101: '5 (Keypad)',102: '6 (Keypad)',188: ', (Comma)',190: '. (Period)',191: '/ (Slash)',38: 'Up Arrow',97: '1 (Keypad)',98: '2 (Keypad)',99: '3 (Keypad)',17: 'Control',37: 'Left Arrow',40: 'Down Arrow',39: 'Right Arrow',96: '0 (Keypad)',110: '. (Keypad)',16: 'Shift'};dw.prototype.setBaseGamePath = function(nH) { this.baseGamePath = nH; };dw.prototype.setGameID = function(id) { this.gameID = id; };dw.prototype.setTargetFPS = function(jP) { this.targetFPS = parseInt(jP); };
dw.prototype.setSkipFrames = function(uu) { this.skipFrames = !!uu; };dw.prototype.setState = function(name) { this.state = name; };dw.prototype.setKeysActive = function(Gt) { this.keysActive = !!Gt; };dw.prototype.setMouseActive = function(Gt) { this.mouseActive = !!actve; };dw.prototype.getAverageFPS = function() { return this.jP.Iz; };dw.prototype.getCurrentFPS = function() { return this.jP.lG; };dw.prototype.resetAverageFPS = function() { this.jP.RH = 0; this.jP.Mh = 0; };dw.prototype.setHandler = function(name, hm) {if (!this[name]) this[name] = [];array_push( this[name], hm );};dw.prototype.clearHandler = function(name) {if (this[name]) this[name] = [];};dw.prototype.fireHandler = function(name) {var dh = array_slice( arguments, 1 );if (this[name]) {var HD = always_array( this[name] );for (var ah = 0, it = HD.length; ah < it; ah++) {var bN = false;var si = HD[ah];if (typeof(si) == 'function') bN = si.apply(window, dh);else if (isa_array(si)) {if (typeof(si[1]) == 'function') bN = si[1].apply(si[0], dh);else bN = si[0][ si[1] ](dh);}else if (window[si]) bN = window[si].apply(window, dh);else return throwError("Unsupported si type: " + name + ": " + si);if (!bN) return bN;} }for (var ah = 0; ah < this.lu.length; ah++) {if (this.lu[ah][name]) {var HD = always_array(this.lu[ah][name]);for (var ah = 0, it = HD.length; ah < it; ah++)HD[ah].apply(this.lu[ah], dh);}}return true;};
dw.prototype.setStateHandler = function(name, hm) {this.Rc[name] = hm;};dw.prototype.getGamePath = function() {return this.baseGamePath + '/' + this.gameID;};dw.prototype.load = function(hd) {;if (hd) {this.clearHandler('onLoadGame');this.setHandler('onLoadGame', hd);}this.br.nV('gGame.kW()');};dw.prototype.kW = function() {this.br.RC(0, 1);this.br.show();if (this.Xw.enabled) this.Xw.FF();else this.nM();};dw.prototype.nM = function() {if (this.hB.enabled) this.hB.FF();else this.ge();};dw.prototype.setGameDef = function(obj) {game_def = obj;};dw.prototype.ge = function() {if (window.game_def) {gGame.TP();}else {game_def = null;this.Dc.PJ('game_def', 'gGame.TP()');this.Dc.Ud('game_def', true);}};dw.prototype.TP = function() {;this.def = game_def;
this.Dc.pp();this.Dc.onLoad = 'gGame.kb()';if (game_def.preload_objects) {this.Dc.SN();for (var ah = 0; ah < game_def.preload_objects.length; ah++) {var PG = game_def.preload_objects[ah];gCodeLoader.Ud( gGame.objectCodePath + '/' + PG );}this.Dc.TG();}else gGame.kb();};dw.prototype.kb = function() {;this.hB.pp();this.gJ.pp();if (this.def.preload_audio) this.hB.gl(this.def.preload_audio);if (this.def.preload_images) this.gJ.loadImages(this.def.preload_images);if (this.def.preload_fonts) {for (var nO in this.def.preload_fonts) {var font = this.def.preload_fonts[nO];var CB = this.fontImagePath + '/' + nO;var kq = [];for (var ah = 0; ah < font.glyphs.length; ah++) {array_push( kq, CB + '/' + font.glyphs[ah] + '.' + font.ext );} this.gJ.loadImages( kq );this.fonts[nO] = font;} } if (this.def.preload_objects) {for (var ah = 0; ah < this.def.preload_objects.length; ah++) {var type = this.def.preload_objects[ah];;;if (window[type].prototype.audio)this.hB.gl(window[type].prototype.audio);if (window[type].prototype.images)this.gJ.loadImages(window[type].prototype.images);}
}this.Qb();};dw.prototype.Qb = function() {var Xk = ( this.hB._r() + this.gJ._r() ) / 2;this.br.RC( Xk, 1 );if (Xk >= 1.0) {this.hB.ZL();this.loaded = true;this.br.hide();this.fireHandler('onLoadGame');}else {setTimeout( 'gGame.Qb()', 100 );}};dw.prototype.addLevel = function(name, level) {this.levels[name] = level;};dw.prototype.loadLevel = function(name, hd) {;this.levelName = name;if (hd) {this.clearHandler('onLoadLevel');this.setHandler('onLoadLevel', hd);}if (this.levels[name]) {this.level = deep_copy_object( this.levels[name] );if (this.level.tileset) this.tileImagePath = this.level.tileset;this.fireHandler('onLoadLevel');return;}this.br._text = "Loading...";this.br.RC(0, 1);if (!num_keys(this.levels)) this.br.show();this.br.timeStart = now_epoch();level = null;this.Dc.PJ(this.levelPath + '/' + name, 'gGame.cp()');this.Dc.Ud(this.levelPath + '/' + name, true);
};dw.prototype.saveLevelState = function() {this.levels[this.levelName] = deep_copy_object( this.level );};dw.prototype.restoreLevelState = function() {this.level = deep_copy_object( this.levels[this.levelName] );};dw.prototype.cp = function() {;this.levels[this.levelName] = level;this.level = deep_copy_object( level );this.level.loaded = false;level = null;if (this.level.tileset) this.tileImagePath = this.level.tileset;if (this.level.preload_objects && num_keys(this.level.preload_objects)) {var ZN = [];var Yz = hash_keys_to_array(this.level.preload_objects);for (var ah = 0; ah < Yz.length; ah++) {if (!window[Yz[ah]]) {array_push( ZN, this.objectCodePath + '/' + Yz[ah] + '.js' );}}if (ZN.length) {this.Dc.pp();this.Dc.onLoad = 'gGame.OY()';this.Dc.Ud( ZN );}else this.OY();} else this.OY();};dw.prototype.OY = function() {this.hB.pp();this.gJ.pp();if (this.level.audio) this.hB.gl(this.level.audio);if (this.level.images) this.gJ.loadImages(this.level.images);if (this.level.tiles_used) {var lQ = [];for (var ah = 0; ah < this.level.tiles_used.length; ah++) {array_push( lQ, this.tileImagePath + '/' + this.level.tiles_used[ah] + 
'.' + this.tileExt );}if (this.level.dead_tile_idx) {array_push( lQ, this.tileImagePath + '/' + this.level.dead_tile_idx + '.' + this.tileExt );}this.gJ.loadImages( lQ );}if (this.level.preload_objects) {for (var type in this.level.preload_objects) {;if (window[type].prototype.audio)this.hB.gl(window[type].prototype.audio);if (window[type].prototype.images)this.gJ.loadImages(window[type].prototype.images);}}this.qv();};dw.prototype.qv = function() {var Xk = ( this.hB._r() + this.gJ._r() ) / 2;if (now_epoch() - this.br.timeStart >= 3) this.br.show();this.br.RC( Xk, 1 );if (Xk >= 1.0) {this.hB.ZL();this.level.loaded = true;this.br.hide();this.fireHandler('onLoadLevel');}else {setTimeout( 'gGame.qv()', 100 );}};dw.prototype.run = function() {if (!this.inGame) {if (!this.level) this.level = level = {}; this.inGame = true;this.zW = this.vN = now_epoch();this.Iq();
}};dw.prototype.stop = function() {if (this.inGame) {this.inGame = false;if (this.Mj) clearTimeout( this.Mj );this.Mj = null;}};dw.prototype.Iq = function() {this.Mj = null;if (this.inGame) {var Ez = now_epoch();if (this.skipFrames) {var Og = 1 / this.targetFPS;var ee = parseInt( (Ez - this.zW) / Og );if (ee < 1) ee = 1;if (ee > this.maxLogicsPerFrame) ee = this.maxLogicsPerFrame;for (var ah = 0; ah < ee; ah++) this.logic();}else {this.logic();}this.draw();this.gJ.dynaIdle(false);var ZO = parseInt(Ez);if (ZO != this.jP.el) {this.jP.RH += this.jP.UI;if (!this.jP.Mh) this.jP.Mh = ZO - 1;this.jP.Iz = this.jP.RH / (ZO - this.jP.Mh);this.jP.lG = this.jP.UI;this.jP.UI = 0;this.jP.el = ZO;}this.jP.UI++;var XZ = now_epoch();var jZ = 1 / this.targetFPS;var tW = XZ - this.vN;if (!this.lastSleep) this.lastSleep = jZ;var delay = this.lastSleep - (tW - jZ);
if (delay > jZ) delay = jZ;else if (delay < 0.001) delay = 0.001;this.Mj = setTimeout( 'gGame.Iq()', parseInt(delay * 1000) );this.zW = Ez;this.vN = XZ;this.lastSleep = delay;} };dw.prototype.logic = function() {if (this.level.events && this.level.events.enabled && this.level.events[this.logicClock]) {for (var hm in this.level.events[this.logicClock]) {if (window[hm]) {;window[hm]( this.level.events[this.logicClock][hm] );}else return throwError("Function not found: " + hm);}}for (var ah = 0; ah < this.lu.length; ah++) {this.lu[ah].logic();}this.VQ.logic();this.fireHandler('onLogic');if (this.Rc[this.state]) {var pV = this.Rc[this.state];if (typeof(pV) == 'function') pV();else if (window[pV]) window[pV]();else eval(pV);}this.logicClock++;if (this.We[this.logicClock]) {var ya = this.We[this.logicClock];for (var ah = 0, it = ya.length; ah < it; ah++) {var cq = ya[ah];;this.fireHandler.apply( this, array_cat([cq.si], cq.dh) );}delete this.We[this.logicClock];}};
dw.prototype.draw = function() {for (var ah = 0; ah < this.lu.length; ah++) {this.lu[ah].draw();}this.fireHandler('onDraw');this.drawClock++;};dw.prototype.scheduleEvent = function(rE, si) {if (rE < this.logicClock) rE += this.logicClock;if (!this.We[rE]) this.We[rE] = [];array_push( this.We[rE], {si: si,dh: array_slice( arguments, 2 )} );};dw.prototype.attach = function(port) {port.game = this;array_push( this.lu, port );if (port.init) port.init();};Portal.prototype.getPortal = function(id) {return find_object( this.lu, { id: id } );};dw.prototype.setKeyHandler = function(Sp, si) {var mD = this.keys[Sp];if (!mD) return throwError( "Cannot find keyboard definition for: " + Sp );if (!mD.HD) mD.HD = [];array_push( mD.HD, si );};dw.prototype.resetKeys = function() {for (var Sp in this.keys) {this.keys[Sp].down = false;}};dw.prototype.getLevelMusic = function() {return gAudio.getTrack( this.level.background_music );};dw.prototype.changeZoomLevel = function(nr) {if (this.inGame) {this.tg = true;
this.stop();setTimeout( "gGame.changeZoomLevel(" + nr + ")", 250 );return;}for (var ah = 0; ah < this.lu.length; ah++) {this.lu[ah].reset();this.lu[ah].hO = nr;}this.imagePath = this.imagePath.replace( /zoom_\d+/, 'zoom_' + nr );this.br._text = "One Moment Please...";this.br.RC(0, 1);this.br.show();setTimeout( 'gGame.nQ()', 1 );};dw.prototype.nQ = function() {this.gJ.reloadAll();this.oN();};dw.prototype.oN = function() {var Xk = this.gJ._r();this.br.RC( Xk, 1 );if (Xk >= 1.0) {this.br.hide();for (var ah = 0; ah < this.lu.length; ah++) {var port = this.lu[ah];if (port.init) port.init();port.setScroll( port.scrollX, port.scrollY );port.draw(true);}if (this.tg) {this.tg = false;this.run();}}else {setTimeout( 'gGame.oN()', 250 );}};dw.prototype.setKeyDefinition = function(name, ST) {this.keys[name] = { code: always_array(ST), down: false };
};dw.prototype.getLocalMousePosition = function(e, obj) {return get_mouse_coords(e, obj);};var zt = null;function mb(e) {if (!gGame || !gGame.mouseActive) return true;if (window.event) e = window.event;var _Z = e.button;if (!_Z) _Z = 1;;var em = e.target ? e.target : e.srcElement;while (em && !em.tagName.match(/^(BODY|HTML)$/) && !em.captureMouse) {em = em.parentNode ? em.parentNode : em.parentElement;}if (em && em.captureMouse) {var bi = get_mouse_coords(e, em);zt = em;if (zt.captureMouse.onMouseDown) {var HD = always_array( zt.captureMouse.onMouseDown );for (var ah = 0, it = HD.length; ah < it; ah++) {var bN = pass_event_if((typeof(HD[ah]) == 'function') ? HD[ah].apply( zt.captureMouse, [e, bi, _Z]) : window[HD[ah]].apply( zt.captureMouse, [e, bi, _Z]), e );if (!bN) return false; } } } var bi = get_mouse_coords(e);gGame.mouseIsDown = true;gGame.mousePt.set( bi );return pass_event_if( gGame.fireHandler('onMouseDown', e, bi, _Z), e );}function ZI(e) {if (!gGame || !gGame.mouseActive) return true;if (window.event) e = window.event;var zz = get_mouse_coords(e);if ((zz.x < 0) || (zz.y < 0)) return true;
if (zt) {var bi = get_mouse_coords(e, zt);if (zt.captureMouse.onMouseMove) {var HD = always_array( zt.captureMouse.onMouseMove );for (var ah = 0, it = HD.length; ah < it; ah++) {var bN = pass_event_if( (typeof(HD[ah]) == 'function') ? HD[ah].apply( zt.captureMouse, [e, bi]) : window[HD[ah]].apply( zt.captureMouse, [e, bi]), e );if (!bN) return false; } } } gGame.mousePt.set( zz );return pass_event_if( gGame.fireHandler('onMouseMove', e, zz), e );}function mc(e) {if (!gGame || !gGame.mouseActive) return true;if (window.event) e = window.event;var _Z = e.button;if (!_Z) _Z = 1; ;if (zt) {var bi = get_mouse_coords(e, zt);var HD = zt.captureMouse.onMouseUp ? always_array( zt.captureMouse.onMouseUp ) : [];var Kz = zt.captureMouse;zt = null;for (var ah = 0, it = HD.length; ah < it; ah++) {var bN = (typeof(HD[ah]) == 'function') ? HD[ah].apply( Kz, [e, bi, _Z]) : window[HD[ah]].apply( Kz, [e, bi, _Z]);if (!bN) return stop_event(e);}}var bi = get_mouse_coords(e);gGame.mouseIsDown = false;gGame.mousePt.set( bi );return pass_event_if( gGame.fireHandler('onMouseUp', e, bi, _Z), e );}
function iK(e) {if (!gGame || !gGame.keysActive) return true;if (window.event) e = window.event;;for (var HT in gGame.keys) {var mD = gGame.keys[HT];for (var MP = 0; MP < mD.code.length; MP++) {if (e.keyCode == mD.code[MP]) {if (!mD.down || gGame.autoKey || mD.autoKey) {mD.down = true;if (mD.HD) {for (var ba = 0; ba < mD.HD.length; ba++) {var si = mD.HD[ba];if (si.onKeyDown) si.onKeyDown(HT);} } } break;} } } return pass_event_if( gGame.fireHandler('onKeyDown', e), e );}function PN(e) {if (!gGame || !gGame.keysActive) return true;if (window.event) e = window.event;for (var HT in gGame.keys) {var mD = gGame.keys[HT];for (var MP = 0; MP < mD.code.length; MP++) {if (e.keyCode == mD.code[MP]) {mD.down = false;if (mD.HD) {for (var ba = 0; ba < mD.HD.length; ba++) {var si = mD.HD[ba];if (si.onKeyUp) si.onKeyUp(HT);} } break;} } 
} return pass_event_if( gGame.fireHandler('onKeyUp', e), e );}function Af(e) {if (!gGame || !gGame.keysActive || !gGame.inGame) return true;if (window.event) e = window.event;var TQ = 0;if (e.wheelDelta) {TQ = e.wheelDelta / 120;if (window.opera) TQ = -TQ;}else if (e.detail) {TQ = -e.detail / 3;}if (!TQ) return true;return pass_event_if( gGame.fireHandler('onMouseWheel', TQ), e );}function dB(e) {if (JI) mb(e);return pass_event_if( !gGame.inGame, e );}function pass_event_if(state, e) {if (state) return true; else return stop_event(e);}function stop_event(e) {;if (e.preventDefault) {e.preventDefault();e.stopPropagation();}else {e.returnValue = false;e.cancelBubble = true;}return false;}if (window.addEventListener) {window.addEventListener( 'mousedown', mb, false );window.addEventListener( 'mousemove', ZI, false );
window.addEventListener( 'mouseup', mc, false );window.addEventListener( 'keydown', iK, false );window.addEventListener( 'keyup', PN, false );window.addEventListener( 'DOMMouseScroll', Af, false);}else {if (document.captureEvents) {document.captureEvents(Event.MOUSEDOWN);document.captureEvents(Event.MOUSEMOVE);document.captureEvents(Event.MOUSEUP);document.captureEvents(Event.KEYDOWN);document.captureEvents(Event.KEYUP);}window.onmousedown = document.onmousedown = document.body.onmousedown = mb;window.onmousemove = document.onmousemove = document.body.onmousemove = ZI;window.onmouseup = document.onmouseup = document.body.onmouseup = mc;window.onkeydown = document.onkeydown = iK;window.onkeyup = document.onkeyup = PN;window.onmousewheel = document.onmousewheel = Af;}window.oncontextmenu = document.oncontextmenu = dB;So.prototype.onError = function(id, Cs) {return throwError("A communication error occured with the multiplayer servers. Please refresh your browser and try again.\n\n" + Cs);};gGame = new dw();append_to_callback('onload', "gGame.fireHandler('onInit');");;
