$(document).ready(function(){

   if (runAnimation == true){
      delay = 100;
      for(x=0;x<5;x++) setTimeout("runAnim('"+(x+1)+"')",delay*x);
   }
   else{
      $(".box").each(function(i,elem){
                         $(elem).show();
      })
   }

   logoAnim();

    // hyphenator
    Hyphenator.config({
        		displaytogglebox : false
        	});
    Hyphenator.addExceptions('cs','OSPZVASO, OSPZV-ASO, OSPZV, ASO');

    Hyphenator.run();

})

function logoAnim(){
    $("#logoBGimg").fadeIn(1200);
}

function search(val){
    document.getElementById('searchString').value = val;
    document.search.submit();
}

function runAnim(i){
      $("#box"+i).show("slide", { direction: "up" }, 800);
}

function moveUp(){
      $("#shrink").animate({'height': '-=270'}, 500, function(){
          changeDir('Down','Up');
      });
      ajax('/ajax/system.php?dir=up','null');
      return false;
}

function moveDown(){
      $("#shrink").animate({'height': '+=270'}, 500, function(){
          changeDir('Up','Down');
      });
      ajax('/ajax/system.php?dir=down','null');
      return false;
}


function changeDir(dirdisplay,dirhide){
      document.getElementById("menu"+dirhide).style.display='none';
      document.getElementById("menu"+dirdisplay).style.display='';
}

function searchForm(val){
   if (val=='vyhledat...') document.getElementById('searchString').value = '';
}

function fbBTN(state){
 if (state=='on') $('#fake_facebook_button').attr({'class': 'fake_facebook_button_hover'});
 else             $('#fake_facebook_button').attr({'class': ''});
}


function passThrough(e) {
    $("#fake_facebook_button").each(function() {
       // check if clicked point (taken from event) is inside element
       var mouseX = e.pageX;
       var mouseY = e.pageY;
       var offset = $(this).offset();
       var width = $(this).width();
       var height = $(this).height();

       if (mouseX > offset.left && mouseX < offset.left+width
           && mouseY > offset.top && mouseY < offset.top+height){
           $("#fake_facebook_button").css({'display':'none'});
           fbclick(e);
         }

    });
}

function fbclick(e){
 var x = e.pageX;
 var y = e.pageY;
 alert($(document.elementFromPoint(x, y)).name);
 $(document.elementFromPoint(x, y)).click();
}


