// NAVIGATION FADE OUT ON HOVER
$(document).ready(function() {
	$(function() {
		// set opacity to nill on page load
		$("#navigation ul li").css("opacity","1");
		
		// on mouse over
		$("#navigation ul li").hover(function () {
			// animate opacity to full
			$(this).stop().animate({
				opacity: 0.8
			}, 'fast');
		},
		
		// on mouse out
		function () {
			// animate opacity to nill
			$(this).stop().animate({
				opacity: 1
			}, 'fast');
		});
	});
});	
	
// TOGGLE
$(function toggleMenu(){
	
	jQuery(".toggle_container").hide(); 
	jQuery(".toggle_container:first").show(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	jQuery("h3.trigger").click(function(){
		jQuery(this).toggleClass("active").next().slideToggle("slow");
		return false; //Prevent the browser jump to the link anchor
	});
						
});

// TOOLTIP 
$(document).ready(function() {
//Tooltips
	var tip;
	$(".tip_trigger").hover(function(){

		//Caching the tooltip and removing it from container; then appending it to the body
		tip = $(this).find('.tip').remove();
		$('body').append(tip);

		tip.show(); //Show tooltip

	}, function() {

		tip.hide().remove(); //Hide and remove tooltip appended to the body
		$(this).append(tip); //Return the tooltip to its original position

	}).mousemove(function(e) {
	//console.log(e.pageX)
		  var mousex = e.pageX + 20; //Get X coodrinates
		  var mousey = e.pageY + 20; //Get Y coordinates
		  var tipWidth = tip.width(); //Find width of tooltip
		  var tipHeight = tip.height(); //Find height of tooltip

		 //Distance of element from the right edge of viewport
		  var tipVisX = $(window).width() - (mousex + tipWidth);
		  var tipVisY = $(window).height() - (mousey + tipHeight);

		if ( tipVisX < 20 ) { //If tooltip exceeds the X coordinate of viewport
			mousex = e.pageX - tipWidth - 20;
			$(this).find('.tip').css({  top: mousey, left: mousex });
		} if ( tipVisY < 20 ) { //If tooltip exceeds the Y coordinate of viewport
			mousey = e.pageY - tipHeight - 20;
			tip.css({  top: mousey, left: mousex });
		} else {
			tip.css({  top: mousey, left: mousex });
		}
	});
});

$(document).ready(function(){
    $(".entry-content a").append("<span></span>");
    $(".entry-content a").hover(function(){
        $(this).children("span").fadeIn(300);
    },function(){
        $(this).children("span").fadeOut(200);
    });
}); 

// CENIK TABLE BG
$('body.page-template-page-cenik-php table td').addClass('dark'); 
