//ą

$(document).ready(function () {
  /* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("#content a.prev").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview' style='display:none;'><img src='"+ $(this).find("span.href").text() +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn(500);						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("#content a.prev").mousemove(function(e){
		var posY;
		
		if (e.pageY - $(window).scrollTop() + $('#preview').height() >= $(window).height() ) {
		posY = $(window).height() + $(window).scrollTop() - $('#preview').height() - 15 ;
		} else {
		posY = e.pageY - 15;
		}
		$("#preview")
		.css("top",(posY) + "px")
		.css("left",(e.pageX + 15) + "px");
	});		
	
	$('#koszyk').click(function(){
    $(this).parent("form").submit();
	});
});
