/*
 * 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 = -300;
		yOffset = -350;

		windowSize = getWinSize();

		alert(windowSize.height);

		//innerheight = (window.innerHeight);

		//alert(innerheight);

		// 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 + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#preview").remove();
    });
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY + yOffset) + "px")
			.css("left",(e.pageX + xOffset) + "px");
	});
};
*/

////////////////////////////////////////////////////////////
// getWinSize(window)
function getWinSize(win)
{
    if(!win) win = window;
    var s = new Object();
    if(typeof win.innerWidth != 'undefined')
    {
        s.width = win.innerWidth;
        s.height = win.innerHeight;
    }
    else
    {
         var obj = getBody(win);
         s.width = parseInt(obj.clientWidth);
         s.height = parseInt(obj.clientHeight);
    }
    return s;
}
////////////////////////////////////////////////////////////
// Der IE hat 2 verschiedene Objekte für den strict und quirks Mode.
function getBody(w)
{
    return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}


this.imagePreview = function(){
	// CONFIG

	xOffset =  -320;
	yOffset =  -200;

	windowSize = getWinSize();

	// these 2 variable determine popup's distance from the cursor
	// you might want to adjust to get the right result


	$("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",((windowSize.height / 2) + yOffset) + "px")
			.css("left",((windowSize.width / 2) + xOffset) + "px")
			.fadeIn("slow");
    },
	function(){
		this.title = this.t;
		$("#preview")
			.fadeOut("slow")
			.remove()
		;
    });

    $("a.preview2").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",(-350 + e.pageY) + "px")
			.css("left",((windowSize.width / 2) + xOffset) + "px")
			.fadeIn("slow");
    },
	function(){
		this.title = this.t;
		$("#preview")
			.fadeOut("slow")
			.remove()
		;
    });

	$("a.preview2").mousemove(function(e){
		$("#preview")
			.css("top",(-350 + e.pageY) + "px")
	});

};


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