var iehack=($.browser.msie && $.browser.version<9);
//iehack=0

function bubble_show(item,visible) {
 if(visible){
  if(iehack){
    $('.bubble_onesol').css('visibility','hidden');
    $('.bubble_blog').css('visibility','hidden');
    $('#'+item).show();
    //$('#'+item).css("display","block");
    $('#'+item+'_full').show();
  }else{
    $('.bubble_onesol').stop().fadeTo(200,0);
    $('.bubble_blog').stop().fadeTo(200,0);
    $('#'+item).stop().fadeTo(200,1);
    $('#'+item+'_full').css('display','block');
    $('#'+item+'_full').stop().fadeTo(400,1);
  }
 }else{
  if(iehack){
    $('#'+item+'_full').hide();
    $('#'+item).hide();
    $('.bubble_onesol').css('visibility','visible');
    $('.bubble_blog').css('visibility','visible');
  }else{
    $('#'+item+'_full').stop().fadeTo(300,0,function(){$('#'+item+'_full').css('display','none');});
    $('#'+item).stop().fadeTo(400,0);
    $('.bubble_onesol').stop().fadeTo(300,1);
    $('.bubble_blog').stop().fadeTo(300,1);
  }
 }
}



var blog_pages=5;
var blog_page=0;
var blog_timer=0;
function blog_slide(page,timer) {
 if (page==blog_page) return;
 if (timer && timer!=blog_timer) return;
 blog_timer++; setTimeout("blog_slide(0,"+blog_timer+")",15000);

 if (blog_page==0) {
   blog_page=page?page:1;
   if (iehack){
     $('#blog_clanek'+blog_page).show();
   }else{
     $('#blog_clanek'+blog_page).fadeIn(800);
   }
 }else{
   var last=blog_page;
   blog_page=page?page:blog_page+1;
   if (blog_page>blog_pages) blog_page=1;
   if (iehack){
     $('#blog_clanek'+last).hide();
     $('#blog_clanek'+blog_page).show();
   }else{
     $('#blog_clanek'+last).stop().fadeTo(500,0,function(){
       $('#blog_clanek'+last).css('display','none');
       $('#blog_clanek'+blog_page).css('opacity','0');
       $('#blog_clanek'+blog_page).css('display','block');
       $('#blog_clanek'+blog_page).stop().fadeTo(700,1);
     });
   }
 }

 var bullets="";
 for (var i=1;i<=blog_pages;i++) {
   bullets+='<img src="/img/page-dot'+(blog_page==i?1:0)+'.png" class="bullet" width="6px" height="6px" alt="" onclick="blog_slide('+i+')" />';
 }
 $('.bullet_blog').html(bullets);
}


var ref_pages=5;
var ref_page=0;
var ref_timer=0;
function ref_slide(page,timer) {
 if (page==ref_page) return;
 if (timer && timer!=ref_timer) return;
 ref_timer++; setTimeout("ref_slide(0,"+ref_timer+")",12000);

 if (ref_page==0) {
   ref_page=page?page:1;
   if (iehack){
     $('#ref_slide'+ref_page).show();
   }else{
     $('#ref_slide'+ref_page).fadeIn(700);
   }
 }else{
   var last=ref_page;
   ref_page=page?page:ref_page+1;
   if (ref_page>ref_pages) ref_page=1;
   if (iehack){
     $('#ref_slide'+last).hide();
     $('#ref_slide'+ref_page).show();
   }else{
     $('#ref_slide'+last).stop().fadeTo(300,0,function(){
       $('#ref_slide'+last).css('display','none');
       $('#ref_slide'+ref_page).css('opacity','0');
       $('#ref_slide'+ref_page).css('display','block');
       $('#ref_slide'+ref_page).stop().fadeTo(700,1);
     });
   }
 }

 var bullets="";
 for (var i=1;i<=ref_pages;i++) {
   bullets+='<img src="/img/page-dot'+(ref_page==i?1:0)+'.png" class="bullet" width="6px" height="6px" alt="" onclick="ref_slide('+i+')"/>';
 }
 $('.bullet_ref').html(bullets);
}



var pay_selected="";
function pay_show(item){
  if (item && $('#'+item).attr("checked")) return;
  if (iehack) {
    $('#'+item+'_img').show();
  }else{
    if (!$('#'+item).attr("checked")) $('#'+item+'_img').stop().css("opacity",0);
    $('#'+item+'_img').show().fadeTo(200,0.5);
  }
}
function pay_hide(item,force){
  if (!force && $('#'+item).attr("checked")) return;
  if (iehack) {
    $('#'+item+'_img').hide();
  }else{
    $('#'+item+'_img').stop().fadeTo(200,0);
  }
}
function pay_change(item){
  if (pay_selected){
    pay_hide(pay_selected,1);
    $('#'+pay_selected+'_butt').hide();
  }
  if (iehack) {
    $('#'+item+'_butt').show();
  }else{
    $('#'+item+'_img').fadeTo(200,1);
    $('#'+item+'_butt').show().fadeTo(200,1);
  }
  pay_selected=item;
}





var jqhint_width=0;
function jqhint(e) {
  text=$(e).attr("popis");
  if (!text) text=$(e).attr("alt");
  if (!text) text="n/a";//TODO nebo raci return;
  $('#jqhint_text').html(text);

  if (jqhint_width){
    $('#jqhint').width(jqhint_width);
  }else{
    $('#jqhint').width("auto");
    if ($('#jqhint').width()>550) $('#jqhint').width(550);
  }
  jqhint_width=0;

  //IE7 hack
  if ($.browser.msie && $.browser.version>=7) $('#jqhint_img').hide();

  var pos = $(e).position();
  var stred=pos.left+parseInt($(e).width())/2;
  $('#jqhint').css("left",Math.round(stred-parseInt($('#jqhint').width())/2)+"px");
  var l=$('#jqhint').position().left;//kua proc nejede?
  l=parseInt($('#jqhint').css("left"))
  if (l<30) $('#jqhint').css("left","30px");
  //y=pos.top+$(e).height()+4;
  y=pos.top-$('#jqhint').height()-4;
  $('#jqhint').css("top",y+"px");

  var epos=$(e).position();
  var sipka=parseInt(epos.left) - parseInt($('#jqhint').css("left")) + parseInt($(e).width()/2 - 8);
  $('#jqhint_img').css("margin-left",sipka+"px");

  //IE7 hack
  if ($.browser.msie && $.browser.version>=7) {
    $('.jqhint_tb').width(parseInt($('#jqhint').width())-10)+"px";
  }

  $('#jqhint').show();
  y+=4;
  if (!iehack) $('#jqhint').stop().css("opacity",0).animate({top:y+"px",opacity:0.8},300);
}
function jqhint_hide() {
  if (iehack) {
    $('#jqhint').hide();
  }else{
    $('#jqhint').stop().fadeTo(100,0.1,function(){$('#jqhint').hide();});
  }
}


