var WgLib=function(){function t(a,c,b){c=document.createElement("DIV");c.innerHTML=a;c.style.margin="5px";c.style.textDecoration="none";c.style.color="#000000";c.style.backgroundColor="#FFFFF0";c.style.font="small Arial";c.style.fontWeight="bold";c.style.border="1px solid black";c.style.padding="2px";c.style.textAlign="center";c.style.cursor="pointer";google.maps.event.addDomListener(c,"click",function(){b()});return c}function n(a,c){if(c)for(var b=0;b<c.length;b++)WgUtil.addOpt(a,c[b][0],c[b][1],
a.options.length)}function f(a,c){return WgUtil.getLangText(a,c)}function x(a,c){c||(c=function(){});navigator.geolocation&&navigator.geolocation.getCurrentPosition(a,c)}function u(){var a={};a.image=new google.maps.MarkerImage("/images/markers-v3/image.png",new google.maps.Size(29,30),new google.maps.Point(0,0),new google.maps.Point(15,30));a.shadow=new google.maps.MarkerImage("/images/markers-v3/shadow.png",new google.maps.Size(47,30),new google.maps.Point(0,0),new google.maps.Point(15,30));a.shape=
{coord:[20,0,23,1,24,2,26,3,27,4,27,5,28,6,28,7,24,8,25,9,25,10,26,11,26,12,26,13,26,14,25,15,25,16,25,17,24,18,23,19,22,20,20,21,19,22,18,23,17,24,16,25,15,26,15,27,15,28,14,29,14,29,13,28,13,27,12,26,11,25,11,24,9,23,8,22,7,21,5,20,3,19,2,18,1,17,0,16,0,15,0,14,4,13,3,12,3,11,2,10,2,9,2,8,2,7,3,6,3,5,4,4,4,3,5,2,7,1,9,0,20,0],type:"poly"};return a}var q={};this.langdir=f("langdir","dir");var v=function(a){function c(c,b){var e;e=d.id_georegion.val();if(b&&b.id_georegion)e=b.id_georegion;$.getJSON("/int/ajax/wg_ajax_json_select.php",
{q:"zeme",id_georegion:e,exist_spots:a.exist_spots,id_model:a.id_model},function(a){d.id_zeme[0].length=0;WgUtil.addOpt(d.id_zeme[0],-1,"--"+f("spotmenu","sel_zeme")+"-- ("+a.count+" "+f("spotmenu","num_zeme")+")",0);WgUtil.addOpt(d.id_zeme[0],0,"--"+f("spotmenu","sel_all")+"--");n(d.id_zeme[0],a.zeme);if(WgUtil.isDefined(c))d.id_zeme[0].value=c})}function b(c,b){var l,k,r;l=d.id_region.val();k=d.id_zeme.val();r=d.id_georegion.val();var y=e();if(b){if(b.id_region)l=b.id_region;if(b.id_zeme)k=b.id_zeme;
if(b.id_georegion)r=b.id_georegion}$.getJSON("/int/ajax/wg_ajax_json_select.php",{q:"spots",id_zeme:k,id_region:l,id_georegion:r,cats:y,id_cuser:a.id_cuser,id_model:a.id_model,special:a.special,opt:a.opt},function(a){d.id_spot[0].length=0;WgUtil.addOpt(d.id_spot[0],0,"--"+f("spotmenu","sel_spot")+"-- ("+a.count+" "+f("spotmenu","num_spot")+")",0);n(d.id_spot[0],a.spots);if(WgUtil.isDefined(c))d.id_spot[0].value=c;var b=Array(d.id_spot[0].length);for(i=0;i<b.length;i++)b[i]=new Option(d.id_spot[0][i].text,
d.id_spot[0][i].value);h=b;g&&g.addMapSpots(a.spots)})}function k(a,b){var c,e;c=d.id_zeme.val();e=d.id_georegion.val();if(b){if(b.id_zeme)c=b.id_zeme;if(b.id_georegion)e=b.id_georegion}$.getJSON("/int/ajax/wg_ajax_json_select.php",{q:"regions",id_zeme:c,id_georegion:e},function(b){d.id_region[0].length=0;WgUtil.addOpt(d.id_region[0],0,"--"+f("spotmenu","sel_all")+"-- ("+b.count+" "+f("spotmenu","num_reg")+")",0);n(d.id_region[0],b.regions);if(WgUtil.isDefined(a))d.id_region[0].value=a})}function e(){for(var a=
j.find(".typspots").find("input:checked"),b=[],c=0;c<a.length;c++)b[c]=a[c].value;return b.join("_")}var d={},h=[],g,m=this,j=$("#"+a.spot_select);this.id=a.spot_select;d.id_georegion=j.find(".id_georegion");d.id_zeme=j.find(".id_zeme");d.id_region=j.find(".id_region");d.id_spot=j.find(".id_spot");d.filter=j.find(".filter_search");d.refresh=j.find(".spot_refresh");if(!WgUtil.isDefined(a.exist_spots))a.exist_spots=1;if(!WgUtil.isDefined(a.id_model))a.id_model=0;if(!WgUtil.isDefined(a.id_cuser))a.id_cuser=
0;if(!WgUtil.isDefined(a.opt))a.opt="";if(!WgUtil.isDefined(a.special))a.special="";if(WgUtil.isDefined(a.spotmap))g=a.spotmap,g.setSpotSelect(this);WgUtil.addOpt(d.id_zeme[0],0,"--"+f("spotmenu","sel_zeme")+"-- (0 "+f("spotmenu","num_zeme")+")");WgUtil.addOpt(d.id_region[0],0,"--"+f("spotmenu","sel_all")+"-- (0 "+f("spotmenu","num_reg")+")");WgUtil.addOpt(d.id_spot[0],0,"--"+f("spotmenu","sel_spot")+"-- (0 "+f("spotmenu","num_spot")+")");if(a.id_georegion)d.id_georegion[0].value=a.id_georegion,c(a.id_zeme,
a),a.id_zeme&&(k(a.id_region,a),b(a.id_spot,a));d.id_georegion.change(function(){d.id_region[0].length=0;d.id_spot[0].length=0;WgUtil.addOpt(d.id_region[0],0,"--"+f("spotmenu","sel_all")+"-- (0 "+f("spotmenu","num_reg")+")");WgUtil.addOpt(d.id_spot[0],0,"--"+f("spotmenu","sel_spot")+"-- (0 "+f("spotmenu","num_spot")+")");c()});d.id_zeme.change(function(){k();b()});d.id_region.change(function(){b()});d.id_spot.change(function(){var a=d.id_spot.val();g&&g.showMapSpot(a)});d.filter.length&&d.filter.keyup(function(){var a=
d.id_spot[0];a.options.length=0;var b=d.filter.val().toLowerCase();for(i=0;i<h.length;i++)if(b==""||h[i].text.toLowerCase().indexOf(b)>=0)a.options[a.options.length]=h[i]});d.refresh.length&&d.refresh.click(function(){g&&g.deleteMarkers();b()});this.setMap=function(a){g=a;g.setSpotSelect(m)};this.hideMap=function(){g&&g.hide()};this.selectSpot=function(a,b){WgUtil.optExist(d.id_spot[0],a)||(WgUtil.optExist(d.id_spot[0],-100)||WgUtil.addOpt(d.id_spot[0],-100,"--------------"),WgUtil.addOpt(d.id_spot[0],
a,b));d.id_spot[0].value=a}},z=function(a){function c(){if(!this.mcoptions){var a=[45,49,60,70,80],b=[34,37,45,52,60],c=[];for(i=1;i<=5;++i)c.push({url:"/images/wgmc"+i+".png",height:b[i-1],width:a[i-1]});this.mcoptions={gridSize:45,maxZoom:10,styles:c}}return new MarkerClusterer(g,[],this.mcoptions)}function b(){if(!g){var a={zoom:3,center:new google.maps.LatLng(20,0),mapTypeId:google.maps.MapTypeId.ROADMAP};g=new google.maps.Map(d,a);a=t("Reset markers",g,h.resetMarkers);a.index=1;g.controls[google.maps.ControlPosition.RIGHT_TOP].push(a);
o=c();f.jqResize(".jqResize").mouseup(function(){google.maps.event.trigger(g,"resize")})}}var f=$("#"+a),e,d=document.getElementById(a+"_gmap"),h=this,g,m={},j,p,o,l=!1,n=new google.maps.InfoWindow({content:""});this.id=a;this.setPosition=function(){var a=f.offset(),b=$(window).width()-a.left-10,a=$(window).height()-a.top-10;b>1200&&(b=1200);a>700&&(a=700);b<600&&(b=600);a<300&&(a=300);f.width(b);f.height(a);g&&google.maps.event.trigger(g,"resize")};this.setToggleCheckbox=function(a){e=$("#"+a);e.click(function(){e.attr("checked")==
"checked"?(f.show(),h.setPosition(),b(),h.addMapSpots(j)):h.hide()})};this.hide=function(){e&&e.attr("checked",!1);f.hide()};this.isVisible=function(){if(f.is(":visible"))return!0;return!1};this.addMapSpots=function(a){if(WgUtil.isDefined(a)&&(j=a,g&&h.isVisible())){for(var b=[],c,d=[],e=0;e<a.length;e++){var f={id_spot:a[e][0],spotname:a[e][1],lat:a[e][2],lon:a[e][3]};c=new google.maps.LatLng(f.lat,f.lon);b.push(c);if(!m[f.id_spot]){c=w(f,!1);var k;k=l?l(f,{spotselect:p}):s(f,{spotselect:p});c.setInfoWindow({infowindow:n,
map:g,content:k});c.spotselect=p;c.setupClickEvent();m[f.id_spot]=c;m[f.id_spot].spotdef=a[e];d.push(c)}}o.addMarkers(d);if(b.length>0){a=new google.maps.LatLngBounds;for(d=0;d<b.length;d++)a.extend(b[d]);g.fitBounds(a)}}};this.resetMarkers=function(){h.isVisible()&&(h.deleteMarkers(),h.addMapSpots(j))};this.deleteMarkers=function(){g&&(o&&o.clearMarkers(),o=c(),m={})};this.setSpots=function(a){j=a};this.setSpotSelect=function(a){p=a};this.showMapSpot=function(a){if(g&&h.isVisible()&&(a=m[a]))g.setCenter(a.getPosition()),
g.getZoom()<11&&g.setZoom(11),a.openInfoWindow()};this.setMarkerFunction=function(a){l=a}},s=function(a,c){var b;c||(c={});$.isFunction(c.content_function)?b=c.content_function(a):(b="<b>"+a.spotname+'</b><br/><br/>[<a href="/'+langdir+"/index.php?sc="+a.id_spot+'" target="_top">'+f("gmap","link_f")+"</a>]",b+=' [<a href="/'+langdir+"/historie.php?id_spot="+a.id_spot+'" target="_top">'+f("gmap","link_a")+"</a>]",b+=' [<a href="/'+langdir+"/spot.php?id_spot="+a.id_spot+'" target="_top">'+f("gmap",
"link_d")+"</a>]",b+="<br/><br/>",c.spotselect instanceof v&&(b+="[<a href=\"javascript:WgLib.spotSelectHideMap('"+c.spotselect.id+"');\">"+f("gmap","link_s")+"</a>] "),b+='[<a href="/'+langdir+"/nastaveni.php?cast=fspot&akce=new&odeslano=1&spotid="+a.id_spot+'" target="_top">'+f("gmap","link_add")+"</a>]");return b},w=function(a,c,b){var f,e,d=u();a.lat&&a.lon&&(f=new google.maps.LatLng(a.lat,a.lon));b||(b={});if(!b.icon)b.icon=d.image;if(!b.shadow)b.shadow=d.shadow;if(!b.shape)b.shape=d.shape;if(!WgUtil.isDefined(b.draggable))b.draggable=
!1;if(f)b.position=f;if(c)b.map=c;e=new google.maps.Marker(b);e.spot=a;e.spotselect=!1;e.openInfoWindow=function(){e.iw.setContent(e.iwcontent);e.iw.open(e.iwmap,e)};e.setInfoWindow=function(a){if(a.infowindow)e.iw=a.infowindow;else if(!e.iw)e.iw=new google.maps.InfoWindow({content:""});if(a.content)e.iwcontent=$.isFunction(a.content)?a.content():a.content;else if(!e.iwcontent)e.iwcontent=s(e.spot);if(a.map)e.iwmap=a.map};e.setupClickEvent=function(){google.maps.event.addListener(e,"click",function(){e.spotselect&&
e.spotselect.selectSpot(e.spot.id_spot,e.spot.spotname);e.openInfoWindow()})};return e};this.wgCatsStr=function(){var a="";for(i=1;i<=idtyps.length;i++)idtyps[i]==1&&(a+="_"+i);return a!=""?a.substr(1):""};return{spotSelect:function(a){a=new v(a);return q[a.id]=a},spotSelectHideMap:function(a){q[a]&&q[a].hideMap()},spotMap:function(a,c,b){a=new z(a);a.setPosition();a.setToggleCheckbox(c);b&&a.setMarkerFunction(b);return a},mapIcon:function(){return u()},infoWindow:function(a,c){var b=s(a,c);return new google.maps.InfoWindow({content:b})},
mapMarker:function(a,c,b){return w(a,c,b)},mapControl:function(a,c,b){return t(a,c,b)},myPosition:function(a,c){x(a,c)}}}();

