PageSourceSearch

https://www.tanvald.cz/js/map4u.js

js tanvald.cz collected 2026-10-02 18:11:33 UTC 71,855 bytes, 2,228 lines download raw bytes

1/** mapOnaLoad.js
2 *  ver 1.0 - 8.06.2012
3 *  (C) www.as4u.cz
4 *  - dodatecne nacteni skriptu a vseho potrebneho pro mapu 
5 */  
6 
7var mapload = false;
8var map_winScroll = 0;
9var routeData = '';
10
11var recordIDglob = null;
12var skatIDglob = null;
13var katIDglob = null;
14var routeIDglob = null;
15
16
17var as4uMapGpsFormId = 0;
18var mapShowType = '';
19
20var onPageLoad = true;
21
22
23var userPoints = new Array();
24var completLoadWayPoint = 0;
25
26
27var scriptsForLoad = [
28  //{link:'http://'+location.host + '/js/suggest.js', callback: ''},
29  /*{link:'http://'+location.host + '/aplikace/mapy-udalosti/js/mapy-udalosti.js', callback: function(){
30    frontentMapScriptIsOnLoad();
31    return;     
32  }}  */
33];
34
35var cssForLoad = [
36  //'http://'+location.host + '/aplikace/mapy-udalosti/css/mapy-udalosti.css'
37];
38
39
40var loaderNotLoaded = true; 
41
42function frontentMapScriptIsOnLoad() {
43
44  if (typeof MapAppLoader == "undefined") {
45      //nutno nepouzivat jquery aby fungovala funkce v MapAppLoader.js pro detekci umisteni skriptu
46    var script = document.createElement('script');
47    var head = document.getElementsByTagName('head')[0];
48    script.type = 'text/javascript';
49    head.appendChild(script);     
50    script.src = 'http://apps.hfbiz.cz/glog/JavaScript/hslayers/trunk/Apps/MapAppLoader.js'; 
51    
52    var fce = function () {
53
54      if (typeof MapAppLoader != "undefined") {
55        if (typeof MapAppLoader._instance != "undefined") {
56            if (loaderNotLoaded) {
57              MapAppLoader.load({
58                  uiLibrary: "",
59                  proxy: "http://" + location.hostname + "/mapy/proxy.php?url=",
60                  scripts: [
61                      "http://apps.hfbiz.cz/glog/Glog/MapPortal/www/mapportal-core.js"
62                  ],
63                  debug: false
64              });
65              loaderNotLoaded = false;
66            }
67            if (MapAppLoader.isReady(MapAppLoader._instance)) {
68              MapAppLoader.onStartApplication = function() {
69                startApplication();
70              };  
71           
72              var anotherFce = function () { 
73                if (typeof window.HSLayers != "undefined"){
74                  //frontendScriptIsReadyToGo();
75                  mapyUdalostiOnLoadInit();
76                } else {
77                  setTimeout(anotherFce, 100);
78                }
79              };
80              anotherFce();
81            } else {
82              setTimeout(fce, 100);
83            }
84         
85        } else {
86           setTimeout(fce, 100);
87        }
88
89      } else {
90        setTimeout(fce, 100);
91      }
92    }; 
93    fce();
94
95  } else {
96    mapyUdalostiOnLoadInit();
97  } 
98}
99 
100function frontendScriptIsReadyToGo() {
101 
102  for (var i in cssForLoad) {
103    if (cssForLoad[i]) {
104      var css = jQuery("<link>");
105      jQuery("head").append(css);
106      css.attr({
107        rel:  "stylesheet",
108        type: "text/css",
109        href: cssForLoad[i]
110      }); 
111      cssForLoad[i] = '';
112    }
113  }
114  
115  for (var i in scriptsForLoad) {  
116
117    if (scriptsForLoad[i].link) {   
118      $.getScript(scriptsForLoad[i].link, function() {
119        scriptsForLoad[i].link = '';
120        if (typeof scriptsForLoad[i].callback == "function") scriptsForLoad[i].callback();        
121      }).fail(function(jqxhr, settings, exception) {
122
123      });
124    } else {
125      if (typeof scriptsForLoad[i].callback == "function") scriptsForLoad[i].callback();
126    }
127  }
128 
129 //$.script('http:') 
130};
131
132
133function mapyUdalostiOnLoadInit() { 
134  onLoad();
135}
136
137
138function sugestInit(id) {
139  var url = 'http://'+location.host+'/mapy/ajax.php?htmlAjax=yes&akce=map4uBasic&subakce=suggestaddress';
140  log(id);
141  jQuery("#"+id).autocomplete({
142    source: url,
143		extraParams: {subakce: 'suggestaddress', htmlAjax: 'yes', akce: 'map4uBasic'},
144    width: 320,
145		max: 10,
146		matchSubset: false,
147		//highlight: false,
148		//multiple: true,
149		//multipleSeparator: " ",
150		scroll: true,
151		scrollHeight: 300,
152		selectFirst: false,
153    open: function(){
154      jQuery(this).autocomplete('widget').css('z-index', 300);
155      return false;
156    },
157		select: function( event, ui ) {
158      as4uMapfindAddress();
159		}
160	});
161
162
163  $("#"+id).keyup(function(event) {
164    if (event.keyCode == 13) {
165      as4uMapfindAddress();
166    }
167  });
168}
169
170
171function as4uMapfindAddress(){
172  var text = HSLayers.Apps.Utility.getElement("search_adres").value;
173  if(text != ""){
174    text = text.replace(","," ").replace("  "," ");
175
176    //var text = HSLayers.Apps.Utility.getElement("text").value;
177    var url = "http://apps.hfbiz.cz/glog/Glog/entry.php?class=Address.Search&key=" + this.key + "&searchText=" + text;
178    var resultString = HSLayers.Apps.Utility.loadURLSync(url);
179    var result = eval("(" + resultString.trim() + ")");
180    if (result.objectCount > 0) {
181        var locations = [];
182        for (var i = 0; i < result.objects.length; i++) {
183            var address = result.objects[i];
184            var x = address.x;
185            var y = address.y;
186            //TODO convert souradnic
187            var coords = HSLayers.Apps.MapPortal.Rincon.ShowObject.getMapAppAPI().reprojectCoords(
188                           "epsg:2065", "epsg:4326", [[address.x,address.y]], null, null
189                        );
190            var x = coords[0][0];
191            var y = coords[0][1];
192            address.info += '<br /><a href="javascript:;
192" onclick="setLocation2form(\''+x+'\',\''+y+'\')">Nalezený bod</a>';
193            locations.push({
194                x: address.x,
195                y: address.y,
196                name: address.name,
197                info: address.info
198            });
199        }
200        HSLayers.Apps.MapPortal.Rincon.ShowObject.addLocations(locations, true, true);
201    } else {
202      alert('Litujeme. Pro požadovaný dotaz nebylo nic nalezeno. ' + result.objectCount);
203    }
204  }
205}
206
207
208function addFoto2map(x, y, img, size, info, bublesize) {
209
210    info = '<div style="width: ' + bublesize + 'px; height: ' + (bublesize + 20) + 'px;"><strong>' + info + '</strong><br /><img src="http://'+location.host+'/galerie/' + img + '_' + bublesize + '_' + bublesize + '_6.jpg" /></div>'
211    log(info);
212    log('pozice ' + x + ' / ' + y);
213    var pointsParam = [];
214
215    pointsParam.push({
216        coordX: x,
217        coordY: y,
218        iconUrl: 'http://'+location.host+'/galerie/' + img + '_' + size + '_' + size + '_6.jpg',
219        iconWidth: size,
220        iconHeight: size,
221        popupContent: info
222    });
223
224
225    var points = HSLayers.Apps.MapPortal.Rincon.ShowObject.addPointsWgs(pointsParam);
226
227
228};
229
230function addPoint2map(x, y) {
231
232
233  jQuery.get('http://' + location.hostname + '/mapy/proxy.php?url=' + encodeURIComponent('http://apps.hfbiz.cz/glog/Glog/entry.php?class=Tools.Reproject&srsIn=epsg:4326&srsOut=epsg:2065&coords=' + x + ' ' + y ),
234    function(data){
235      log(data);
236      var wgsArr = data.split(' ');
237      log(wgsArr[1]);
238      log(wgsArr[2]);
239
240
241      mapAppAPI = MapAppLoader.getInstance().getAPI();
242      userPoints[1000] = mapAppAPI.addUserPoint(
243          wgsArr[1],
244          wgsArr[2],
245          'http://'+location.host+'/mapy/icons/public4u/point.png', 20, 20,
246          null,
247          null,
248          null
249      );
250      HSLayers.Apps.MapPortal.Rincon.ShowObject.getMapAppAPI().getOpenLayersMap().setCenter(new OpenLayers.LonLat(wgsArr[1], wgsArr[2]), 9);
251
252  	});
253
254
255
256
257};
258
259
260
261/***************************************************************************
262 * Callback funkce, ktera je vyvolana po zobrazeni kompletni mapy
263 **************************************************************************/
264function afterLoad() {
265  mapload = true;
266
267  //switchMapToGpsReturn();
268
269
270  if(mapShowType == 'showGalleryOnMap'){
271    var arrElm = jQuery('div[id ^= imageID_]');
272
273    var arrX = new Array();
274    var arrY = new Array();
275
276    for (i=0;i<arrElm.length;i++){
277
278      var elmAddID = jQuery(arrElm[i]).attr("id");
279
280      var elmIdArr = elmAddID.split("_");
281
282      if(elmIdArr[1] > 0){
283        var formid = '_' + elmIdArr[1];
284      }
285      if(jQuery('#gpsNs' + formid).length > 0){
286        if((jQuery('#gpsNs' + formid).val() != 0) && (jQuery('#gpsEs' + formid).val() != 0)){
287          arrX[i] = (jQuery('#gpsEs' + formid).val() * 1) + (jQuery('#gpsEm' + formid).val() / 60) + (jQuery('#gpsEv' + formid).val() / 3600);
288          arrY[i] = (jQuery('#gpsNs' + formid).val() * 1) + (jQuery('#gpsNm' + formid).val() / 60) + (jQuery('#gpsNv' + formid).val() / 3600)
289          addFoto2map(arrX[i], arrY[i], elmIdArr[1], 50, jQuery('#imageTitle' + formid).val(), 150);
290        }
291
292      } else if(jQuery('#obr_gps_sirka' + formid).length > 0){
293
294        if((jQuery('#obr_gps_sirka' + formid).html() != 0) && (jQuery('#obr_gps_delka' + formid).html() != 0)){
295          arrX[i] = (jQuery('#obr_gps_delka' + formid).html() * 1);
296          arrY[i] = (jQuery('#obr_gps_sirka' + formid).html() * 1);
297          addFoto2map(arrX[i], arrY[i], elmIdArr[1], 50, jQuery('#imageTitle' + formid).html(), 150);
298        }
299      } 
300
301    }
302
303    if(arrX.length > 0){
304      var nejmensiX = nejvetsiX = arrX[0];
305      for (i=0;i<arrX.length;i++){
306        if (arrX[i] < nejmensiX){nejmensiX = arrX[i];}
307        if (arrX[i] > nejvetsiX){nejvetsiX = arrX[i];}
308      }
309
310      var nejmensiY = nejvetsiY = arrY[0];
311      for (i=0;i<arrY.length;i++){
312        if (arrY[i] < nejmensiY){nejmensiY = arrY[i];}
313        if (arrY[i] > nejvetsiY){nejvetsiY = arrY[i];}
314      }
315
316      log(nejmensiX + ' ' + nejmensiY);
317      log(nejvetsiX + ' ' + nejvetsiY);
318
319      jQuery.get('http://' + location.hostname + '/mapy/proxy.php?url=' + encodeURIComponent('http://apps.hfbiz.cz/glog/Glog/entry.php?class=Tools.Reproject&srsIn=epsg:4326&srsOut=epsg:2065&coords=' + nejmensiX + ' ' + nejmensiY + ',' + nejvetsiX + ' ' + nejvetsiY),
320
321        function(data){
322
323          var wgsArr = data.split(',');
324          var wgsArrNejmensi = wgsArr[0].split(' ');
325          var wgsArrNejvetsi = wgsArr[1].split(' ');
326          HSLayers.Apps.MapPortal.Rincon.ShowObject.zoomToExtent(wgsArrNejmensi[1],wgsArrNejmensi[2],wgsArrNejvetsi[0],wgsArrNejvetsi[1]);
327
328      	});
329
330
331    }
332
333
334  }
335
336
337  if(mapShowType == 'set2fromGPS'){
338
339    if(as4uMapGpsFormId > 0){
340      var formid = '_' + as4uMapGpsFormId;
341    }else{
342      var formid = '';
343    }
344
345    if((jQuery('#gpsNs' + formid).val() != '0') && (jQuery('#gpsEs' + formid).val() != '0')){
346
347      //addFoto2map();
348      var pointID = addPoint2map((jQuery('#gpsEs' + formid).val() * 1) + (jQuery('#gpsEm' + formid).val() / 60) + (jQuery('#gpsEv' + formid).val() / 3600), (jQuery('#gpsNs' + formid).val() * 1) + (jQuery('#gpsNm' + formid).val() / 60) + (jQuery('#gpsNv' + formid).val() / 3600));
349      log('pridano ' + pointID);
350    }
351
352    jQuery('#as4uPopupDataContainerIn1').append('<div id="as4uMapSearchTools"></div>');
353    jQuery('#as4uMapSearchTools').load('http://'+location.host+'/mapy/ajax.php?akce=map4uBasic&htmlAjax=yes&subakce=loadsearchtools', function() {
354
355    });
356
357
358  }
359  
360
361  jQuery('#as4u_map').css('background-image', '');
362  HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleLayer("poi", true);
363
364  HSLayers.Apps.MapPortal.Rincon.ShowObject.routingSetGenerateItinerary(true);
365  setRouteType();
366
367  if(recordIDglob > 0){
368    HSLayers.Apps.MapPortal.Rincon.ShowObject.showObjectInMapById(recordIDglob);
369  }
370
371  if((skatIDglob > 0) && (katIDglob > 0)){
372    jQuery('#mapKat-' + katIDglob + '-' + skatIDglob).attr('checked', true);
373    changeCategory(katIDglob, skatIDglob);
374  } else if(katIDglob > 0) {
375    jQuery('#mapKat-' + katIDglob + '-0').attr('checked', true);
376    changeCategory(katIDglob, 0);
377  }
378  
379  if(routeIDglob > 0){
380    showSawedRoute(routeIDglob);
381  }
382
383
384
385};
386
387
388/***************************************************************************
389 * Callback funkce ktera se zavola pred vyhledani objektu. Parametr "request"
390 * obsahuje parametry vyhledavani.
391 *
392 * "Napojeni" teto funkce na mapovou knihovnu se provadi ve funkci
393 *  initialize().
394 **************************************************************************/
395function beforeSearch(request) {
396    var continueSearch = true;
397    if (request.fromMap) {
398        alert(
399            "Souřadnice zadaného výřezu : \n" +
400            request.fromMap.minx + ", " + request.fromMap.miny + "\n" +
401            request.fromMap.maxx + ", " + request.fromMap.maxy
402        );
403        continueSearch = false;
404    }
405    return continueSearch;
406};
407
408/***************************************************************************
409 * Schova nastrojovou listu v mape
410 **************************************************************************/
411function hideControlPanel() {
412    HSLayers.Apps.MapPortal.Rincon.ShowObject.setControlPanelVisible(false);
413};
414
415/***************************************************************************
416 * Vrati zadane ID objektu
417 **************************************************************************/
418function getObjectId() {
419    return HSLayers.Apps.Utility.getElement("objectid").value;
420};
421
422
423/***************************************************************************
424 * Vrati seznam zadanych SKATID pro zobrazeni v mape
425 **************************************************************************/
426function getSkatId() {
427    return HSLayers.Apps.Utility.getElement("skatid").value;
428};
429
430/***************************************************************************
431 * Vrati pole se seznam zadanych SKATID pro zobrazeni v mape
432 **************************************************************************/
433function getVisibleSkatArray(skatid) {
434    return [{layerName:"poi",skat: skatid}];
435    if (skatid.indexOf(',')) {
436      var arr = [];
437      var items = skatid.split(',');
438      for (var i in items) {
439        arr.push({layerName:"poi",skat: items[i]});
440      }
441      return arr;
442    } else {
443      return [{layerName:"poi",skat: skatid}];
444    }
445};
446
447/***************************************************************************
448 * Po nacteni dokumentu je nutne zavolat metodu "MapAppLoader.afterDocLoaded"
449 **************************************************************************/
450function onLoad() {
451  MapAppLoader.afterDocLoaded();
452};
453
454/***************************************************************************
455 * Nastavi zadane SKATID a prekresli mapu
456 **************************************************************************/
457function setVisibleSkat(skatid) {
458    HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleSkat(
459        getVisibleSkatArray(skatid),
460        true
461    );
462};
463
464/***************************************************************************
465 * Nastavi zoom level v mape
466 **************************************************************************/
467function setZoom() {
468    HSLayers.Apps.MapPortal.Rincon.ShowObject.zoomTo(
469        HSLayers.Apps.Utility.getElement("zoom").value
470    );
471};
472
473/***************************************************************************
474 * Zobrazi nastrojovou listu v mape
475 **************************************************************************/
476function showControlPanel() {
477    HSLayers.Apps.MapPortal.Rincon.ShowObject.setControlPanelVisible(true);
478};
479
480/***************************************************************************
481 * Zobrazi objekty v mape
482 **************************************************************************/
483function showObjectInMap() {
484    HSLayers.Apps.MapPortal.Rincon.ShowObject.showObjectInMapById(
485        getObjectId(), {zoomLevel: 7}
486    );
487};
488
489/***************************************************************************
490 * Funkce provede inicializaci parametru mapove knihovny, a nasledne provede
491 * zobrazeni mapoveho okna a vyhledani pozadovaneho objektu.
492 **************************************************************************/
493function startApplication() {
494
495    if (typeof HSLayers != "undefined") {
496/*
497      jQuery("map").css('overflow', 'hidden');
498      jQuery("status").innerHTML = "Zobrazuji mapu, čekejte ...";
499*/
500      //as4uPopup.show4map(false,jQuery(window).width()-80,jQuery(window).height()-20);
501
502      initOptions("map", recordIDglob, skatIDglob, "", afterSearch);
503
504/*
505      var mapidshow = document.getElementById('mapidshow').innerHTML;
506      HSLayers.Apps.MapPortal.Rincon.ShowObject.showMap(mapidshow);
507*/
508
509    } else {
510
511      setTimeout(startApplication, 100);
512    }
513};
514
515function afterSearch() {
516  try {
517    jQuery("#map")[0].style.visibility = "visible";
518    jQuery("#status")[0].style.display = "none";
519    jQuery("#status")[0].innerHTML = "";
520  } catch(e) {}
521};
522
523function getPopupContent(dataObject) {
524  var content = "";
525  if (!dataObject.objectId)
526    return false;
527
528
529  if (dataObject != null) {
530      if (dataObject.objectId != undefined) {
531        log('Nacteni bubliny');
532        log(dataObject);
533          content = '<div id="mapbuble" style="width: 300px; height: 180px; overflow: auto;">Načítám data...</div>';
534          loadData2Buble(dataObject.objectId);
535      }
536  }
537  return content;
538};
539
540function initOptions(mapDivId, objectID, layerID, defaultControl, afterSearchFunc) {
541  /*if (!getPopupContentFunc) {
542    getPopupContentFunc = getPopupContent;
543  }*/
544  HSLayers.Apps.MapPortal.Rincon.ShowObject.initOptions({
545
546        afterLoad: afterLoad,
547
548        afterSearch: afterSearchFunc,
549
550        // zakladni URL pro volani funkcionality implementovane na serverove strane
551        // !!! NEMENIT !!!
552        baseUrl: "http://apps.hfbiz.cz/glog/glog",
553
554        // id HTML elementu (DIV), do ktereho bude vygenerovane mapove okno
555        containerId: mapDivId,
556
557        // nastaveni viditelnosti nastrojove listy v mape
558        controlPanelVisible: false,
559
560        // nastroj, ktery je implicitne zapnuty :
561        //   "info"                     - zapne nastroj info
562        //   "" , nebo nezadana hodnota - zapne nastroj "navigation" (pohyb
563        //                                v mape - pan, zoom)
564        defaultControl: "",
565
566        // cesta k obrazkum, ktere nahrava mapova knihovna
567        // !!! NEMENIT !!!
568        imgPath: "http://apps.hfbiz.cz/glog/JavaScript/hslayers/trunk/img/",
569
570        // callback funkce, ktera se zavola pri zobrazeni informacni bubliny
571        getPopupContent: getPopupContent,
572
573        // nazev projektu na serveru, ktery obsahuje definici prislusnych dat
574        // !!! NEMENIT !!!
575        projectName: "RinconPublic4u",
576
577        // povoli pouzivat modul Routing
578        routing: true,
579
580        // callback funkce pro modul Routing
581        routingCallback: {
582            addNode: addNodeFromMap,
583            removeNode: function() {
584                //console.log("remove node");
585                //console.log(arguments);
586            },
587            findRoute: findRouteCallback,
588            scope: null
589        },
590
591        // urcuje jestli budou zobrazeny vsechny objektu (POI) v mape, nebo
592        // pouze pozadovany objekt (false - pouze pozadovany, true - vsechny
593        // objekty)
594        showObjectsInMap: true
595    });
596
597    // vyhledani objektu a zazoomovani na nej. Predava se ID pozadovaneho
598    // objektu (takze v realne aplikaci se bude generovat). Jako parameter lze
599    // zadat jednu z nasledujicich moznosti :
600    // - jedno ID jako cislo
601    // - jedno ID jako retezec
602    // - vice ID oddelenych mezerou jako retezec
603    // - null - neni vyhledano nic, pokud je zadany zoomLevel, provede se zoom
604    //
605    // Dalsi volitelny parametr je pole se seznamem SKATID pro jednotlive vrstvy s POI
606    // a zoomLevel (platne jen pokud je parametr id=null)
607
608    HSLayers.Apps.MapPortal.Rincon.ShowObject.showMap(
609        null, [{layerName:"poi",skat:"-1"}], null
610    );
611};
612
613
614/********************************************************************************
615 *     fce prevzate z hfbizmapy.js
616 **
617 */
618
619var hfbizmapisshowed = 'yes';
620
621
622function checkKeyMap(evt){
623
624  var charCode = (evt.which) ? evt.which : event.keyCode
625
626  if(charCode == 27){
627    closemapshow();
628  }
629}
630
631function loadData2Buble(recordID){
632  if(document.getElementById('mapbuble')){
633    jQuery('#mapbuble').load('/redakce/ajax.php?akce=mapa&subakce=mapbuble&htmlAjax=yes&dr='+recordID);
634  } else {
635    setTimeout(function(){loadData2Buble(recordID)}, 50);
636  }
637}
638
639
640
641
642/* prenesene funkce */
643
644/***************************************************************************
645 * Callback funkce, ktera je vyvolana po pridani uzlu trasy z mapy
646 **************************************************************************/
647function addNodeFromMap(node, type) {
648
649    switch (type) {
650        case 1:
651            //HSLayers.Apps.Utility.getElement("fromText").value = node.x + " " + node.y;
652            break;
653        case 3:
654            //HSLayers.Apps.Utility.getElement("toText").value = node.x + " " + node.y;
655            break;
656    }
657};
658
659var oldSelectedInstruction = '';
660var oldSelectedInstructionClick = '';
661function drawSelectedRouteInstruction(routeString, zoom) {
662  // routeInfo = true / fasle
663  if((oldSelectedInstruction != '') && (oldSelectedInstruction != oldSelectedInstructionClick)){
664    HSLayers.Apps.MapPortal.Rincon.ShowObject.routingDrawRouteFeatures(oldSelectedInstruction.split(","), false, false);
665  }
666  
667  if(zoom == true){
668    if(oldSelectedInstructionClick != ''){
669      HSLayers.Apps.MapPortal.Rincon.ShowObject.routingDrawRouteFeatures(oldSelectedInstructionClick.split(","), false, false);
670    }
671    oldSelectedInstructionClick = routeString;
672  }
673  
674  oldSelectedInstruction = routeString;
675  if(routeString != ''){
676    var route = routeString.split(",");
677    var selected = true;
678    //var zoom = selected ? true : false;
679    HSLayers.Apps.MapPortal.Rincon.ShowObject.routingDrawRouteFeatures(
680        route, selected, zoom
681    );
682  }
683
684};
685
686
687function setSelectedRouteInstruction(){
688   jQuery(".routeselector").click(function() {
689     drawSelectedRouteInstruction(jQuery(this).attr('rel'), true);
690   });
691
692  jQuery(".routeselector").hover(
693    function() {
694      drawSelectedRouteInstruction(jQuery(this).attr('rel'), false);
695    },
696    function() {
697      drawSelectedRouteInstruction('', false);
698    }
699  );
700
701
702}
703
704function toRoute(){
705
706  var arrElm = jQuery('.itinerar_gps');
707  if(arrElm.length > 1){
708
709    var carka = "";
710    var points = "";
711    for (i=0;i<arrElm.length;i++){
712      points += carka + '"' + jQuery(arrElm[i]).html() + '"';
713      carka = ", ";
714    }
715
716    var routeType = jQuery('#routeType').val();
717    var generateItinerary = true;
718
719    var url =
720        'http://apps.hfbiz.cz/glog/Glog/entry.php?class=MapPortal.Routing.Routing&project=RinconRouting&' +
721        'params={"operation":"findPath",' +
722        '"routeType":"' + routeType + '",' +
723        '"generateInfo":' + generateItinerary + ',' +
724        '"points":[' + points + ']}';
725    routeData = HSLayers.Apps.Utility.loadURLSync(url);
726
727    HSLayers.Apps.MapPortal.Rincon.ShowObject.routingShowRouteData(routeData);
728    var routeDataObject = jQuery.parseJSON(routeData);
729    
730    /*
731    try {
732      $('#routeInfo').html('<h3>Délka trasy: ' + mapConvertNumber(routeDataObject.info.length, '1000', true) + ' km </h3>');
733  
734      var json = new OpenLayers.Format.JSON();
735      routeData = json.write(routeDataObject.info.itinerary);
736  
737      jQuery.post('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=renderItinerary&lanG='+jQuery('#lanG').val(),
738        {
739         routeData: routeData,
740         objectsNearRoute: objectsNearRoute
741        },
742        function(xml){
743          jQuery(xml).find('response').each(function(){
744            if(jQuery(this).find('status').text() == 'OK'){
745  
746              jQuery('#div_iterinar_ovl').show();
747              jQuery('#div_iterinar').html(jQuery(this).find('routeData').text());
748              initBuble();
749  
750            } else {
751              alert(jQuery(this).find('alert').text());
752            }
753         });
754      	}, "xml");
755      } catch(e) {
756        log('tRoute error ' + e.message);
757      }  */
758
759      
760
761    //$("#itineraryCont").css('display','');
762    //ProfiMapy.showItinerary(routeDataObject);
763
764
765  } else {
766    alert('Vyberte alespoň dva body'); // vyberte alespoň dva body
767  }
768
769
770}
771
772function showPointOnMap(id, skat) {
773  if (id) { 
774  
775   HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleSkat([{layerName:"poi",skat:skat}], true);
776   /*                
777   HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleObjectId(
778            "poi", id, true
779        );*/
780   
781   HSLayers.Apps.MapPortal.Rincon.ShowObject.showObjectInMapById(
782            id
783        );
784          
785   /*var idArray = id.split(" ");
786    MapAppLoader.getInstance().getAPI().searchObjectsById(
787          idArray,
788          {}
789      );   */
790  }
791    
792}
793
794
795//zpracovani bodu pobliz routy - rozparserovani JSON casti kde jsou souradnice
796function prepareNearRoutePoints(objects) {
797  var json = new OpenLayers.Format.JSON();
798  for (var i in objects) {
799    objects[i].go = json.read(objects[i].geometryOrigin);  
800  }  
801  return objects;
802}
803
804  //vraci seznam skatID ktere jsou zvoleny a k nim hodnotu predaneho parametru
805function getSelectedSkats(allwaysRetThis) {
806  var poisCont = jQuery('#obsahZalozek').find('.body-zajmu').eq(0);
807  var skats = [];
808  //if (allwaysRetThis) skats.push(allwaysRetThis);
809  if (!allwaysRetThis) var allwaysRetThis = 0;
810  poisCont.find('input[type=checkbox]').each(function(){    
811    if (this.checked) {
812      var arr = jQuery(this).val().split('-');
813      if (arr[1] != allwaysRetThis && arr[1] > 0)
814        skats.push(arr[1]);
815    }   
816  });
817    
818  return skats.join(',');
819}
820
821
822function setSortable(){
823	jQuery("#map_route_point").sortable();
824	jQuery("#map_route_point").disableSelection();
825};
826
827
828/***************************************************************************
829 * Callback funkce, ktera je vyvolana po vyhledani trasy
830 **************************************************************************/
831function findRouteCallback(route) {
832    var selectElement = HSLayers.Apps.Utility.getElement("itinerary");
833
834
835    $('#routeInfo').html('<h3>Délka trasy: ' + mapConvertNumber(route.info.length, '1000', true) + ' km </h3>');
836
837    var json = new OpenLayers.Format.JSON();
838    
839    routeDataInfo = json.write(route.info);
840
841
842    //routovani dokonceno -> nacteni bodu kolem routy 24.12.2012
843    try {
844      log('najit body kolem trasy');
845      var nearRouteDistance = 300;
846      var skats = '96'; //hodnoty oddelene carkou - vtzdy zvolena mesta a obce
847                     //nejprve nacteme extra obce a posleze pokud jsou dalsi tak dalsi body
848      var param = HSLayers.Apps.MapPortal.Rincon.ShowObject.getRoutingModule().getCore().getParamForFindObjectsNearOfRoute(nearRouteDistance, {skat:skats});
849      var url = 
850          'http://apps.hfbiz.cz/glog/Glog/entry.php?class=MapPortal.Rincon.RinconGeoSearchObjects&project=Rincon.CeskyRaj_poi&' +
851          'operation=buffer&';
852      var objectsNearRoute = null;    
853                      
854      OpenLayers.Request.POST({
855          url: url,
856          data: param,
857          success: function(request) { 
858            log('nalezene obce a mesta');
859            var json = new OpenLayers.Format.JSON();
860            var objects = json.read(request.responseText);
861            log(objects);
862            var routeObjectsMesta = prepareNearRoutePoints(objects.objects);
863            
864            var skats = getSelectedSkats('96'); //hodnoty oddelene carkou - vtzdy zvolena mesta a obce
865            
866            var onNearRouteFinish = function() {
867              try {
868                //routeData = json.write(route.info.itinerary);
869                log('New route data');
870                log(newRouteData);
871                jQuery.post('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=renderItinerary&lanG='+jQuery('#lanG').val(),
872                {
873                 routeData: routeData,
874                 routeDataInfo: routeDataInfo
875                },
876                function(xml){
877                  jQuery(xml).find('response').each(function(){
878                    if(jQuery(this).find('status').text() == 'OK'){
879          
880                      jQuery('#div_iterinar_ovl').show();
881                      jQuery('#div_iterinar').html(jQuery(this).find('routeData').text());
882                      initBuble();
883                      setSelectedRouteInstruction();
884          
885          
886                    } else {
887                      alert(jQuery(this).find('alert').text());
888                    }
889                 });
890              	}, "xml");
891                
892              } catch(e) {
893                log('toRoute error ' + e.message);
894              }
895            
896            };
897            
898            if (skats) { //mame jine zaskrtane skat
899              
900              if (jQuery('#nearRouteDistance').length > 0) nearRouteDistance = jQuery('#nearRouteDistance').val();
901              var param = HSLayers.Apps.MapPortal.Rincon.ShowObject.getRoutingModule(
901).getCore().getParamForFindObjectsNearOfRoute(nearRouteDistance, {skat:skats});
902              var url = 
903                  'http://apps.hfbiz.cz/glog/Glog/entry.php?class=MapPortal.Rincon.RinconGeoSearchObjects&project=Rincon.CeskyRaj_poi&' +
904                  'operation=buffer&';
905              var objectsNearRoute = null;    
906              //hledame dalsi poi ale blize k route
907              OpenLayers.Request.POST({
908                  url: url,
909                  data: param,
910                  success: function(request) {
911                      var json = new OpenLayers.Format.JSON();
912                      var objects = json.read(request.responseText);
913                      log('Nalezene objekty');
914                      log(objects);
915                      //HSLayers.Apps.MapPortal.Rincon.lastNearRouteFindedObjects = prepareNearRoutePoints(objects.objects); 
916                      //var objects = filterGasStation(objects.objects);
917                      //showGasStationObjects(objects); 
918                      var nearRouteObjects = prepareNearRoutePoints(objects.objects);
919                      //spojime pole s nalezenymi poi podel routy
920                      if (routeObjectsMesta.length) {
921                        //var newArray = [];
922                        for (var i in nearRouteObjects) {
923                          routeObjectsMesta.push(nearRouteObjects[i]);  
924                        }
925                        nearRouteObjects = routeObjectsMesta;
926                      }
927                      
928                      //log(route.info.itinerary);
929                      var newRouteData = {
930                        itinerary: route.info.itinerary,
931                        nearRouteObjects: nearRouteObjects  
932                      };
933                      //objectsNearRoute = json.write(nearRouteObjects);
934                      
935                      //routeDataObject.info.itinerary.nearPoints = objectsNearRoute;
936                      routeData = json.write(newRouteData);
937                      onNearRouteFinish(); 
938                                           
939                  }
940              }); 
941              
942            } else {
943              //mame pouze mesta, nehledame dalsi objetky
944              var newRouteData = {
945                itinerary: route.info.itinerary,
946                nearRouteObjects: routeObjectsMesta  
947              };
948              routeData = json.write(newRouteData);
949              onNearRouteFinish();
950            }
951            
952         }
953        });
954      
955    } catch (e) {
956      log('Chyba zjisteni bodu kolem routy ' + e.message );
957    }
958
959    
960
961
962
963};
964
965
966/* turisticka / ortofoto */
967function setBacgroundMap(layerName) {
968
969  HSLayers.Apps.MapPortal.Rincon.ShowObject.setBackgroundLayer(layerName);
970
971};
972
973function setVisibleLayer(layerName, id) {
974
975  HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleLayer(layerName,jQuery('#'+ layerName).is(':checked'));
976
977
978};
979
980
981// ovladani stromu vrstev
982function treeChange(idTree, show){
983  if(((document.getElementById('ul' + idTree).style.display == "none") && (show != 'no')) || (show == 'yes')){
984    document.getElementById('ul' + idTree).style.display = "";
985    document.getElementById('a' + idTree).innerHTML = '<img src="http://www.liberecky-kraj.cz/galerie/obrazky/image.php?img=119976&x=14&y=9" width="14px" height="9px" style="border:0; vertical-align:middle;" />';
986  } else if(((document.getElementById('ul' + idTree).style.display == "") && (show != 'yes')) || (show == 'no')){
987    document.getElementById('ul' + idTree).style.display = "none";
988    document.getElementById('a' + idTree).innerHTML = '<img src="http://www.liberecky-kraj.cz/galerie/obrazky/image.php?img=119977&x=14&y=9" width="14px" height="9px" style="border:0; vertical-align:middle;" />';
989  }
990}
991
992
993// ovladani vrstev
994function changeCategory(kat, skat){
995
996
997  if(skat == 0){
998
999    var elmArr = jQuery('input[id ^= mapKat-'+kat+'-]');
1000    for (i=0;i<=elmArr.length;i++){
1001
1002      var elmID = jQuery(elmArr[i]).attr("id");
1003      if(elmID != undefined){
1004
1005        var elmIDArr = elmID.split("-");
1006        if(elmIDArr[2] == 0){
1007          continue;
1008        }
1009
1010        if(jQuery('#mapKat-'+kat+'-0').is(':checked') == true){
1011          jQuery('#'+elmID).attr('checked', 'checked');
1012          jQuery('#catimg-'+kat+'-'+elmIDArr[2]).attr('src', jQuery('#catimg-'+kat+'-'+elmIDArr[2]).attr('src').replace('/mapico_na/','/mapico/'));
1013        } else {
1014          jQuery('#'+elmID).removeAttr('checked');
1015          jQuery('#catimg-'+kat+'-'+elmIDArr[2]).attr('src', jQuery('#catimg-'+kat+'-'+elmIDArr[2]).attr('src').replace('/mapico/','/mapico_na/'));
1016        }
1017
1018      } else {
1019        break;
1020      }
1021    }
1022
1023
1024  } else if (skat > 0){
1025
1026
1027    if(jQuery('#mapKat-'+kat+'-'+skat).is(':checked') == true){
1028      jQuery('#catimg-'+kat+'-'+skat).attr('src', jQuery('#catimg-'+kat+'-'+skat).attr('src').replace('/mapico_na/','/mapico/'));
1029      treeChange(kat, 'yes');
1030    } else {
1031      jQuery('#catimg-'+kat+'-'+skat).attr('src', jQuery('#catimg-'+kat+'-'+skat).attr('src').replace('/mapico/','/mapico_na/'));
1032      jQuery('#mapKat-'+kat+'-0').removeAttr('checked');
1033    }
1034
1035    if((jQuery('input[id ^= mapKat-'+ kat+']').length - 1) == jQuery('input[id ^= mapKat-'+ kat+']:checked').length){
1036      jQuery('#mapKat-'+kat+'-0').attr('checked', true);
1037    }
1038
1039  }
1040
1041
1042  var layerShow = "";
1043  var carka = "";
1044  var elmArr = jQuery('input[id ^= mapKat-]');
1045  for (i=0;i<elmArr.length;i++){
1046    var elmID = jQuery(elmArr[i]).attr("id");
1047    if(elmID != undefined){
1048      var elmIDArr = elmID.split("-");
1049      if(elmIDArr[2] == 0){
1050        continue;
1051      }
1052      if(jQuery('#mapKat-'+elmIDArr[1]+'-'+elmIDArr[2]).is(':checked') == true){
1053        jQuery('#catimg-'+elmIDArr[1]+'-'+elmIDArr[2]).attr('src', jQuery('#catimg-'+elmIDArr[1]+'-'+elmIDArr[2]).attr('src').replace('/mapico_na/','/mapico/'));
1054        treeChange(elmIDArr[1], 'yes');
1055        layerShow += carka + elmIDArr[2];
1056        carka = ",";
1057      } else {
1058        jQuery('#catimg-'+elmIDArr[1]+'-'+elmIDArr[2]).attr('src', jQuery('#catimg-'+elmIDArr[1]+'-'+elmIDArr[2]).attr('src').replace('/mapico/','/mapico_na/'));
1059      }
1060    }
1061  }
1062
1063  if(layerShow == ""){
1064    HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleSkat([{layerName:"poi",skat:"-1"}], true);
1065  } else {
1066    HSLayers.Apps.MapPortal.Rincon.ShowObject.setVisibleSkat([{layerName:"poi",skat:layerShow}], true);
1067  }
1068
1069
1070}
1071
1072function as4uMapShow(showType, data){
1073
1074  mapShowType = showType;
1075  if(mapShowType == 'set2fromGPS'){
1076    as4uMapGpsFormId = data;
1077  }
1078
1079
1080  recordIDglob = null;
1081  skatIDglob = null;
1082  katIDglob = null;
1083
1084  //map_winScroll = jQuery(window).scrollTop();
1085
1086  //noScrolPage();
1087
1088
1089  as4uPopup.show4map('defaultmap',jQuery(window).width()-80,jQuery(window).height()-20);
1090
1091  if(mapload == false){
1092
1093
1094
1095
1096
1097  } else {
1098
1099
1100  }
1101
1102}
1103
1104
1105// neni mozne posouvat se strankou dokud je zobrazena mapa
1106function noScrolPage(){
1107  if(jQuery('#map_transparent').css('display') != 'none'){
1108    jQuery('html, body').animate({scrollTop: map_winScroll+'px'}, 1);
1109    setTimeout('noScrolPage()',50);
1110  }
1111}
1112
1113
1114function as4uMapShowSize(aaWidth, aaHeight){
1115  aaWidth = aaWidth * 1;
1116  aaHeight = aaHeight * 1;
1117
1118  aaWidthOriginal = aaWidth;
1119  aaHeightOriginal = aaHeight;
1120
1121  if(document.getElementById('map_transparent').style.display != 'none'){
1122
1123  	if (window.innerHeight){
1124      wSizeH = window.innerHeight;
1125      wSizeW = window.innerWidth;
1126  	} else if (document.documentElement && document.documentElement.clientHeight){
1127  		wSizeH = document.documentElement.clientHeight;
1128  		wSizeW = document.documentElement.clientWidth;
1129  	} else if (document.body && document.body.clientHeight){
1130  		wSizeH = document.body.clientHeight;
1131  		wSizeW = document.body.clientWidth;
1132    }
1133
1134
1135    if(!jQuery.browser.msie){
1136      wSizeW = wSizeW - 20;
1137    }
1138    if(jQuery.browser.msie){
1139      var msieVersion = jQuery.browser.version.substring(0, 1);
1140      msieVersion = msieVersion * 1;
1141      if(msieVersion >= 9){
1142        wSizeW = wSizeW - 20;
1143      }
1144    }
1145
1146
1147    if(aaHeight > wSizeH){
1148      aaHeight = wSizeH - 40;
1149      aaWidth = aaWidth + 20;
1150    }
1151
1152    if(aaWidth > wSizeW){
1153      aaWidth = wSizeW - 20;
1154    }
1155
1156    if(wSizeH == 0){
1157    } else {
1158      document.getElementById('map_transparent').style.height = wSizeH + 'px';
1159      document.getElementById('map_transparent').style.width = wSizeW + 'px';
1160
1161      ajaxSizeObH = (aaHeight * 1) + 20;
1162      ajaxSizeObW = (aaWidth * 1);
1163
1164      document.getElementById('map_view').style.height = ajaxSizeObH + 'px';
1165      document.getElementById('map_view').style.width = ajaxSizeObW + 'px';
1166      document.getElementById('map_view_close').style.width = ajaxSizeObW + 'px';
1167
1168      ajaxSizeH = ajaxSizeObH - 20;
1169      ajaxSizeW = ajaxSizeObW;
1170
1171      document.getElementById('as4u_map_controls').style.height = ajaxSizeH + 'px';
1172
1173      jQuery('#obsahZalozek').css('height', ajaxSizeH - jQuery('.menuZalozek').outerHeight(true) - jQuery('.eu_banner_mapa').outerHeight(true));
1174
1175      document.getElementById('as4u_map').style.height = ajaxSizeH + 'px';
1176      document.getElementById('as4u_map').style.width = (ajaxSizeW - 300) + 'px';
1177
1178      posAjaxH = ((wSizeH - ajaxSizeObH) / 2);
1179      posAjaxW = ((wSizeW - ajaxSizeW) / 2);
1180
1181      if (document.documentElement && document.documentElement.scrollTop) {
1182        winScroll = document.documentElement.scrollTop;
1183      } else if (document.body) {
1184        winScroll = document.body.scrollTop;
1185      } else {
1186        winScroll = 0;
1187      }
1188
1189      document.getElementById('map_transparent').style.top = (winScroll) + 'px';
1190
1191      document.getElementById('map_view').style.top = (winScroll + posAjaxH) + 'px';
1192      document.getElementById('map_view').style.left = (posAjaxW) + 'px';
1193
1194      setTimeout('as4uMapShowSize(' + aaWidthOriginal + ', ' + aaHeightOriginal + ')', 100);
1195
1196    }
1197
1198  }
1199}
1200
1201function as4uMapClose(){
1202
1203  document.getElementById('map_transparent').style.display = 'none';
1204  document.getElementById('map_view').style.display = 'none';
1205
1206  //jQuery('div.stranka').css('display', '');
1207
1208}
1209
1210function afterSearch(){
1211  if(recordIDglob > 0 && skatIDglob > 0){
1212    for (var i = 0; i < 1000; i++) {
1213      if(jQuery('#c'+i).length > 0){
1214        var skatVal = jQuery('#c'+i).val().split("-");
1215        if(skatVal[1] == skatIDglob){
1216          jQuery('#c'+i).attr('checked', true);
1217          jQuery('#ul'+skatVal[0]).css('display', '');
1218          changeCategory(i, 's');
1219          break;
1220        }
1221      } else {
1222        break;
1223      }
1224    }
1225  }
1226}
1227
1228/* naseptavac adresa a bodu */
1229function initMapAutocomplete(elm) {
1230
1231  var el = $('#' + elm);
1232  if (el.length > 0) { //existuje element?
1233    //http://new.liberecky-kraj.cz/redakce/ajax.php?akce=naseptavac - url s XML vylsekdem naseptavani
1234    var urlXml = 'http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=naseptavac&lanG=' + jQuery('#lanG').val() + '&qelm=' + elm;
1235
1236    el.autocomplete({
1237      source: function(req, responseFn) {
1238        var findText = req.term;
1239        $.ajax({
1240          url: urlXml,
1241          dataType: 'xml',
1242          type: 'POST',
1243          data: 'q='+findText,
1244          success: function(xml) {
1245            var results = [];
1246            $(xml).find('item').each(function() {
1247                var value = $(this).find('vzhled').text();
1248                var text = $(this).find('hodnota').text();
1249                results[results.length] = { 'data': { text: text, value: value },
1250                    'result': text, 'value': value
1251                };
1252            });
1253            responseFn (results);
1254          }
1255
1256        });
1257      },
1258      width: parseInt($(el).width()),
1259  		max: 10,
1260  		delay: 200,
1261      open: function(){
1262        var offset = $(el).offset();
1263        $(this).autocomplete('widget').css('left', offset.left - ($(this).autocomplete('widget').width() - $(el).width()));
1264        return false;
1265      },
1266  		matchSubset: false,
1267  		scroll: true,
1268  		scrollHeight: 350,
1269  		selectFirst: false /*.result(function(event, item) {
1270
1271    })*/
1272    }).data( "autocomplete" )._renderItem = function( ul, item ) {
1273
1274      var offset = $(el).offset();
1275      $(ul).css({top:offset.top+(parseInt($(el).height())),position:'absolute',zIndex:50});
1276      $(ul).unbind('click');
1277
1278			return $( "<li></li>" )
1279        .bind('mouseover', function() { if (!$(this).hasClass('active')) $(this).addClass('active'); })
1280        .bind('mouseout', function() {$(this).removeClass('active'); })
1281				.data( "item.autocomplete", item )
1282				.append( item.label )
1283				.appendTo( ul );
1284
1285		};
1286
1287  }
1288}
1289
1290function setRouteType() {
1291
1292  var routeType = jQuery('#routeType').val();
1293
1294  HSLayers.Apps.MapPortal.Rincon.ShowObject.routingSetRouteType(routeType);
1295  HSLayers.Apps.MapPortal.Rincon.ShowObject.routingTryRoute();
1296};
1297
1298
1299function clearPath() {
1300
1301  HSLayers.Apps.MapPortal.Rincon.ShowObject.routingClearPath();
1302  jQuery('#routeInfo').html('');
1303  jQuery('#div_iterinar').html('');
1304  jQuery('#div_iterinar_ovl').hide();
1305  routeData = '';
1306
1307  var arrElm = jQuery('span[id ^= pointid_]');
1308  if(arrElm.length > 1){
1309    for (i=0;i<arrElm.length;i++){
1310      if(jQuery(arrElm[i]).html() != ''){
1311        mapAppAPI.removeUserPoint(userPoints[jQuery(arrElm[i]).html()]);
1312      }
1313    }
1314  }
1315
1316  jQuery('#map_route_point').html('');
1317
1318};
1319
1320function showPointOnMouse(){
1321  
1322  if(userPoints[1000] != undefined){
1323    mapAppAPI.removeUserPoint(userPoints[1000]);
1324  }
1325
1326  if(jQuery('#point').length == 0){
1327    var point = jQuery('<img id="point" src="http://www.as4u.cz/mapy/icons/public4u/point.png" style="position: absolute; z-index: 100;" />');
1328    jQuery('body').append(point);
1329  }
1330
1331  $(this).mousemove(function(e) {
1332      $("#point").css({
1333          left: e.pageX - 10,
1334          top: e.pageY - 20
1335      });
1336  });
1337  
1338  
1339}
1340
1341
1342function toItineraryFromMap() {
1343  
1344  //jQuery('.olMapViewport').css('cursor', 'url(/mapy/icons/public4u/point.png),auto');
1345  //jQuery('body').css('cursor', 'url(/mapy/icons/public4u/point.png),auto');
1346
1347  showPointOnMouse();
1348
1349  MapAppLoader.getInstance().getAPI().selectLocation(selectLocationDone, null);
1350}
1351
1352function selectLocationDone(x, y) {
1353
1354
1355  jQuery('#point').remove();
1356  
1357  var idNewElm = x + '_' + y;
1358
1359  for (i=0;i<5;i++){
1360    idNewElm = idNewElm.replace('-', '');
1361    idNewElm = idNewElm.replace('.', '');
1362  }
1363
1364  log('vkladaenID '+idNewElm);
1365  
1366  var $newLi = $('<li id="itinerar_poi_'+idNewElm+'">');
1367  $("#map_route_point").append($newLi);
1368
1369  
1370  jQuery.post('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=locationPointToItinerary&lanG='+jQuery('#lanG').val(),
1371    {
1372     x: x,
1373     y: y
1374    },
1375    function(xml){
1376      jQuery(xml).find('response').each(function(){
1377        if(jQuery(this).find('status').text() == 'OK'){
1378          //jQuery("#map_route_point").append(jQuery(this).find('elm').text());
1379          jQuery('#itinerar_poi_' + idNewElm).html(jQuery(this).find('elm').text());
1380
1381          var label = {
1382              text: "info o bodu 1",
1383              fontColor: "#000000",
1384              fontSize: "12px",
1385              fontFamily: "Arial",
1386              fontWeight: "bold",
1387              align: "rc"
1388          }
1389
1390          var iUserPoints = userPoints.length;
1391          mapAppAPI = MapAppLoader.getInstance().getAPI();
1392          userPoints[iUserPoints] = mapAppAPI.addUserPoint(
1393              x,
1394              y,
1395              "http://www.as4u.cz/mapy/icons/public4u/point.png", 20, 20,
1396              jQuery('#itinerar_poi_' + jQuery(this).find('pointid').text() + ' > strong').html(),
1397              jQuery('#itinerar_poi_' + jQuery(this).find('pointid').text() + ' > strong').html(),
1398              null
1399          );
1400          //jQuery('#pointid_' + jQuery(this).find('pointid').text()).html(iUserPoints);
1401          jQuery('#pointid_' + idNewElm).html(iUserPoints);
1402          completLoadWayPoint ++ ;
1403
1404        } else {
1405          alert(jQuery(this).find('alert').text());
1406        }
1407     });
1408  	}, "xml");
1409
1410
1411}
1412
1413function doItinerare(addid){
1414
1415  zobrazZalozku(1);
1416
1417  if(jQuery('#ajax_transparent').css('display') != 'none'){
1418    closeajax();
1419  }
1420  jQuery('.ui-autocomplete').css('display', 'none');
1421
1422  if(jQuery('#itinerar_poi_' + addid).length > 0){
1423
1424    alert(as4u_jsLang('Bod již v itineráři existuje!'));
1425
1426  } else {
1427
1428    if(jQuery("#map_route_point").length > 0){
1429    
1430      
1431      
1432      var $newLi = $('<li id="itinerar_poi_'+addid+'">');
1433      $("#map_route_point").append($newLi);
1434
1435      jQuery.get('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=toItinerarElm&dr='+addid+'&lanG='+jQuery('#lanG').val(),
1436        function(xml){
1437          jQuery(xml).find('response').each(function(){
1438            if(jQuery(this).find('status').text() == 'OK'){
1439              //jQuery("#map_route_point").append(jQuery(this).find('elm').text());
1440              jQuery('#itinerar_poi_' + addid).html(jQuery(this).find('elm').text());
1441              completLoadWayPoint ++ ;
1442            } else {
1443              jQuery('#itinerar_poi_' + addid).remove();
1444              alert(jQuery(this).find('alert').text());
1445            }
1446         });
1447      	}, "xml");
1448
1449    } else {
1450      map_toolsSwitch('set_route');
1451      setTimeout(function(){doItinerare(addid)}, 500);
1452    }
1453
1454  }
1455
1456}
1457
1458
1459function rmPointFromItinerar(id){
1460  jQuery('#itinerar_poi_'+id).hide('slow', function() {
1461  
1462    if(jQuery('#pointid_'+id).length > 0){
1463      if(jQuery('#pointid_'+id).html() != ''){
1464        mapAppAPI.removeUserPoint(userPoints[jQuery('#pointid_'+id).html()]);
1465      }
1466    }
1467  
1468    jQuery('#itinerar_poi_'+id).remove();
1469  });
1470
1471}
1472
1473
1474
1475
1476
1477// inicializace zalozek
1478/** Obecna inicializace zalozek
1479 *  - menu v ul seznamu -> pokud rel, prevede se na ajax volani, jinak prepinani obsahu
1480 *
1481 */
1482function obecneZalozky(id, beforeZalozkyClick) {
1483  if (typeof id == "string") {
1484    var el = $('#'+id);
1485  } else {
1486    var el = $(id);
1487  }
1488
1489  var toto = this;
1490  var obsahy = [];
1491  var zalozkyObsah = $('.obsahZalozek',el).eq(0);
1492
1493  el.find('#'+$(zalozkyObsah).attr('id')+' > .zalozkaObsah').each(function(index, element) {
1494
1495    obsahy.push($(element));
1496    if (index > 0) {
1497      $(element).css("display", "none");
1498    } else {
1499      $(element).addClass('aktivniZalozka');
1500    }
1501    $(element).css("top", "0");
1502    $(element).css("left", "0");
1503  });
1504
1505  $('#'+el.attr('id')+' > .menuZalozek').find('a').each(function(index, element) {
1506    $(element).attr('href', 'javascript:;');
1507    if (index == 0) {
1508      $(element).addClass('aktivniLinkZalozky');
1509    }
1510
1511    $(element).click(function(){
1512      if (typeof beforeZalozkyClick == "function") {
1513        if (!beforeZalozkyClick()) {
1514          return false;
1515        }
1516      }
1517
1518      var aktivni = el.find('#'+$(zalozkyObsah).attr('id')+' > .aktivniZalozka').eq(0);
1519      if (aktivni) {
1520        var aktHeight = $(aktivni).height();
1521
1522        $(aktivni).css('display', 'none');
1523        $(aktivni).removeClass('aktivniZalozka');
1524      }
1525      var aktivniLink = $('#'+el.attr('id')+' > .menuZalozek .aktivniLinkZalozky').eq(0);
1526      if (aktivniLink) {
1527        $(aktivniLink).removeClass('aktivniLinkZalozky');
1528      }
1529      if (obsahy[index]) {
1530        if (typeof aktHeight != "undefined") {
1531          obsahy[index].css('display', 'block');
1532          obsahy[index].css("height", 'auto');
1533          var finalheight = obsahy[index].height();
1534          obsahy[index].css("height", aktHeight);
1535          speedetimertime = 10;
1536          obsahy[index].css('overflow', 'hidden');
1537          obsahy[index].animate({
1538              height: finalheight
1539            },500,'',function() {
1540              obsahy[index].css("height", 'auto');
1541              speedetimertime = 500;
1542            });
1543
1544
1545
1546        } else {
1547            obsahy[index].css('display', 'block');
1548          }
1549        obsahy[index].addClass('aktivniZalozka');
1550      }
1551      $(element).addClass('aktivniLinkZalozky');
1552
1553
1554    });
1555  });
1556
1557}
1558
1559function zobrazZalozku(index){
1560  jQuery('.menuZalozek').find('a').removeClass('aktivniLinkZalozky');
1561  jQuery('.menuZalozek > ul > li:eq('+index+') > a').addClass('aktivniLinkZalozky');
1562
1563  jQuery('.zalozkaObsah').removeClass('aktivniZalozka');
1564  jQuery('.zalozkaObsah').css('display', 'none');
1565
1566  jQuery('#obsahZalozek > div:eq('+index+')').addClass('aktivniZalozka');
1567  jQuery('#obsahZalozek > div:eq('+index+')').css('display', '');
1568
1569}
1570
1571
1572function findInMap(fromElm, returnTo){
1573
1574
1575
1576    var find_string = jQuery('#' + fromElm).val();
1577
1578    as4uAjaxAlertShow('440', '600');
1579
1580
1581    jQuery('#ajax_transparent').css('z-index', '150');
1582    jQuery('#ajax_view').css('z-index', '151');
1583
1584    document.getElementById('ajax_content').innerHTML = "<img src='/images/gallery/loading.gif' width='50px' height='50px' />";
1585
1586
1587    jQuery('#ajax_content').load('http://'+location.host+'/redakce/ajax.php?akce=mapa&htmlAjax=yes&subakce=searchwindow&lanG=' + jQuery('#lanG').val(), function() {
1588
1589      jQuery.post('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=naseptavac&returnLimit=200&lanG=' + jQuery('#lanG').val() + '&qelm=' + fromElm,
1590        {
1591         q: jQuery("#"+fromElm).val()
1592        },
1593        function(xml){
1594          jQuery(xml).find('response').each(function(){
1595            var dataStr = '';
1596            var dataArr = jQuery(this).find('vzhled');
1597
1598            if(dataArr.length > 0){
1599              for (i=0;i<=dataArr.length;i++){
1600                 dataStr += '<li>' + jQuery(dataArr[i]).text() + '</li>';
1601              }
1602              jQuery("#map_search_poi_return").html(dataStr);
1603            } else {
1604              jQuery("#map_search_poi_return").html('<li>' + jQuery('#map_search_status_noreturn').html() + '</li>');
1605            }
1606            jQuery('#map_search_status').hide();
1607            jQuery('#map_search_poi_div').show();
1608
1609         });
1610      	}, "xml");
1611
1612
1613    });
1614
1615
1616}
1617
1618function generatePDF(url2routeProfile){
1619
1620  var context = HSLayers.Apps.MapPortal.Rincon.ShowObject.getPrintContext();
1621
1622  jQuery.post('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=generatePDF&lanG=' + jQuery('#lanG').val(),
1623    {
1624     dataPrint: context,
1625     url2routeProfile: url2routeProfile,
1626     routeData: routeData
1627    },
1628    function(xml){
1629      jQuery(xml).find('response').each(function(){
1630        if(jQuery(this).find('status').text() == 'OK'){
1631          jQuery('#map_pdf_link').html(jQuery(this).find('link2pdf').text());
1632
1633          jQuery('#pdfLoad').submit();
1634
1635        } else {
1636          alert(jQuery(this).find('alert').text());
1637        }
1638     });
1639  	}, "xml");
1640
1641
1642}
1643
1644function savePathDialog(){
1645  as4uAjaxAlertShow('605', '305');
1646  
1647  jQuery('#ajax_transparent').css('z-index', '150');
1648  jQuery('#ajax_view').css('z-index', '151');
1649  
1650  jQuery('#ajax_content').load('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=savePathDialog&htmlAjax=yes&routeid=' + jQuery('#routeid').val() + '&lanG=' + jQuery('#lanG').val());
1651
1652}
1653
1654function savePath(routeid){
1655
1656  //var arrElm = jQuery('.itinerar_gps');
1657  var arrElm = jQuery('li[id ^= itinerar_poi_]');
1658  if(arrElm.length > 1){
1659
1660    var carka = '';
1661    var points = '';
1662    var idElms = '';
1663    for (i=0;i<arrElm.length;i++){
1664      var elmAddID = jQuery(arrElm[i]).attr("id");
1665      points += carka + jQuery('#'+elmAddID).find('.itinerar_gps').html();
1666      idElms += carka + elmAddID.substring(13);
1667      
1668      
1669      carka = ",";
1670
1671
1672    }
1673
1674    var routeType = jQuery('#routeType').val();
1675    
1676    
1677    jQuery.post('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=savePath&lanG=' + jQuery('#lanG').val(),
1678      {
1679       routeid: routeid,
1680       points: points,
1681       idElms: idElms,
1682       routeType: routeType,
1683       route_name: jQuery("#route_name").val(),
1684       route_description: jQuery("#route_description").val()
1685      },
1686      function(xml){
1687        jQuery(xml).find('response').each(function(){
1688          if(jQuery(this).find('status').text() == 'OK'){
1689            alert(jQuery(this).find('alert').text());
1690            reloadCartMapPaths(jQuery(this).find('routeid').text());
1691            closeajax();
1692          } else {
1693            alert(jQuery(this).find('alert').text());
1694          }
1695       });
1696    	}, "xml");
1697
1698  }
1699
1700}
1701
1702function reloadCartMapPaths(id){
1703
1704  jQuery('#routeid').load('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=reloadCartMapPaths&htmlAjax=yes&lanG=' + jQuery('#lanG').val(), function() {
1705    if(id > 0){
1706      jQuery('#routeid').val(id);
1707    }
1708  });
1709
1710}
1711
1712function deletePathDialog(){
1713
1714  if(jQuery('#routeid').val() > 0){
1715
1716    if (confirm("Opravdu chcete smazat vybranou trasu?")){
1717
1718      jQuery.get('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=deletePath&routeid=' + jQuery('#routeid').val() + '&lanG=' + jQuery('#lanG').val(),
1719        function(xml){
1720          jQuery(xml).find('response').each(function(){
1721            if(jQuery(this).find('status').text() == 'OK'){
1722              alert(jQuery(this).find('alert').text());
1723            } else {
1724              alert(jQuery(this).find('alert').text());
1725            }
1726            reloadCartMapPaths(0);
1727            clearPath();
1728         });
1729      	}, "xml");
1730    }
1731  } else {
1732    alert('Není vybrána trasa!');
1733  }
1734}
1735
1736function showSawedRoute(routeID){
1737
1738  completLoadWayPoint = 0;
1739  
1740  clearPath();
1741
1742  if(routeID == null){
1743    routeID = jQuery('#routeid').val();
1744  }
1745
1746  if(routeID > 0){
1747
1748    jQuery.get('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=loadPath&lanG=' + jQuery('#lanG').val() + '&id=' + routeID,
1749      function(xml){
1750        jQuery(xml).find('response').each(function(){
1751          if(jQuery(this).find('status').text() == 'OK'){
1752            var idElmsArr = jQuery(this).find('idElms').text().split(",");
1753            var pointsArr = jQuery(this).find('points').text().split(",");
1754
1755            jQuery('#routeType').val(jQuery(this).find('routeType').text());
1756
1757
1758            for (var i = 0; i < idElmsArr.length; i++) {
1759              //var n = idElmsArr[i].indexOf("_");
1760              if(idElmsArr[i].indexOf("_") > 0){
1761                var pointsThis = pointsArr[i].split(" ");
1762                selectLocationDone(pointsThis[0], pointsThis[1]);
1763              } else {
1764                doItinerare(idElmsArr[i]);
1765              }
1766
1767            }
1768
1769            setTimeout(function(){generateRouteAfterLoadWayPoints(i)}, 100);
1770
1771          } else {
1772            alert(jQuery(this).find('alert').text());
1773          }
1774       });
1775    	}, "xml");
1776  
1777  }
1778
1779}
1780
1781
1782function generateRouteAfterLoadWayPoints(totalLoadWayPoint){
1783  if(completLoadWayPoint == totalLoadWayPoint){
1784    toRoute();
1785  } else {
1786    setTimeout(function(){generateRouteAfterLoadWayPoints(totalLoadWayPoint)}, 100);
1787  }
1788}
1789
1790
1791// obecne funkce - vrati GPS pozici
1792function switchMapToGpsReturn(){
1793  showPointOnMouse();
1794  MapAppLoader.getInstance().getAPI().selectLocation(setLocation2form, null);
1795}
1796
1797function setLocation2form(x,y){
1798  jQuery('#point').remove();
1799  if(as4uMapGpsFormId > 0){
1800    var formid = '_' + as4uMapGpsFormId;
1801  }else{
1802    var formid = '';
1803  }
1804  log(formid);
1805
1806  jQuery.get('http://' + location.hostname + '/mapy/proxy.php?url=' + encodeURIComponent('http://apps.hfbiz.cz/glog/Glog/entry.php?class=Tools.Reproject&srsIn=epsg:2065&srsOut=epsg:4326&coords=' + x + ' ' + y ),
1807    function(data){
1808      var wgsArr = data.split(' ');
1809
1810      var gpsNs = Math.floor(wgsArr[2]);
1811      var gpsNmNonRound = (wgsArr[2] - gpsNs) * 60;
1812      var gpsNm = Math.floor(gpsNmNonRound);
1813      var gpsNv = Math.round((gpsNmNonRound - gpsNm) * 60);
1814
1815      var gpsEs = Math.floor(wgsArr[1]);
1816      var gpsEmNonRound = (wgsArr[1] - gpsEs) * 60;
1817      var gpsEm = Math.floor(gpsEmNonRound);
1818      var gpsEv = Math.round((gpsEmNonRound - gpsEm) * 60);
1819      
1820      jQuery('#gpsNs' + formid).val(gpsNs);
1821      jQuery('#gpsNm' + formid).val(gpsNm);
1822      jQuery('#gpsNv' + formid).val(gpsNv);
1823      
1824      jQuery('#gpsEs' + formid).val(gpsEs);
1825      jQuery('#gpsEm' + formid).val(gpsEm);
1826      jQuery('#gpsEv' + formid).val(gpsEv);
1827      
1828
1829      as4uSaveGpsForm(as4uMapGpsFormId);
1830
1831      as4uPopup.close();
1832      
1833  	});
1834}
1835
1836/***************************************************************************
1837 * Vypocet vyskoveho profilu pro nalezenou trasu. Parametr type muze byt :
1838 * - chartUrl - sluzba vrati URL grafu
1839 * - data - sluzba vrati data pro vyskovy profil
1840 **************************************************************************/
1841function calcElevationProfile(type) {
1842  if(type == "show"){
1843    as4uAjaxAlertShow('605', '305');
1844
1845    jQuery('#ajax_transparent').css('z-index', '150');
1846    jQuery('#ajax_view').css('z-index', '151');
1847
1848    document.getElementById('ajax_content').innerHTML = "<img src='/images/gallery/loading.gif' width='50px' height='50px' />";
1849
1850    typeGenerate = 'chartUrl';
1851  } else if (type == "print"){
1852
1853    as4uAjaxAlertShow('300', '200');
1854
1855    jQuery('#ajax_transparent').css('z-index', '150');
1856    jQuery('#ajax_view').css('z-index', '151');
1857
1858    jQuery('#ajax_content').load('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=waiting2pdf&htmlAjax=yes&lanG=' + jQuery('#lanG').val());
1859
1860    typeGenerate = 'chartUrl';
1861  } else {
1862    typeGenerate = type;
1863  }
1864
1865  var points = HSLayers.Apps.MapPortal.Rincon.ShowObject.getRoutingModule().getCore().getRoutePointsInOrder();
1866  if (points.length > 0) {
1867      var lineString = "";
1868      for (var i = 0; i < points.length; i++) {
1869          if (lineString != "") {
1870              lineString += ",";
1871          }
1872          lineString += points[i][0] + " " + points[i][1];
1873      }
1874      var data = "{outputType:\"" + typeGenerate + "\",line:\"" + lineString + "\"}";
1875
1876      var url = "http://apps.hfbiz.cz/glog/Glog/entry.php?class=MapPortal.Dmt.GetElevationProfile&project=CrElevationProfile";
1877      OpenLayers.Request.POST({
1878          url: url,
1879          data: data,
1880          success: function(request) {
1881              var json = new OpenLayers.Format.JSON();
1882              var data = json.read(request.responseText);
1883              if (data && data.status == "OK") {
1884                  if (type == "data") {
1885                    var data = data.response.data;
1886                  } else if (type == "print"){
1887                    generatePDF(data.response.chartUrl);
1888                  } else if(type == "show"){
1889                    var chartUrl = data.response.chartUrl;
1890                    document.getElementById('ajax_content').innerHTML = '<a href="javascript:closeajax()"><img src="'+chartUrl+'"  /></a>';
1891                  }
1892              } else {
1893                  alert("Error");
1894              }
1895          },
1896          failure: function(request) {
1897              alert("Error");
1898          }
1899      });
1900  } else {
1901      alert("Není vyhledaná žádná trasa");
1902  }
1903};
1904
1905function downloadMap(type){
1906
1907  as4uAjaxAlertShow('300', '200');
1908
1909  jQuery('#ajax_transparent').css('z-index', '150');
1910  jQuery('#ajax_view').css('z-index', '151');
1911  jQuery("#ajax_content").css('backgroundColor', 'white');
1912
1913  jQuery('#ajax_content').load('http://'+document.location.host+'/redakce/ajax.php?akce=mapa&subakce=waiting2pdf&htmlAjax=yes&type=' + type + '&lanG=' + jQuery('#lanG').val());
1914
1915
1916  var context = HSLayers.Apps.MapPortal.Rincon.ShowObject.getPrintContext();
1917  jQuery.post('http://'+location.host+'/redakce/ajax.php?akce=mapa&subakce=generatePDF&lanG=' + jQuery('#lanG').val(),
1918    {
1919     dataPrint: context,
1920     url2routeProfile: 'maponly',
1921    },
1922    function(xml){
1923      jQuery(xml).find('response').each(function(){
1924        if(jQuery(this).find('status').text() == 'OK'){
1925          jQuery('#map_pdf_link').html(jQuery(this).find('link2pdf').text());
1926
1927          jQuery('#pdfLoad').submit();
1928
1929        } else {
1930          alert(jQuery(this).find('alert').text());
1931        }
1932     });
1933  	}, "xml");
1934
1935}
1936
1937
1938/* bubliny */
1939function initBuble(){
1940
1941  var elmArr = jQuery('.as4uT2B');
1942  for (i=0;i<=elmArr.length;i++){
1943    var bubleContent = '';
1944    if(jQuery(elmArr[i]).attr('title')){
1945      bubleContent = jQuery(elmArr[i]).attr('title');
1946    } else if(jQuery(elmArr[i]).attr('alt')){
1947      bubleContent = jQuery(elmArr[i]).attr('alt');
1948    }
1949    if(bubleContent != ''){
1950      jQuery(elmArr[i]).attr('onmouseover', 'showBubleInfoFromTitle(this,\''+jQuery(elmArr[i]).attr('title')+'\',event);');
1951      jQuery(elmArr[i]).attr('onmouseout', 'hideBubbleInfoFromTitle(this)');
1952      jQuery(elmArr[i]).attr('title', '');
1953      jQuery(elmArr[i]).attr('alt', '');
1954    }
1955
1956  }
1957}
1958
1959
1960function hideBubbleInfoFromTitle(el) {
1961  profiPopup.close(0);
1962  jQuery(el).removeClass('bubbleOpen');
1963}
1964
1965function showBubleInfoFromTitle(el, title, event) {
1966  profiPopup.close(0);
1967  if (!jQuery(el).hasClass('bubbleOpen')){
1968    jQuery(el).addClass('bubbleOpen');
1969    profiPopup.show(title,100,'auto', event, 'onmouseover');
1970  }
1971  return false;
1972}
1973
1974
1975
1976/* *** As4u mapy *** */
1977
1978function mapConvertNumber(number, div, rnd) {
1979  var num = parseInt(number) / parseInt(div);
1980  if (rnd) {
1981    var rndCoef = '1';
1982    for (var j = 1; j <= rnd; j++) {
1983      rndCoef += '0';
1984    }
1985    num = Math.round(num*rndCoef)/rndCoef;
1986  }
1987  num = num + '';
1988  num = num.replace(".", ",");
1989
1990  if (num > 999) {
1991    var parts = num.split(",");
1992    var fullPart;
1993    for (var i=3; i < parts[0].length; i += 3) {
1994      fullPart =  parts[0].substr(parts[0].length-i,3) + ' ' + fullPart;
1995    }
1996    num = fullPart + (parts[1] ?  ',' + parts[1] : '');
1997  }
1998  return num;
1999};
2000
2001
2002
2003
2004/** *************************************************************************
2005*           Vyskakovaci okna upravena pro tooltip ucely
2006*
2007*/
2008
2009  /** Vyskakovaci okno
2010 *  v 1.2.2
2011 */
2012function ProfiPopup() {
2013  this.overlay = [];
2014  this.dataContainer = [];
2015  this.dataContainerBubbleTop = [];
2016  this.dataContainerBubbleMiddle = [];
2017  this.dataContainerBubbleBottom = [];
2018  this.dataContainerClose = [];
2019  this.dataContainerIn = [];
2020  this.dataContainerLista = [];
2021  this.nooverlay = true; //nezobrazovat overlay
2022  this.counter = 0;
2023  this.afterDataLoaded = "";
2024  var obj = this;
2025  $(document).mousemove(function(e){
2026     obj.reposition(350,'auto',e);
2027  });
2028}
2029
2030
2031                                             //novinka - prijimame i mouse event kvuli pozici kurzoru
2032ProfiPopup.prototype.show = function(html,cw,ch,mouseevent,eventType) {
2033    var profi = this;
2034    if (!this.overlay) {
2035      this.overlay = [];
2036    }
2037    if (eventType == 'onmouseover') {
2038      this.close(0);
2039      var counter = this.counter = 0;
2040    } else {
2041      this.counter++;
2042      var counter = this.counter;
2043    }
2044    //if (!this.overlay) {
2045    var isoverlay = this.nooverlay;
2046
2047    for (var i=0; i < this.overlay.length;i++) {
2048      if (this.overlay[i]) {
2049        if (this.overlay[i].attr('id')) {
2050          isoverlay = true;
2051        }
2052      }
2053    }
2054
2055    if (!isoverlay) {
2056      var overlayheight = $(window).height() > $('body').height() ? $(window).height() : $('body').height();
2057      this.overlay[this.counter] = $('<div>', {
2058                      id: "profiPopupOverlay"+this.counter,
2059                      'class': "profiPopupOverlay",
2060                      click: function(){
2061                        profi.close(counter);
2062                      }
2063                    }).appendTo('body').css("width",$('body').width()).css("height",overlayheight).css("opacity",0.5);
2064    }
2065    if (this.mouseMoveEvent) var mouseevent = this.mouseMoveEvent;
2066    var positions = this.countPosition(cw,ch,mouseevent);
2067    var cw = positions[0];
2068    var ch = positions[1];
2069    var top = positions[2];
2070    var left = positions[3];
2071    var isLeft = positions[4];
2072    var isTop = positions[5];
2073
2074    //create data container
2075
2076    this.dataContainer[this.counter] = $('<div>',{ id: "profiPopupDataContainer"+this.counter, 'class': "profiPopupDataContainer"
2077              }).appendTo('body').css("width", cw).css("height",ch).css("top",top).css("left",left).css("z-index", "666666");
2078
2079    var className = (isLeft == true) ? "profiPopupDataContainerBubbleTopI" : "profiPopupDataContainerBubbleTop";
2080    if (isTop) {
2081      className = "profiPopupDataContainerBubbleTopNo";
2082    }
2083    var classNameBottom = (isTop == true) ? ((isLeft == true) ? "profiPopupDataContainerBubbleBottomIL" : "profiPopupDataContainerBubbleBottomI" ) : "profiPopupDataContainerBubbleBottom";
2084
2085    this.dataContainerBubbleTop[this.counter] = $('<div>', { 'class': className , id : 'profiPopupDataContainerBubbleTop'+this.counter}).appendTo(this.dataContainer[this.counter]);
2086
2087    this.dataContainerBubbleMiddle[this.counter] = $('<div>', { 'class': "profiPopupDataContainerBubbleMiddle" }).appendTo(this.dataContainer[this.counter]);
2088
2089    this.dataContainerBubbleBottom[this.counter] = $('<div>', { 'class': classNameBottom, id : 'profiPopupDataContainerBubbleBottom'+this.counter }).appendTo(this.dataContainer[this.counter]);
2090
2091
2092    this.dataContainerIn[this.counter] = $('<div>',{ id: "profiPopupDataContainerIn"+this.counter, 'class': "profiPopupDataContainerIn"
2093              }).appendTo(this.dataContainerBubbleMiddle[this.counter]);
2094
2095    //nastaveni dragable
2096    this.dataContainer[this.counter].draggable({handle:profi.dataContainerLista[profi.counter]});
2097
2098    if (html) {
2099      this.loadData(html);
2100    } else {
2101      this.reposition(cw,ch,mouseevent);
2102      return this.counter;
2103    }
2104    this.reposition(cw,ch,mouseevent);
2105
2106};
2107
2108ProfiPopup.prototype.reposition = function(cw,ch,mouseevent) {
2109  try {
2110    this.mouseMoveEvent = mouseevent;
2111    var positions = this.countPosition(cw,ch,mouseevent);
2112    var cw = positions[0];
2113    var ch = positions[1];
2114    var top = positions[2];
2115    var left = positions[3];
2116    var isLeft = positions[4];
2117    var isTop = positions[5];
2118    var counter = this.counter;
2119    var className = (isLeft == true) ? "profiPopupDataContainerBubbleTopI" : "profiPopupDataContainerBubbleTop";
2120    if (isTop) {
2121      className = "profiPopupDataContainerBubbleTopNo";
2122    }
2123    var classNameBottom = (isTop == true) ? ((isLeft == true) ? "profiPopupDataContainerBubbleBottomIL" : "profiPopupDataContainerBubbleBottomI" ) : "profiPopupDataContainerBubbleBottom";
2124
2125
2126    $('#profiPopupDataContainerBubbleTop'+counter).removeClass( $('#profiPopupDataContainerBubbleTop'+counter).attr('class') );
2127    $('#profiPopupDataContainerBubbleTop'+counter).addClass(className);
2128
2129    $('#profiPopupDataContainerBubbleBottom'+counter).removeClass( $('#profiPopupDataContainerBubbleBottom'+counter).attr('class') );
2130    $('#profiPopupDataContainerBubbleBottom'+counter).addClass(classNameBottom);
2131
2132    this.dataContainer[this.counter].css("width", cw).css("height",ch).css("top",top).css("left",left);
2133    /*
2134    if ($('#debugJs')) {
2135      $('#debugJs').html('Isleft : ' + isLeft + '<br />Class : ' + className + '<br />top: '+ top + '<br />left: '+left);
2136    } */
2137
2138  } catch(e) {}
2139}
2140
2141ProfiPopup.prototype.countPosition = function (cw,ch,mouseevent) {
2142
2143
2144  if (!cw) {
2145    var cw = Math.round($(window).width()*0.6);
2146  }
2147  if (!ch) {
2148    var ch = Math.round($(window).height()*0.75);
2149  }
2150  if (ch != 'auto') {
2151    if (ch+80 > $(window).height()) {
2152      var ch = Math.round($(window).height()-105);
2153    }
2154  }
2155  if (ch == 'auto' && !mouseevent && cw != 'auto') {
2156    ch = cw;
2157  }
2158
2159  var isLeft = false;
2160  var isTop = false;
2161
2162  //alert( mouseevent.pageX );
2163  //alert( $(window).width() - 325 );
2164
2165  if (mouseevent) {
2166    if ($('#profiPopupDataContainer'+this.counter).length > 0) {
2167      var bHeight = $('#profiPopupDataContainer'+this.counter).height(); //vyska bubliny
2168    } else {
2169      var bHeight = 50;
2170    }
2171    isLeft = (mouseevent.pageX > $(window).width() - 325);
2172    if (bHeight + mouseevent.pageY > $(window).height()+$(window).scrollTop()) {
2173      isTop = true;
2174    }
2175    //musime spocitat horni vs dolni pozici
2176
2177    var top = (isTop == false) ? Math.round(mouseevent.pageY) + 20 : Math.round(mouseevent.pageY) - bHeight - 3;
2178    var left = (isLeft == false) ? Math.round(mouseevent.pageX) + (isTop == false ? 10 : 0) : Math.round(mouseevent.pageX) - 350;
2179  } else {
2180    var top = Math.round($(window).height()/2 - (ch)/2 - 65/2);
2181    var left = Math.round($(window).width()/2 - cw/2);
2182  }
2183
2184  return [cw, ch, top, left, isLeft, isTop];
2185
2186};
2187
2188ProfiPopup.prototype.close = function(id) {
2189    try {
2190
2191      if (!id) {
2192        var id = this.counter;
2193      }
2194      if (this.overlay[id])
2195        this.overlay[id].detach();
2196        this.overlay[id] = '';
2197      if (this.dataContainer[id].length > 0)
2198        this.dataContainer[id].detach();
2199      $('#profiPopupDataContainer'+id).detach();
2200      //$("#tooltip_preload .show").removeClass('shown');
2201    } catch(e) {}
2202};
2203
2204ProfiPopup.prototype.loadData = function(html,plus) {
2205    var profi = this;
2206    var counter = this.counter;
2207    this.dataContainerIn[this.counter].css("background",'url(/images/gallery/loading.gif) no-repeat scroll center center #FFFFFF');
2208    //$.ajax({ url: url,
2209    //  success: function(html){
2210        profi.dataContainerIn[counter].css("background",'transparent');
2211        //profi.dataContainer[counter].show();
2212        if (!plus) {
2213          profi.dataContainerIn[counter].html(html);
2214        } else {
2215          profi.dataContainerIn[counter].html(html+profi.dataContainerIn[counter].html());
2216        }
2217        if (typeof profi.afterDataLoaded == "function") { //callback
2218          profi.afterDataLoaded();
2219          profi.afterDataLoaded = "";
2220        }
2221     //}});
2222};
2223
2224ProfiPopup.prototype.move = function(x,y) {
2225  //this.dataContainer[this.counter].css("top",y).css("left",x)
2226}
2227
2228var profiPopup = new ProfiPopup();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.