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

//Novinky
var novinky_pages=5;
var novinky_page=0;
var novinky_timer=0;
function novinky_slide(page,timer) {
 if (page==novinky_page) return;
 if (timer && timer!=novinky_timer) return;
 novinky_timer++; setTimeout("novinky_slide(0,"+novinky_timer+")",15000);

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

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

//Slider
function sluzby_slide(delta,auto) {
  clearTimeout(sluzby_timer);
  var current=sluzby_index;
  sluzby_index+=delta;
  if ($.browser.msie && $.browser.version==7) $("#sluzby_content").css("position","relative");//IE7 hack
  if (sluzby_index>sluzby_count-4) sluzby_index=sluzby_count-4;
  if (sluzby_index==current && auto) sluzby_index=0;
  if (sluzby_index<0) sluzby_index=0;
  $("#sluzby_slider").stop().animate({left:-sluzby_index*sluzby_width},600);
  sluzby_timer=setTimeout("sluzby_slide(1,1)",10000);
}

//jQhint
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;

  var ykorekce=125;
  var xkorekce=parseInt($('#pozadi').position().left);
  if (!$.browser.msie) xkorekce+=parseInt($('#pozadi').css('margin-left'));

  //IE7 hack
  if ($.browser.msie && $.browser.version>=7) $('#jqhint_img').hide();
  var pos = $(e).position();
  var stred=pos.left+parseInt($(e).width())/2;
  stred+=xkorekce;
  $('#jqhint').css("left",Math.round(stred-parseInt($('#jqhint').width())/2)+"px");
  var l=$('#jqhint').position().left;
  l=parseInt($('#jqhint').css("left"));
  if (l<30) $('#jqhint').css("left","30px");
  y=pos.top-$('#jqhint').height()-4;
  y+=ykorekce;
  $('#jqhint').css("top",y+"px");

  var epos=$(e).position();
  var sipka=parseInt(epos.left) - parseInt($('#jqhint').css("left")) + parseInt($(e).width()/2 - 8);
  sipka+=xkorekce;
  $('#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();});
  }
}


//Tarify
//var tarify=new Array("webstart","weboptim","webprofi","webcool");
var tarify={1:"webstart",2:"weboptim",3:"webprofi",8:"webcool"};


var tarif_index=3;
function tarif_switch(t) {
  if (t==tarif_index) return;
  var o="tarif_"+tarify[t];

  $("#tarif_"+tarify[tarif_index]).hide();
  $("#tarif_"+tarify[tarif_index]+"_img").fadeOut(400);

  if ($.browser.msie) {
    $("#tarify_obsah_"+tarify[tarif_index]).slideUp(400);
    $("#tarify_obsah_"+tarify[t]).slideDown(400);
  }else{
    $("#tarify_obsah_"+tarify[tarif_index]).hide();
    $("#tarify_obsah_"+tarify[t]).fadeIn(400);
  }

  $("#tarif_"+tarify[t]).show();
  $("#tarif_"+tarify[t]+"_img").fadeIn(400);
  tarif_index=t;
  $("#tid").attr('value',t);
}



function obj_pravniforma(id) {
  if (id<10) {
    $("#table_fak,#table_sz,#dom_on_help,#fak_on_help,#fak_on,#fak_ic,#fak_dic,#dom_on,#dom_ic,#dom_dic").hide();
    if (id==1) $("#table_fak").show();
    if (id==2) $("#table_fak,#fak_on,#fak_ic,#fak_dic,#fak_on_help").show();
    if (id==3) $("#table_fak,#fak_on,#fak_ic,#fak_dic").show();
    if (id==4) $("#table_sz").show();
  }else{
    $("#dom_on,#dom_ic,#dom_dic,#dom_on_help").hide();
    if (id==11) $("#table_fak").show();
    if (id==12) $("#dom_on,#dom_ic,#dom_dic,#dom_on_help").show();
    if (id==13) $("#dom_on,#dom_ic,#dom_dic").show();
  }
}


function dealer_pravniforma(id) {
  $("#dealer_on,#dealer_ic,#dealer_dic,#dealer_on_help").hide();
  if (id==2) $("#dealer_on,#dealer_ic,#dealer_dic,#dealer_on_help").show();
  if (id==3) $("#dealer_on,#dealer_ic,#dealer_dic").show();
}








