
/*------------------------------------------------------------------------
# K2 Object Manager Class
# ------------------------------------------------------------------------
# author:    Dmitry Zhuk
# copyright: Copyright (C) 2013 zhuk.cc. All Rights Reserved.
# license:   http://creativecommons.org/licenses/by-nc-nd/4.0/
#            Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
# website:   http://zhuk.cc
# Technical Support Forum: http://forum.zhuk.cc/
# version: 6.3.1
-------------------------------------------------------------------------*/
function zhomK2Manager(){zhomK2Manager.ac+=1;this.bQ=zhomK2Manager.ac;this.map=null;this.aj=jQuery.noConflict();this.ad=[];this.dG;this.bB="";this.bO="";this.bF="";this.dM="";this.cG=0;this.cX=0;this.cz=false;this.cO=false;this.cu;this.cK="0";this.cF=false;this.cw="";this.cA="";this.dz="";this.dA="";this.cC=0;this.hY="";this.bV="";this.fC=0;this.fq="";this.hm="";this.cb=0;this.df="default";this.dJ;this.kJ="";zhomK2Manager.aO[this.bQ]=this;};zhomK2Manager.ac=0;zhomK2Manager.aO=[];zhomK2Manager.prototype.cS=function(l){var mw=l;var ak=mw.map;var cQ=mw.cu;if(typeof ak!=='undefined'&&ak!=null){if(!mw.cF){if(this.cO){cQ.clearLayers();}else{ak.eachLayer(function(layer){if(layer instanceof L.Marker){ak.removeLayer(layer);}});}mw.ad=[];if(mw.cz){mw.dG=L.latLngBounds();}mw.cF=true;}}else{}};zhomK2Manager.prototype.AddMarker=function(cq,gm,aa,bG,au,bb,bA,ca,cj,jO,lq,kg,ln,jT,kp){var ak=this.map;var cB;if(typeof ak!=='undefined'&&ak!=null){cB=new Object();cB.cg=cq;cB.ce=aa;cB.dI=bG;cB.cr=au;cB.dp=bb;cB.cV=bA;cB.dR=gm;cB.di=ca;cB.du=cj;cB.created_date=jO;cB.created_date_user=lq;cB.marker_extra_1=kg;cB.marker_extra_2=ln;cB.marker_extra_3=jT;cB.marker_extra_4=kp;this.ad.push(cB);this.cT(cB,true);}else{cB=new Object();cB.cg=cq;cB.ce=aa;cB.dI=bG;cB.cr=au;cB.dp=bb;cB.cV=bA;cB.dR=gm;cB.di=ca;cB.du=cj;cB.created_date=jO;cB.created_date_user=lq;cB.marker_extra_1=kg;cB.marker_extra_2=ln;cB.marker_extra_3=jT;cB.marker_extra_4=kp;this.ad.push(cB);}};zhomK2Manager.prototype.cT=function(fR,dH){var ak=this.map;var ds;var bd;var dB;var dm;var ck;var dQ=this.bB;var ig;var cQ=this.cu;var dO=this.dJ;ds=L.latLng(fR.ce,fR.dI);bd=L.marker(ds,{title:fR.dR});if(this.cz){ig=this.dG;ig.extend(ds);}dB="";dm=0;ck=0;if(fR.cr!=""){dB=fR.cr;if(fR.dp!=0){dm=fR.dp;}if(fR.cV!=0){ck=fR.cV;}}else if(this.dM!=""){dB=this.dM;if(this.cG!=0){dm=this.cG;}if(this.cX!=0){ck=this.cX;}}if(dB!=""){var ev=new Image();ev.onload=function(){var dW;if(dB.substring(0,8)=="default#"){dW=7;}else{dW=this.width/2;}var fJ=parseInt(dm)+dW;var ef=parseInt(ck)+this.height;var dK=L.icon({iconUrl:dQ+dB.replace("#","%23")+".png",iconSize:[this.width,this.height],iconAnchor:[fJ,ef]});bd.setIcon(dK);};ev.src=this.bB+dB.replace("#","%23")+".png";}bd.zhomPlacemarkID=fR.cg;bd.zhomPlacemarkLink=fR.di;bd.zhomTitle=fR.dR;bd.zhomActionByClick=fR.du;bd.zhomPlacemark_sitelocation=fR.di;bd.zhomPlacemark_zoombyclick=100;bd.zhomCreateddate=fR.created_date;bd.zhomCreateddateUser=fR.created_date_user;bd.marker_extra_1=fR.marker_extra_1;bd.marker_extra_2=fR.marker_extra_2;bd.marker_extra_3=fR.marker_extra_3;bd.marker_extra_4=fR.marker_extra_4;bd.zhomExtraFieldsList=fR.marker_extra_4;this.as(bd);if(this.cO){cQ.addLayer(bd);dO.setLinkType(fR.du);dO.PlacemarkAdd(0,fR.cg,bd,null);}else{bd.addTo(ak);}if(dH){if(this.cz){if(this.ad.length>1){ak.fitBounds(ig);}else{ak.setView(ds,ak.getZoom());}}}this.cF=false;};zhomK2Manager.prototype.RenderMap=function(){var ae=this.aj;var ak=this.map;var fm=this.ad;var mw=this;if(this.cz){this.dG=L.latLngBounds();}for(var i=0;i<fm.length;i++){this.cT(fm[i],false);}if(this.cz){if(fm.length>0){ak.fitBounds(this.dG);}}if(this.cC==1||this.cC==2){if(this.cw!=""){if(this.cA!=""){ae(this.cw).find(this.cA).click(function(){mw.cS(mw);});}if(this.dz!=""){ae(this.cw).find(this.dz).click(function(){mw.cS(mw);});}}}};zhomK2Manager.prototype.setMap=function(t){this.map=t;};zhomK2Manager.prototype.setObjectManager=function(t){this.dJ=t;};zhomK2Manager.prototype.setDefaultIcon=function(t,bb,bA){this.dM=t;this.cG=bb;this.cX=bA;};zhomK2Manager.prototype.setIcoIcon=function(t){this.bB=t;};zhomK2Manager.prototype.setPlacemarkDateFormat=function(t){this.kJ=t;};zhomK2Manager.prototype.setIcoUtils=function(t){this.bO=t;};zhomK2Manager.prototype.setIcoDir=function(t){this.bF=t;};zhomK2Manager.prototype.enableFitBounds=function(){this.cz=true;};zhomK2Manager.prototype.setMarkerSpinner=function(t){this.cK=t;};zhomK2Manager.prototype.setFormSelector=function(t){this.cw=t;};zhomK2Manager.prototype.setSubmitSelector=function(t){this.cA=t;};zhomK2Manager.prototype.setResetSelector=function(t){this.dz=t;};zhomK2Manager.prototype.setResultSelector=function(t){this.dA=t;};zhomK2Manager.prototype.setAjaxForm=function(t){this.cC=t;};zhomK2Manager.prototype.enableClusterer=function(t){this.cO=true;this.cu=t;};zhomK2Manager.prototype.setRequestURL=function(t){this.bV=t;};zhomK2Manager.prototype.setArticleID=function(t){this.hY=t;};zhomK2Manager.prototype.setPlacemarkTitleTag=function(t){this.fq=t;};zhomK2Manager.prototype.setPlacemarkCreationInfo=function(t){this.fC=t;};zhomK2Manager.prototype.setPopupStyle=function(t){this.cb=t;};zhomK2Manager.prototype.setPopupTemplate=function(t){this.df=t;};zhomK2Manager.prototype.setMapLanguageTag=function(t){this.hm=t;};zhomK2Manager.prototype.as=function(am){var mw=this;am.zhomPlacemarkConfigLoaded=0;am.on('click',function(event){var bw=mw.bV+'index.php?option=com_zhosmmap&no_html=1&format=raw&task=getK2PlacemarkDetails';var av={id:this.zhomPlacemarkID,detaillink:this.zhomPlacemarkLink,iconicon:mw.bB,iconutil:mw.bO,icondir:mw.bF,articleid:mw.hY,placemarktitletag:mw.fq,language:mw.hm,showcreateinfo:mw.fC,tabid:mw.cb,item_template:mw.df,markerspinner:mw.cK,actionbyclick:this.zhomActionByClick,zoombyclick:this.zhomPlacemark_zoombyclick,placemark_date_format:mw.kJ,marker_extra_1:this.marker_extra_1,marker_extra_2:this.marker_extra_2,marker_extra_3:this.marker_extra_3};if(this.zhomPlacemarkConfigLoaded!=0){setTimeout(function f(){mw.hF(mw,am);},5);}else{var ae=mw.aj;ae.ajax({url:bw,type:'post',data:av,dataType:'json',async:true,success:function(responseText){var H=document.getElementById("OMapsLoading"+mw.hY);H.style.display='none';var bc=responseText;mw.aq(mw,bc,am);},beforeSend:function(){var H=document.getElementById("OMapsLoading"+mw.hY);H.style.display='block';},fail:function(xhr,textStatus){var H=document.getElementById("OMapsLoading"+mw.hY);H.style.display='none';alert("Error"+textStatus);}});}});};zhomK2Manager.prototype.hF=function(l,bD){var mw=l;var ak=mw.map;var aR=parseInt(bD.zhomPlacemark_actionbyclick);var bM=parseInt(bD.zhomPlacemark_zoombyclick);if(aR==0){if(bM!=100){ak.setView(bD.getLatLng(),bM);}}else if(aR==1){if(bM!=100){ak.setView(bD.getLatLng(),bM);}var ha=bD.zhomPlacemark_contentstring;var aC=bD.zhomPlacemark_contentstyle;bD.openPopup();}else if(aR==2){if(bM!=100){ak.setView(bD.getLatLng(),bM);}var cI=bD.zhomPlacemark_sitelocation;window.open(cI);}else if(aR==3){if(bM!=100){ak.setView(bD.getLatLng(),bM);}var cI=bD.zhomPlacemark_sitelocation;window.location=cI;}else{alert("Unexpected action by click: "+aR);}};zhomK2Manager.prototype.aq=function(l,v,bD){if(v.dataexists==1){var mw=l;var ak=mw.map;var aR=v.actionbyclick;var bM=v.zoombyclick;bD.zhomPlacemark_actionbyclick=aR;bD.zhomPlacemark_zoombyclick=bM;var cI=v.hrefsite;bD.zhomPlacemark_sitelocation=cI;if(aR==0){if(bM!=100){ak.setView(bD.getLatLng(),bM);}}else if(aR==1){if(bM!=100){ak.setView(bD.getLatLng(),bM);}var ha=eval(v.contentstring);var aC="";if(v.contentstyle!=""){aC=eval("("+v.contentstyle+")");}bD.zhomPlacemark_contentstring=ha;bD.zhomPlacemark_titleplacemark=v.titleplacemark;if(aC!=""){bD.zhomPlacemark_contentstyle=aC;bD.bindPopup(L.popup(aC).setContent(ha));}else{bD.bindPopup(ha);}bD.openPopup();}else if(aR==2){if(bM!=100){ak.setView(bD.getLatLng(),bM);}var cI=v.hrefsite;bD.zhomPlacemark_sitelocation=cI;window.open(cI);}else if(aR==3){if(bM!=100){ak.setView(bD.getLatLng(),bM);}var cI=v.hrefsite;bD.zhomPlacemark_sitelocation=cI;window.location=cI;}else{alert("Unexpected action by click: "+aR);}bD.zhomPlacemarkConfigLoaded=1;}else{}}; 