      

    var icoTownS;    
    var icoTownM;
    var icoTownB;
    
    var idMaps = null;
    var mapWidth,mapHeight;
    var cityMaxZoom;
    var itemsUrl;
    var utilsUrl = "/_utils/";
    
    var idlayers = new Array("7","8","10"); // tablica z id dostepnych warstw na tej mapie
    var idtypes= new Array("2","1","3"); // tablica z id typow dostepnych obiektow na tej mapie
    var hmoOnLayers= {"lay_7":0,"lay_8":0,"lay_10":0}; //tablica licznik obiektow w tabach 
    var markerManager;
    
    var baseIcon4346 = new GIcon();  
    baseIcon4346.iconSize=new GSize(43,46);  
    baseIcon4346.shadowSize=new GSize(43,46);  
    baseIcon4346.iconAnchor=new GPoint(21,46);  
    baseIcon4346.infoWindowAnchor=new GPoint(30,0);
         
    function configureMap(){
      idMaps = 4;
      mapWidth = 678;
      mapHeigth = 450;
      cityMaxZoom = 10;
      icoTownS = new GIcon(baseIcon12, "/_items/bzwbk.pl/mm/img/ico_city12x12.png", null, "");    
      icoTownM = new GIcon(baseIcon16, "/_items/bzwbk.pl/mm/img/ico_city16x16.png", null, "");
      icoTownB = new GIcon(baseIcon20, "/_items/bzwbk.pl/mm/img/ico_city20x20.png", null, "");
      icoCluster = new GIcon(baseIcon4346, "/_items/bzwbk.pl/mm/img/ico_green_std.png", null, "");
      itemsUrl = "/_items/bzwbk.pl/";
      
      templateDIV = {"7":["\" + Lokalizacja + \"<br \/><b>\" + Ulica + \"<\/b><br \/>"],"8":["\" + Nazwa + \"<br \/><b>\" + Ulica + \"<\/b><br \/>"],"10":["\" + Lokalizacja + \"<br \/><b>\" + Ulica + \"<\/b><br \/>"]};
templateIW = {"7":["<div class=\\\"infos_header\\\"><p><label class=\\\"lay_title\\\">\" + pname + \"<\/label><\/p><\/div><div class=\\\"infos_location\\\"><p><label class=\\\"info_bold\\\">\" + Lokalizacja + \"<\/label><\/p><p><label class=\\\"info_bold\\\">\" + Ulica + \"<\/label><\/p><p><label class=\\\"info\\\">\" + Miasto + \"<\/label><\/p><p><\/div><div class=\\\"infos_details\\\"><label class=\\\"info\\\">Dost\u0119pno\u015b\u0107:<\/label><label class=\\\"info_bold\\\"> \" + Dostepnosc + \"<\/label><\/p><\/div>"],"8":["<div class=\\\"infos_header\\\"><label class=\\\"lay_title\\\"> \" + Nazwa + \"<\/label><\/div><div class=\\\"infos_location\\\"><p><label class=\\\"info_bold\\\">\" + Ulica + \"<\/label><\/p><p><label class=\\\"info\\\">\" + Kod + \" \" + Miasto + \"<\/label><\/p><\/div><div class=\\\"infos_details\\\"><p><label>Numer telefonu:<\/label><label class=\\\"info_bold\\\"> \" + Nr_telefonu + \"<\/label><\/p><p><label>Fax:<\/label><label class=\\\"info_bold\\\"> \" + Fax + \"<\/label><\/p><p><label>Godziny otwarcia:<\/label><label class=\\\"info_bold\\\">  \" + Godziny_pracy + \"<\/label><\/p><\/div>"],"10":["<div class=\\\"infos_header\\\"><p><label class=\\\"lay_title\\\">\" + pname + \"<\/label><\/p><\/div><div class=\\\"infos_location\\\"><p><label class=\\\"info_bold\\\">\" + Lokalizacja + \"<\/label><\/p><p><label class=\\\"info_bold\\\">\" + Ulica + \"<\/label><\/p><p><label class=\\\"info\\\">\" + Miasto + \"<\/label><\/p><p><\/div><div class=\\\"infos_details\\\"><label class=\\\"info\\\">Dost\u0119pno\u015b\u0107:<\/label><label class=\\\"info_bold\\\"> \" + Dostepnosc + \"<\/label><\/p><\/div>"]};
templateIWList = {"7":["<b>\" + Lokalizacja + \"<\/b>  \" + Ulica + \"<br \/>"],"8":["<b>\" + Nazwa + \" <\/b> \" + Ulica + \"<br \/>"],"10":["<b>\" + Lokalizacja + \"<\/b>  \" + Ulica + \"<br \/>"]};
           
    }


