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

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;
}

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 externalLinks = {
  config:
  {
    externalClass: 'external',
    titleAppend:   ' [odkaz na jiný web]'
  },
  init: function()
  {
    $('#main a[href^="http"]:not([href*='+window.location.host+'])').each(
      function()
      {
        $(this).addClass(externalLinks.config.externalClass ).attr('title', $(this).attr('title') + externalLinks.config.titleAppend );
        $(this).click(
          function()
          {
            if(typeof(t)=='object')
            {
              t._trackPageview ('/out/' + $(this).attr('href').replace(/(http|https):\/\//, '' ) );
            }
          }
        );
      }
    );
  }
};

/*******************************************
 *
 *  on DOM ready
 *
 ********************************************/
$(document).ready(function() {

  Cufon.replace('.cufon' );


  $('body').prepend('<a href="#content" accesskey="0" class="forBlind">Přejít na obsah<'+'/a>');

  customLightbox.init();

  externalLinks.init();

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

});

