﻿

$(document).ready(function() {

    $(".menu").find("a").each(function() {
        NewSrcForImage(jQuery(this));
    });

    $(".product_sec span").find("a").each(function() {
        NewSrcForImage(jQuery(this));
    });

    $(".right_sec .download").each(function() {
        NewSrcForImage(jQuery(this));
    });

    screenshoot();

    $("#left_container .tab ul li a").each(function() {

        if (this.href == location.href) {
            $(this).parent().css("background-image", "url(skins/skin_1/images/tab-hover.png");
        }
    });
});

function NewBackgroundForLi(obj) {
//    jQuery(obj).mouseover(function() {
//        //obj.parent().addClass("tab-hover");
//        //obj.parent().removeClass("tab");
//    });
//    jQuery(obj).mouseout(function() {
//        //obj.parent().addClass("tab");
//        //obj.parent().removeClass("tab-hover");
//    });
}


function NewSrcForImage(obj) {
    var src = obj.find("img").attr("src");
    var newSrc = "";

    if (src.indexOf("-hover") > 0) {
        newSrc = src.replace("-hover", "");
    }
    else {
        newSrc = newSrc + src.replace(/(.+)(\.[a-z]+)$/, "$1-hover$2");
    }

    jQuery(obj).mouseover(function() {
        obj.find("img").attr("src", newSrc);
    });
    jQuery(obj).mouseout(function() {
        obj.find("img").attr("src", src);
    });
}

function screenshoot() {
    xOffset = 5;
    yOffset = 5;
    $("#footer").each(function() {
        $("img.screenshot").mouseover(function(e) {
        var imgpath = $(this).attr("src");
        var newSrc = "";
        newSrc = newSrc + imgpath.replace(/(.+)(\.[a-z]+)$/, "$1-hover$2");
            $("#screenshot").show();
            $("#screenshot").html("<img src='" + newSrc + "' alt='url preview' height='500px' width='430px' />")
            //.css("top", (e.pageY - xOffset) + "px")
            .css("top", '150px')
            .css("left", "200px")
			//.css("left", (e.pageX + yOffset) + "px")
			.fadeIn("fast");
        });

        $("img.screenshot").mouseout(function(e) {
            $("#screenshot").hide();
        });
       
        $("img.screenshot").mousemove(function(e) {
            $("#screenshot")
			//.css("top", (e.pageY - xOffset) + "px")
			//.css("left", (e.pageX + yOffset) + "px");
        });
    });
   
    
}

