// left menu
jQuery().ready(function(){	
	jQuery('#leftmenu').Accordion({	  
		active: 'a.selected',
		header: 'a.firstLevel',
		alwaysOpen: false,
		animated: true,				
		showSpeed: 200,
		hideSpeed: 400
	});
});

// top menu
$(function() {
    $('#topmenu').droppy();
  });



// externí odkazy
jQuery().ready(function(){
  $('a.externalLink').click(function(){
    window.open(this.href);
    return false;
  });
});


// colorbox with fit to window 
$(document).ready(function(){
  var winHcolorbox = parseInt($(window).height()-30);
  var winWcolorbox = parseInt($(window).width()-30);
  //
  if(lang == 'cz'){
    var cInfoText = 'obrázek {current} z {total}';
  }
  else{
    var cInfoText = 'obrázok {current} z {total}';  
  }
  //  
  $('.colorbox').colorbox({transition:'elastic', speed:350, current: cInfoText, opacity: 0.7, maxWidth: winWcolorbox+'px', maxHeight: winHcolorbox+'px'});
});



// rozbalovací světla
$(document).ready(function() {
  $("#btnViewAllLightsContainer").show();
  $("#viewAllLightsContainer").hide();
  
  $("#btnViewAllLightsContainer").click(function(){ 
    $("#btnViewAllLightsContainer").hide(); 
    $("#viewAllLightsContainer").show();     
  });
  $(".closeAllLightsContainer").click(function(){ 
    $("#btnViewAllLightsContainer").show(); 
    $("#viewAllLightsContainer").hide();     
  });  

});

// rozbalovací sestavy
$(document).ready(function() {
  $(".sestavyOther .btnAll").show();
  $("#sestavyOtherContainer").hide();
  
  $("#sestavyOther").click(function(){ 
    $("#sestavyOther .btnAll").hide();
    //$(".sestavyHeadInfo").hide(); 
    $("#sestavyOtherContainer").show();  
        $('.imgFitSestavy').each(function() {
        var maxWidth = 200; // Max width for the image
        var maxHeight = 200;    // Max height for the image
        var ratio = 0;  // Used for aspect ratio
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height
 
        // Check if the current width is larger than the max
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            $(this).css("width", maxWidth); // Set new width
            $(this).css("height", height * ratio);  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
        }
 
        // Check if current height is larger than max
        if(height > maxHeight){
            ratio = maxHeight / height; // get ratio for scaling image
            $(this).css("height", maxHeight);   // Set new height
            $(this).css("width", width * ratio);    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
        }
    });   
  });
  $(".closesestavyOtherContainer").click(function(){ 
    $("#sestavyOther .btnAll").show();
    //$(".sestavyHeadInfo").show(); 
    $("#sestavyOtherContainer").hide();     
  });
});


// link parent menu with js
jQuery().ready(function(){
  var pathLang = path+lang; 
  
  $("#leftmenu .koupelnove-sestavy").click(function(){
    if(!$(this).hasClass("selected")){      
      window.location=pathLang+"/koupelnove-sestavy#content";   
    }
  });
  $("#leftmenu .umyvadlove-skrinky").click(function(){
    if(!$(this).hasClass("selected")){      
      window.location=pathLang+"/umyvadlove-skrinky#content";   
    }
  });  
  $("#leftmenu .expozice").click(function(){
    if(!$(this).hasClass("selected")){      
      window.location=pathLang+"/expozice#content";   
    }
  });
  
  $("#leftmenu .kuchyne").click(function(){
    if(!$(this).hasClass("selected")){      
      window.location=pathLang+"/kuchyne#content";   
    }
  });
  
  $("#leftmenu .interiery").click(function(){
    if(!$(this).hasClass("selected")){      
      window.location=pathLang+"/interiery#content";   
    }
  });  
// uc
  
  $("#leftmenu .doplnkove-skrinky").click(function(){          
      window.location=pathLang+"/doplnkove-skrinky#content";
  });  
  $("#leftmenu .zrcadla").click(function(){          
      window.location=pathLang+"/zrcadla#content";
  });    
  $("#leftmenu .umyvadla").click(function(){          
      window.location=pathLang+"/umyvadla#content";
  }); 
  $("#leftmenu .osvetleni").click(function(){          
      window.location=pathLang+"/osvetleni#content";
  }); 
  $("#leftmenu .doplnky").click(function(){          
      window.location=pathLang+"/doplnky#content";
  }); 
});



// e-shop objekty
$(document).ready(function() {  
  $("a[href='../pages/support/e-shop-objekty.php']").colorbox({width:"350px", height:"300px", opacity: 0.7, initialHeight:"300px", initialWidth:"350px", iframe:true});
});


// ukotvit / skrýt banner (cookie cookieBanner - fixed, bottom)
jQuery().ready(function(){
  function FixBanner(){
    $("#bottomFixedContainer").css("position", "fixed");
    $("#bottomFixedContainer").css("z-index", "3000");
    $("#bottomFixedContainer").css("bottom", "0px");
    $("#btnCloseBanner").css("display", "block");
    $("#btnPlaceBanner").css("display", "none");
    $("#bottomDistance").css("display", "block");    
  }

  function unFixBanner(){
    $("#bottomFixedContainer").css("position", "relative")
    $("#btnCloseBanner").css("display", "none");
    $("#btnPlaceBanner").css("display", "block");
    $("#bottomDistance").css("display", "none");   
  }
  
  if(!$.cookie('cookieBanner')){    
    $.cookie('cookieBanner', 'fixed', {expires: 365, path: '/'});
    FixBanner();
  }
  if($.cookie('cookieBanner')=='fixed'){ 
    FixBanner();  
  }  
  if($.cookie('cookieBanner')=='bottom'){ 
    unFixBanner();  
  }
  
  $("#btnCloseBanner").click(function(){ 
    $.cookie('cookieBanner', 'bottom', {expires: 365, path: '/'});
    unFixBanner();
  }); 
     
  $("#btnPlaceBanner").click(function(){ 
    $.cookie('cookieBanner', 'fixed', {expires: 365, path: '/'});
    FixBanner();
  });
  
});

// skrýt float news
jQuery().ready(function(){
  function hideFloatNews(){
    $("#floatNewsContainer").css("display", "none");   
  }
  function viewFloatNews(){
    $("#floatNewsContainer").css("display", "block");   
  }  
  
  if(!$.cookie('cookieFloatNews')){    
    $.cookie('cookieFloatNews', 'visible', {path: '/'});
    viewFloatNews();
  }
  if($.cookie('cookieFloatNews')=='hidden'){ 
    hideFloatNews();  
  }
  else{
    viewFloatNews();
  }
  
  
  $("#floatNewsBtnMore").click(function(){ 
    $.cookie('cookieFloatNews', 'hidden', {path: '/'});
    hideFloatNews();
  }); 
  
  $("#floatNewsBtnClose").click(function(){ 
    $.cookie('cookieFloatNews', 'hidden', {path: '/'});
    hideFloatNews();
  });
  
});

// tooltip
$(document).ready(function(){
	tooltip();
});


























