/*
2 * Url preview script
3 * powered by jQuery (http://www.jquery.com)
4 *
5 * written by Alen Grakalic (http://cssglobe.com)
6 *
7 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
8 *
9 */
/*
 * 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 = 75;
		yOffset = 20;
		
		xOffsetLoading = 15;
		yOffsetLoading = 2;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.imgRolloverPreview").hover(function(e){
		//showAlert(this);
		
		if($.browser.name == 'msie'){
			this.rel = this.rel+"?"+Math.random();
		}
		
		this.t = this.title;//this.title;
		this.tf = this.name;
		this.title = "";
		var c = (this.tf != "") ? "<br/>" + this.tf : "";
		$("body").append("<div id='imgRolloverPreview'>"+
			"<div style='margin-bottom:5px'><img id='myImage'/></div>"+
			"<div style='padding-left:1px; float:left; width:200px;'>"+this.tf+"</div>"+
			"</div>"
			);
 	
	$("body").append("<p id='imgRolloverPreviewLoading'><img src=\"files/images/loader-circle.gif\" width='16' height='16' /></p>");	
		$("#myImage").attr('src', this.rel).load(function() {  
			$("#imgRolloverPreview")
			.fadeIn("def");	
			$("#imgRolloverPreviewLoading").remove();
		}); 
		$("#imgRolloverPreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");	
			
		$("#imgRolloverPreviewLoading")
			.css("top",(e.pageY - yOffsetLoading) + "px")
			.css("left",(e.pageX + xOffsetLoading) + "px")
			.fadeIn("fast");	
							
    },
	function(){
		this.title = this.t;	
		$("#imgRolloverPreview").remove();
		$("#imgRolloverPreviewLoading").remove();
    });	
	
	$("a.imgRolloverPreview").mousemove(function(e){
		$("#imgRolloverPreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
			
		$("#imgRolloverPreviewLoading")
			.css("top",(e.pageY - yOffsetLoading) + "px")
			.css("left",(e.pageX + xOffsetLoading) + "px");
	});			
};

// jQBrowser v0.2: http://davecardwell.co.uk/javascript/jquery/plugins/jquery-browserdetect/
(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);}return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';}if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';}r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);

// starting the script on page load
$(document).ready(function(){
	screenshotPreview();
	
});