// JavaScript Document


var StoreId;
var StoreCode;
var StoreName;

var serverData;

function changeMyTesco(StoreId, StoreCode, StoreName) {
	document.location.href = 'registrace-3.html?shop_id='+StoreId;
}

function viewMyTesco(StoreId, StoreCode, StoreName) {
	document.location.href = 'moje-tesco.html?shop='+StoreCode;
}

$(document).ready(function() {

     function urlencode (str) {
         // http://kevin.vanzonneveld.net
         // +   original by: Philip Peterson
         // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
         // +      input by: AJ
         // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
         // +   improved by: Brett Zamir (http://brett-zamir.me)
         // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
         // +      input by: travc
         // +      input by: Brett Zamir (http://brett-zamir.me)
         // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
         // +   improved by: Lars Fischer
         // +      input by: Ratheous
         // %          note 1: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
         // *     example 1: urlencode('Kevin van Zonneveld!');
         // *     returns 1: 'Kevin+van+Zonneveld%21'
         // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
         // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
         // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
         // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'                                  
         var hash_map = {}, unicodeStr='', hexEscStr='';
         var ret = (str+'').toString();         
         var replacer = function (search, replace, str) {
             var tmp_arr = [];
             tmp_arr = str.split(search);
             return tmp_arr.join(replace);
         };         
         // The hash_map is identical to the one in urldecode.
         hash_map["'"]   = '%27';
         hash_map['(']   = '%28';
         hash_map[')']   = '%29';
         hash_map['*']   = '%2A';
         hash_map['~']   = '%7E';
         hash_map['!']   = '%21';
         hash_map['%20'] = '+';
         hash_map['\u00DC'] = '%DC';
         hash_map['\u00FC'] = '%FC';
         hash_map['\u00C4'] = '%D4';
         hash_map['\u00E4'] = '%E4';
         hash_map['\u00D6'] = '%D6';
         hash_map['\u00F6'] = '%F6';
         hash_map['\u00DF'] = '%DF';
         hash_map['\u20AC'] = '%80';
         hash_map['\u0081'] = '%81';
         hash_map['\u201A'] = '%82';
         hash_map['\u0192'] = '%83';
         hash_map['\u201E'] = '%84';
         hash_map['\u2026'] = '%85';
         hash_map['\u2020'] = '%86';
         hash_map['\u2021'] = '%87';
         hash_map['\u02C6'] = '%88';
         hash_map['\u2030'] = '%89';
         hash_map['\u0160'] = '%8A';
         hash_map['\u2039'] = '%8B';
         hash_map['\u0152'] = '%8C';
         hash_map['\u008D'] = '%8D';
         hash_map['\u017D'] = '%8E';
         hash_map['\u008F'] = '%8F';
         hash_map['\u0090'] = '%90';
         hash_map['\u2018'] = '%91';
         hash_map['\u2019'] = '%92';
         hash_map['\u201C'] = '%93';
         hash_map['\u201D'] = '%94';
         hash_map['\u2022'] = '%95';
         hash_map['\u2013'] = '%96';
         hash_map['\u2014'] = '%97';
         hash_map['\u02DC'] = '%98';
         hash_map['\u2122'] = '%99';
         hash_map['\u0161'] = '%9A';
         hash_map['\u203A'] = '%9B';
         hash_map['\u0153'] = '%9C';
         hash_map['\u009D'] = '%9D';
         hash_map['\u017E'] = '%9E';
         hash_map['\u0178'] = '%9F';         
         // Begin with encodeURIComponent, which most resembles PHP's encoding functions
         ret = encodeURIComponent(ret);      
         for (unicodeStr in hash_map) {
             hexEscStr = hash_map[unicodeStr];
             ret = replacer(unicodeStr, hexEscStr, ret); // Custom replace. No regexing
         }         
         // Uppercase for full PHP compatibility
         return ret.replace(/(\%([a-z0-9]{2}))/g, function (full, m1, m2) {
             return "%"+m2.toUpperCase();
         });
     }
 
     /**/
     /**/
     /**/  
     /**/
     /**/
     /* ILAYER FUNCTIONALITY */
     /* fce */
     function LoadIlayer(param) { 
     
          $.getJSON("cmsapi.php?module=clubcard&method=ilayer", function(data) {
               serverData = data;
          });
     
          //alert(param);
		/*$("div#ILAYERcontainer").load('ilayer.php', function(data) {	*/	          
		          /* init - tlačítka */
                    $("div.ILAYERtools").hide();
                    $("div.ILAYERtools > a").click(function(){
                         if($("div.ILAYERresultINNER").is(".hidden")) {
                              /* pokud není vybrán obchod */
                              alert('Nebyl vybrán žádný obchod');                      
                         }else{
                              /* pokud je něco ve výsledku */
                              $("div.Profile").click(function(){
                                   /* kliknutí na profil, pošlu data a vypnu okno */
                                   $("div.ILAYERcontainer").hide();
                                   $("div.ILAYERcurtain").hide(); 
                                   $("div#ILAYERcontainer").html('');
                                   viewMyTesco(StoreId, StoreCode, StoreName);
                              });
                              $("div.SetMyTesco").click(function(){
                                   /* kliknutí na profil, pošlu data a vypnu okno */
                                   $("div.ILAYERcontainer").hide();
                                   $("div.ILAYERcurtain").hide(); 
                                   $("div#ILAYERcontainer").html('');
                                   changeMyTesco(StoreId, StoreCode, StoreName);
                              });
                              $("div.Choose").click(function(){
                                   /* kliknutí na profil, pošlu data a vypnu okno */
                                   $("div.ILAYERcontainer").hide();
                                   $("div.ILAYERcurtain").hide(); 
                                   $("div#ILAYERcontainer").html('');
                                   selectTesco(StoreId, StoreCode, StoreName);
                              });
                         } 
 
                                               
                    });
                    /**/
                    /**/
                    /* BEGIN search !!!!!!!!!!!!!!!!! */
                    /**/
                    $("input.ILAYERsearchINPUT").keypress(function(e) {
                         if(e.keyCode==13){
                               return false;
                         }
                    });
                    $("div.ILAYERsearchBlok > div.button").click(function(){
                         if(($("input.ILAYERsearchINPUT").attr("value").length)<=3){
                              alert('Zadaný dotaz je příliš krátký');
                         }
                         else {
                              /* vynulování výsledků */                              
                              $("img[class^='map']").hide();
                              $("img[class^='map']").removeClass("selectedMap");
                              $("div.ILAYERtownINNER, div.ILAYERstoreINNER").html('');
                              
                              $("div.ILAYERresultINNER").addClass("hidden");
							  $("div.Choose").removeClass("hidden");
                              
                              $("div#type1, div#type2, div#type3, div#type4, div#type5, div#type7").addClass("checked");
                              $("div#nonstop, div#gasstation").removeClass("checked"); 
                              $("div.ILAYERgrayed").show();
                              hemala = 1; 
                              WhatToSearch = urlencode($("input.ILAYERsearchINPUT").attr("value"));
                              /* load */
                              $.getJSON("cmsapi.php?module=clubcard&method=ilayersearch&q="+WhatToSearch, function(datasearch){
                                   searchStep=0;
                                   while(searchStep < datasearch.length){
                                        $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="" class="'+searchStep+'">'+datasearch[searchStep]['name']+'</span></div>');
                                        searchStep++;
                                   }
                                   $("div.ILAYERstoreINNERitem > span").click(function(){
                                        /* klikání na seznam */
                                        $("div.ILAYERstoreINNERitem").removeClass("Active");
                                        $(this).parent("div.ILAYERstoreINNERitem").addClass("Active");
                                        /* vypis do pravého bloku */
                                        var selectStore = $(this).attr('class');
                                        $("div.ILAYERresultINNER").removeClass("hidden");
                                        $("div.ILAYERresultINNER > b.nazev").html(datasearch[selectStore]['name']);
                                        $("div.ILAYERresultINNER > span.typ").html(datasearch[selectStore]['type']);
                                        $("div.ILAYERresultINNER > span.ulice").html(datasearch[selectStore]['address_street']);
                                        $("div.ILAYERresultINNER > span.number").html(datasearch[selectStore]['address_number']);
                                        $("div.ILAYERresultINNER > span.psc").html(datasearch[selectStore]['address_zipcode']);
                                        $("div.ILAYERresultINNER > span.mesto").html(datasearch[selectStore]['address_city']);
                                        $("div.ILAYERresultINNER > span.openingTime").html(datasearch[selectStore]['opening_time']);
                                        $("div.ILAYERresultINNER > span.phone").html(datasearch[selectStore]['phone']);
                                        $("div.ILAYERresultINNER > span.finOpeningTime").html(datasearch[selectStore]['financial_services_opening_time']);
                                        $("div.ILAYERresultINNER > span.finPhone").html(datasearch[selectStore]['financial_services_phone']);
                                        $("div.ILAYERresultINNER > span.selectedStoreType").html(datasearch[selectStore]['type_id']);
                                        $("div.ILAYERresultINNER > span.nonstop").html(datasearch[selectStore]['opening_nonstop']);                     
                                        $("div.ILAYERresultINNER > span.gasstation").html(datasearch[selectStore]['gas_station']);  
                                        StoreId = datasearch[selectStore]['id'];
                                        StoreCode = datasearch[selectStore]['code'];
                                        StoreName = datasearch[selectStore]['name'];
                                   });
                              });                     
                         }
                    });
                    /* END search */
                    		
                    /* checkboxy, použita funkce aby nebyly ovlivněny žádné jiné checkboxy, jen ty v ilayeru  */
                    $("div.ILAYERfiltry").each(function(){
                         $("div.ILAYERfiltry").find(":checkbox").css({display:"none"}); 
                         //$("form.favoriteCat div").css("margin-bottom","5px");          
                         $("div.ILAYERfiltry").find(":checkbox").wrap("<div class='checkdiv'></div>");                    
                         $("div.ILAYERfiltry").find(":checkbox").each(function(){ /* priradi divu ID podrazeneho checkboxu */
                              var title = $(this).attr("id");
                              $(this).parent("div.checkdiv").attr("id", function(){ return title; });
                         });    
                         $("div.ILAYERfiltry").find(":checked").each(function(){
                              $(this).parent("div").addClass("checked");
                         });                    
                         $("div.ILAYERfiltry").find("div.checkdiv").click(function(){
                              if($(this).children().is(":checked")==true){
                                   $(this).children().removeAttr("checked");
                                   $(this).removeClass("checked");
                              }else{
                                   $(this).children().attr("checked","checked");
                                   $(this).addClass("checked");    
                              };
                         });
                    });
                    
                    /* nastaveni klikací mapy */                    
                   $("#kraj1").mouseover(function(){
                         $("img.map1").show();
                    });
                    $("#kraj1").mouseout(function(){
                         if ($("img.map1").is(".selectedMap")){
                              $("img.map1").show();
                         }else{
                              $("img.map1").hide();
                         }
                    }); 
                    $("#kraj2").mouseover(function(){
                         $("img.map2").show();
                    });
                    $("#kraj2").mouseout(function(){
                         if ($("img.map2").is(".selectedMap")){
                              $("img.map23").show();
                         }else{
                              $("img.map2").hide();
                         }
                    }); 
                    $("#kraj3").mouseover(function(){
                         $("img.map3").show();
                    });
                    $("#kraj3").mouseout(function(){
                         if ($("img.map3").is(".selectedMap")){
                              $("img.map3").show();
                         }else{
                              $("img.map3").hide();
                         }
                    });      
                    $("#kraj4").mouseover(function(){
                         $("img.map4").show();
                    });
                    $("#kraj4").mouseout(function(){
                         if ($("img.map4").is(".selectedMap")){
                              $("img.map4").show();
                         }else{
                              $("img.map4").hide();
                         }
                    });        
                    $("#kraj5").mouseover(function(){
                         $("img.map5").show();
                    });
                    $("#kraj5").mouseout(function(){
                         if ($("img.map5").is(".selectedMap")){
                              $("img.map5").show();
                         }else{
                              $("img.map5").hide();
                         }
                    });          
                    $("#kraj6").mouseover(function(){
                         $("img.map6").show();
                    });
                    $("#kraj6").mouseout(function(){
                         if ($("img.map6").is(".selectedMap")){
                              $("img.map6").show();
                         }else{
                              $("img.map6").hide();
                         }
                    });            
                    $("#kraj7").mouseover(function(){
                         $("img.map7").show();
                    });
                    $("#kraj7").mouseout(function(){
                         if ($("img.map7").is(".selectedMap")){
                              $("img.map7").show();
                         }else{
                              $("img.map7").hide();
                         }
                    });               
                    $("#kraj8").mouseover(function(){
                         $("img.map8").show();
                    });
                    $("#kraj8").mouseout(function(){
                         if ($("img.map8").is(".selectedMap")){
                              $("img.map8").show();
                         }else{
                              $("img.map8").hide();
                         }
                    }); 
                    $("#kraj9").mouseover(function(){
                         $("img.map9").show();
                    });
                    $("#kraj9").mouseout(function(){
                         if ($("img.map9").is(".selectedMap")){
                              $("img.map9").show();
                         }else{
                              $("img.map9").hide();
                         }
                    });    
                    $("#kraj10").mouseover(function(){
                         $("img.map10").show();
                    });
                    $("#kraj10").mouseout(function(){
                         if ($("img.map10").is(".selectedMap")){
                              $("img.map10").show();
                         }else{
                              $("img.map10").hide();
                         }
                    });  
                    $("#kraj11").mouseover(function(){
                         $("img.map11").show();
                    });
                    $("#kraj11").mouseout(function(){
                         if ($("img.map11").is(".selectedMap")){
                              $("img.map11").show();
                         }else{
                              $("img.map11").hide();
                         }
                    });    
                    $("#kraj12").mouseover(function(){
                         $("img.map12").show();
                    });
                    $("#kraj12").mouseout(function(){
                         if ($("img.map12").is(".selectedMap")){
                              $("img.map12").show();
                         }else{
                              $("img.map12").hide();
                         }
                    });    
                    $("#kraj13").mouseover(function(){
                         $("img.map13").show();
                    });
                    $("#kraj13").mouseout(function(){
                         if ($("img.map13").is(".selectedMap")){
                              $("img.map13").show();
                         }else{
                              $("img.map13").hide();
                         }
                    });    
                    $("#kraj14").mouseover(function(){
                         $("img.map14").show();
                    });
                    $("#kraj14").mouseout(function(){
                         if ($("img.map14").is(".selectedMap")){
                              $("img.map14").show();
                         }else{
                              $("img.map14").hide();
                         }
                    })                  
                    $("area").click(function(){
                         $("img[class^='map']").hide();
                         $("img[class^='map']").removeClass("selectedMap");
                         aktKraj = $(this).attr("id");
                         aktKraj = aktKraj.substring(4, 6);
                         aktKraj = 'map'+aktKraj;                         
                         $("img."+aktKraj).show();
                         $("img."+aktKraj).addClass("selectedMap");
                    }); 
        
                    
                    /* nastaveni buttonu a další inicializace */
                    if (param == 'PressedTop') {
                         $("div.Profile").show();
                         $("div.SetMyTesco").show();
                    }
                    if (param=='ManageAddStoreToList'){
                         $("div.Profile").hide();
                         $("div.SetMyTesco").hide();
                         $("div.Choose").show();
                    }
                    $("div.ILAYERgrayed").hide();
                    /* výběr kraje */
                    kraj = '';
                    $("#kraj1,#kraj2,#kraj3,#kraj4,#kraj5,#kraj6,#kraj7,#kraj8,#kraj9,#kraj10,#kraj11,#kraj12,#kraj13,#kraj14").click(function(){
                         kraj = $(this).attr("class");
                         $("div.ILAYERstoreINNER").html('');
                         $("div.ILAYERresultINNER").addClass("hidden");
                         $("div.ILAYERgrayed").hide();
                         $("input.ILAYERsearchINPUT").attr("value","");
                         Zkouska(kraj);

                    });
                    /* klikání na checkboxy */
                    $("div.checkdiv").click(function(){              
                         //if (kraj=='') { Zkouska(kraj); }
                         //Zkouska(kraj); 
                         //alert(kraj)
                         /* pokud ještě není vybrán kraj, pak má klikání na checkboxy jen přípravnou funkci pro další zpracování. pokud už kraj vybrán je, jsou checkboxy ovládané dále v kódu */
                    });
                    /* vypnuti ilayeru a unload obsahu */
                    $("div.cross").click(function(){
                         $("div.ILAYERcontainer").hide();
                         $("div.ILAYERcurtain").hide(); 
                         $("div#ILAYERcontainer").html('');               
                    });  
		/*}); */
     };
     function Zkouska(kraj) { 
          if ($("div#type1").is(".checked")){ var type1 = '1'; }else{ var type1 = '0'; }
          if ($("div#type2").is(".checked")){ var type2 = '1'; }else{ var type2 = '0'; }
          if ($("div#type3").is(".checked")){ var type3 = '1'; }else{ var type3 = '0'; }
          if ($("div#type4").is(".checked")){ var type4 = '1'; }else{ var type4 = '0'; }
          if ($("div#type5").is(".checked")){ var type5 = '1'; }else{ var type5 = '0'; }
          if ($("div#type7").is(".checked")){ var type7 = '1'; }else{ var type7 = '0'; }
          
          if (kraj=='') { /*alert('nezadan kraj,ale mam pripraveny parametry');*/ }
          if (kraj!='') { 
               /*alert('Kraj: '+kraj+' MyStores: '+type1+' Obchodni dum: '+type2+' Hypermarket: '+type3+' Supermarket: '+type4);*/ 
               //$.getJSON("cmsapi.php?module=tesco&method=ilayer", function(data){
               
                    data = serverData;
               
                    idkraje = kraj;
                    idmesta = 1;    
                                    
                    region = data[idkraje];
                    //alert(region['region_name']); 
                    mesta = region['city'];
                    
                    mesto = mesta[0];
                    //alert(mesto['city_name']);
                    
                    shopy = mesto['shop'];
                    shop = shopy[0];
                    
                    //alert(shop['name']);
                    //alert(data[idkraje]['city'][idmesta]['shop'][0]['name']);  /*  */  
                    
                    /* po vybrání města na mapce se vypíše seznam dostupných měst */
                    countTown = 0;  
                    $("div.ILAYERtownINNER").html('');
                    while (countTown < mesta.length){                         
                         $("div.ILAYERtownINNER").append('<div class="ILAYERtownINNERitem"><span class="'+countTown+'">'+mesta[countTown]['city_name']+'</span></div>');
                         /* BEGIN zde zjistim, kolik obchodu odpovida zadanemu filtru a podle toho pak zobrazím města */
                         var countStoresInf = 0;
                         xy=0; add=0;
                         while (countStoresInf < data[idkraje]['city'][countTown]['shop'].length){
                              //alert(data[idkraje]['city'][countTown]['city_name']+' pocet: '+countStoresInf);
                              if (($("div#type1").is(".checked"))&&((mesta[countTown]['shop'][countStoresInf]['type_id']==1))) { xy=1; }
                              if (($("div#type2").is(".checked"))&&((mesta[countTown]['shop'][countStoresInf]['type_id']==2))) { xy=1; }
                              if (($("div#type3").is(".checked"))&&((mesta[countTown]['shop'][countStoresInf]['type_id']==3))) { xy=1; }
                              if (($("div#type4").is(".checked"))&&((mesta[countTown]['shop'][countStoresInf]['type_id']==4))) { xy=1; }
                              if (($("div#type5").is(".checked"))&&((mesta[countTown]['shop'][countStoresInf]['type_id']==5))) { xy=1; }  
                              if (($("div#type7").is(".checked"))&&((mesta[countTown]['shop'][countStoresInf]['type_id']==7))) { xy=1; }                             
                              if (xy==1){
                                   //alert(xy);
                                   /* jestliže jsou vybírány nějaké typy, má smysl kontrolovat služby. pokud se shodne, proměnná ADD má hodnotu jedna, jinak zůstává nula.  */
                                  if ((($("div#nonstop").is(".checked")==false))&&($("div#gasstation").is(".checked")==false)) { add++; }
                                  if (($("div#nonstop").is(".checked"))&&($("div#gasstation").is(".checked")==false)){ 
                                        if(mesta[countTown]['shop'][countStoresInf]['opening_nonstop']==1) { add++; }
                                  }
                                  if (($("div#gasstation").is(".checked"))&&($("div#nonstop").is(".checked")==false)){ 
                                        if(mesta[countTown]['shop'][countStoresInf]['gas_station']==1) { add++; }
                                  }                                
                                   if(($("div#gasstation").is(".checked"))&&($("div#nonstop").is(".checked"))){ 
                                        if ((mesta[countTown]['shop'][countStoresInf]['opening_nonstop']==1)&&(mesta[countTown]['shop'][countStoresInf]['gas_station']==1)) { add++; }
                                   }  
                              }                                  
                              countStoresInf++;
                         }
                         /* kontrola podle předchozího. pokud je to pravda, bude zobrazený DIV znovu schován */
                         if((xy==0)||(add==0)){ $("div.ILAYERtownINNERitem > span."+countTown).parent("div").hide(); }
                         
                         //if((xy==0)||(add==0)){ $("div.ILAYERtownINNERitem > span."+countTown).parent("div").hide(); }  
                         //if (xy==0){ $("div.ILAYERtownINNERitem > span."+countTown).parent("div").hide(); }  
                         /* END zde zjistim, kolik obchodu odpovida zadanemu filtru a podle toho pak zobrazím města */                                               
                         countTown++;
                    } 

                    /* BEGIN zde zjistim, kolik obchodu odpovida zadanemu filtru a podle toho pak zobrazím města */
                    $("div.checkdiv").click(function(){
                         //alert('kliknuto!!!!!!');
                         $("div.ILAYERtownINNERitem").each(function(){
                         
                              pocet = $(this).children("span").attr("class");
                              //alert(pocet);
                              var countStoresInf2 = 0;
                              add2=0;
                              while (countStoresInf2 < data[idkraje]['city'][pocet]['shop'].length){
                                   //alert(countStoresInf2);
                                   xy2=0;
                                   /* kontrola jednotlivych typu, pokud se aspon jeden shodne, kontrolní proměnná XY má hodnotu jedna, jinak nula */
                                   if (($("div#type1").is(".checked"))&&((mesta[pocet]['shop'][countStoresInf2]['type_id']==1))) { xy2=1; }
                                   if (($("div#type2").is(".checked"))&&((mesta[pocet]['shop'][countStoresInf2]['type_id']==2))) { xy2=1; }
                                   if (($("div#type3").is(".checked"))&&((mesta[pocet]['shop'][countStoresInf2]['type_id']==3))) { xy2=1; }
                                   if (($("div#type4").is(".checked"))&&((mesta[pocet]['shop'][countStoresInf2]['type_id']==4))) { xy2=1; }
                                   if (($("div#type5").is(".checked"))&&((mesta[pocet]['shop'][countStoresInf2]['type_id']==5))) { xy2=1; }   
                                   if (($("div#type7").is(".checked"))&&((mesta[pocet]['shop'][countStoresInf2]['type_id']==7))) { xy2=1; }  
                                   if (xy2==1){
                                        //alert(xy);
                                        /* jestliže jsou vybírány nějaké typy, má smysl kontrolovat služby. pokud se shodne, proměnná ADD má hodnotu jedna, jinak zůstává nula.  */
                                       if ((($("div#nonstop").is(".checked")==false))&&($("div#gasstation").is(".checked")==false)) { add2++; }
                                       if (($("div#nonstop").is(".checked"))&&($("div#gasstation").is(".checked")==false)){ 
                                             if(mesta[pocet]['shop'][countStoresInf2]['opening_nonstop']==1) { add2++; }
                                       }
                                       if (($("div#gasstation").is(".checked"))&&($("div#nonstop").is(".checked")==false)){ 
                                             if(mesta[pocet]['shop'][countStoresInf2]['gas_station']==1) { add2++; }
                                       }                                
                                        if(($("div#gasstation").is(".checked"))&&($("div#nonstop").is(".checked"))){ 
                                             if ((mesta[pocet]['shop'][countStoresInf2]['opening_nonstop']==1)&&(mesta[pocet]['shop'][countStoresInf2]['gas_station']==1)) { add2++; }
                                        }  
                                   } 
                                   countStoresInf2++;
                              }
                               if((add2==0)){ $("div.ILAYERtownINNERitem > span."+pocet).parent("div").hide(); }  
                               else  { $("div.ILAYERtownINNERitem > span."+pocet).parent("div").show(); }                               
                               
                         });
                    });
                    /* END zde zjistim, kolik obchodu odpovida zadanemu filtru a podle toho pak zobrazím města */  
                        
                    /* po vybrání města se objeví seznam obchodů */
                    $("div.ILAYERtownINNERitem").mouseover(function(){                              
                         $(this).css("background-color","#deecf7");
                    });   
                    $("div.ILAYERtownINNERitem").mouseout(function(){                              
                         $(this).css("background-color","#f1f6fa");
                    });                       
                    $("div.ILAYERtownINNERitem > span").click(function(){
                         $("div.ILAYERresultINNER").addClass("hidden");
                         $("div.ILAYERtownINNERitem").removeClass("Active");
                         $(this).parent("div").addClass("Active");
                         var selectMesto = $(this).attr('class');
                         var countStores = 0;  

                         $("div.ILAYERstoreINNER").html('');                       
                         while (countStores < data[idkraje]['city'][selectMesto]['shop'].length){     
                              if (($("div#type1").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==1)){                              
                                   if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                        if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen nonstop */
                                   else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen gas */
                                   else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* nefiltrujeme */
                                   else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                   {
                                      $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                   }
                              }
                              if (($("div#type2").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==2)){                              
                                   if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                        if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen nonstop */
                                   else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen gas */
                                   else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* nefiltrujeme */
                                   else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                   {
                                      $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                   }
                              }
                              if (($("div#type3").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==3)){                              
                                   if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                        if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen nonstop */
                                   else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen gas */
                                   else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* nefiltrujeme */
                                   else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                   {
                                      $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                   }
                              }
                              if (($("div#type4").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==4)){                              
                                   if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                        if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen nonstop */
                                   else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen gas */
                                   else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* nefiltrujeme */
                                   else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                   {
                                      $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                   }
                              }
                              if (($("div#type5").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==5)){                              
                                   if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                        if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen nonstop */
                                   else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen gas */
                                   else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* nefiltrujeme */
                                   else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                   {
                                      $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                   }
                              }    
                              if (($("div#type7").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==7)){                              
                                   if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                        if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen nonstop */
                                   else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* jen gas */
                                   else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                        if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                             $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                        }
                                   }
                                   /* nefiltrujeme */
                                   else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                   {
                                      $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                   }
                              }                                               
                              countStores++;                              
                         }
                         /* když kliknu vlevo na výběr, musí se seznam obchodů přerovnat a případně smazat ILAYERresultINNER */
                         $("div.checkdiv").click(function(){  
                                   //$("div.ILAYERresultINNER").addClass("hidden");
                                   var selectMesto = $("div.ILAYERtownINNER > div.Active > span").attr('class');
                                   var activeStore = $("div.ILAYERstoreINNER > div.Active > span").attr('class');
                                   var selectedStoreType = $("span.selectedStoreType").html(); /* pokud je vybraný nějaký obchod, podívám se na jeho typ do skrytého spanu a přečtu ho */    
                                   var nonstop = $("span.nonstop").html(); /* pokud je nonstop */
                                   var gasstation = $("span.gasstation").html(); /* pokud je gasstation */                                    
                                   var countStores = 0;  

                                   $("div.ILAYERstoreINNER").html('');
                                   while (countStores < data[idkraje]['city'][selectMesto]['shop'].length){
                                        if (($("div#type1").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==1)){
                                             if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                                  if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen nonstop */
                                             else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen gas */
                                             else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* nefiltrujeme */
                                             else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                             {
                                                $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                             }
                                        }
                                        if (($("div#type2").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==2)){
                                             if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                                  if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen nonstop */
                                             else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen gas */
                                             else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* nefiltrujeme */
                                             else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                             {
                                                $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                             }
                                        }
                                        if (($("div#type3").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==3)){
                                             if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                                  if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen nonstop */
                                             else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen gas */
                                             else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* nefiltrujeme */
                                             else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                             {
                                                $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                             }
                                        }
                                        if (($("div#type4").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==4)){
                                             if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                                  if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen nonstop */
                                             else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen gas */
                                             else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* nefiltrujeme */
                                             else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                             {
                                                $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                             }
                                        }
                                        if (($("div#type5").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==5)){
                                             if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                                  if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen nonstop */
                                             else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen gas */
                                             else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* nefiltrujeme */
                                             else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                             {
                                                $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                             }                                         
                                        }
                                        if (($("div#type7").is(".checked"))&&(mesta[selectMesto]['shop'][countStores]['type_id']==7)){
                                             if (($("div#gasstation").is(".checked")) && ($("div#nonstop").is(".checked"))) {
                                                  if ((mesta[selectMesto]['shop'][countStores]['gas_station']==1) && (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1)) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen nonstop */
                                             else if ((($("div#gasstation").is(".checked")==false)) && ($("div#nonstop").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['opening_nonstop']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* jen gas */
                                             else if ((($("div#nonstop").is(".checked")==false)) && ($("div#gasstation").is(".checked"))) {
                                                  if (mesta[selectMesto]['shop'][countStores]['gas_station']==1) {
                                                       $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                                  }
                                             }
                                             /* nefiltrujeme */
                                             else if ((($("div#nonstop").is(".checked"))==false) && (($("div#nonstop").is(".checked"))==false))
                                             {
                                                $("div.ILAYERstoreINNER").append('<div class="ILAYERstoreINNERitem"><span name="'+selectMesto+'" class="'+countStores+'">'+mesta[selectMesto]['shop'][countStores]['name']+'</span></div>');
                                             }                                         
                                        }
                                        countStores++;                              
                                   } /* konec obrovského podmínkovaného cyklu při filtrování */
                                   
                                   /* pokud potřeba, vyčistit Výsledek hledání */
                                   if ((($("div#type1").is(".checked"))==false)&&(selectedStoreType==1)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#type2").is(".checked"))==false)&&(selectedStoreType==2)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#type3").is(".checked"))==false)&&(selectedStoreType==3)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#type4").is(".checked"))==false)&&(selectedStoreType==4)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#type5").is(".checked"))==false)&&(selectedStoreType==5)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#type7").is(".checked"))==false)&&(selectedStoreType==7)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#nonstop").is(".checked"))==true)&&(nonstop==0)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if ((($("div#gasstation").is(".checked"))==true)&&(gasstation==0)) { $("div.ILAYERresultINNER").addClass("hidden"); }
                                   if (activeStore!=undefined) { $("div.ILAYERstoreINNERitem > span."+activeStore).parent("div.ILAYERstoreINNERitem").addClass("Active"); }
                                   /* v seznamu obchodů kliknu na jeho název, vyberu, toto je stejný kód jako dolejš, jen je spuštěn v jiné chvíli, a to pokud byl změněn filtr */
                                  $("div.ILAYERstoreINNERitem > span").click(function(){
                                        $("div.ILAYERstoreINNERitem").removeClass("Active");
                                        $(this).parent("div").addClass("Active");
                                        var selectMesto = $(this).attr('name');
                                        var selectStore = $(this).attr('class');
                                        $("div.ILAYERresultINNER").removeClass("hidden");
                                        $("div.ILAYERresultINNER > b.nazev").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['name']);
                                        /* dočasně si vypíšu */
                                        /*$("div.ILAYERresultINNER > span.info").html("typ:"+data[idkraje]['city'][selectMesto]['shop'][selectStore]['type_id']+' nonstop:'+data[idkraje]['city'][selectMesto]['shop'][selectStore]['opening_nonstop']+' gas:'+data[idkraje]['city'][selectMesto]['shop'][selectStore]['gas_station']);*/
                                        /* end */
                                        $("div.ILAYERresultINNER > span.typ").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['type']);
                                        $("div.ILAYERresultINNER > span.ulice").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_street']);
                                        $("div.ILAYERresultINNER > span.number").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_number']);
                                        $("div.ILAYERresultINNER > span.psc").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_zipcode']);
                                        $("div.ILAYERresultINNER > span.mesto").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_city']);
                                        $("div.ILAYERresultINNER > span.openingTime").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['opening_time']);
                                        $("div.ILAYERresultINNER > span.phone").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['phone']);
                                        $("div.ILAYERresultINNER > span.finOpeningTime").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['financial_services_opening_time']);
                                        $("div.ILAYERresultINNER > span.finPhone").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['financial_services_phone']);
                                        $("div.ILAYERresultINNER > span.selectedStoreType").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['type_id']);
                                        $("div.ILAYERresultINNER > span.nonstop").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['opening_nonstop']);                     
                                        $("div.ILAYERresultINNER > span.gasstation").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['gas_station']);                                            
                                        StoreId = data[idkraje]['city'][selectMesto]['shop'][selectStore]['id'];
                                        StoreCode = data[idkraje]['city'][selectMesto]['shop'][selectStore]['code'];
                                        StoreName = data[idkraje]['city'][selectMesto]['shop'][selectStore]['name'];                                         
                                   });      /* */    
                         });
                         /* END - klikání na checkboxy pro filtrování obchodu v konkrétním městě */

                         
                         /* v seznamu obchodů kliknu na jeho název, vyberu */
                         $("div.ILAYERstoreINNERitem").mouseover(function(){                              
                              $(this).css("background-color","#deecf7");
                         });   
                         $("div.ILAYERstoreINNERitem").mouseout(function(){                              
                              $(this).css("background-color","#f1f6fa");
                         }); 
                        $("div.ILAYERstoreINNERitem > span").click(function(){

                              $("div.ILAYERstoreINNERitem").removeClass("Active");
                              $(this).parent("div").addClass("Active");
                              var selectMesto = $(this).attr('name');
                              var selectStore = $(this).attr('class');
                              $("div.ILAYERresultINNER").removeClass("hidden");
                              $("div.ILAYERresultINNER > b.nazev").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['name']);
                              /* dočasně si vypíšu */
                              /*$("div.ILAYERresultINNER > span.info").html("typ:"+data[idkraje]['city'][selectMesto]['shop'][selectStore]['type_id']+' nonstop:'+data[idkraje]['city'][selectMesto]['shop'][selectStore]['opening_nonstop']+' gas:'+data[idkraje]['city'][selectMesto]['shop'][selectStore]['gas_station']);*/
                              /* end */
                              $("div.ILAYERresultINNER > span.typ").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['type']);
                              $("div.ILAYERresultINNER > span.ulice").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_street']);
                              $("div.ILAYERresultINNER > span.number").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_number']);
                              $("div.ILAYERresultINNER > span.psc").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_zipcode']);
                              $("div.ILAYERresultINNER > span.mesto").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['address_city']);
                              $("div.ILAYERresultINNER > span.openingTime").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['opening_time']);
                              $("div.ILAYERresultINNER > span.phone").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['phone']);
                              $("div.ILAYERresultINNER > span.finOpeningTime").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['financial_services_opening_time']);
                              $("div.ILAYERresultINNER > span.finPhone").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['financial_services_phone']);
                              $("div.ILAYERresultINNER > span.selectedStoreType").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['type_id']);                  
                              $("div.ILAYERresultINNER > span.gasstation").html(data[idkraje]['city'][selectMesto]['shop'][selectStore]['gas_station']);   
                              StoreId = data[idkraje]['city'][selectMesto]['shop'][selectStore]['id'];
                              StoreCode = data[idkraje]['city'][selectMesto]['shop'][selectStore]['code'];
                              StoreName = data[idkraje]['city'][selectMesto]['shop'][selectStore]['name'];                     
                                                                         
                         });      /* */                    
                    });                              
               //});   
          } /* konec podminky */
     }

     /* init */
     $("div.ILAYERcontainer").hide();
     $("div.ILAYERcurtain").hide();
     
     var loadIlayer = 0; /**/
     
     /* load
     $("a.change").click(function(){  
          LoadIlayer('PressedTop');           
          $("div.ILAYERcontainer").show();
          $("div.ILAYERcurtain").show();          
     });    */
     $("a.addNewStore").click(function(){  
          LoadIlayer('ManageAddStoreToList');           
          $("div.ILAYERcontainer").show();
          $("div.ILAYERcurtain").show();
     }); 
     $("div.ILAYERcontainer").each(function(){  
          $("img.transparentSticker").css("display","none");    
          LoadIlayer('PressedTop'); 
          $(this).show();
     });  
     
     /**/
     /* ILAYER FUNCTIONALITY - end */


});
