jQuery.cookie=function(_1,_2,_3){
if(typeof _2!="undefined"){
_3=_3||{};
if(_2===null){
_2="";
_3.expires=-1;
}
var _4="";
if(_3.expires&&(typeof _3.expires=="number"||_3.expires.toUTCString)){
var _5;
if(typeof _3.expires=="number"){
_5=new Date();
_5.setTime(_5.getTime()+(_3.expires*24*60*60*1000));
}else{
_5=_3.expires;
}
_4="; expires="+_5.toUTCString();
}
var _6=_3.path?"; path="+(_3.path):"";
var _7=_3.domain?"; domain="+(_3.domain):"";
var _8=_3.secure?"; secure":"";
document.cookie=[_1,"=",encodeURIComponent(_2),_4,_6,_7,_8].join("");
}else{
var _9=null;
if(document.cookie&&document.cookie!=""){
var _a=document.cookie.split(";");
for(var i=0;i<_a.length;i++){
var _c=jQuery.trim(_a[i]);
if(_c.substring(0,_1.length+1)==(_1+"=")){
_9=decodeURIComponent(_c.substring(_1.length+1));
break;
}
}
}
return _9;
}
};
(function($){
var _e,t;
function show(){
clearInterval(t);
_e.stop().hide();
if(this.value){
return;
}
var o=$(this).offset();
_e.css({left:o.left,top:o.top+this.offsetHeight});
_e.text(this.fieldTip.title).show();
t=setInterval($.fieldTipHide,this.fieldTip.lifeTime);
}
function watch(){
if(this.value){
$.fieldTipHide();
}else{
show.call(this);
}
}
$.fieldTipHide=function(){
clearInterval(t);
_e.hide();
};
$.fn.fieldTip=function(opt){
opt=$.extend({className:"fieldTip"},opt);
if(!_e){
_e=$("<div>").addClass(opt.className).css({position:"absolute",zIndex:1}).hide().appendTo(document.body);
}
this.each(function(){
if(this.title){
this.fieldTip=$.extend({title:this.title,lifeTime:1000+this.title.length*80},opt);
$(this).removeAttr("title").bind("focus.fieldTip",show).bind("blur.fieldTip",$.fieldTipHide).bind("keyup.fieldTip",watch);
}
});
return this;
};
})(jQuery);
(function($){
var $el,t;
$.fn.showWarning=function(_15,opt){
opt=$.extend({className:"warningTip"},opt);
if(!$el){
$el=$("<div>").addClass(opt.className).css({position:"absolute",zIndex:2}).hide().appendTo(document.body);
}
this.eq(0).each(function(){
var o=$(this).offset(),lf=2000+_15.length*50;
$el.css({left:o.left,top:o.top+this.offsetHeight});
$el.text(_15).show();
clearInterval(t);
t=setInterval(function(){
clearInterval(t);
$el.hide();
},lf);
});
return this;
};
})(jQuery);
(function($){
$.fn.hilite=function(opt){
var $T=this,t,i=0;
opt=$.extend({cssClass:"hilite",pattern:"e1a1a1a1",unit:180},opt);
opt.pattern=opt.pattern.toUpperCase();
function step(){
clearInterval(t);
if(i==opt.pattern.length){
$T.removeClass(opt.cssClass);
$T=opt=null;
return;
}
var c=opt.pattern.charCodeAt(i++);
if(c<65){
$T.not("."+opt.cssClass).addClass(opt.cssClass);
}else{
$T.filter("."+opt.cssClass).removeClass(opt.cssClass);
}
t=setInterval(step,opt.unit*(c<65?c-48:c-64));
}
t=setInterval(step,1);
return this;
};
})(jQuery);
(function($){
$.delay=function(fn,ms,_22){
var t=setInterval(function(){
clearInterval(t);
fn.apply(_22);
},ms);
};
})(jQuery);
(function($){
var _25,_26,_27,_28,_29,_2a,_2b,_2c,_2d=false,_2e,_2f,_30,$dt,dt,_33,$dd,$dl;
function dtUp(){
_28=false;
}
function dtDown(e){
_26=e.clientX;
_27=e.clientY;
dt=this;
_33=Math.floor(dt.offsetHeight/2);
$dt=$(dt);
$dd=$dt.nextAll("dd:first");
$dl=$(dt.parentNode);
var pos=$dt.offset();
_29=pos.left;
_2a=e.clientY-pos.top;
_2d=false;
_28=true;
var w=$dt.width()-(0|parseInt($dt.css("paddingLeft")))-(0|parseInt($dt.css("paddingRight"))),h=$dt.height();
_30=$dt.clone().css(pos).css({width:w,height:h,position:"absolute",display:"none"}).appendTo(document.body);
$(document.body).bind("mousemove.resortable",function(e){
if(!_2d&&_28&&Math.pow(_26-e.clientX,2)+Math.pow(_27-e.clientY,2)>=4){
_2d=true;
_30.show();
_2e.css($dt.offset()).css({width:dt.offsetWidth-2,height:dt.offsetHeight-2}).show();
var $ps=$dt.prev(),$ns=$dt.next();
_2c=$ns.length?$ns.offset().top:3000;
_2b=$ps.length?$ps.offset().top:-3000;
$dt.css({visibility:"hidden"});
$(document.body).bind("mouseup.resortable",documentUp);
for(var i=0,it=$dl[0].firstChild;it;it=it.nextSibling){
if(it.nodeName=="DT"){
it.resortableOrd=i++;
}
}
}else{
if(_2d&&_28){
var _3f=e.clientY-_2a;
_30[0].style.top=_3f+"px";
if(_3f>_2c||_3f<_2b){
var $ps,$ns;
if(_3f>_2c){
$ns=$dt.next();
if($ns.length){
dt.parentNode.removeChild(dt);
$dl[0].insertBefore(dt,$ns[0].nextSibling);
}
}else{
$ps=$dt.prev();
if($ps.length){
dt.parentNode.removeChild(dt);
$dl[0].insertBefore(dt,$ps[0]);
}
}
_2e.css($dt.offset());
$ns=$dt.next();
$ps=$dt.prev();
_2c=$ns.length?$ns.offset().top:3000;
_2b=$ps.length?$ps.offset().top:-3000;
}
}
}
return false;
});
return false;
}
function documentUp(){
if(_2d){
if(_2e.is(":visible")){
for(var i=0,it=$dl[0].firstChild;it;it=it.nextSibling){
if(it.nodeName=="DT"&&it.resortableOrd!=i++){
$dl.trigger("resorted");
break;
}
}
}
}
_28=_2d=false;
$(document.body).unbind("mousemove.resortable").unbind("mouseup.resortable");
_30.stop().animate($dt.offset(),100,null,function(){
_30.remove();
_2e.hide();
$dt.css({visibility:""});
_25=$dl=$dt=$dd=null;
});
}
$.fn.resortable=function(opt){
opt=$.extend({cssClass:"resortable"},opt);
if(!_2e){
_2e=$("<div>").css({position:"absolute",display:"none",padding:0,margin:0,border:"dashed 1px #c0c0c0"}).appendTo(document.body);
}
_2f=_2e[0];
this.each(function(){
$(this).children("dt:not(."+opt.cssClass+")").addClass(opt.cssClass).bind("mousedown.resortable",dtDown).bind("mouseup.resortable",dtUp);
});
return this;
};
})(jQuery);
(function($){
var _44,msw,gap,dpp,_48;
function getLabel(ga){
var res="";
if(ga&&ga._street){
res+=ga._street+(ga._house_no?" "+ga._house_no:"");
}
if(ga&&ga._city){
res+=(res?", ":"")+ga._city;
}
if(res==""&&ga){
res="("+ga.pt.x+", "+ga.pt.y+")";
}
return res;
}
function getDPoint(str){
str=str.replace(/\s/g,"");
if(str.substr(0,1)=="("&&str.substr(-1)==")"){
str=str.substr(1,str.length-2);
}
if(/^\d{1,3}\.\d{3,},\d{1,3}\.\d{3,}$/.test(str)){
var c=str.split(",");
return new dpp(parseFloat(c[0]),parseFloat(c[1]));
}else{
return null;
}
}
function isChar(c){
return (c>=32&&c<35||c>40||c==8);
}
function hideList(){
_44.filter(":visible").fadeOut("normal",function(){
_44.empty();
});
}
function showList(t){
var of=$(t).offset();
_44.css({left:of.left,top:of.top+t.offsetHeight}).fadeIn("fast");
_44.input=t;
t.srch=t.value;
t.focus();
}
function getGeoAddress(){
var T=this;
if(!this.GA){
var pt=getDPoint(this.value);
if(pt){
var ga=new gap();
ga.pt=pt;
T.setGeoAddress(ga,true);
$(T).trigger("submit");
return;
}
msw.Search(this.value,function(res){
if(res.length==0){
$(T).showWarning(HAK.resx.msg7);
return;
}
if(res.length==1){
T.setGeoAddress(res[0],true);
$(T).trigger("submit");
return;
}
_44.filter(":visible").empty();
for(var i=0;i<res.length;i++){
var $li=$("<li>").append(getLabel(res[i]));
$li[0].GA=res[i];
_44.append($li);
$li.mouseover(hoverList).mouseout(unHoverList).click(function(){
T.setGeoAddress(this.GA,true);
T.focus();
});
}
showList(T);
});
return null;
}else{
return this.GA;
}
}
function setGeoAddress(ga,tg){
tg=(false||tg)&&(this.GA!=ga);
this.GA=ga;
this.value=getLabel(ga);
hideList();
if(tg){
$(this).trigger("gaChanged");
}
}
function resetGA(t,tg){
tg=(false||tg)&&(t.GA!=null);
t.GA=null;
if(tg){
$(t).trigger("gaChanged");
}
}
function keypress(e){
if(!_44.is(":visible")){
if(e.which==13){
$(this).trigger("submit");
}else{
if(this.srch!=this.value&&this.GA){
resetGA(this,true);
}
}
}else{
var $li;
switch(e.which){
case 38:
$li=_44.find("li.hover").removeClass("hover").prevAll(":visible:first");
if($li.length==0){
$li=_44.find("li:visible:last");
}
break;
case 40:
$li=_44.find("li.hover").removeClass("hover").nextAll(":visible:first");
if($li.length==0){
$li=_44.find("li:visible:first");
}
break;
case 27:
hideList();
break;
case 13:
case 9:
e.preventDefault();
var $li=_44.find("li.hover");
if($li.length!=0){
this.setGeoAddress($li[0].GA,true);
}
break;
default:
var s=(new String(this.value)).toLowerCase();
_44.find("li").show().filter(function(){
return this.innerHTML.toLowerCase().indexOf(s)==-1;
}).hide();
var sub=_44.find("li:visible:first");
if(sub.length==0||s.length<this.srch.length){
hideList();
resetGA(this,true);
}else{
sub.addClass("hover").siblings().removeClass("hover");
}
}
if($li){
$li.addClass("hover");
}
}
}
function hoverList(){
$(this).addClass("hover").siblings().removeClass("hover");
}
function unHoverList(){
$(this).removeClass("hover");
}
$.fn.geoAddressInput=function(_5e,_5f,_60){
if(!_44){
_44=$("<ul>").addClass("dropdown").hide().css({position:"absolute",zIndex:1}).appendTo(document.body);
}
msw=_5e||msw;
gap=_5f||gap;
dpp=_60||dpp;
this.blur(hideList).keyup(keypress).each(function(){
this.getGeoAddress=getGeoAddress;
this.setGeoAddress=setGeoAddress;
this.GA=null;
});
return this;
};
})(jQuery);
(function(){
var _61=16,_62=16,_63=16,_64=80,_65=5,_66=6,_67=6,_68=4,map,_6a,_6b,_6c,_6d=null,_6e={},_6f=null,_70=null,_71=21,_72,_73,_74,_75=2,_76=3,_77=3,_78=250,_79=HAK.resx,_7a=["blnToHere","blnFromHere","blnNearby"],_7b=["blnAddDestination","blnNearby"],_7c=0,_7d=0,_7e={};
poiCacheLength=function(){
var i=0,p;
for(p in _6e){
i++;
}
return i;
};
var _81={blnClose:_79.blnClose,blnToHere:_79.blnToHere,blnFromHere:_79.blnFromHere,blnAddDestination:_79.blnAddDestination,blnNearby:_79.blnNearby,blnMore:_79.blnMore,blnLess:_79.blnLess};
var _82=false;
function resize(){
var _83=$(window).height(),_84=$(window).width(),_85=document.getElementById("topbar").offsetHeight,_86=document.getElementById("bottombar").offsetHeight,_87=document.getElementById("leftbar").offsetWidth,_88=_83-14-_85-10-10-_86-10,_89=_84-15-190-8-15;
$("#bottombar").width(_84-15-15);
$("#leftbar").height(_88);
$("#main").height(_88-12).width(_89-12);
$("#topbar").width(_89).find(".form").css("paddingLeft",Math.max(100,Math.floor(_89/2)-280));
if(map){
$("#iframe").width(_89-12).height(_88-12);
map.OP();
}
$("#mask, #maskedContent").width(_84).height(_83);
}
function init(){
$.ajaxSetup({async:true,cache:false,error:function(r,s,t){
_82=false;
alert((s?s:"")+"\n"+(t?t:""));
},timeout:15000,type:"POST",url:"PoiServer.asmx"});
$(document.body).removeClass("loading");
$("form > .hidden").show();
if($.browser.mozilla){
$(window).resize(function(){
resize();
resize();
});
}else{
$(window).resize(resize);
}
$(window).trigger("resize");
$("form").submit(function(e){
e.preventDefault();
});
$("#topbar .form li").click(function(){
var a=this.id.split(":")[1],b="",b1=$("#topbar > .active");
if(b1.length){
b=b1[0].id.split(":")[1];
}
_72=a;
if(a==b){
return;
}
$("#topbar .active").removeClass("active");
$("#leftbar > .active").removeClass("active");
$("#topbar ."+a).addClass("active");
$("#leftbar > ."+a).addClass("active");
$(this).addClass("active");
if(a=="atlas"&&$("#leftbar .atlas :checkbox").is(":checked")&&_6f!="atlas"){
$("#categories").trigger("changedView");
}
if(a=="poi"&&_6f!="poi"&&$("#txtWhat").val()){
cleanPoiCache();
_6f="poi";
$("#poi li").hide();
}
});
$("#topbar .form input").bind("dblclick",function(){
this.select();
}).filter(".geoAddress").bind("submit",function(){
$(this).parent().eq(0).next("button").trigger("click");
}).end().not(".geoAddress").keypress(function(e){
if(e.which==13){
$(this).parent().eq(0).next("button").trigger("click");
}
});
$("#txtWhere").bind("gaChanged",function(){
var ga=this.GA;
if(ga){
if(ga.rc.x1){
map.setBounds(ga.rc);
}else{
map.setCenterAndZoom(ga.pt,_76);
}
$(this).trigger("submit");
}
});
$("#topbar button").bind("click",function(){
switch(this.id){
case "btnAtlas":
(function(_93){
var ga=_93.getGeoAddress();
if(ga){
if(ga.rc.x1){
map.setBounds(ga.rc);
if(isMajor(ga)){
return;
}else{
_6b.Ov(ga);
}
}else{
map.setCenterAndZoom(ga.pt,_75);
}
showBalloon(ga);
}
})(document.getElementById("txtAtlas"));
break;
case "btnPoi":
(function(_95,_96){
var ga=_96.getGeoAddress(),_98=$("#poi li");
if(ga||_96.value==""){
if(_95.value==""){
$(_95).showWarning(HAK.resx.msg1);
}
if(ga){
if(ga.rc.x1){
map.setBounds(ga.rc);
}else{
map.setCenterAndZoom(ga.pt,_76);
}
}
var b=map.getBounds();
var rq="naziv="+_95.value+"&x1="+b.x1+"&y1="+b.y2+"&x2="+b.x2+"&y2="+b.y1;
$.ajax({url:location.href.toLowerCase().indexOf("localhost")==-1?"/Umbraco/WebServices/PoiServer.asmx/SelectPoiByNaziv":"PoiServer.asmx/SelectPoiByNaziv",data:rq,success:function(_9b){
var i=0,p;
cleanPoiCache();
_6f="poi";
var _9e=false;
$("PoiMin",_9b).each(function(){
_9e=true;
var $li=_98.eq(i++);
if($li.length==0){
return;
}
var poi=new PoiMin(this),pt=new MAP.DPoint(poi.WGS_x,poi.WGS_y),_a2=new MAP.MapMarker($li[0].mapIcon,pt,poi.naziv);
poi.marker=_a2;
_a2.id_poi=poi.id_poi;
_6e[poi.id_poi]=poi;
map.addMapMarker(_a2);
$li[0].id_poi=poi.id_poi;
$li.find("h4").text(poi.naziv).end().find("p").text(poi.adresa+(poi.naselje?", "+poi.naselje:"")).end().find("em").each(function(){
if(poi.more&&poi.fk_kategorija!=_71){
$(this).text(_79.lbl1).attr("title",_79.lbl1title).show().click(function(e){
e.stopPropagation();
_6d=poi.toGeoAddress();
$(_6a).trigger("blnMore",[poi]);
});
}else{
$(this).empty().hide();
}
}).end().show();
});
if(!_9e){
$(_95).showWarning(_79.msg7);
}
_98.filter(":gt("+(i-1)+")").hide();
}});
}
})(document.getElementById("txtWhat"),document.getElementById("txtWhere"));
break;
case "btnRouter":
(function(_a4,to){
var ga1=_a4.getGeoAddress();
if(!ga1){
_a4.focus();
return;
}
var ga2=to.getGeoAddress();
if(!ga2){
to.focus();
return;
}
_6c.clear(true);
(new RouterPoint(ga1,_6c)).append();
(new RouterPoint(ga2,_6c)).append();
$("#btnRouteCalculate").trigger("click");
})(document.getElementById("txtFrom"),document.getElementById("txtTo"));
break;
}
});
var _a8=false;
$("#categories").bind("changedView",function(){
if(_a8){
return;
}
_a8=true;
var _a9=[],b=map.getBounds(),rq;
$("#categories li.selected").each(function(){
_a9.push(this.id.substr(3));
});
if(_a9.length==0){
_a8=false;
cleanPoiCache();
return;
}
rq="categories="+_a9.join(",")+"&x1="+b.x1+"&y1="+b.y2+"&x2="+b.x2+"&y2="+b.y1;
$.ajax({url:location.href.toLowerCase().indexOf("localhost")==-1?"/Umbraco/WebServices/PoiServer.asmx/SelectPoiRect":"PoiServer.asmx/SelectPoiRect",data:rq,error:function(){
_a8=false;
},success:function(_ac){
var c=0,p;
if(_6f!="atlas"){
cleanPoiCache();
_6f="atlas";
}
for(p in _6e){
_6e[p].mark=true;
}
$("PoiMin",_ac).each(function(){
++c;
if(c>_64){
return false;
}
var poi=new PoiMin(this),n;
poi.mark=false;
if(poi.id_poi in _6e){
_6e[poi.id_poi].mark=false;
}else{
_6e[poi.id_poi]=poi;
poi.marker=new MAP.MapMarker($("#cat"+poi.fk_kategorija)[0].mapIcon,new MAP.DPoint(poi.WGS_x,poi.WGS_y),poi.naziv);
map.addMapMarker(poi.marker);
poi.marker.id_poi=poi.id_poi;
}
});
cleanPoiCache(true);
if(c>_64){
if(_7d<2){
$("#btnRefreshPoi").showWarning(_79.msg4);
++_7d;
}else{
$("#btnRefreshPoi").showWarning(_79.msg5);
}
}
if(HAK.oldMaxPoiZoom){
_66=HAK.oldMaxPoiZoom;
HAK.oldMaxPoiZoom=0;
$("#leftbar div.atlas:visible:not(.disabled)").fadeTo(1,0.3).addClass("disabled").find("li").addClass("disabled").end().find("button").addClass("disabled").end().find(":checkbox").addClass("disabled");
}
_a8=false;
}});
});
$("#menuRouter li").click(function(){
switch(this.id){
case "router:calculate":
$("#btnRouteCalculate").trigger("click");
break;
case "router:reverse":
_6c.reverse();
break;
case "router:eraseAll":
_6c.clear();
break;
}
});
$("#topbar input").fieldTip();
}
function loadMap(){
var _b1=$("<iframe id=\"iframe\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" src=\"mireomap.html\"></iframe>");
_b1.width($("#main").width()).height($("#main").height());
$("#main").append(_b1);
}
HAK.startMap=function(d){
_6a=d;
map=MAP.CK=MAP.map=new MAP.MireoMap(d);
if(!HAK.showLayer){
var loc=new MAP.DPoint(15.999923944473267,45.777505896427286);
map.setCenterAndZoom(loc,5);
var hak=new Image();
hak.src="css/hak_logo_karta.gif";
var ico=new MAP.MapIcon(hak.src,new MAP.Size(100,43),new MAP.Point(0,0));
var _b6=new MAP.MapMarker(ico,loc,"HRVATSKI AUTOKLUB");
_b6.id="hak";
map.addMapMarker(_b6);
}else{
map.setBounds(new MAP.DRect(13.095703125,46.619261036171515,19.44580078125,42.22851735620852));
}
var _b7=new Image();
_b7.src="css/map/pinsh.png";
var t;
map.click=function(pt,_ba){
var _bb=!(!window.opera&&!(navigator.vendor&&navigator.vendor.indexOf("Apple")>-1)&&MAP.event&&MAP.event.button!=2);
clearInterval(t);
t=setInterval(function(){
clearInterval(t);
$(d).trigger("gaClick",[pt,_ba,_bb]);
},_78);
};
map.dblclick=function(pt){
clearInterval(t);
$(d).trigger("gaDblclick",[pt]);
};
var _bd=$("#menu",MAP.doc),_be,t,w,h,fw=$("#main").width()-30,fh=$("#main").height()-30;
function showMenu(){
if(_6c.length<2){
_bd.find("#addStart, #addEnd").show().end().find("#addNewEnd").hide();
}else{
_bd.find("#addStart, #addEnd").hide().end().find("#addNewEnd").show();
}
_bd.show().css("visibility","hidden");
w=_bd[0].offsetWidth;
h=_bd[0].offsetHeight;
var x=_73>=fw-w?_73-w-1:_73+1,y=_74>=fh-h?_74-h-1:_74+1;
_bd.css({visibility:"visible"}).hide();
_bd.css({left:x,top:y}).show();
$(document.body).bind("mouseup.temp",function(e){
hideMenu(true);
});
}
function hideMenu(o){
clearInterval(t);
if(o){
_bd.hide();
$(document.body).unbind("mouseup.temp");
}else{
t=setInterval(function(){
hideMenu(true);
},2000);
}
}
_bd.hover(function(){
clearInterval(t);
},function(){
hideMenu();
});
_bd.find("li").click(function(){
hideMenu(true);
switch(this.id){
case "addStart":
(function(){
var ga=new MAP.GeoAddress();
ga.pt=_be;
(new RouterPoint(ga,_6c)).prepend();
if(_6c.length==1){
$("#txtFrom")[0].setGeoAddress(_6c.points[0].GA,false);
}else{
if(_6c.length==2){
$("#txtFrom")[0].setGeoAddress(_6c.points[0].GA,false);
$("#txtTo")[0].setGeoAddress(_6c.points[1].GA,false);
}
}
})();
break;
case "addEnd":
case "addNewEnd":
(function(){
var ga=new MAP.GeoAddress();
ga.pt=_be;
(new RouterPoint(ga,_6c)).append();
if(_6c.length==1){
$("#txtTo")[0].setGeoAddress(_6c.points[0].GA,false);
}else{
if(_6c.length==2){
$("#txtFrom")[0].setGeoAddress(_6c.points[0].GA,false);
$("#txtTo")[0].setGeoAddress(_6c.points[1].GA,false);
}
}
})();
break;
case "nearby":
map.setCenterAndZoom(_be,_77);
var ga=new MAP.GeoAddress();
ga.pt=_be;
$("#txtWhere")[0].setGeoAddress(ga,false);
$("#topbar .form li[id='show:poi']").trigger("click");
if($("#txtWhat").val()){
$("#txtWhere").trigger("submit");
}else{
$("#txtWhat").hilite()[0].focus();
}
break;
case "info":
(function(){
var ga=new MAP.GeoAddress();
ga.pt=_be;
showBalloon(ga);
})();
break;
case "zoomIn":
map.setCenterAndZoom(_be,Math.max(map.getZoomLevel()-1,0));
break;
case "zoomOut":
map.setCenterAndZoom(_be,Math.min(map.getZoomLevel()+1,11));
break;
case "center":
map.moveCenterTo(_be,true);
break;
}
});
$(d).bind("gaClick",function(e,pt,_cd,_ce){
if(_cd&&_cd.id_poi!=null){
hideMenu(true);
showBalloon(_6e[_cd.id_poi],_cd);
}else{
if(_bd.is(":visible")){
hideMenu(true);
}else{
if(_ce){
showMenu();
_be=pt;
hideMenu();
}
}
}
});
$(d).bind("gaDblclick",function(e,pt){
hideMenu(true);
MAP.map.moveCenterTo(pt,true);
$(_6a).bind("areaChanged.temp",function(e){
$(_6a).unbind("areaChanged.temp");
MAP.MapSearchWeb.FindClosestStreet(pt,function(ga){
showBalloon(ga);
});
});
});
$(d).bind("mouseup",function(e){
_73=e.clientX;
_74=e.clientY;
});
$("#topbar .geoAddress").geoAddressInput(MAP.MapSearchWeb,MAP.GeoAddress,MAP.DPoint);
function setGa(obj,ga,val){
obj.GA=ga;
obj.value=val;
}
$("#txtAtlas").bind("gaChanged",function(e){
if(this.GA){
setGa($("#txtWhere")[0],this.GA,this.value);
}
});
$("#txtWhere").bind("gaChanged",function(e){
if(this.GA){
setGa($("#txtAtlas")[0],this.GA,this.value);
}
});
$("#txtFrom, #txtTo").bind("gaChanged",function(e){
if(this.GA){
setGa($("#txtAtlas")[0],this.GA,this.value);
setGa($("#txtWhere")[0],this.GA,this.value);
}
});
var _da=false,_db,lb;
setInterval(function(){
var z=map.getZoomLevel();
if(d.zoomLevel!=z){
d.zoomLevel=z;
$(d).trigger("zoomChanged");
}
var b=map.getBounds();
if(!lb){
lb=b;
$(d).trigger("areaChanged");
}else{
if(lb.x1!=b.x1||lb.y1!=b.y1||lb.x2!=b.x2||lb.y2!=b.y2){
lb=b;
_da=true;
_db=_68;
}else{
if(_da&&--_db==0){
$(d).trigger("areaChanged");
_da=false;
}
}
}
},250);
$(d).bind("zoomChanged",function(){
if(d.zoomLevel<=_66){
$("#leftbar div.atlas.disabled:visible").fadeTo(1,1).removeClass("disabled").find("li").removeClass("disabled").end().find("button").removeClass("disabled").end().find(":checkbox").removeClass("disabled");
if(_66==100){
$("#cat"+HAK.showLayer).click();
}
}else{
$("#leftbar div.atlas:visible:not(.disabled)").fadeTo(1,0.3).addClass("disabled").find("li").addClass("disabled").end().find("button").addClass("disabled").end().find(":checkbox").addClass("disabled");
}
}).bind("areaChanged",function(){
if($("#chkAutoPoi").is(":checked:not(.disabled)")&&$("#topbar .form li.active")[0].id=="show:atlas"){
$("#btnRefreshPoi").trigger("click");
}
});
_6b=new MAP.GeoAddressDrawer(224,236,0,140,5);
map.addOverMapDrawer(_6b);
$("#topbar .form li:eq(0)").trigger("click");
var _df=new MAP.RouteDrawer(160,0,0,255,5,0,0,255);
map.addOverMapDrawer(_df);
_6c=new Router($("#router"),_df);
$("#routerList:visible").hide();
$("#btnRouteCalculate").click(function(){
_6c.calculate();
});
_6c.$list.bind("routeChanged",function(e){
_6c.dirty=true;
_6c.drawer.setRoute();
});
$(_6a).bind("blnNearby",function(){
map.setCenterAndZoom(_6d.pt,_77);
$("#txtWhere")[0].setGeoAddress(_6d,false);
$("#topbar .form li[id='show:poi']").trigger("click");
if($("#txtWhat").val()){
$("#txtWhere").trigger("submit");
}else{
$("#txtWhat").hilite()[0].focus();
}
}).bind("blnMore",function(e,poi){
$.ajax({url:location.href.toLowerCase().indexOf("localhost")==-1?"/Umbraco/WebServices/PoiServer.asmx/GetPoiDetails":"PoiServer.asmx/GetPoiDetails",data:"id_poi="+poi.id_poi,cache:true,success:function(_e3){
var p=new Poi(_e3);
p.marker=poi.marker;
showBalloon(p,p.marker);
}});
}).bind("blnLess",function(e,poi){
if(poi.id_poi in _6e){
showBalloon(_6e[poi.id_poi],poi.marker);
}
}).bind("blnToHere",function(e,poi){
(new RouterPoint(poi,_6c)).append();
if(_6c.length==1){
$("#txtTo")[0].setGeoAddress(_6c.points[0].GA,false);
}else{
if(_6c.length==2){
$("#txtFrom")[0].setGeoAddress(_6c.points[0].GA,false);
$("#txtTo")[0].setGeoAddress(_6c.points[1].GA,false);
}
}
}).bind("blnFromHere",function(e,poi){
(new RouterPoint(poi,_6c)).prepend();
if(_6c.length==1){
$("#txtFrom")[0].setGeoAddress(_6c.points[0].GA,false);
}else{
if(_6c.length==2){
$("#txtFrom")[0].setGeoAddress(_6c.points[0].GA,false);
$("#txtTo")[0].setGeoAddress(_6c.points[1].GA,false);
}
}
}).bind("blnAddDestination",function(e,poi){
(new RouterPoint(poi,_6c)).append();
});
$.ajax({url:location.href.toLowerCase().indexOf("localhost")==-1?"/Umbraco/WebServices/PoiServer.asmx/SelectKategorija":"PoiServer.asmx/SelectKategorija",data:"",success:function(_ed){
var _ee=$("#categories"),i=1;
$("Kategorija",_ed).each(function(){
var id=$("id_kategorija",this).text(),_f1=$("naziv",this).text();
_7e[id]=i;
var $li=$("<li id=\"cat"+id+"\">"+_f1+"</li>").attr("ord",i++).appendTo(_ee);
});
_ee.find("li").each(function(){
var i=$(this).attr("ord");
this.mapIcon=new MAP.MapIcon("PinFactory.aspx?l="+i+"&n="+i+"&f=1",new MAP.Size(25,31),new MAP.Point(1,30),"css/map/pinsh.png",new MAP.Size(46,26),new MAP.Point(2,23));
}).mouseover(function(){
$(this).not(".disabled").toggleClass("hover");
}).mouseout(function(){
$(this).not(".disabled").toggleClass("hover");
}).click(function(){
var $t=$(this),n=$t.attr("ord");
if($t.hasClass("disabled")){
$t.showWarning(_79.msg3);
}else{
$t.toggleClass("selected").filter(".selected").css("listStyleImage","url(PinFactory.aspx?l="+n+"&n="+n+")").end().not(".selected").css("listStyleImage","");
if(_7c<1&&$("li.selected",_ee).length==_65&&$t.hasClass("selected")){
$t.showWarning(_79.msg2);
++_7c;
}
$("#btnRefreshPoi").trigger("click");
}
});
$("#btnRefreshPoi").click(function(e){
if(!MAP){
return;
}
var $t=$(this);
if($t.hasClass("disabled")){
$t.showWarning(_79.msg3);
e.preventDefault();
return;
}
$("#categories").trigger("changedView");
});
$("#leftbar .atlas :checkbox").click(function(e){
var $t=$(this);
if($t.hasClass("disabled")){
$t.showWarning(_79.msg3);
e.preventDefault();
return;
}
if($t.is(":checked")){
$("#categories").trigger("changedView");
}
});
if(HAK.showLayer){
HAK.oldMaxPoiZoom=_66;
_66=100;
$(_6a).trigger("zoomChanged");
}
}});
var i,_fb=$("#poi"),_fc=$("<li><em></em><h4></h4><p></p></li>").hide();
_fb.empty();
for(i=1;i<=_63;i++){
_fc.clone().css("listStyleImage","url(PinFactory.aspx?l="+i+"&n=0)").appendTo(_fb);
}
i=0;
_fb.find("li").each(function(){
this.mapIcon=new MAP.MapIcon("PinFactory.aspx?l="+(++i)+"&n=1&f=1",new MAP.Size(25,31),new MAP.Point(1,30),"css/map/pinsh.png",new MAP.Size(46,26),new MAP.Point(2,23));
}).click(function(){
$(_6a).trigger("gaClick",[null,_6e[this.id_poi].marker]);
});
if(HAK.searchPoi){
$("#txtWhat").val(HAK.searchPoi);
$("#topbar .form li.showPoi").click();
$("#txtWhere").focus();
}
if(HAK.searchAtlas){
$("#txtAtlas").val(HAK.searchAtlas);
$("#txtWhere").val(HAK.searchAtlas);
if(HAK.searchPoi){
$("#topbar .form li.showPoi").click();
$("#btnPoi").click();
}else{
$("#topbar .form li.showAtlas").click();
$("#btnAtlas").click();
}
}else{
if(HAK.initialTab){
$("#topbar .form ul li").eq(HAK.initialTab).click();
}
}
for(var key in HAK.resx.ctxMenu){
$("#"+key,MAP.doc).text(HAK.resx.ctxMenu[key]);
}
if($.browser.msie){
$("#menu li",MAP.doc).hover(function(){
$(this).addClass("hover");
},function(){
$(this).removeClass("hover");
});
}
if(!HAK.showLayer){
var _fe=setInterval(function(){
clearInterval(_fe);
$(_6a).bind("zoomChanged.temp",function(e){
MAP.map.removeMapMarker(_b6);
$(_6a).unbind("zoomChanged.temp");
});
},15000);
}
};
function showBalloon(obj,_101,btn,_103){
var res="",br="<br />",b,x,y,_109=[];
if(PoiMin.prototype.isPrototypeOf(obj)&&obj.fk_kategorija==_71){
$.ajax({url:location.href.toLowerCase().indexOf("localhost")==-1?"/Umbraco/WebServices/PoiServer.asmx/GetPoiDetails":"PoiServer.asmx/GetPoiDetails",data:"id_poi="+obj.id_poi,cache:true,success:function(data){
var p=new Poi(data);
p.marker=obj.marker;
showBalloon(p,p.marker);
}});
return;
}
if(MAP.GeoAddress.prototype.isPrototypeOf(obj)){
x=obj.pt.x;
y=obj.pt.y;
res="<h2>Adresa:</h2>";
res+="<address>";
if(obj._street){
res+=obj._street+(obj._house_no?" "+obj._house_no:"")+br;
}
if(obj._city){
res+=obj._city+br;
}
if(!isMajor(obj)&&obj._area&&!obj._street){
res+=obj._area+br;
}
if(!(obj._street||obj._city||obj._area)){
res+="("+obj.pt.x+", "+obj.pt.y+")";
}
res+="</address>";
_6d=obj;
}else{
if(PoiMin.prototype.isPrototypeOf(obj)){
x=obj.WGS_x;
y=obj.WGS_y;
res="<h2>"+obj.naziv+"</h2>";
if(obj.slika){
res+="<img title=\"\" alt=\"\" style=\"float: left;\" src=\""+obj.slika+"\" />\"";
}
res+="<address>";
if(obj.adresa){
res+=obj.adresa+br;
}
if(obj.naselje){
res+=obj.naselje+br;
}
if(obj.url){
res+="<a href=\""+obj.url+"\" target=\"_blank\">"+obj.url+"</a>"+br;
}
res+="</address>";
if(obj.lead){
res+="<p>"+obj.lead+"</p>";
}
_6d=obj.toGeoAddress();
if(!btn&&obj.more){
_109.push("blnMore");
}
}else{
if(Poi.prototype.isPrototypeOf(obj)){
x=obj.WGS_x;
y=obj.WGS_y;
res="<h2>"+obj.naziv+"</h2>";
if(obj.opis){
res+="<p>"+obj.opis+"</p>";
}
_6d=obj.toGeoAddress();
if(!btn&&obj.fk_kategorija!=_71){
_109.push("blnLess");
}
}
}
}
if(!btn){
btn=[];
}
if(_6c.length<2){
btn=btn.concat(_7a);
}else{
btn=btn.concat(_7b);
}
btn=btn.concat(_109);
b="<ul id=\"buttons\">";
for(var i=0;i<btn.length;i++){
b+="<li class=\""+btn[i]+"\">"+_81[btn[i]]+"</li>";
}
b+="</ul><br />";
res+=b;
res="<div id=\"balloon\">"+res+"</div>";
if(_101){
map.displayInfoWindowOnMarker(_101,res);
_70=_101;
}else{
map.displayInfoWindow(_6d.pt,res);
}
$("#buttons",MAP.doc).ready(function(){
$("#balloon",MAP.doc).parent().eq(0).next().text(_79.blnClose);
$("#buttons li",MAP.doc).bind("click",function(){
var evt=$(this).attr("class");
$("#buttons",MAP.doc).empty();
map.closeInfoWindow();
_70=null;
$(_6a).trigger(evt,[obj]);
});
});
}
function isMajor(ga){
return !!(ga._type&&ga._area&&",capital,major city,large city,town,".indexOf(","+ga._type.toLowerCase()+",")!=-1);
}
function cleanPoiCache(_10f){
var p;
for(p in _6e){
if(!_10f||_10f&&_6e[p].mark){
map.removeMapMarker(_6e[p].marker);
delete _6e[p];
}
}
if(_70&&!_6e[_70.id_poi]){
map.closeInfoWindow();
_70=null;
}
}
function PoiMin(data){
var _112=$(data);
this.id_poi=_112.find("id_poi").text();
this.naziv=_112.find("naziv").text();
this.adresa=_112.find("adresa").text();
this.naselje=_112.find("naselje").text();
this.WGS_x=parseFloat(_112.find("WGS_x").text());
this.WGS_y=parseFloat(_112.find("WGS_y").text());
this.lead=_112.find("lead").text();
this.fk_kategorija=parseInt(_112.find("fk_kategorija").text());
this.more=(_112.find("more").text()+"").toLowerCase()=="true";
this.mark=true;
this.marker=null;
}
PoiMin.prototype.toGeoAddress=function(){
var ga=new MAP.GeoAddress();
ga._city=this.naselje;
ga._street=this.adresa;
ga._POI=this.naziv;
ga.pt=new MAP.DPoint(this.WGS_x,this.WGS_y);
ga.poi=this;
return ga;
};
function Poi(data){
var _115=$(data);
this.id_poi=_115.find("id_poi").text();
this.naziv=_115.find("naziv").text();
this.adresa=_115.find("adresa").text();
this.naselje=_115.find("naselje").text();
this.WGS_x=parseFloat(_115.find("WGS_x").text());
this.WGS_y=parseFloat(_115.find("WGS_y").text());
this.lead=_115.find("lead").text();
this.opis=_115.find("opis").text();
this.fk_kategorija=parseInt(_115.find("fk_kategorija").text());
this.more=_115.find("more").text()=="true";
this.mark=true;
this.marker=null;
}
Poi.prototype.toGeoAddress=PoiMin.prototype.toGeoAddress;
Router=function(list,_117){
this.length=0;
this.points=[];
this.directions=[];
this.$list=$(list);
this.drawer=_117;
this.dirty=false;
var T=this;
this.$list.bind("resorted",function(e){
T.points=[];
$("dt",this).each(function(){
T.points.push(this.routerPoint);
});
if(!this.dirty){
$(this).trigger("routeChanged");
}
});
this.clear=function(_11a){
while(this.length){
this.points[0].remove();
}
this.dirty=false;
if(!_11a){
$("#txtFrom, #txtTo").each(function(){
this.setGeoAddress(null);
});
}
};
this.reverse=function(){
var t=[];
this.points.reverse();
this.$list.empty();
for(var i=0;i<this.points.length;i++){
this.$list.append(this.points[i].$dt);
if(this.points[i].$dd){
this.$list.append(this.points[i].$dd);
}
}
this.$list.find("dt").removeClass("resortable");
this.$list.resortable();
if(!this.dirty){
this.$list.trigger("routeChanged");
}
this.dirty=true;
};
this.calculate=function(){
if(this.dirty&&this.length>1){
var ary=[],i,x1=1000,y1=1000,x2=0,y2=0,pt;
for(i=0;i<this.length;i++){
ary.push(this.points[i].GA);
pt=this.points[i].GA.pt;
if(pt.x<x1){
x1=pt.x;
}
if(pt.x>x2){
x2=pt.x;
}
if(pt.y<y1){
y1=pt.y;
}
if(pt.y>y2){
y2=pt.y;
}
}
var T=this;
MAP.calculate(ary,this.drawer,function(res){
var t=res.time_length<3600?Math.round(res.time_length/60)+" min":Math.floor(res.time_length/3600)+":"+("00"+Math.round((res.time_length%3600)/60)).substr(("00"+Math.round((res.time_length%3600)/60)).length-2,2)+" h";
$("#routeTime").text(t);
$("#routeLength").text((Math.round(res.length/10)/100)+" km");
MAP.map.setBounds(new MAP.DRect(x1,y1,x2,y2));
});
}
this.dirty=false;
};
};
RouterPoint=function(obj,rtr){
this.router=rtr;
this.obj=obj;
if(MAP.GeoAddress.prototype.isPrototypeOf(obj)){
this.GA=obj;
}else{
this.GA=obj.toGeoAddress();
}
this.label="";
if(this.GA._POI){
this.label=this.GA._POI;
}
if(this.GA._street){
this.label+=(this.label?"<br />":"")+this.GA._street+(this.GA._house_no?" "+this.GA._house_no:"");
}
if(this.GA._city){
this.label+=(this.label?"<br />":"")+this.GA._city;
}
if(this.label==""){
this.label="("+this.GA.pt.x+", "+this.GA.pt.y+")";
}
this.marker=new MAP.MapMarker(new MAP.MapIcon("PinFactory.aspx?n=7&f=1",new MAP.Size(25,31),new MAP.Point(1,30),"css/map/pinsh.png",new MAP.Size(46,26),new MAP.Point(2,23)),this.GA.pt,this.label);
this.directions=[];
var s="<dt><span class=\"label\"><span class=\"time\"></span>"+this.label+"</span><ul>"+"<li class=\"remove\">"+_79.lbl3+"</li>"+"<li class=\"show\">"+_79.lbl6+"</li></ul></dt>";
this.$dt=$(s);
this.$dt[0].routerPoint=this;
this.$dd=null;
function bindActions(obj){
$("li",obj.$dt).click(function(){
switch(this.className){
case "remove":
obj.remove();
break;
case "show":
showBalloon(obj.obj);
break;
}
});
$("> span",obj.$dt).click(function(){
showBalloon(obj.obj);
});
}
this.append=function(){
this.router.points.push(this);
this.router.$list.append(this.$dt).resortable();
if(this.$dd){
this.router.$list.append(this.$dd);
}
++this.router.length;
if(!this.router.dirty){
this.router.$list.trigger("routeChanged");
}
this.router.dirty=true;
$("#topbar .form li.showRouter").trigger("click");
bindActions(this);
$("#routerList:hidden").show();
};
this.prepend=function(){
this.router.points.unshift(this);
if(this.$dd){
this.router.$list.prepend(this.$dd);
}
this.router.$list.prepend(this.$dt).resortable();
++this.router.length;
if(!this.router.dirty){
this.router.$list.trigger("routeChanged");
}
this.router.dirty=true;
$("#topbar .form li.showRouter").trigger("click");
bindActions(this);
$("#routerList:hidden").show();
};
this.setDirections=function(ary){
if(this.$dd){
this.clearDirections();
}
this.directions=ary;
this.$dd=$("<dd><ol></ol></dd>");
var $ol=$dd.find("ol");
$.each(ary,function(i,o){
$ol.append($("<li>"+o+"</li>"));
});
this.$dt.after(this.$dd);
};
this.clearDirections=function(){
if(this.$dd){
this.$dd.remove();
this.$dd=null;
}
for(var i=0;i<this.directions.length;i++){
this.directions[i]=null;
}
this.directions=[];
};
this.remove=function(){
for(var i=0;i<this.router.points.length;i++){
if(this.router.points[i]==this){
this.$dt.resortable(false).remove();
this.router.points.splice(i,1);
--this.router.length;
if(!this.router.dirty){
this.router.$list.trigger("routeChanged");
}
this.router.dirty=true;
this.clearDirections();
if(this.router.length==0){
$("#routerList:visible").hide();
}
break;
}
}
this.router=this.obj=this.GA=this.label=this.marker=this.$dt=this.$dt.routerPoint=this.$dd=null;
};
};
Direction=function(){
};
$(init);
$(window).load(loadMap);
})();

