/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = 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 */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset -200) + "px")
			.css("left",(e.pageX + yOffset -300) + "px");
	});			
};

function loadthis(a)
{
	$('#menu a').removeClass('selected');
	$(a).addClass('selected');
	$("html").css("cursor", "progress");
	
	var pokaz=false;

	//if(a.href.match("id=([0-9])")) 
	//	if(a.href.match("id=([0-9])")[1]==4) pokaz=true;
	//if (a.href.match("kt=([0-9])"))
	//	if (a.href.match("kt=([0-9])")[1]==1) pokaz=true;
	//$("#column1 a").removeClass('selected');
	//$("#column1").find("a[href*='id="+a.href.match("id=([0-9]+)")[1]+"']").addClass('selected')
	//if (pokaz) $(".menu2").fadeIn(); else 
		if($(a).parent().parent().parent()[0].className!='menu2')$(".menu2").fadeOut();
		$(a).parent().next().fadeIn();

	if(a.href.indexOf('?')!=-1)window.location.hash=a.href.substr(a.href.indexOf('?')+1);
	$('#column2').fadeOut(150);
	$('#column2').load(a.href+'&ajax', function()
		{
			$("html").css("cursor", "auto");
			$('#column2').fadeIn();
			//setTimeout($('#column2').fadeIn(),500);
		});
	return false;
}

// starting the script on page load
$(document).ready(function(){
	imagePreview();		
	//by xadi

	//inicjalizacja dzialania menu ajaxowego
	$('#menu a').each(function(i,a)
		{
		if (a.href.indexOf('index.php')!=-1)
		$(a).click(function(){return loadthis(this);});
		//jesli jest hash, to wczytajmy ten plik 
		}
	);
	//$('#column2').load('index.php?'+window.location.hash.substr(1)+'&ajax');
	$("#column1").find("a[href='index.php?"+window.location.hash.substr(1)+"']").click();//addClass('selected')
	//by xadi end.
});


						   
if(0)$(document).ready(function(){
	$('#column1>#menu:eq(1)').parent().append('<div style="display:relative;"><div id="curr" >•</div></div>');

var i=0;
if(0)setInterval(function(){
var ile='rotate(-'+ i++ +'deg)';
$('#curr').attr('style',
'width:5px;border:1px solid black;'
+'-moz-transform: '+ile
+';'+'-o-transform: '+ile
+';'+'-webkit-transform: '+ile
+';'+'filter: progid:DXImageTransform.Microsoft.BasicImage(rotation='+i*0.011+')'
+'; display:block;');},100);
});
