jQuery.noConflict();

jQuery(document).ready(function() {
  jQuery('#table-emails tr:even').hide();
  jQuery('#table-emails a').click(function() {
    jQuery(this).parents('tr').next().toggle();
    return false;
  });
  
  jQuery('#table-newsletters tr:even').hide();
  jQuery('#table-newsletters .toggle').click(function() {
    jQuery(this).parents('tr').next().toggle();
    return false;
  });
  
  jQuery('#table-categories ul li:not(.active) ul').hide();
  /*jQuery('#table-categories ul li .toggle').click(function() {
    jQuery(this).next().toggle();
    jQuery(this).parent().toggleClass('active');    
    return false;
  });*/
  
  if(jQuery('#submenu-nav li').index(jQuery('.activeli'))==1) {
    jQuery('#submenu-nav').addClass('active-link-categories');
  } else {
    jQuery('#submenu-nav').addClass('active-link-shops');
  }    
  jQuery('#submenu-nav a').click(function() {    
    id = jQuery(this).attr('id');
    jQuery('#submenu-nav').attr('class', 'active-' + id );     
  }); 
  
  jQuery('.scrollable').scrollable({ 
    size: 3,
    onReload: function() {
      if(this.getSize()<4) {
        jQuery('.nextPage').hide();
      }
    } 
  });
  jQuery('.scrollable a').click(function() {    
    var path = jQuery(this).find('img').attr('src').replace('thumbnails/', '');
    var alt = jQuery(this).find('img').attr('alt');
    var width = jQuery(this).find('img').attr('width');        
    var height = jQuery(this).find('img').attr('height');
    if(width>height) {
      var ratio = 300/width;
    } else {
      var ratio = 300/height;
    }
    width = Math.round(width*ratio);
    height = Math.round(height*ratio);                
    jQuery('#ig-right img').attr({
      src: path,
      alt: alt,
      width: width,
      height: height      
    });
    jQuery('#ig-right a').attr('href', path);
    return false;
  });
  
  if(jQuery('.scrollable')[0]) {
    var path = jQuery('.scrollable a:first img').attr('src').replace('thumbnails/', '');
    var alt = jQuery('.scrollable a:first img').attr('alt');
    var width = jQuery('.scrollable a:first img').attr('width');        
    var height = jQuery('.scrollable a:first img').attr('height');
    if(width>height) {
      var ratio = 300/width;
    } else {
      var ratio = 300/height;
    }
    width = Math.round(width*ratio);
    height = Math.round(height*ratio);
    jQuery('#ig-right img').attr({
      src: path,
      alt: alt,
      width: width,
      height: height
    });
    jQuery('#ig-right a').attr('href', path);
    
    jQuery('.scrollable a img').each(function() {           
      if(jQuery(this).height()<jQuery(this).width()) {        
        var margin = Math.floor((93-jQuery(this).height())/2);
        if(navigator.appVersion.indexOf('MSIE 7.')!=-1) {
          margin = margin-2; 
        }
        jQuery(this).css('margin-top', margin + 'px');        
      }      
    });
  }   
});  

if(jQuery('#submenu-nav')[0]) {
  var tabber1 = new Yetii({
    id: 'submenu',
    persist: true,
    leavecallback: function(tab) {
      if(tab==2) {
        window.location = "/obchody/";        
      }     
    } 
  });
}

function initialize() {
  var map = new GMap2(document.getElementById("map-canvas"));  
  var position = new GLatLng(48.185856, 17.134173);
  map.setCenter(position, 15);
  map.setUIToDefault();
  map.addOverlay(new GMarker(position));
}  