///----------------- chmurki
 
  /**
   * Pokaz liste z obiektami w chmurce Google
   */     
  function showInfoWindowList(marker,coordObj){
      
    var infoObj;
    var tabs= [];
    var tabsHtml;
    var hmo = coordObj.hmo;
    var hml = coordObj.lays.length;
    
    if (hml > 0){
        //stworz obiekty przechowujace html dla kazdej warstwy lay_NRWARSTWY
        for (var i=0;i<hml;i++) {
          eval ("lay_"+ coordObj.lays[i] + " = \'\'");      
        }
        //dla kazdego obiektu
        for (var obj=0;obj<hmo;obj++){
          infoObj = coordObj[obj];
        //pobierz informacje na temat tego obiektu (lista chmurki google)
          eval ("lay_"+ infoObj.idl + " += getObjectInfo(infoObj,1)");
              
        }
        var winHeight = 0.5 * mapHeight;
        var winWidth = 0.9 * mapWidth;
        // umiesc stworzone htmle w tabsach
        for (var i=0;i<hml;i++) {          
            tabs.push(new GInfoWindowTab(coordObj.laysname[i],
            "<div class=\'iefix\' style=\'height:" + winHeight + "px;overflow-x:hidden;overflow-y:auto\'><a href=\'javascript:printListDiv();\'>Drukuj list&#x119;</a>" + eval("lay_"+coordObj.lays[i]) +" &nbsp;&nbsp;&nbsp;<br /></div>"));
        }
        cityMarker.openInfoWindowTabsHtml(tabs,{"maxWidth":winWidth}); 
        //cityMarker.openInfoWindowTabsHtml(tabs); 
        
        iwTabs = tabs;   
    }else {
      cityMarker.openInfoWindow(getInfoNoObjects());
      clearAllInfoObjDiv();
    }    
  }
  
  
  function getImageForType(type){
    if (type === "Bank 24h"){
      return "<a href=\'/50667\' target=\'_blank\'>" + "<img src=\'/_items/mm/images/ico_bank24.png\' alt=\'Bank 24h\' /></a>";
    }else if (type.indexOf("Bankomat Nordea") !== -1){ 
      return "<a href=\'/50242\' target=\'_blank\'>" + "<img src=\'/_items/mm/images/ico_bankomat_1.gif\' alt=\'Bankomat Nordea\' /></a>";  
    }else if (type.indexOf("Bankomat BZ WBK") !== -1){ 
      return "<a href=\'/50242\' target=\'_blank\'>" +"<img src=\'/_items/mm/images/ico_bankomat_2.gif\' alt=\'Bankomat BZ WBK\' /></a>";   
    }else if (type.indexOf("Bankomat eCard") !== -1){ 
      return "<a href=\'/50242\' target=\'_blank\'>" +"<img src=\'/_items/mm/images/ico_bankomat_4.gif\' alt=\'Bankomat eCard\' /></a>"; 
    }else if (type.indexOf("Bankomat Euronet") !== -1){ 
      return "<a href=\'/50242\' target=\'_blank\'>" +"<img src=\'/_items/mm/images/ico_bankomat_3.gif\' alt=\'Bankomat Euronet\' /></a>";   
    }else if (type.indexOf("Wpłatomat Nordea") !== -1){ 
      return "<a href=\'/50242\' target=\'_blank\'>" +"<img src=\'/_items/mm/images/ico_bankomat_1.gif\' alt=\'Wpłatomat Nordea\' /></a>";                     
    } else {
      return "<a href=\'/50242\' target=\'_blank\'>" +"<img src=\'/_items/mm/images/ico_bankomat_1.gif\' alt=\'Nordea\' /></a>";
    }
  
  }
    
  function wrapInfoDivIntoDiv(txt,row,type){
   
    if (row%2 === 0) {
      return "<div class=\'inner_content\'> " 
  			//	+ "<div class=\'img\'>" + getImageForType(type) + "</div> "
  				+ "<div class=\'text\'>" + txt +  "</div>"
  				+ "<div class=\'cleaner\'></div>"
  			  + "</div>";  
    }else {
      return "<div class=\'inner_content_odd\'> " 
  				//+ "<div class=\'img\'> " + getImageForType(type) + " </div> "
  				+ "<div class=\'text\'>" + txt +  "</div>"
  				+ "<div class=\'cleaner\'></div>"
  			  + "</div>";
    
    }
			  
  }

  /**
   * Pokaz liste z obiektami pod mapa
   */     
  function showInfoDivListShort(coordObj){
      
    var infoObj;
    var tabs= [];
    var tabsHtml;
    var hmo = coordObj.hmo;
    var hml = coordObj.lays.length;
   /*
    information = "test";
    information = wrapInfoDivIntoDiv("test",1,"Bank 24h");
  //  GLog.write(information);
    //eval ("var last = document.getElementById(\'tab_layer"+ coordObj[obj].idl + "\').innerHTML;");
    //GLog.write(hmo);
    var newContent = "";
    for (var obj=0;obj<hmo;obj++){
       newContent = newContent.concat(wrapInfoDivIntoDiv("test",1,"Bank 24h"));
    }
   // GLog.write("newcontent = " + newContent);
    restoreTab(2);
    showInfoObjDiv(2);
    eval ("document.getElementById(\'tab_layer2\').innerHTML += newContent");
*/

   
    if (hml > 0){
       // clearAllInfoObjDiv();
        //pokaz divy warstw z obiektami
        //alert("jestem");
        // var idb = 6;
        var infoOnLays = [];
      
        for (var i=0,idb=coordObj.lays[0];i<hml;i++) {
          //  showInfoObjDiv(coordObj.lays[i]);    
          idl = coordObj.lays[i];
          //restoreTab(idl);          
          //tam gdzie jest wiecej obiektow
          //if (coordObj.hmoinl[idb] > coordObj.hmoinl[idl]){
          //pierwsza warstwa od lewej jako aktywna
          if (idb > idl){          
            idb = idl;
          }
          infoOnLays[idl] = "";
        }
       // console.debug(idb);
        //showTab(idb);
        
       /*
        showInfoObjDiv(idb);
        hideAllTabs();     
        showTab(idb);
        */
        //GLog.write(coordObj.toSource());
        //dla kazdego obiektu
        
        var infoAll = "";
        for (var obj=0;obj<hmo;obj++){
          infoObj = coordObj[obj];
          
         if (hmoOnLayers["lay_"+infoObj.idl] !== undefined){
            hmoOnLayers["lay_"+infoObj.idl]++;
            nRow = hmoOnLayers["lay_"+infoObj.idl];
          }  
                      
          information = getObjectInfoShort(infoObj,2,nRow);
          //hmoInLayers[coordObj[obj].idl]
          try {
            information = wrapInfoDivIntoDiv(information,obj,infoObj.type);
            
            //infoAll = infoAll.concat(information);
            infoOnLays[infoObj.idl] = infoOnLays[infoObj.idl].concat(information); 
          }catch (err){
            GLog.write(err.message);
          }
         // alert("jestem");
          //GLog.write(document.getElementById("tab_layer2").innerHTML);
        }
  
   for (var i=0;i<hml;i++) {      
      eval ("document.getElementById(\'divcontentobj"+coordObj.lays[i]+"\').innerHTML += infoOnLays["+ coordObj.lays[i]+ "]");      
   }  


  //showInfoObjDiv(2);
       
     
	$("#search_results .ui-tabs-panel .inner_content").mouseover(function() {
   // alert ($(this).parent().attr("class"));	 
    $(this).addClass("highlight");
	});
	
	$("#search_results .ui-tabs-panel .inner_content").mouseout(function() {
    $(this).removeClass("highlight");
	});	        

	$("#search_results .ui-tabs-panel .inner_content_odd").mouseover(function() {	 
    $(this).addClass("highlight");
	});
	
	$("#search_results .ui-tabs-panel .inner_content_odd").mouseout(function() {
    $(this).removeClass("highlight");
	});	        
/*
	$("#tabs_content tab_content a").click(function() {
    removeRoutingTab();
    hideRoutingTab();
   // alert("clicked");    
		return false;
	});
  */ 
    }else {
     clearAllInfoObjDiv();
    }   
  }

  /**
   * Pokaz liste z obiektami pod mapa
   */     
  function showInfoDivList(coordObj){
      
    var infoObj;
    var tabs= [];
    var tabsHtml;
    var hmo = coordObj.hmo;
    var hml = coordObj.lays.length;
   
    
    if (hml > 0){
        //GLog.write(coordObj.toSource());
        //dla kazdego obiektu
        for (var obj=0;obj<hmo;obj++){
          infoObj = coordObj[obj];
          information = getObjectInfo(infoObj,2);
          //hmoInLayers[coordObj[obj].idl]
          try {
            information = wrapInfoDivIntoDiv(information,obj,infoObj.type);
           
          //  console.debug(information);
            eval ("document.getElementById(\'divcontentobj"+ coordObj[obj].idl + "\').innerHTML += information");
          }catch (err){
            GLog.write(err.message);
          }
         // alert("jestem");
          //GLog.write(document.getElementById("tab_layer2").innerHTML);
        }
        
	$("#tabs #tabs_content .tab_content .inner_content").mouseover(function() {
   // alert ($(this).parent().attr("class"));	 
    $(this).addClass("highlight");
	});
	
	$("#tabs #tabs_content .tab_content .inner_content").mouseout(function() {
    $(this).removeClass("highlight");
	});	        

	$("#tabs #tabs_content .inner_content_odd").mouseover(function() {	 
    $(this).addClass("highlight");
	});
	
	$("#tabs #tabs_content .inner_content_odd").mouseout(function() {
    $(this).removeClass("highlight");
	});	        

	$("#tabs_content tab_content a").click(function() {
    removeRoutingTab();
    hideRoutingTab();
    alert("clicked");    
		return false;
	});
   
    }else {
     clearAllInfoObjDiv();
    }    
  }
 /**
   *   Zwraca szablon z wypelnionymi polami na podstawie infoObj
   *   Nazwy parametrow musza sie zgadzac z tymi zapisanymi w szablonie!
   *   nRow - ktory to obiekt z kolei   
   */     
  function getObjectInfoShort(infoObj,idtemplate,nRow){
 //  GLog.write("GETobjectinfoshort");
 
   try {
    pname = infoObj.pname;
   } catch (e){
    pname = "";
   }
   try {
    pcityname = infoObj.pcityname;
   } catch (e){
    pcityname = "---";
   }
   try {
    pregion = infoObj.pregion;
   } catch (e){
    pregion = "---";
   }
   try {
    idvalue = infoObj.idv;
   } catch (e){
    idvalue = "0";
   }
   try {
    objname = infoObj.objname;
   } catch (e){
    objname = "";
   }   
   for (i=0;i<infoObj.hmp;i++){    
    //stworz obiekt o podanej nazwie i wartosci tekstowej txt (Nazwisko = "Marczewski")
    if (infoObj[i].t === null) {
        infoObj[i].t = "---";
    }    
    eval(infoObj[i].n + " = \'" + infoObj[i].t + "\';");
   }

   
   
   var out = "---";
   
   try {
       if (idtemplate === 0) {
         eval ("var str = templateIW[" + infoObj.idl + "]");
       }else   if (idtemplate === 1) {
         eval ("var str = templateIWList[" + infoObj.idl + "]");
       }else    if (idtemplate === 2) {
         eval ("var str = templateDIV[" + infoObj.idl + "]");
       }
       
       if (str === undefined) {
        str = "<br /> ---"; 
        if (debug) {
          GLog.write("Brak template listy google dla wyswietlanego obiektu");
        }  
       } 
       
       
       str = " \" " + str + " \" ";   
      // GLog.write(str);     
       eval ("out = " + str); 

       if (nRow !== undefined){
         

            
       //     out = "<label class=\'bold\'>"+ parseInt(nRow) + ".</label>" + out;      
            
        
        //dodaj ktory to jest obiekt
       }
    
       if (idtemplate === 0){
   //       out += getRoutingDiv();
       }else {
          //out += getInfoLink(infoObj.idvalue,infoObj.idl); 
         // GLog.write(infoObj.idv + " " + infoObj.idl + out);
          out = getInfoLinkWithContent(infoObj.idv,infoObj.idl,out,infoObj);
       }
      
   }catch (e){
    
     if (debug === 1){              
       if (idtemplate === 0){
        GLog.write (getInfoErrorInTemplate(" chmurki Google") + e);
        return getInfoAboutError("701","");
       }else   if (idtemplate === 1){
        GLog.write (getInfoErrorInTemplate(" chmurki Google listy") + e);
        return getInfoAboutError("702","");
       }else    if (idtemplate === 2){
        GLog.write (getInfoErrorInTemplate(" diva informacyjnego") + e);
        return getInfoAboutError("703","");
       }    
     }
        reqObjActive = false;  
        return getInfoNoInfoAboutObject(); 
   }  
      return out;   
  } 
 /**
   *   Zwraca szablon z wypelnionymi polami na podstawie infoObj
   *   Nazwy parametrow musza sie zgadzac z tymi zapisanymi w szablonie!
   */     
  function getObjectInfo(infoObj,idtemplate){
  // GLog.write("GETobjectinfo");

  
   try {
    pname = infoObj.pname;
   } catch (e){
    pname = "";
   }
   try {
    pcityname = infoObj.pcityname;
   } catch (e){
    pcityname = "---";
   }
   try {
    pregion = infoObj.pregion;
   } catch (e){
    pregion = "---";
   }
   try {
    idvalue = infoObj.idv;
   } catch (e){
    idvalue = "0";
   }   
   try {
    objname = infoObj.objname;
   } catch (e){
    objname = "";
   }      
   for (i=0;i<infoObj.hmp;i++){    
    //stworz obiekt o podanej nazwie i wartosci tekstowej txt (Nazwisko = "Marczewski")
    if (infoObj[i].txt === null) {
        infoObj[i].txt = "---";
    }    
    eval(infoObj[i].name + " = \'" + infoObj[i].txt + "\';");
   }

   
   
   var out = "---";
   
   try {
       if (idtemplate === 0) {
         eval ("var str = templateIW[" + infoObj.idl + "]");
       }else   if (idtemplate === 1) {
         eval ("var str = templateIWList[" + infoObj.idl + "]");
       }else    if (idtemplate === 2) {
         eval ("var str = templateDIV[" + infoObj.idl + "]");
       }
       
       if (str === undefined) {
        str = "<br /> ---"; 
        if (debug) {
          GLog.write("Brak template listy google dla wyswietlanego obiektu");
        }  
       } 
      // str = " \\\\" " + str + " \\\\" ";
     // GLog.write(str);   
       str = " \" " + str + " \" ";   
//       GLog.write(str);     
       eval ("out = " + str); 
     
       if (idtemplate === 0){
   //       out += getRoutingDiv();
       }else {
          //out += getInfoLink(infoObj.idvalue,infoObj.idl); 
          out = getInfoLinkWithContent(infoObj.idvalue,infoObj.idl,out,infoObj);
       }
      
   }catch (e){
    
     if (debug === 1){              
       if (idtemplate === 0){
        GLog.write (getInfoErrorInTemplate(" chmurki Google") + e);
        return getInfoAboutError("701","");
       }else   if (idtemplate === 1){
        GLog.write (getInfoErrorInTemplate(" chmurki Google listy") + e);
        return getInfoAboutError("702","");
       }else    if (idtemplate === 2){
        GLog.write (getInfoErrorInTemplate(" diva informacyjnego") + e);
        return getInfoAboutError("703","");
       }    
     }
        reqObjActive = false;  
        return getInfoNoInfoAboutObject(); 
   }

   return out;   
  }  
  

    window.unload = new GUnload();
  

