function get_fb_comments(el)
{
    var fb = document.createElement('fb:comments');
    fb.setAttribute('numposts','20');
    fb.setAttribute('width','265');
    document.getElementById(el).appendChild(fb);
}

function get_fb_like(el)
{
    var fb = document.createElement('fb:like');
    fb.setAttribute('show_faces','false');
    fb.setAttribute('layout','button_count');
    fb.setAttribute('width','265');
    document.getElementById(el).appendChild(fb);
}

function get_fbml(){
    var html = document.getElementsByTagName('html')[0];
    html.setAttribute('xmlns:fb','http://www.facebook.com/2008/fbml');
}

function submenu()
{
    var topmenu = $("#mainmenu li.top");
    var submenu = $("#mainmenu li ul");
    var curr_ul = $("#mainmenu li.curr ul");
    var curr_li = $("#mainmenu li.curr")[0];
    var image_h = $("#header-image").attr("class");

    $.each(topmenu, function(key, el)
    {
      $(this).bind({
        mouseenter: function()
        {
          submenu.css({display: 'none'});
          $(el).children('ul').fadeIn(0);

          $("#header-image").removeClass(image_h).addClass($(el).attr('id').replace('nav_',''));
        },
        mouseleave: function()
        {
          submenu.css({display: 'none'});
          $(curr_ul).fadeIn(0);

          $("#header-image").removeClass($(el).attr('id').replace('nav_',''));
        },
      });
    });
    $('#mainmenu').bind({
      mouseleave: function()
      {
        $("#header-image").addClass(image_h);
      }
    });
}

function ratings()
{
    if (document.getElementById('rating_handler'))
    {
      var stars = $("#rating_handler a");
      var handler = $("#rating_handler");
      var pos = 0;
      $.each(stars, function(key, el) 
      {
        el.onmouseover = function()
        {
          switch(key)
          {
            case 0: pos = 11; break;
            case 1: pos = 22; break;
            case 2: pos = 33; break;
            case 3: pos = 44; break;
            case 4: pos = 55; break;
          }
          handler.css('background-position','0 -'+pos+'px');
        }
        el.onmouseout = function()
        {
          handler.css('background-position','0 0');
        }
      });
    }
}
function blockhiding()
{
  if ($('#partners_block') && $('#partners_block div.partner').length == 0)
  {
      $('#partners_block').css({ display: 'none' });
  }
  if ($('#pr_block') && $('#pr_block div.item-ad').length == 0)
  {
      $('#pr_block').css({ display: 'none' });
  }
}

$(document).ready(function ()
{	
	submenu();
	blockhiding();

    /*
    $('a[rel=gallery]').colorbox({
      iframe:true, width:'1050px', height:'700px', slideshow:false, transition:'fade',close:false,current:'', previous: false, next: false
    });
    */
    //$("a[rel=gallery]").colorbox({slideshow:false, transition:'fade',close:"Zavřít",current:"{current} z {total}", previous:"předchozí", next: "další", slideshowStart: "spustit slideshow", slideshowStop: "zastavit slideshow"});

    ratings();
    
    // comment form
    $('#btn-add-comment').click(function(){
      $('#btn-add-comment').css('display','none');
      $('#comment-add').fadeIn('fast');
    });
    // replies forms
    var replies = $('#comment-list .btn-add-reply');
    $.each(replies, function(key, el)
    {
      $(el).click(function(){
        var frm_id = $(el).attr('id').replace('btn-add-reply-','reply-add-');
        $(el).css('display','none');
        
        $('#'+frm_id).fadeIn('fast');
      });
      
      $('#comment-form').submit(function() {
        
      });
    });
});



