$(document).ready(function(){
	
	var old_pos = $('.libg').position();
	var old_left = old_pos.left;
	var old_width = $('.libg').css('width');
	
	$('#top_nav2 ul li').hover(function(){
		
		var pos = $(this).position();
		var new_left = pos.left;
		var new_width = $(this).css('width');
		//alert(new_width);
		
		$('.libg').stop().animate({
			left: new_left+'px',
			width: new_width
		},800,'easeOutBack');
		
	}, function(){
		$('.libg').stop().animate({
			left: old_left+'px',
			width: old_width
		},800,'easeOutBack');
	});
	
	tooltip();
	
	$.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };

	$('.rez_izb li').click(function(){
		var b = $('.current').attr('title');
		$('.current').removeClass('current');
		$(this).addClass('current');
		var a = $(this).attr('title');
		
		$('#'+b).attr('style','display:none;');
		$('#'+a).fadeIn(); //attr('style','display:block;');
		//$(this).addClass('current');
	});
	
});


this.tooltip = function(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$(".tooltip").hover(function(e){											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$(".tooltip").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

