/*
 * TOOLTIP Script  by Peminator for slovak CK
 * powered by jQuery (http://www.jquery.com)
 * based on work of Alen Grakalic (cssglobe.com)
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 */
 

                

 /* compatibility fix by peminator : all $ rewritten to jQuery */
this.screenshotPreview = function(){	
	/* CONFIG */
             // pozor x zvisle y vodorovne
		xOffset = 60; //
                yOffset = -100;
                xOffsetOk =0; // korekcia pozicie by peminator  -global var meni sa v skripte
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	/*  keby to bolo na a obalujuce img ... $(this).find('img:first').attr('id')   */
        


	// PRELOAD TOOLTIP IMAGEZ
        jQuery("img.screenshot").each(function(i){
		var bigsrc = this.src;
		var zoom = 1 ; // pomer zoomu oproti originalu: 1 = 100%
		var bigsrcl = bigsrc.length;
		bigsrcl = bigsrcl-4;
		// var bigsrcb = bigsrcl-15;
                /*	var bigsr = bigsrc.substring(0,bigsrcl) + "_med.jpg"; */
		var bigsr = bigsrc.substring(0,bigsrcl) + "2.jpg";  // image_s2.jpg
                var newImg = new Image();
                newImg.src = bigsr;
        });

	
	jQuery("img.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";
                //var neww = this.width*2;
                //var newh = this.height*2;
                
                // POPISKA OFF (vklada z title dane na img)
                var c = "" ; //var c = (this.t != "") ? "<br/>" + this.t : "";
		
                var bigsrc = this.src;
		var zoom = 1 ; // pomer zoomu oproti originalu: 1 = 100%
		
                var bigsrcl = bigsrc.length;
		bigsrcl = bigsrcl-4;
		var bigsrcb = bigsrcl-15;
                /*	var bigsr = bigsrc.substring(0,bigsrcl) + "_med.jpg"; */
		var bigsr = bigsrc.substring(0,bigsrcl) + "2.jpg";  // image_s2.jpg
                
                
                
                var newImg = new Image();
                newImg.src = bigsr;
                
                
                var bigsrtext = bigsr;
		var bigsrtextl = bigsrtext.length;
		var bigsrtexts= bigsrtextl -20;
		var bigsrtexto = bigsrtext.substring(bigsrtexts,bigsrtextl);
		var image1 = jQuery('<img />').attr('src', bigsr);

                var newh = newImg.height*zoom;
                xOffsetOk = xOffset + newh; // oprava pozicie
                var neww = newImg.width*zoom;

jQuery("body").append("<div id='screenshot'><img src='"+ bigsr + "' alt='preview' width='"+neww+"' height='"+newh+"' />" + c + "</div>");
jQuery("#screenshot")
	.css("top",(e.pageY - xOffsetOk) + "px")
	.css("left",(e.pageX + yOffset) + "px")
	.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		jQuery("#screenshot").remove();
    });	
	// bolo jQuery("a.screenshot").mousemove(function(e){
        jQuery("img.screenshot").mousemove(function(e){
		jQuery("#screenshot")
			.css("top",(e.pageY - xOffsetOk ) + "px")
			.css("left",(e.pageX + yOffset ) + "px");
	});			
};


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