-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathjquery.pp3Diso-v2.min.js
13 lines (13 loc) · 33.3 KB
/
jquery.pp3Diso-v2.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* pp3Diso
* http://www.prelude-prod.fr
*
* @author Jean-François RENAULD
* @version 2.3
* Cette oeuvre est mise à disposition selon les termes de la Licence GPL v3 : http://www.gnu.org/licenses/gpl-3.0.txt
*
* Si vous utilisez ce plugin, vous devez mettre un lien retour vers le site : http://www.prelude-prod.fr
*
* Date: Sun Aug 03 11:30:00 UTC 2013
*/
(function(a){a.fn.pp3Diso=function(a7){var a7=a.extend({CSSid:"",mapId:1,map:"",mapZones:"",mapZonesColors:"",zone:"",tx:0,ty:0,ty2:0,zoom:1,positionFixe:false,pathfinding:false,PF_corners:true,cursorPF:"",cursorZindex:0,PF_decx:0,PF_decy:0,PF_max:false,mousewheel:false,zoom_min:0.25,zoom_max:10,zoom_pas:0.5,fluide:true,nbrTitleSetsSlide:1,auto_resize:true,mode2d:false,mode2d_viewx:5,mode2d_viewy:5,mode2d_select:"#FBE6C1",mode2d_select_off:"#F47070",mode2d_fond:"#ffffff",titre_map:{},titre_case:"",mode2d_avatar:"Avatar",move_avatar_speed:50,bulle_auto_x:true,bulle_auto_y:"top",bulle_obj_deca_y:6,keys:true,keys_tab:{key_n:[38,104],key_ne:[105],key_e:[39,102],key_se:[99],key_s:[40,98],key_so:[97],key_o:[37,100],key_no:[103],key_zoom:[33],key_dezoom:[34],key_clic:[32,101]},prefix:"map-",path:"images/",fogofwar:0,speed_avatar:250,speed_map:100,speed_map_while:100,speed_by_titleset:1,drag:true,cursorDelay:false,oncursordelay:function(bt,bv,bu){},onmoveavatar:function(bt,bv,bu){},beforemoveavatar:function(bt,bv,bu){return true},onmovepathfinding:function(bt,bv,bu){},beforeclosewin:function(bu,bt){return true},afterclosewin:function(bu,bt){},onenterbuilding:function(bt,bv,bu){},onleavebuilding:function(bt,bv,bu){},onenterobject:function(bt,bv,bu){},onleaveobject:function(bt,bv,bu){},onclicbuilding:function(bt,bv,bu){},onclicobject:function(bt,bv,bu){},onchangezoom:function(bt){},onclicright:""},a7);var j=a(this);var d=this;var al=("ontouchstart" in window);if(a7.positionFixe==true){a7.drag=false}a7.ty2=(a7.tx>>2);var n=1;var e=0;var c=0;var an=0;var X=0;if(a7.mode2d){mousewheel=false}var v;var S=a7.tx;var R=a7.ty;var aw=a7.ty2;var ak="";var aG=0;var aD=0;var bq=1;var bo=1;var q,bg,aF;var a3,a2;var ah=0;var ag=0;var ax=null;var A=[];var aV=[];var aa=false;var O,N;var m="";var aC="";var bc=0;var bb=0;var V=0;var T=0;var ao=false;var ai;var bm=false;var ar=false;var w;var a6=[];var bl=a7.PF_max;var ab;var aU;var bi=false;var M,bn,J,K,ad,I,E;var G,D,aL,am,aN,aM,C;var bj=[];var aq,bp,at;var af,ae,H;var aA,ay;var ap=false;var r,p;var a1=false;var a4=0;move_map_waiting=false;aO();var z;var bs=null;var L="";var av=1;function aO(){v=~~(a7.zoom*100)+"%";a7.tx=S*a7.zoom;a7.ty=R*a7.zoom;a7.ty2=aw*a7.zoom;bi=false;af=j.width();ae=j.height();if(a7.zone=="undefined"){a7.zone=""}var bA=j.children(".pp3diso_users").detach();j.children().remove().empty();j.append(bA);a(".pp3diso_users").css({"z-index":760000});if(!a7.mode2d){j.append('<div id="pp3Diso-wait"></div>');ab=a("#pp3Diso-wait")}bn=a7.map.split(":");if(a7.zone!=""){var bz=a7.zone.split(":")}M=a7.path+a7.prefix;dummy=bn[0].split(",");J=bn.length;K=dummy.length;w=new Array(K);for(bt=0;bt<J;bt++){w[bt]=new Array(J)}aL=(a7.tx>>1);am=a7.ty2;aN=(K*((a7.tx)>>1))+(J*((a7.tx)>>1));aM=(K*((a7.ty)>>1))+(J*((a7.ty)>>1));C=aN>>1;if(a7.mapZones!=""){var bv=a7.mapZones.split(":")}ad=new Array(J);I=new Array(J);E=new Array(J);z=new Array(J);aq=new Array(J);G=0;D=0;aj();for(var by=1;by<=J;by++){E[by]=new Array(K);ad[by]=new Array(K);aq[by]=new Array(K);I[by]=new Array(K);z[by]=new Array(K);var bx=bn[by-1].split(",");if(a7.zone!=""){var bw=bz[by-1].split(",")}if(a7.mapZones!=""){var bu=bv[by-1].split(",")}for(var bt=1;bt<=K;bt++){E[by][bt]=~~(bx[bt-1]);if(a7.fogofwar>0){I[by][bt]=0}else{I[by][bt]=1}f(bt,by);if(a7.zone!=""){ad[by][bt]=~~(bw[bt-1])}else{if(E[by][bt]>0){ad[by][bt]=1}else{ad[by][bt]=0}}if(a7.mapZones!=""){aq[by][bt]=(bu[bt-1]|0)}else{aq[by][bt]=0}}}if(a7.auto_size){j.css({width:aN,height:aM})}e=((af-aN)>>1);c=((ae-aM)>>1);an=e;X=c;aS(E);bd((K|0),(J|0));aX(E);a("#ppISO").bind("mouseenter",function(){a("#ppISO").focus()});a("#ppISO").focus()}function aS(bO){O=0;N=0;var bG="";var bJ=[0,am,aL,0,a7.tx,am,aL,am<<1];var bK=(a7.zoom<<3);var bI=(bK>>1);var by=[-bK,am,aL,-bI,a7.tx+bK,am,aL,(am<<1)+bI];if(a("#pp3Diso-conteneur").length==0){j.append('<div id="pp3Diso-conteneur"></div>')}a(".pp3diso").unbind("keyup");H=a("#pp3Diso-conteneur");if(!a7.mode2d){H.css({display:"block",position:"absolute",top:9999,left:9999,width:aN,height:aM})}if(a7.mousewheel){ac()}var bE=a7.mapZonesColors.split(":");if(!a7.mode2d&&a7.mapZones!=""&&a("#pp3Diso-mapZone").length==0){H.append('<div id="pp3Diso-mapZone"></div>');var bw=bE.length;bp=new Array(bw);at=new Array(bw);var bP=new Array(bw);for(var bL=0;bL<bw;bL++){bP[bL]=document.createElement("canvas");bP[bL].id="pp3Diso-mapZone-canvas-"+bL;a("#pp3Diso-mapZone").append(bP[bL]);bp[bL]=a("#pp3Diso-mapZone-canvas-"+bL)[0];at[bL]=bp[bL].getContext("2d");bp[bL].width=aN;bp[bL].height=aM;a("#pp3Diso-mapZone-canvas-"+bL).css({display:"none",position:"absolute",top:0,left:0,"z-index":299000,"-moz-opacity":0.5,opacity:0.5,filter:"alpha(opacity=50)"})}a("#pp3Diso-mapZone").css({display:"block",position:"absolute",top:0,left:0,width:aN,height:aM,"z-index":299000})}if(!a7.mode2d){ab.css("display","block")}if(a("#pp3Diso-bulle").length==0){H.append('<div id="pp3Diso-bulle"></div>')}aU=a("#pp3Diso-bulle");aU.css("display","none");var bN="pp3diso-Map-"+n;n++;var bz='<map name="'+bN+'" id="'+bN+'">';for(var bD=1;bD<=J;bD++){for(var bF=1;bF<=K;bF++){bG="c_"+bD+"_"+bF;var bB=bk(bD,bF);var bC=u(bD,bF);z[bD][bF]=new Array(2);z[bD][bF][0]=(bC|0);z[bD][bF][1]=(bB|0);if(a7.mapZones!=""&&!a7.mode2d){if(aq[bD][bF]>0){var bH=aq[bD][bF]-1;at[bH].fillStyle=bE[bH];at[bH].beginPath();at[bH].moveTo(~~(by[0]+bC),~~(by[1]+bB));var bx=bJ.length-1;for(var bM=2;bM<bx;bM+=2){at[bH].lineTo(~~(by[bM]+bC),~~(by[bM+1]+bB))}at[bH].closePath();at[bH].fill()}}if(a7.mode2d){}else{var bA="";var bx=bJ.length;for(var bL=0;bL<bx;bL+=2){var bv=~~((bJ[bL])+bC);var bu=~~((bJ[bL+1])+bB);bA+=","+bv+","+bu}bA=bA.substring(1);var bt="s_"+bD+"_"+bF;bA='<area id="'+bt+'" class="pp3diso-shap" shape="poly" coords="'+bA+'" alt="" />';bz+=bA}}}if(!a7.mode2d){bz+="</map>";H.prepend('<div id="pp3diso-clicks"><img src="'+a7.path+'vide.gif" id="pp3diso-mapControl" width="'+aN+'" height="'+aM+'" alt="" />'+bz+"</div>");a("#pp3diso-mapControl").attr("usemap","#"+bN);a("#pp3diso-clicks").css({"z-index":750000,position:"absolute",left:0,top:0,display:"block"})}if(a7.keys){a(window).keyup(function(bW){var bR=V;var bX=T;var bU=false;var bQ=null;for(var bV in a7.keys_tab){for(var bT in a7.keys_tab[bV]){if(a7.keys_tab[bV][bT]==bW.keyCode){bQ=bV;bU=true;break}}}switch(bQ){case"key_n":bX--;break;case"key_ne":bX--;bR++;break;case"key_e":bR++;break;case"key_se":bX++;bR++;break;case"key_s":bX++;break;case"key_so":bX++;bR--;break;case"key_o":bR--;break;case"key_no":bX--;bR--;break;case"key_clic":if(a0(bR,bX)){B(bR,bX,true)}break;case"key_zoom":b(a7.zoom+a7.zoom_pas);break;case"key_dezoom":b(a7.zoom-a7.zoom_pas);break}if(bU){if(!a7.mode2d){var bS=a("#s_"+bX+"_"+bR);if(bS.length){a9(bS)}}else{var bS=a("#c_"+bX+"_"+bR);if(bS.length){a9(bS)}}}if(bU===true){bW.stopPropagation();bW.preventDefault();return}else{return false}})}if(!a7.mode2d){if(a7.onclicright!=""){a(".pp3diso-shap").bind("contextmenu",(function(bQ){a7.onclicright(bq,bo,a7.mapId)}))}a(".pp3diso-shap").bind("click",(function(){if(window.Touch){a9(a(this))}if(!a1){aQ(a(this))}}));if(a7.cursorDelay!==false){a(".pp3diso-shap").bind("mouseenter",function(){L=a(this).attr("id");if(av==1){bs=window.setTimeout(function(){window.clearTimeout(bs);var bQ=L.split("_");a7.oncursordelay(bQ[2],bQ[1],a7.mapId)},a7.cursorDelay)}});a(".pp3diso-shap").bind("mouseout",function(){window.clearTimeout(bs)})}if(!al){a(".pp3diso-shap").bind("mouseenter",function(){a9(a(this))})}}if(a7.drag&&!a7.mode2d){a("#pp3Diso-conteneur").bind("touchstart",function(bR){a1=false;var bS=bR.originalEvent;var bQ=H.position();r=bS.changedTouches[0].clientX-bQ.left;p=bS.changedTouches[0].clientY-bQ.top;a("#pp3Diso-conteneur").bind("click",function(){return false});a("#pp3Diso-conteneur").bind("touchmove",function(bT){ba(bT)});a("#pp3Diso-conteneur").bind("touchend touchcancel",function(bT){br(bT,a(this))});if(!ar){ar=true;setTimeout(function(){ar=false},100)}});a(".pp3diso-shap").bind("mousedown",function(bS){a1=false;var bQ=bS||window.event;var bR=H.position();r=bQ.clientX-bR.left;p=bQ.clientY-bR.top;a("#pp3Diso-conteneur").bind("click",function(){return false});a("#pp3Diso-conteneur").bind("mousemove",aE).bind("mouseup",br);return false})}j.focus()}function aE(bw){bw.preventDefault();a1=true;var bv=bw||window.event;var bu=bv.clientX-r;var bt=bv.clientY-p;if(bt>(a7.ty<<1)){bt=a7.ty<<1}if(bu>(a7.tx)){bu=a7.tx}if(bu<-((aN-af)+(a7.tx*2))){bu=-((aN-af)+(a7.tx*2))}if(bt<-((aM-ae)+a7.ty)){bt=-((aM-ae)+a7.ty)}H.css({left:bu,top:bt});return false}function br(bz,bx){var by=H.position();var bu=~~(-by.left/a7.tx);var bt=~~(-by.top/a7.ty);var bw=e;var bv=c;e=by.left;c=by.top;a("#pp3Diso-conteneur").unbind("mousemove",aE).unbind("mouseup",br);if(bw!=e&&bv!=c){aX(E)}a(".pp3diso-shap").unbind("touchmove");a(".pp3diso-shap").unbind("ontouchend");if(ar){ar=false;aQ(bx)}return false}function ba(bv){bv.preventDefault();a1=true;var bw=bv.originalEvent;var bu=bw.changedTouches[0].clientX-r;var bt=bw.changedTouches[0].clientY-p;if(bt>(a7.ty<<1)){bt=a7.ty<<1}if(bu>(a7.tx)){bu=a7.tx}if(bu<-((aN-af)+a7.tx)){bu=-((aN-af)+a7.tx)}if(bt<-((aM-ae)+a7.ty)){bt=-((aM-ae)+a7.ty)}H.css({left:bu,top:bt});return false}function ac(){var bu=["DOMMouseScroll","mousewheel"];if(this.addEventListener){for(var bt=bu.length;bt;){j[0].addEventListener(bu[--bt],be,false)}}else{j[0].onmousewheel=be}}var aY=0;function be(by){var bA=new Date();by.preventDefault();by.stopPropagation();var bw=by||window.event,bv=[].slice.call(arguments,1),bz=0,bx=true,bu=0,bt=0;by=a.event.fix(bw);by.type="mousewheel";if(bw.wheelDelta){bz=bw.wheelDelta/120}if(bw.detail){bz=-bw.detail/3}bt=bz;if(bw.axis!==undefined&&bw.axis===bw.HORIZONTAL_AXIS){bt=0;bu=-1*bz}if(bw.wheelDeltaY!==undefined){bt=bw.wheelDeltaY/120}if(bw.wheelDeltaX!==undefined){bu=-1*bw.wheelDeltaX/120}bv.unshift(by,bz,bu,bt);if((bA.valueOf()-aY)>1000){if(bv[1]<0){b(a7.zoom-a7.zoom_pas)}else{b(a7.zoom+a7.zoom_pas)}aY=bA.valueOf()}return false}function t(){if(!a7.mode2d){for(var bw=1;bw<=J;bw++){for(var bt=1;bt<=K;bt++){id="c_"+bw+"_"+bt;var bu=g(bw,bt)+c;var bv=h(bw,bt)+e;if(bv>-tx&&bv<(af+tx)&&bu>-ty&&bu<(ae+ty)){H.append('<div id="'+id+'" class="pp3diso-sol"></div>');a("#"+id).css({"z-index":aT(bw,bt),position:"absolute",left:(bv|0),top:(bu|0),width:a7.tx,height:a7.ty,display:"block"})}}}}}function Q(){if(a7.mode2d){aX(E)}if(a4==0&&!a7.mode2d){if(move_map_waiting){H.css("display","none")}move_map_waiting=false;bm=true;if(a7.positionFixe==true){H.animate({left:(an|0),top:(X|0)},a7.speed_map,function(){aX(E);bm=false;H.fadeIn("100");ab.css("display","none")})}else{if(a7.fluide){H.animate({left:(e|0),top:(c|0)},a7.speed_map,function(){aX(E);bm=false;H.fadeIn("100");ab.css("display","none")})}else{H.css({left:(e|0),top:(c|0)});aX(E);bm=false;ab.css("display","none")}}}else{move_map_waiting=true}}function bf(bt,bu){if(!a7.mode2d){bt=(bt|0);bu=(bu|0);id="c_"+bu+"_"+bt;a("#"+id).fadeTo(0,I[bu][bt]);id="b_"+bu+"_"+bt;a("#"+id).fadeTo(0,1);id="o_"+bu+"_"+bt;a("#"+id).fadeTo(0,1)}}function aB(bB,bA,bv){bB=(bB|0);bA=(bA|0);bv=(bv|0);if(bA<1||bB<1||bA>J||bB>K){return}if(I[bA][bB]<bv){I[bA][bB]=bv}if(I[bA][bB]>1){I[bA][bB]=1}bf(bB,bA);var bu=a7.fogofwar;for(var bt=bB-bu;bt<=bB+bu;bt++){var bx=Math.abs(bt-bB);for(var bz=bA-bu;bz<=bA+bu;bz++){var by=Math.abs(bz-bA);if(bx>by){by=bx}if(bt!=bB||bz!=bA){if(!(bz<1||bt<1||bz>J||bt>K)){var bw=(bv/by);if(I[bz][bt]<bw){I[bz][bt]=bw}if(I[bz][bt]>1){I[bz][bt]=1}bf(bt,bz)}}}}}function aX(bO){var bF="";var bt="";var bM=a7.tx*3;var by=a7.ty*3;if(V<1){V=1}if(T<1){T=1}if(a7.mode2d){var bD=(V|0)-(a7.mode2d_viewx|0);var bA=(V|0)+(a7.mode2d_viewx|0);if(bD<1){bA=bA-(bD-1)}if(bA>K){bD=K-(((a7.mode2d_viewx|0)<<1))}var bB=(T|0)-(a7.mode2d_viewy|0);var bz=(T|0)+(a7.mode2d_viewy|0);if(bB<1){bz=bz-(bB-1)}if(bz>J){bB=J-(((a7.mode2d_viewy|0)<<1))}if(bD<1){bD=1}if(bA>K){bA=K}if(bB<1){bB=1}if(bz>K){bz=J}}var bx=af+bM;var bv=ae+by;for(var bI=1;bI<=J;bI++){if(a7.mode2d){if(bI>=bB&&bI<=bz){bt=bt+'<tr><th id="y'+bI+'" axis="axe des ordonn�es">'+bI+"</th>"}}var bu="c_"+bI;for(var bJ=1;bJ<=K;bJ++){var bH=z[bI][bJ][0];var bG=z[bI][bJ][1];var bE=bH+e;var bL=bG+c;var bK=bu+"_"+bJ;var bw=a("#"+bK);if(a7.mode2d){if(bJ>=bD&&bJ<=bA&&bI>=bB&&bI<=bz){bt=bt+'<td headers="x'+bJ+" y"+bI+'" id="'+bK+'"></td>'}}else{if(bE>-bM&&bE<(bx)&&bL>-by&&bL<(bv)){if(bw.length==0){bt=bt+'<div id="'+bK+'" class="pp3diso-sol"></div>'}else{if(a7.fogofwar>0){bf(bJ,bI)}if(bw[0].getAttribute("display")!="block"){bw.css("display","block")}}}else{bw.remove().empty()}}}if(a7.mode2d){if(bI>=bB&&bI<=bz){bt=bt+"</tr>"}}}if(a7.mode2d){totalFrag_dummy='<table id="pp3diso_table">';totalFrag_dummy=totalFrag_dummy+"<tr><td> </td>";for(bJ=bD;bJ<=bA;bJ++){totalFrag_dummy=totalFrag_dummy+'<th id="x'+bJ+'" axis="axe des abscisses">'+bJ+"</th>"}totalFrag_dummy=totalFrag_dummy+"</tr>";bt=totalFrag_dummy+bt+"</table>";a("#pp3diso_table").remove()}H.append(bt);var bC="100%";for(var bI=1;bI<=J;bI++){for(var bJ=1;bJ<=K;bJ++){var bH=h(bI,bJ);var bG=g(bI,bJ);var bE=bH+e;var bL=bG+c;var bK="c_"+bI+"_"+bJ;var bw=a("#"+bK);if(a7.mode2d){var bN=aJ(bJ,bI,bO);bw.html(bN).click(function(){var bP=a(this).attr("id");var bR=bP.split("_");var bS=bR[2];var bQ=bR[1];if(a0(bS,bQ)){B(bS,bQ,true)}a9(a(this))}).mouseover(function(){a9(a(this))})}else{if(bE>-bM&&bE<(af+bM)&&bL>-by&&bL<(ae+by)){if(!bw.length==0){bF=bO[bI][bJ]+".png";if(bF!="NaN.png"){bF=M+bF;bw.css({"z-index":aT(bI,bJ),position:"absolute",left:(bH|0),top:(bG|0),width:a7.tx,height:a7.ty,"background-image":"url('"+bF+"')",display:"block","-webkit-background-size":bC+" "+bC,"-o-background-size":bC+" "+bC,"-moz-background-size":bC+" "+bC,"background-size":bC+" "+bC})}}}}}}}function aJ(bt,by,bx){var bw="<p>";var bv="";var bu=" ";if(a7.titre_case!=""){bv=a7.titre_case;bv=aK(bv,"[x]",bt);bv=aK(bv,"[y]",by)}bw=""+bv+bu;bw=bw+""+a7.titre_map[bx[by][bt]]+bu;bv=aH(bt,by);if(bv!=""){bw=bw+""+bv+bu}if(bq==bt&&bo==by){bw=bw+""+a7.mode2d_avatar+bu}bw=bw+"</p>";return bw}function aK(bv,bu,bt){SRRi=bv.indexOf(bu);SRRr="";if(SRRi==-1){return bv}SRRr+=bv.substring(0,SRRi)+bt;if(SRRi+bu.length<bv.length){SRRr+=aK(bv.substring(SRRi+bu.length,bv.length),bu,bt)}return SRRr}function aT(bu,bt){return(bt<<1)+(bu<<1)}function u(bv,bt){bt=bt|0;bv=bv|0;var bu=C+((bt-1)*aL);bu=bu-(aL*(bv+1))+aL;return(bu|0)}function bk(bv,bt){bt=bt|0;bv=bv|0;var bu=(bv-1)*(am);bu=bu+(am*(bt-1));return(bu|0)}function h(bu,bt){return z[bu|0][bt|0][0]}function g(bu,bt){return z[bu|0][bt|0][1]}function W(bt){return(bt|0)}function aI(bt,bv){for(var bu in bj){if(bj[bu]["x"]==bt&&bj[bu]["y"]==bv){return true}}return false}function aH(bt,bx,bv){if(typeof(bv)=="undefined"){bv=" / "}var bw="";for(var bu in bj){if(bj[bu]["x"]==bt&&bj[bu]["y"]==bx){bw=bw+bv+bj[bu]["titre"]}}bw=bw.substr(bv.length);return bw}function a9(bv){var bw=bv.attr("id");if(typeof(bw)=="undefined"){return}var by=bw.split("_");var bu=by[2];var bA=by[1];if(V!=bu||T!=bA){if(ad[T][V]==2){a7.onleavebuilding(V,T,a7.mapId)}else{if(aI(V,T)){a7.onleaveobject(V,T,a7.mapId)}}}V=bu;T=bA;var bt=h(bA,bu)+(bc*a7.zoom);var bz=g(bA,bu)+(bb*a7.zoom);if(a0(bu,bA)){a("#pp3diso-cursor-img").attr("src",m);color_m2d=a7.mode2d_select}else{a("#pp3diso-cursor-img").attr("src",aC);color_m2d=a7.mode2d_select_off}if(!a7.mode2d){if(a7.cursorZindex>0){var bx=300000+aT(bA|0,bu|0)+(a7.cursorZindex|0);a("#pp3diso-cursor").css({display:"block",left:bt,top:bz,"z-index":bx})}else{a("#pp3diso-cursor").css({display:"block",left:bt,top:bz})}}else{a("#pp3diso_table td").css("background-color",a7.mode2d_fond);bv.css("background-color",color_m2d);bv.first("p").focus()}if(ad[bA][bu]==2){a7.onenterbuilding(bu,bA,a7.mapId)}else{if(aI(bu,bA)){a7.onenterobject(bu,bA,a7.mapId)}}}var aW=false;function az(){if(!aW){a6=null;a6=[];for(y=0;y<J;y++){for(x=0;x<J;x++){if(ad[y+1][x+1]==1){w[x][y]=1}else{w[x][y]=0}}}}}function a5(bD,bB){var by=bq;var bv=bo;var bz=bD;var bw=bB;var bC,bx,bA,bu;az();if(bl!=false){bC=by-(bl+1);bx=by+bl;bA=bv-(bl+1);bu=bv+bl;if(bC<0){bC=0}if(bx>=K){bx=K}if(bA<0){bA=0}if(bu>=J){bu=J}}else{bC=false;bx=false;bA=false;bu=false}var bt=astar(by-1,bv-1,bz-1,bw-1,w,a7.PF_corners,bA,bu,bC,bx);if(bt!=null){aR(bt);return true}else{return false}}function a8(bI,bH,bB){var bK=bq;var bJ=bo;var bG=bI;var bF=bH;var bC,bA,bz,by;var bx,bw,bv,bu;az();if(bl!=false){bx=bK-(bl+1);bw=bK+bl;bv=bJ-(bl+1);bu=bJ+bl;if(bx<0){bx=0}if(bw>=K){bw=K}if(bv<0){bv=0}if(bu>=J){bu=J}}else{bx=false;bw=false;bv=false;bu=false}var bL=astar(bK-1,bJ-1,bG-1,bF-1,w,a7.PF_corners,bv,bu,bx,bw);if(bL!=null){var bE=bL.length;for(var bO=0;bO<bE;bO++){var bN=h(bL[bO].col+1,bL[bO].row+1);var bM=g(bL[bO].col+1,bL[bO].row+1);var bQ=a7.tx>>1;var bD=a7.ty>>1;if(!a7.beforemoveavatar(bI,bH,a7.mapId)){return}if(bO<1){bC=bq;bA=bo}else{bC=bL[bO-1].row+1;bA=bL[bO-1].col+1}bz=bL[bO].row+1;by=bL[bO].col+1;var bt=1;if(bz>bC){bt=3}else{if(bz<bC){bt=2}else{if(by>bA){bt=1}else{if(by<bA){bt=4}else{bt=1}}}}if(bO<1){ag=bt}else{A.push(bt)}bq=bI;bo=bH;a6.push(bL[bO].col+1+","+bL[bO].row+1);var bP=a("#pp3diso-avatar");aV.push(300000+aT(bL[bO].col+1,bL[bO].row+1));bP.animate({left:bN+aG,top:bM+aD},{step:function(){ax++;if(ax>a7.move_avatar_speed){Z();ax=0}},duration:a7.speed_avatar,complete:function(){var bR=bL.length-A.length;if(!!bL[bR]){a7.onmovepathfinding(bL[bR].row+1,bL[bR].col+1,a7.mapId)}if(A.length){ag=A.shift()}else{if(bB){a7.onmoveavatar(bI,bH,a7.mapId)}}var bT=a6.pop();var bS=aV.shift();if(aV.length<=1){}bP.css("z-index",bS)}});if(a7.fogofwar>0){aB(bI,bH,1)}}}}function Z(){if(aa){var bt=~~((a3*(ah))*a7.zoom);var bu=~~((a2*(ag-1))*a7.zoom);a("#pp3diso-avatar-img").css({left:-bt,top:-bu});ah++;if(ah>=aF){ah=0}}}function aR(by){a(".pp3Diso_PF").remove().empty();var bx=by.length;for(var bw=0;bw<bx;bw++){var bt=h(by[bw].col+1,by[bw].row+1);var bA=g(by[bw].col+1,by[bw].row+1);var bz="pp3Diso_PF_"+bt+"-"+bA;var bv='<div id="'+bz+'" class="pp3Diso_PF"></div>';H.append(bv);var bu="100%";a("#"+bz).css({position:"absolute",display:"block",width:a7.tx,height:a7.ty,"background-image":"url('"+a7.cursorPF+"')","-webkit-background-size":bu+" "+bu,"-o-background-size":bu+" "+bu,"-moz-background-size":bu+" "+bu,"background-size":bu+" "+bu,left:bt+a7.PF_decx,top:bA+a7.PF_decy,"z-index":300000+by[bw].col+1+by[bw].row+1})}}function a0(bt,bv){if(a7.pathfinding){return a5(bt,bv)}else{var bu=false;if(ak==""){bu=true}else{bt=(bt|0);bv=(bv|0);if(bt>=bq-1&&bt<=bq+1&&bv>=bo-1&&bv<=bo+1){bu=true}else{bu=false}}if(ad[bv][bt]==1&&bu){return true}else{return false}}}function B(bB,bA,bD){bB=(bB|0);bA=(bA|0);var bz=h(bA,bB);var by=g(bA,bB);var bw=a7.tx>>1;var bE=a7.ty>>1;if(a7.pathfinding){a8(bB,bA,bD)}else{if(!a7.beforemoveavatar(bB,bA,a7.mapId)){return}if(!a7.mode2d){var bx=a("#pp3diso-avatar");bx.animate({left:bz+aG,top:by+aD},a7.speed_avatar);bx.css({"z-index":300000+aT(bA,bB)})}bq=bB;bo=bA;if(a7.fogofwar>0){aB(bB,bA,1)}if(bD){a7.onmoveavatar(bB,bA,a7.mapId)}}modif_move=false;if(af<aN+(a7.tx>>1)){var bv=a7.nbrTitleSetsSlide*a7.tx;var bt=~~(bz+e+bw);var bu=((af>>1)+bv);if(bt>bu){while(bt>bu){e-=bv;bt=~~(bz+e+bw)}modif_move=true}bu=((af>>1)-bv);if(bt<bu){while(bt<bu){e+=bv;bt=~~(bz+e+bw)}modif_move=true}}if(ae<aM+(a7.ty>>1)){var bv=a7.nbrTitleSetsSlide*a7.ty;var bt=~~(by+c+bE);var bu=((ae>>1)+bv);if(bt>bu){while(bt>bu){c-=bv;bt=~~(by+c+bE)}modif_move=true}bu=((ae>>1)-bv);if(bt<bu){while(bt<bu){c+=bv;bt=~~(by+c+bE)}modif_move=true}}V=bq;T=bo;if(!a7.mode2d){var bC=a("#s_"+T+"_"+V);if(bC.length){a9(bC)}}else{var bC=a("#c_"+T+"_"+V);a9(bC);modif_move=true}if(modif_move){Q()}}function aQ(bu){var bv=bu.attr("id");var bw=bv.split("_");var bt=bw[2];var bx=bw[1];aU.css("display","none");if(ad[bx][bt]==2){a7.onclicbuilding(bt,bx,a7.mapId)}else{if(aI(bt,bx)){a7.onclicobject(bt,bx,a7.mapId)}}if(a0(bt,bx)){B(bt,bx,true)}}function F(bt){bt=bt.substring(0,bt.length-2);return(bt|0)}function aj(){a("#pp3diso-avatar").remove().empty()}this.reload=function(bv,bt,bw,bu){bj=null;bj=[];aP();bq=1;bo=1;V=1;T=1;a7.map=bv;a7.zone=bt;a7.mapZones=bw;a7.mapId=bu;aO();Q()};this.show=function(bt){if(!a7.fogofwar>0){}B(bq,bo,bt);H.css("display","none")};this.changeCursor=function(bu,bv,bt,bw){a("#pp3diso-cursor").remove().empty();O=0;l(bu,bv,bt,bw)};this.cursor=function(bu,bv,bt,bw){l(bu,bv,bt,bw)};function l(bu,bv,bt,bw){m=bu;aC=bv;bc=bt;bb=bw;if(!a7.mode2d){H.append('<div id="pp3diso-cursor"><img id="pp3diso-cursor-img" src="'+bu+'" alt="" /></div>');a("#pp3diso-cursor-img").load(function(){if(this.width<1){}else{if(O<1){a("#pp3diso-cursor-img").attr("rel",this.width+":"+this.height);O=~~(this.width*a7.zoom);N=~~(this.height*a7.zoom);this.width=O;this.height=N}}});a("#pp3diso-cursor").css({"z-index":299000,position:"absolute",left:0,top:0,display:"block"})}}function bd(bt,bw){var bv=h(bw,bt);var bu=g(bw,bt);e=-((bv-(af>>1))|0);c=-((bu-(ae>>1))|0);V=bt;T=bw;bq=bt;bo=bw;if(bm){setTimeout(function(){bd(bt,bw)},250)}else{Q();H.css("display","block")}}this.moveTo=function(bt,bu){bd(bt,bu)};this.getMonde=function(){var bt=new Array(K+1);for(x=1;x<=K;x++){bt[x]=new Array(J+1);for(y=1;y<=J;y++){bt[x][y]=E[y][x]}}return bt};this.getObjects=function(){return bj};this.getBuilding=function(){var bt=new Array(K+1);for(x=1;x<=K;x++){bt[x]=new Array(J+1);for(y=1;y<=J;y++){bu="";var bv="b_"+y+"_"+x;if(a("#"+bv+" img").length>0){var bu=a("#"+bv+" img").attr("src")}bt[x][y]=bu}}return bt};this.moveObject=function(bt,bB,bz,bu,bx){for(var bw in bj){if(bj[bw]["id"]==bt){bj[bw]["x"]=bB;bj[bw]["y"]=bz;var bC=h(bz,bB)+(bj[bw]["decx"]*a7.zoom);var bA=g(bz,bB)+(bj[bw]["decy"]*a7.zoom);var bv="o_"+bt;if(bu){var by=300000+aT(bz,bB);a("#"+bv).css("z-index",by).animate({left:(bC|0),top:(bA|0)},bx)}else{a("#"+bv).css({"z-index":300000+aT(bz,bB),left:(bC|0),top:(bA|0)})}break}}};this.killAvatar=function(){aj()};this.avatar=function(bu,bz,bw,bt,by,bv,bx){au(bu,bz,bw,bt,by,bv,bx)};function au(bB,bA,bt,bv,bu,bw,bz){if(bm){setTimeout(function(){au(bB,bA,bt,bv,bu,bw,bz)},250);return}aj();if(typeof(bw)=="undefined"){bw=false;bz=1;var bx=1}else{var bx=4}var by=~~(100*bz)+"%";aG=bv*a7.zoom;aD=bu*a7.zoom;q=bv;bg=bu;bq=bB;bo=bA;aF=bz;aa=bw;ak=bt;if(!a7.mode2d){H.append('<div id="pp3diso-avatar"><img id="pp3diso-avatar-img" src="'+bt+'" alt="" /></div>');a("#pp3diso-avatar-img").load(function(){var bD=this.width;var bC=this.height;a3=~~(bD/bz);a2=~~(bC/bx);var bF=~~(a3*a7.zoom);var bE=~~(a2*a7.zoom);var bG=a("#pp3diso-avatar-img");a("#pp3diso-avatar").css({"z-index":300000+aT(bA,bB),position:"absolute",left:h(bA,bB)+bv,top:g(bA,bB)+bu,width:bF,height:bE,overflow:"hidden",display:"block"});bG.css({position:"absolute",display:"block",left:0,top:0,width:bF*bz,height:bE*bx});B(bq,bo,false)})}else{B(bq,bo,false)}}this.moveAvatarTo=function(bt,bu){bq=bt;bo=bu;B(bt,bu,false)};this.changeOneMap=function(bt,bz,bw){var by="c_"+bz+"_"+bt;var bv=a("#"+by);var bu="100%";var bx=M+bw+".png";E[bz][bt]=bw;bv.css({"background-image":"url('"+bx+"')","-webkit-background-size":bu+" "+bu,"-o-background-size":bu+" "+bu,"-moz-background-size":bu+" "+bu,"background-size":bu+" "+bu})};this.changeState=function(bt,bv,bu){ad[bv][bt]=bu};this.getState=function(bt,bu){return ad[bu][bt]};this.getOneMap=function(bt,bu){return E[bu][bt]};this.killBuilding=function(bt,bu){f(bt,bu)};function f(bt,bv){var bu="#b_"+bv+"_"+bt;ad[bv][bt]=1;if(a(bu).length){a(bu).remove().empty()}}this.addBuilding=function(bu,bx,bv,bt,bw){aZ(bu,bx,bv,bt,bw)};function aZ(bA,by,bC,bv,bu){var bx=v;var bB=h(by,bA)+(bv*a7.zoom);var bz=g(by,bA)+(bu*a7.zoom);ad[by][bA]=2;var bt="b_"+by+"_"+bA;H.append('<div id="'+bt+'" class="pp3diso-batiment"><img src="'+bC+'" alt="" /></div>');var bw=a("#"+bt);bw.attr("rel",bC+":"+bv+":"+bu);a4++;a("#"+bt+" img").load(function(){var bE=~~(this.width*a7.zoom);var bD=~~(this.height*a7.zoom);a(this).attr("rel",this.width+":"+this.height+":"+this.top+":"+this.left);a(this).width(bE).height(bD);a4--;if(move_map_waiting){Q()}});bw.css({"z-index":300000+aT(by,bA),position:"absolute",left:(bB|0),top:(bz|0),display:"block"})}function s(){var bu=[];for(var bt in bj){if(bj[bt]["id"]!=""){bu[bt]=[];bu[bt]=bj[bt]}}bj=null;bj=bu}this.killObject=function(bt){U(bt)};function U(bv){var bu="#o_"+bv;for(var bt in bj){if(bj[bt]["id"]==bv){bj[bt]["id"]="";break}}s();if(a(bu).length){a(bu).remove().empty()}}this.addObject=function(bu,bA,bv,bt,bz,by,bw,bx){return Y(bu,bA,bv,bt,bz,by,bw,bx)};function Y(bD,bB,bF,bw,bu,bA,by,bt){var bE=h(bB,bD)+(bw*a7.zoom);var bC=g(bB,bD)+(bu*a7.zoom);if(typeof(by)=="undefined"){by=""}dummy=bj.length+1;if(typeof(bt)=="undefined"){bt=dummy}var bx=[];bx.id=bt;bx.x=bD;bx.y=bB;bx.sprite=bF;bx.decx=bw;bx.decy=bu;bx.titre=bA;bx.bulle=by;bj.push(bx);if(a7.mode2d){var bt="c_"+bB+"_"+bD;var bG=a("#"+bt);if(bA!=""){bG.append("<p>"+bA+" ("+by+")</p>")}}else{var bv="o_"+bt;a("#"+bv).remove().empty();var bz="";if(by!=""){bz='<div class="pp3diso-obj-bulle">'+by+"<div>"}H.append('<div id="'+bv+'" class="pp3diso-objet"><img src="'+bF+'" alt="" />'+bz+"</div>");a("#"+bv).attr("rel",bF+":"+bw+":"+bu);a4++;a("#"+bv+" img").load(function(){var bN=~~(this.width*a7.zoom);var bM=~~(this.height*a7.zoom);a(this).width(bN).height(bM);if(by!=""){var bH=a("#"+bv+" .pp3diso-obj-bulle");if(a7.bulle_auto_x){var bI=bH.outerWidth();var bL=~~(((bN-bI)>>1));bH.css({left:bL})}if(a7.bulle_auto_y=="top"){var bJ=bH.height();var bK=-(bJ+a7.bulle_obj_deca_y);bH.css({top:bK})}else{if(a7.bulle_auto_y=="bottom"){var bJ=bH.height();var bK=-(bJ+a7.bulle_obj_deca_y);bH.css({bottom:bK})}}}a4--;if(move_map_waiting){Q()}});a("#"+bv).css({"z-index":300000+aT(bB,bD),position:"absolute",left:~~(bE),top:~~(bC),display:"block"})}}this.changeBulle=function(bt,bu){return P(bt,bu)};function P(bu,bv){for(var bt in bj){if(bj[bt]["id"]==bu){bj[bt]["bulle"]=bv;var bw=a("#o_"+bu+" .pp3diso-obj-bulle");bw.html(bv);break}}}function bh(){a("#pp3diso-win-fond").fadeTo(500,0,function(){a("#pp3diso-win-fond").remove().empty()});a("#pp3diso-win").remove().empty();a("#pp3diso-clicks").css("display","block")}this.message=function(bv,bE,bB){if(a("#pp3diso-win").length!=0){return}aU.css("display","none");var bA='<div id="pp3diso-win-fond"></div>';bA+='<div id="pp3diso-win"><div id="pp3diso-close"></div><div class="pp3diso-win-texte">'+bE+"</div>";if(bB!=""){var bD=bB.split("||");bA+='<div id="pp3diso-win-form">';var bx=bD.length;for(var bz=0;bz<bx;bz++){by=bD[bz].split("::");bA+='<a href="#" rel="'+by[1]+'" class="pp3diso-win-button" id="pp3diso-win-'+bz+'">'+by[0]+"</a>"}bA+="</div>"}bA+="</div>";j.append(bA);a("#pp3diso-win-0").focus();var bC=a("#pp3diso-win");by=(af/3);var bu=(by<<1);var bw=(by>>1);var bt=-1;a("#pp3diso-win-fond").css({position:"absolute",width:aN,height:aM,left:0,top:0,"z-index":800000,display:"block"}).fadeTo(0,0.4);bC.css({position:"absolute",width:bu,left:bw,top:50,"z-index":800001,display:"none"});bC.slideDown(100);a("#pp3diso-clicks").css("display","none");a("#pp3diso-close").click(function(bF){bF.preventDefault();bF.stopImmediatePropagation();a7.beforeclosewin(0);bC.slideUp("fast",function(){bh();a7.afterclosewin(bv,bt)})});if(bB!=""){var bD=bB.split("||");var bx=bD.length;for(var bz=0;bz<bx;bz++){var by=bD[bz].split("::");a("#pp3diso-win-"+bz).click(function(bG){bG.preventDefault();bG.stopImmediatePropagation();var bF=a(this).attr("rel");a7.beforeclosewin(bF);bC.slideUp("fast",function(){bh();a7.afterclosewin(bv,bF)})})}}};this.zoomMap=function(bt){b(bt)};function aP(){a("#pp3diso-clicks").remove().empty();a("#pp3diso-Map").remove().empty();if(a7.mapZonesColors!=""){var bt=a7.mapZonesColors.split(":");var bu=bt.length;for(i=0;i<bu;i++){at[i].clearRect(0,0,bp[i].width,bp[i].height)}a("pp3Diso-mapZone").remove().empty()}}function b(bu){a("#pp3diso-avatar").clearQueue();A=null;A=[];aV=null;aV=[];a(".pp3Diso_PF").remove().empty();if(bu<a7.zoom_min){bu=a7.zoom_min}if(bu>a7.zoom_max){bu=a7.zoom_max}aP();var bx=a7.zoom;a7.zoom=bu;var bC=bx-bu;var bF=e-((e*bC)|0);var bK=c-((c*bC)|0);e=bF;c=bK;v=~~(a7.zoom*100)+"%";a7.tx=S*a7.zoom;a7.ty2=(a7.tx>>1);a7.ty=R*a7.zoom;a7.ty2=aw*a7.zoom;aL=(a7.tx>>1);am=a7.ty2;aN=(K*((a7.tx)>>1))+(J*((a7.tx)>>1));aM=(K*((a7.ty)>>1))+(J*((a7.ty)>>1));C=(aN>>1);an=((af-aN)>>1);X=((ae-aM)>>1);if(a7.mapZonesColors!=""){var bA=a7.mapZonesColors.split(":");var bw=bA.length;for(bI=0;bI<bw;bI++){bp[bI].width=aN;bp[bI].height=aM}}if(a7.auto_size){j.css({width:aN,height:aM})}aS(E);if(!a7.mode2d){ab.css("display","block")}aX(E);var bJ=[];bJ=bj;bj=null;bj=[];for(var bI in bJ){if(bJ[bI]["id"]!=""){var bD="o_"+bJ[bI]["id"];a("#"+bD).remove().empty();Y(bJ[bI]["x"],bJ[bI]["y"],bJ[bI]["sprite"],bJ[bI]["decx"],bJ[bI]["decy"],bJ[bI]["titre"],bJ[bI]["bulle"],bJ[bI]["id"])}}for(var bz=1;bz<=J;bz++){for(var bB=1;bB<=K;bB++){if(ad[bz][bB]==2){var bD="b_"+bz+"_"+bB;bJ=(a("#"+bD).attr("rel")).split(":");a("#"+bD).remove().empty();aZ(bB,bz,bJ[0],bJ[1],bJ[2])}}}var bt=a("#pp3diso-cursor-img");if(!bt.length==0){var bJ=bt.attr("rel").split(":");O=~~(bJ[0]*a7.zoom);N=~~(bJ[1]*a7.zoom);bt.attr("width",O).attr("height",N)}var bH=a("#pp3diso-avatar-img");if(!(bH.length==0)){if(aa){nbr_x=4}else{nbr_x=1}var bv=~~(100*aF)+"%";var bG=~~((a3*aF*a7.zoom)/aF);var bE=~~((a2*a7.zoom));var by=a("#pp3diso-avatar-img");a("#pp3diso-avatar").css({width:bG,height:bE});by.css({position:"absolute",overflow:"hidden",display:"block",left:0,top:0,width:bG*aF,height:bE*nbr_x})}aG=q*a7.zoom;aD=bg*a7.zoom;var bJ=a7.speed_avatar;a7.speed_avatar=1;B(bq,bo);a7.speed_avatar=bJ;Q();a7.onchangezoom(bu)}this.moveMapOn=function(){var bv=["s","n","e","o","se","so","ne","no"];var bu=bv.length;for(var bt=0;bt<bu;bt++){var bw="#pp3diso-fleche-"+bv[bt];if(a(bw).length){a(bw).bind("mouseover",function(){var bx=a(this).attr("id");bx=bx.substr(15);if(!ao){ao=true;k(bx,a7.speed_by_titleset)}});a(bw).bind("mouseout",function(){o()})}}};function k(bv,bw){if(bm){return}var bt=(a7.ty>>1)*bw;var bu=(a7.tx>>1)*bw;switch(bv){case"n":c+=bt;break;case"ne":c-=bt;e-=bu;break;case"e":e-=bu;break;case"se":e-=bu;c+=bt;break;case"s":c-=bt;break;case"so":c+=bt;e+=bu;break;case"o":e+=bu;break;case"no":c-=bt;e+=bu;break}if(e<-(aN-af)){e=-(aN-af)}if(e>0){e=0}if(c<-(aM-ae)){c=-(aM-ae)}if(c>0){c=0}Q();if(ao){clearInterval(ai);ai=setInterval(function(){if(ao&&!bm){k(bv,bw)}},a7.speed_map_while)}}this.moveMapOne=function(bt,bu){k(bt,bu)};this.moveMapWhile=function(bt,bu){ao=true;k(bt,bu)};function o(){ao=false;clearInterval(ai)}this.moveMapStop=function(){o()};this.tipShow=function(bw,bu,bt,bv){aU.css({display:"none"});aU.html(bw);if(bu==0){bt=h(T,V)+bc+bt;bv=g(T,V)+bb+bv}else{if(bu==1){if(bt<0){bt+=af;bt-=aU.outerWidth()}if(bv<0){bv+=ae;bv-=aU.outerHeight()}bt-=e;bv-=c}}aU.css({top:bv,left:bt,display:"none"});aU.stop(true,true).fadeIn("normal");bi=true};this.tipHide=function(){aU.stop(true,true).fadeOut("normal",function(){bi=false})};this.toggleZone=function(bu,bv){if(bv==""){bv="normal"}bu--;var bt=a("#pp3Diso-mapZone-canvas-"+bu);if(bt.css("display")=="none"){bt.fadeIn(bv)}else{bt.fadeOut(bv)}};this.showZone=function(bt,bu){if(bu==""){bu="normal"}bt--;a("#pp3Diso-mapZone-canvas-"+bt).fadeIn(bu)};this.hideZone=function(bt,bu){if(bu==""){bu="normal"}bt--;a("#pp3Diso-mapZone-canvas-"+bt).fadeOut(bu)};this.switchCursorDelay=function(bt){av=bt};return this}})(jQuery);var mapLength,mapRowLength,gMinx,gMaxx,gMiny,gMaxy;function astar(j,f,k,g,b,d,r,o,q,m){var h=[];var l=[];var a=[];if(o==false){gMaxx=b.length}else{gMaxx=o}if(r==false){gMinx=0}else{gMinx=r}if(m==false){gMaxy=b[0].length}else{gMaxy=m}if(q==false){gMiny=0}else{gMiny=q}mapLength=gMaxx;mapRowLength=gMaxy;var e=new Node(k,g,b,null,null);var p=new Node(j,f,b,null,e);addNodeToList(p,h);var c;while(!isListEmpty(h)){c=returnNodeWithLowestFScore(h);addNodeToList(c,l);removeNodeFromList(c,h);if(areNodesEqual(c,e)){pathTo(c,a);a.reverse();return a}c.makeChildNodes(b,d,e);cullUnwantedNodes(c.childNodes,h);cullUnwantedNodes(c.childNodes,l);removeMatchingNodes(c.childNodes,h);removeMatchingNodes(c.childNodes,l);addListToList(c.childNodes,h)}return null}function pathTo(b,a){a.push(new NodeCoordinate(b.row,b.col));if(b.parentNode==null){return}pathTo(b.parentNode,a)}function addListToList(b,a){for(x in b){a.push(b[x])}}function removeMatchingNodes(d,f){var c=d.length;var e=f.length;for(var b=0;b<c;b++){for(var a=0;a<e;a++){if(f[a].row==d[b].row&&f[a].col==d[b].col){f.splice(a,1);e=f.length}}}}function cullUnwantedNodes(d,a){var e=a.length;var f=d.length;for(var c=0;c<e;c++){for(var b=0;b<f;b++){if(d[b].row==a[c].row&&d[b].col==a[c].col){if(d[b].f>=a[c].f){d.splice(b,1);f=d.length}}}}}function areNodesEqual(b,a){if(b.row==a.row&&b.col==a.col){return true}else{return false}}function returnNodeWithLowestFScore(b){var a=b[0];for(x in b){if(b[x].f<a.f){a=b[x]}}return a}function isListEmpty(a){return(a.length<1)?true:false}function removeNodeFromList(b,c){var d=c.length;for(var a=0;a<d;a++){if(b.row==c[a].row&&b.col==c[a].col){c.splice(a,1);break}}}function addNodeToList(a,b){b.push(a)}function returnHScore(b,d){var c=b.row-d.row;if(c<0){c=-c}var a=b.col-d.col;if(a<0){a=-a}if(a>c){return(c*14)+10*(a-c)}else{return(a*14)+10*(c-a)}}function NodeCoordinate(b,a){this.row=b;this.col=a}function Node(d,b,c,a,e){this.row=d;this.col=b;if(d<=gMiny){this.northAmbit=gMiny}else{this.northAmbit=d-1}if(d>=gMaxy-1){this.southAmbit=gMaxy-1}else{this.southAmbit=d+1}if(b<=gMinx){this.westAmbit=gMinx}else{this.westAmbit=b-1}if(b>=gMaxx-1){this.eastAmbit=gMaxx-1}else{this.eastAmbit=b+1}this.parentNode=a;this.childNodes=[];if(a!=null){if(d==a.row||b==a.col){this.g=a.g+10}else{this.g=a.g+14}this.h=returnHScore(this,e)}else{this.g=0;if(c[d][b]=="s"){this.h=returnHScore(this,e)}else{this.h=0}}this.f=this.g+this.h;this.makeChildNodes=function(k,f,l){for(var h=this.northAmbit;h<=this.southAmbit;h++){for(var g=this.westAmbit;g<=this.eastAmbit;g++){if(h!=this.row||g!=this.col){if(k[h][g]!="0"){if(f){this.childNodes.push(new Node(h,g,k,this,l))}else{if(h==this.row||g==this.col){this.childNodes.push(new Node(h,g,k,this,l))}}}}}}}};