﻿/*
* 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 */
    $("img.img_large").hover(function(e) {
        if ($("#giantimage").attr("src") != null && $("#giantimage").attr("src") != "") {
            this.t = this.title;
            this.title = "";
            var c = (this.t != "" && this.t != null) ? "<br/>" + this.t : "";
            //var c = this.title;
            $("body").append("<p id='preview'><img src='" + $("#giantimage").attr("src") + "' alt='' />" + c + "</p>");
            $("#preview")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px")
			.fadeIn("fast");
        }
    },
	function() {
	    if ($("#giantimage").attr("src") != null && $("#giantimage").attr("src") != "") {
	        this.title = this.t;
	        $("#preview").remove();
	    }
	});
    $("img.img_large").mousemove(function(e) {
        $("#preview")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px");
    });
};


this.imagePreview2 = 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 */
    $("img.hovimg1").hover(function(e) {
        var pathel;
        pathel = $(this).next();
        if ($(this).next().attr("value") != null && $(this).next().attr("value") != "") {
            this.t = this.title;
            this.title = "";
            var c = (this.t != "" && this.t != null && this.t != "undefined") ? "<br/>" + this.t : "";
            //var c = this.title;
            $("body").append("<p id='preview'><img src='" + $(this).next().attr("value") + "' alt='' />" + c + "</p>");
            $("#preview")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px")
			.fadeIn("fast");
        }
    },
	function() {
        if ($(this).next().attr("value") != null && $(this).next().attr("value") != "") {
	        this.title = this.t;
	        $("#preview").remove();
	    }
	});
	$($(this)).mousemove(function(e) {
        $("#preview")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px");
    });
};


// starting the script on page load
$(document).ready(function() {
    imagePreview();
    imagePreview2();
});

//used for captcha refresh
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

