$(document).ready(function() {
/*$('#content').prepend('<div id="dev_div">TU JE DEV</div>');
		$(window).scroll(function() {
		  $('#dev_div').html($(window).scrollTop()+'px');
		});*/
/* */
  var scrollElement = 'html, body';
    $('html, body').each(function () {
        var initScrollTop = $(this).attr('scrollTop');
        $(this).attr('scrollTop', initScrollTop + 1);
        if ($(this).attr('scrollTop') == initScrollTop + 1) {
            scrollElement = this.nodeName.toLowerCase();
            $(this).attr('scrollTop', initScrollTop);
            return false;
        }    
    });


	$('.backtotop').click(function(){
		$(scrollElement).animate({scrollTop:0}, 'fast', 'swing');
	});
	
	$('#altLogo').click(function(){
    window.location.href = '/';
  });
	$(window).scroll(function() {
	   
	 /*
	   //http://www.javascriptobfuscator.com/Default.aspx
     if( $(window).scrollTop()==$(document).height()-$(window).height()) { //spodok webu
       //switch mača
       if($('#mac_1').length) {
          $('#mac_1').remove();
       } else {
          $('#content').prepend('<div id="mac_1"></div>');
       }
	   } */
     if( $(window).scrollTop()>146) {
			$('#scrollUp').fadeIn('fast');
			$('#altHead').slideDown('fast','swing');
			//$('#altHead').show();
		} else {
			$('#scrollUp').fadeOut('fast');
			$('#altHead').slideUp('fast','swing');
			//$('#altHead').hide();
		}
	});
     /* */
     /* * /
	  var _0x69a9=["\x68\x74\x6D\x6C\x2C\x20\x62\x6F\x64\x79","\x73\x63\x72\x6F\x6C\x6C\x54\x6F\x70","\x61\x74\x74\x72","\x74\x6F\x4C\x6F\x77\x65\x72\x43\x61\x73\x65","\x6E\x6F\x64\x65\x4E\x61\x6D\x65","\x65\x61\x63\x68","\x66\x61\x73\x74","\x73\x77\x69\x6E\x67","\x61\x6E\x69\x6D\x61\x74\x65","\x63\x6C\x69\x63\x6B","\x2E\x62\x61\x63\x6B\x74\x6F\x74\x6F\x70","\x68\x65\x69\x67\x68\x74","\x6C\x65\x6E\x67\x74\x68","\x23\x6D\x61\x63\x5F\x31","\x72\x65\x6D\x6F\x76\x65","\x3C\x64\x69\x76\x20\x69\x64\x3D\x22\x6D\x61\x63\x5F\x31\x22\x3E\x3C\x2F\x64\x69\x76\x3E","\x70\x72\x65\x70\x65\x6E\x64","\x23\x63\x6F\x6E\x74\x65\x6E\x74","\x66\x61\x64\x65\x49\x6E","\x23\x73\x63\x72\x6F\x6C\x6C\x55\x70","\x73\x6C\x69\x64\x65\x44\x6F\x77\x6E","\x23\x61\x6C\x74\x48\x65\x61\x64","\x66\x61\x64\x65\x4F\x75\x74","\x73\x6C\x69\x64\x65\x55\x70","\x73\x63\x72\x6F\x6C\x6C"];var scrollElement=_0x69a9[0];$(_0x69a9[0])[_0x69a9[5]](function (){var _0x7c59x2=$(this)[_0x69a9[2]](_0x69a9[1]);$(this)[_0x69a9[2]](_0x69a9[1],_0x7c59x2+1);if($(this)[_0x69a9[2]](_0x69a9[1])==_0x7c59x2+1){scrollElement=this[_0x69a9[4]][_0x69a9[3]]();$(this)[_0x69a9[2]](_0x69a9[1],_0x7c59x2);return false;} ;} );$(_0x69a9[10])[_0x69a9[9]](function (){$(scrollElement)[_0x69a9[8]]({scrollTop:0},_0x69a9[6],_0x69a9[7]);} );$(window)[_0x69a9[24]](function (){if($(window)[_0x69a9[1]]()==$(document)[_0x69a9[11]]()-$(window)[_0x69a9[11]]()){if($(_0x69a9[13])[_0x69a9[12]]){$(_0x69a9[13])[_0x69a9[14]]();} else {$(_0x69a9[17])[_0x69a9[16]](_0x69a9[15]);} ;} ;if($(window)[_0x69a9[1]]()>146){$(_0x69a9[19])[_0x69a9[18]](_0x69a9[6]);$(_0x69a9[21])[_0x69a9[20]](_0x69a9[6],_0x69a9[7]);} else {$(_0x69a9[19])[_0x69a9[22]](_0x69a9[6]);$(_0x69a9[21])[_0x69a9[23]](_0x69a9[6],_0x69a9[7]);} ;} );
		
	/* */

  $('.bubbleInfo').each(function () {
    // options
    var distance = 10;
    var time = 250;
    var hideDelay = 500;

    var hideDelayTimer = null;

    // tracker
    var beingShown = false;
    var shown = false;
    
    var trigger = $('.trigger', this);
    var popup = $('.bPopup', this).css('opacity', 0);

    // set the mouseover and mouseout on both element
    $([trigger.get(0), popup.get(0)]).mouseover(function () {
      // stops the hide event if we move from the trigger to the popup element
      if (hideDelayTimer) clearTimeout(hideDelayTimer);

      // don't trigger the animation again if we're being shown, or already visible
      if (beingShown || shown) {
        return;
      } else {
        beingShown = true;

        // reset position of popup box
        popup.css({
          top: 30,
          left: -100,
          display: 'block' // brings the popup back in to view
        })

        // (we're using chaining on the popup) now animate it's opacity and position
        .animate({
          top: '-=' + distance + 'px',
          opacity: .9
        }, time, 'swing', function() {
          // once the animation is complete, set the tracker variables
          beingShown = false;
          shown = true;
        });
      };
      return false;
    }).mouseout(function () {
      // reset the timer if we get fired again - avoids double animations
      if (hideDelayTimer) clearTimeout(hideDelayTimer);
      
      // store the timer so that it can be cleared in the mouseover if required
      hideDelayTimer = setTimeout(function () {
        hideDelayTimer = null;
        popup.animate({
          top: '-=' + distance + 'px',
          opacity: 0
        }, time, 'swing', function () {
          // once the animate is complete, set the tracker variables
          shown = false;
          // hide the popup entirely after the effect (opacity alone doesn't do the job)
          popup.css('display', 'none');
        });
      }, hideDelay);
    });
  });
});
