function log(e)
{
  //return false;
  if(typeof(console)=='object') console.log(e);
  //else alert(e);  
};

var customLightbox = {
  config:
  {
    overlayBgColor:'#000',
    overlayOpacity:0.8,
    fixedNavigation:false,
    imageLoading:'/images/lightbox-ico-loading.gif',
    imageBtnPrev:'/images/lightbox-btn-prev.png',
    imageBtnNext:'/images/lightbox-btn-next.png',
    imageBtnClose:'/images/lightbox-btn-close.png',
    imageBlank:'/images/transparent.png',
    containerResizeSpeed:200,
    txtImage:'Obrázek:<br />',
    txtOf:'z',
    keyToClose:'c',
    keyToPrev:'p',
    keyToNext:'n',
    imageArray:[],
    activeImage:0
  },
  init: function()
  {
    $('a[rel=lightbox],a.lightbox').lightBox(customLightbox.config); //only rel="lightbox"

    var lbRels = new Array();  var thisRel = ''; var trIsIn = false;
    $('a[rel*="lightbox["]').each(function(){ //each rel="lightbox[..."
        thisRel = $(this).attr('rel').replace('lightbox[','').replace(']',''); //curren rel
        for(i=0; i<lbRels.length; i++) { //find if is not yet in array of rels
          if(thisRel == lbRels[i]) trIsIn = true;
          else trIsIn = false;
        }
        if(!trIsIn) lbRels[lbRels.length] = $(this).attr('rel').replace('lightbox[','').replace(']',''); //not i array of rels => store rel
    });
    for(i=0; i<lbRels.length; i++) { $('a[rel="lightbox['+lbRels[i]+']"]').lightBox(customLightbox.config); } //each unique rel => apply lightbox
  }
};

// var autoTabs = {
//   config:
//   {
//     listClass: '.cities',
//     itemClass: '.item',
//     titleClass: '.title',
//     contentClass: '.shops'
//   },
//   init: function()
//   {
//     if(!$(autoTabs.config.listClass).length) return false;
//
//     var tabsHTML = '';
//
//     $(autoTabs.config.listClass+' '+autoTabs.config.titleClass).each(function(i){
//
//         tabsHTML += '<li id="cityhld_'+i+'"><a href="#city_'+i+'" onclick="return autoTabs.toggle('+i+');">'+$(this).text()+'</a></li>';
//
//         if( i > 0 )
//         {
//           $(this).parent().hide();
//         }
//
//         $(this).parent().attr('id', 'city_'+i);
//
//         $(this).remove();
//     });
//
//     var tabsHTML = '<ul class="tabs cleaned">'+tabsHTML+'</ul>';
//
//     $(autoTabs.config.listClass).before(tabsHTML);
//     $('#cityhld_0').addClass('selected');
//
//   },
//   toggle: function(i)
//   {
//     $(autoTabs.config.listClass+' '+autoTabs.config.itemClass+':visible').hide();
//     $('#city_'+i).show();
//     $('#cityhld_'+i).parent().children().removeClass('selected');
//     $('#cityhld_'+i).addClass('selected');
//     return false;
//   }
// };

// var explain = {
//   config:
//   {
//     handlerEl: '.explain[title]',
//     readyClass: 'explainReady',
//     boxClass: 'explainBox',
//     boxIdPattern: 'explainBox_',
//     xOffset: 10,
//     yOffset: 10
//   },
//   init: function()
//   {
//     if(!$(this.config.handlerEl).length) return false;
//     $(this.config.handlerEl).each(function(i){
//       explain.stack[i] = $(this).attr('title');
//       $(this).attr('title', '').addClass(explain.config.readyClass);
//       $(this).hover(function(){ explain.show(i); return false; }, function(){ explain.hide(i); return false; });
//     });
//   },
//   show: function(i)
//   {
//     $('#'+explain.config.boxIdPattern+i).remove();
//     $('body').append('<div id="'+explain.config.boxIdPattern+i+'" class="'+explain.config.boxClass+'">'+explain.stack[i]+'</div>');
//     $().mousemove( function(e) {
//       $('#'+explain.config.boxIdPattern+i).css({ left: e.pageX + explain.config.xOffset, top: e.pageY + explain.config.yOffset });
//     });
//   },
//   hide: function(i)
//   {
//     $('#'+explain.config.boxIdPattern+i).remove();
//     $().unbind('mousemove');
//   },
//   stack: []
//   /*
//   .explainReady {
//   	cursor: help;
//   }
//   .explainBox {
//   	position: absolute;
//   	z-index: 100;
//   	background: #FEFFD0;
//   	color: #646156;
//   	padding: 6px 8px;
//   	border: 1px solid #e9eab6;
//   	font-size: 120%;
//   }
//   */
// };

