$(document).ready(function(){
  $("a[rel^='imageGallery']").prettyPhoto({
    theme: 'facebook'
  });
  
  $("a[rel^='inline']").prettyPhoto({
    theme: 'dark_square'
  });
  
});

$(document).ready(function(){
      $("#zalozka-kamen").hover(function(){
        $(this).css({"background" : "url(/izolacnivata-new/img/zalozka-kamen-akt.png) no-repeat 0 0", "right" : "-152px"}).animate({"right" : "0px"}, 500);  
      }, function(){
          $(this).animate({"right" : "-152px"}, 300, function(){
            $(this).css({"background": "url(/izolacnivata-new/img/zalozka-kamen.png) no-repeat 0 0", "right" : "-156px"});  
          });  
      });
      
      $("#zalozka-vata").hover(function(){
        $(this).animate({"right" : "0px"}, 500);  
      }, function(){
          $(this).animate({"right" : "-155px"}, 300);  
      });
      
      $("#zalozka-sindel").hover(function(){
        $(this).css({"background" : "url(/izolacnivata-new/img/zalozka-sindel-akt.png) no-repeat 0 0", "right" : "-152px"}).animate({"right" : "0px"}, 500);  
      }, function(){
          $(this).animate({"right" : "-152px"}, 300, function(){
            $(this).css({"background": "url(/izolacnivata-new/img/zalozka-sindel.png) no-repeat 0 0", "right" : "-156px"});  
          });  
      });
      
      $("#zalozka-newsletter").hover(function(){
        $(this).animate({
          "right" : "-91px"//,
          //"background": "url(/izolacnivata-new/img/zalozka-newsletter.png) no-repeat 0 0"
        }, 500);  
      }, function(){
        $(this).animate({
          "right" : "-200px"//,
          //"background": "url(/izolacnivata-new/img/zalozka-newsletter.png) no-repeat 0 0"
        }, 500);
      });
      
      /* Kontakt tabs*/
      $("#kontakt-tab").click(function(){
        if($("#kontakt-frm").is(":hidden")) {
          $("#kontakt-frm2").hide();
          $("#kontakt-frm").show();
          $("#navigace ul li").removeClass("aktivni");
          $(this).addClass("aktivni");
        }
      });
      
      $("#kontakt-tab2").click(function(){
        if($("#kontakt-frm2").is(":hidden")) {
          $("#kontakt-frm").hide();
          $("#kontakt-frm2").show();
          $("#navigace ul li").removeClass("aktivni");
          $(this).addClass("aktivni");
        }
      });
      
      $("#produkt-tab").click(function(){
        if($("#produkt-frm").is(":hidden")) {
          $("#produkt-frm2").hide();
          $("#produkt-frm").show();
          $("#navigace ul li").removeClass("aktivni");
          $(this).addClass("aktivni");
          $("#rampopis-panter").show();
        }
      });
      
      $("#produkt-tab2").click(function(){
        if($("#produkt-frm2").is(":hidden")) {
          $("#produkt-frm").hide();
          $("#produkt-frm2").show();
          $("#navigace ul li").removeClass("aktivni");
          $(this).addClass("aktivni");
          $("#rampopis-panter").hide();
        }
      });
      
      
      
      });
      
      $(document).ready(function() {
  
  // Show menu tooltips
  $("#hlavnimenu li").each(function(){
    $(this).children().hover(function(e){
      //$("#menutooltip>li:eq("+$(this).parent().index()+")").css({"left" : $(this).parent().position().left + 55});
      $("#menutooltip>li:eq("+$(this).parent().index()+")").show();
    },function(){
      $("#menutooltip>li:eq("+$(this).parent().index()+")").hide();
    }); 
  });
  
  /*$('#mapa_prodejci').maphilight({

  });  */
  
  function markArea(element, posX, posY){
    var imgUri = "/izolacnivata-new/img/kraje/";
    if(document.getElementById('region').src.indexOf('kraje')!=-1){
      var nazev=element.getAttribute('title');
      var imgsrc=element.getAttribute('rel');
      var spanpopis = document.createElement('span');
      spanpopis.className='description-'+imgsrc;
      spanpopis.setAttribute('id','nazevkraje');
      element.parentNode.appendChild(spanpopis);
      spanpopis.appendChild(document.createTextNode(nazev));
      document.getElementById('region').src=imgUri+imgsrc +'.png';
      //$('#mapTab .occurs#occur'+imgsrc).css('background-position', '0 -30px');
      //moveTooltip(posX, posY);
      //var id = $(element).index()+1;
      //var puntik =  $("#kraj_puntik"+id).css({"background":"url(/izolacnivata-new/img/mapa-puntik-akt.png) no-repeat"});
    }
  }
  
  function areaDescription(posX, posY) {
    posX = posX - 300;
    posY = posY - 200;
    
    $("#nazevkraje").css({"left":posX+"px"});
    $("#nazevkraje").css({"top":posY+"px"});
  }
  
  function unmarkArea(element){
    var imgUri = "/izolacnivata-new/img/kraje/";
    if(document.getElementById('region').src.indexOf('kraje')!=-1 ){
        var imgsrc=element.getAttribute('rel');
        spanpopis=document.getElementById('nazevkraje')
        if(spanpopis){
          spanpopis.removeChild(spanpopis.childNodes[0]);
           element.parentNode.removeChild(spanpopis);
        } 
        document.getElementById('region').src=imgUri+'nic.png';
        //var id = $(element).index()+1;
        //if(id == 1) {id = "";} else if(id == 10) { id = 9;} else if(id == 9) { id =10;}
        //var puntik =  $("#kraj_puntik"+id).css({"background":"url(/izolacnivata-new/img/mapa-puntik-pas.png) no-repeat"});
    }
  }
  
  $('#mapacr area').mouseover(function(e){
    markArea(this,e.pageX, e.pageY);
  });
  
  $('#mapacr area').mouseout(function(){
    unmarkArea(this);
  });
  
});
