function SelectPOI(d){$("#detalii").attr({title:d.feature.title});var b=d.feature.title;poiId=d.feature.myid;var c=d.feature.longlat;if(openedPois[poiId]!==true){boxNumber++;var a=$.post("getDetailsUI.php",{id:d.feature.myid,box:boxNumber},function(e){content[poiId]=$(e).dialog({autoOpen:false,width:255,height:194,zIndex:3000000,resizable:false,title:b,open:function(f,g){openedPois[poiId]=true;this.mic=true;this.idp=poiId;this.longlat=c;this.reloadComments=true;this.tabs=$("#tabs"+poiId).tabs();$("#tabs"+poiId).bind("tabsselect",function(h,i){if(i.index==1){if(this.parentNode.reloadComments){reloadComments(this.parentNode.idp);this.parentNode.reloadComments=false}else{}}});$("#tabs"+this.idp).hide();$("#vot"+this.idp).hide();$("#detalii"+this.idp).click(function(){this.idp=this.parentNode.parentNode.idp;if(this.parentNode.parentNode.mic===true){$("#dialog"+this.idp).dialog("option","width",600);$("#dialog"+this.idp).dialog("option","height",450);$("#dialog"+this.idp).attr({style:"height:388px; min-height:88px; width:auto"});$("#tabs"+this.idp).show();$("#vot"+this.idp).show()}else{$("#tabs"+this.idp).hide();$("#vot"+this.idp).hide();$("#dialog"+this.idp).dialog("option","width",265);$("#dialog"+this.idp).dialog("option","height",214);$("#dialog"+this.idp).attr({style:"height:170px; min-height:88px; width:auto"})}this.parentNode.parentNode.mic=!this.parentNode.parentNode.mic;return false});$("#button"+this.idp).click(function(){this.idp=this.parentNode.parentNode.parentNode.idp;var h=$("#vot"+this.idp+" > * > input[name=star"+boxNumber+"]").val();com=$("#comentariu").val();poiId=this.idp;$.post("putComment.php",{id:this.idp,comm:com,stars:h},function(k){this.idp=poiId;if(k=="NOK"){$("#vot"+this.idp).append("Votul nu a putut fi prelucrat")}else{$("#stele"+this.idp).html(k);$("#vot"+this.idp).html("Votul a fost adaugat");var j=k.match(/\d+ voturi/);var i=j[0].match(/\d+/);$("#linkcom"+this.idp).text("Comentarii ("+i[0]+")");$("#dialog"+poiId)[0].reloadComments=true}})});$("#setstart"+this.idp).click(function(){this.idp=this.parentNode.parentNode.parentNode.idp;var h=this.parentNode.parentNode.parentNode.longlat;directionsManager.addStartPoint(h,directionsManager);$("#dialog"+this.idp).dialog("close")});$("#setstop"+this.idp).click(function(){this.idp=this.parentNode.parentNode.parentNode.idp;var h=this.parentNode.parentNode.parentNode.longlat;directionsManager.addEndPoint(h,directionsManager);$("#dialog"+this.idp).dialog("close")})},close:function(f,g){$(this).dialog("destroy");$(this).remove();openedPois[poiId]=false}});$tabs=$("#tabs"+poiId).tabs();content[poiId].dialog("open")})}featureSelect.unselect(d.feature)}function reloadComments(a){$.post("getComments.php",{id:a},function(b){$("#tabcom"+a).html(b)})}function removePois(b,c){var a;if(b=="cat"){for(a in markers){if(markers[a].cat==c){poisLayer.removeFeatures([markers[a]]);markers[a].destroy();delete markers[a]}}}else{if(b=="subcat"){for(a in markers){if(markers[a].subcat==c){poisLayer.removeFeatures([markers[a]]);markers[a].destroy();delete markers[a]}}}}}function getSubcategorii(c){var b=[];for(var a in c){if(c[a]===true){b.push(a)}}return b}function loadPois(a,c){var e=""+a+"";var b=bounds.clone();var d=b.transform(OSMProjection,CMProjection).toArray();$.ajax({url:"getpois.php",dataType:"json",cache:false,data:{latSW:d[1],lonSW:d[0],latNE:d[3],lonNE:d[2],tip:a,"objs[]":c},success:function(m,j){for(var n=0;n<m.length;n++){var f=m[n].id;var p=m[n].cat;var k=m[n].subcat;var g=m[n].image;if(markers[f]===undefined){var o=new OpenLayers.LonLat(m[n].lon,m[n].lat).transform(CMProjection,OSMProjection);var q=new OpenLayers.Geometry.Point(o.lon,o.lat);if(g===undefined){g="viewpoint.png"}var h={pointRadius:10,externalGraphic:"/images/subcats/"+g,graphicXOffset:-10,graphicYOffset:-10,graphicTitle:m[n].name};var l=new OpenLayers.Feature.Vector(q,null,h);l.myid=f;l.cat=p;l.subcat=k;l.longlat=o;l.title=m[n].name;markers[f]=l;poisLayer.addFeatures([l])}}},error:function(f,h,g){$("#logo").text("Error")}});c=null}function loadCategories(){$.post("getCategories.php",{},function(a){$("#categorii").html(a);$(".tree").checkTree({onCheck:function(e){var c=e.children("input")[0];if(c!==null){var b=c.name;var f=[c.value];if(b.indexOf("chksub")>=0){if(currentZoom>12){loadPois("subcat",f)}subcategorii[c.value]=true}else{if(currentZoom>12){loadPois("cat",f)}for(var d=0;d<categorii[c.value].length;d++){subcategorii[categorii[c.value][d]]=true}}}else{}},onUnCheck:function(e){var c=e.children("input")[0];if(c!==null){var b=c.name;var f=c.value;if(b.indexOf("chksub")>=0){removePois("subcat",f);subcategorii[c.value]=false}else{removePois("cat",f);for(var d=0;d<categorii[c.value].length;d++){subcategorii[categorii[c.value][d]]=false}}}else{}}})})};