// var selectReplace = {
//   init: function(select, seo)
//   {
//     if(!$(select).length) return false;
//
//     selectReplace.selectName = $(select).attr('name');
//
//     selectReplace.list = '<div id="selectReplaced">';
//     selectReplace.list += '<p id="currentSelection">&nbsp;</p>';
//     selectReplace.list += '<ul id="selectList" class="list">';
//     $(select).children('option').each(function(){
//         if($(this).attr('selected'))
//         {
//           selectReplace.selectAfterVal = $(this).attr('value');
//           selectReplace.selectAfterName = $(this).text();
//         }
//         selectReplace.list += '<li class="item"><a href="#main" onclick="selectReplace.select(\''+$(this).attr('value')+'\', \''+$(this).text()+'\');">'+$(this).text()+'</a></li>'
//     });
//     selectReplace.list += '</ul></div>';
//
//     $(select).after('<input type="hidden" name="'+selectReplace.selectName+'" id="selectedStack" />');
//     $(select).replaceWith(selectReplace.list);
//     if(selectReplace.selectAfterVal)
//     {
//       selectReplace.select(selectReplace.selectAfterVal, selectReplace.selectAfterName);
//     }
//     $('#currentSelection').click(function(){selectReplace.open()});
//     $('#selectList').hide();
//     $('#modelSelector').addClass('replaced');
//
//     if(seo)
//     {
//       $('#selectReplaced').parents('form').bind('submit', function(){
//         var link = $('#selectReplaced').parents('form').serialize().split('=');
//         link = link[1]+'/';
//         var url = String(document.location).split('/');
//         var urlComplete = '';
//         for(i=0; i<4; i++)
//         {
//           urlComplete += url[i]+'/';
//         }
//         window.location.href = urlComplete+link+'#main';
//
//         return false;
//       });
//     }
//   },
//   select: function(value, name)
//   {
//     $('#selectedStack').attr('value', value);
//     $('#currentSelection').text(name);
//     selectReplace.close();
//   },
//   open: function()
//   {
//     $('#selectList').toggle();
//   },
//   close: function()
//   {
//     $('#selectList').hide();
//   }
// };


var balanceCols = {
  config:
  {

  },
  init: function()
  {
//     $('.balanced:even').each(
//       function()
//       {
//         if ( $(this).find('.balance').height() > $(this).next().find('.balance').height() )
//         {
//           $(this).next().find('.balance').height($(this).find('.balance').height() );
//         }
//         else
//         {
//           $(this).find('.balance').height($(this).next().find('.balance').height() );
//         }
//       }
//     );
  }
};

function AddFavorite(linkObj,addUrl3,addTitle3)
{
     if (document.all && !window.opera){
         window.external.AddFavorite(addUrl3,addTitle3);
         return false;
     }
     else if (window.opera && window.print)     {
         linkObj.title = addTitle3;
         return true;
     }
     else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function')) {
         window.sidebar.addPanel(addTitle3,addUrl3,'');
         return false;
     }
     window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k Vašim oblíbeným odkazům.');
     return false;
}

//--------------------------------------------------------------------------


$(document).ready(function() {

  Cufon.replace('.cufon' );
  Cufon.replace('#links.cufon', {textShadow: '0 1px #7ee2ad' } );//67da99' } );

//   selectReplace.init('#modelSelector select', true);
  
//   balanceCols.init();

  customLightbox.init();

  $('#content a[href^="http"]:not([href*='+window.location.host+'])').filter(function(){ return !$(this).find('img').length }).addClass('external');


  if( $('#vip').find('.item').length > 8 )
  {
    $('#vip').addClass('scroll');
    $('#vip .outer').scrollable({
      size: 8
    }).circular().mousewheel().autoscroll({ speed: 1000 });
  }

  $(function()
  {
  	$('.scrollable').jScrollPane({showArrows:true, scrollbarWidth:7 });
  });

  try
  {
      DD_belatedPNG.fix('.png');
  }
  catch(e){}

  $('#twitter a').cTwitter({ userId: '102694097' });

});

