/*
 * Url 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.screenshotPreview = 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.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";
		
		var c = "";
		if(this.t != "") 
			c = this.t;
		else
		{
			if(this.href.toLowerCase().indexOf(Configuration.SiteUrl) > -1)
				c = "www.magnetix.dk";
//			c += this.innerText;
		}

        $("body").append('<div id="pop" class="windowPop"><div class="windowPopTitle">'+c+'</div><div class="windowPopImgHolder"><div class="windowPopImg"><img src="'+this.rel+'" alt="" /></div></div></div>');
		$("#pop")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
//			.fadeIn("instant");						
			.show();
    },
	function(){
		this.title = this.t;	
		$("#pop").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#pop")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

this.screenshotInit=function()
{
	var coll = $("a.screenshot");
	
	for(var i=0;i<coll.length;i++)
	{
		var anc = coll[i];
		if(anc["rel"])
			continue;
		var hrefParts = anc.href.split(Configuration.SiteUrl);
		var imageName = /*"www.magnetix.dk"+*/hrefParts[1].replace(/[\?\\\/\:\&\=\%]/ig, "");
		var imageUrl = Configuration.SiteUrl + "preview/" + imageName + ".jpg?uid="+Math.random();
		
		anc["rel"] = imageUrl;
	}
	for(var i=0;i<coll.length;i++)
	{
		
	}
		
}

// starting the script on page load
$(document).ready(function(){
	screenshotInit();
	screenshotPreview();
});
