﻿//file = "";
$(document).ready(function() {
    prodZoom();
    // re-bind
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function() {
    prodZoom();
    }); 
});

function prodZoom() {
    $("div #product-details-zoom-wrap").css("left", ($(window).width() - 780) / 2 + "px");

    $("div #product-details-zoom-img").click(function() { $("div #product-details-zoom-wrap").css("display", "none"); $("div.overDetail").css("display", "none"); });
    $("div #product-details-over-close").click(function() {
        $deleteImage();
        $("div #product-details-zoom-wrap").css("display", "none");
        $("div.overDetail").css("display", "none");
    });
    $("div #zoom-info").click(function() { });

    $("#zoom-button").click(function() {
        $("div #product-details-zoom-wrap").css("display", "block");
        $("div.overDetail").css("display", "block");
        var img = new Image();
        //alert(file);
        $(img).load(function() {
            $(this).hide();
            $('#product-details-zoom-img').removeClass('loading').append(this);
            $(this).show(); //fadeIn();
        }).error(function() {
            $('#product-details-zoom-img').removeClass('loading');
            $('#product-details-zoom-img').append("<b>IMAGE NOT AVAILABLE</b>"); // notify the user that the image could not be loaded
        }).attr('src', file);
    });
}

function $deleteImage() {
    var img = $("#product-details-zoom-img image");
    if (img != null) {
        img.remove()
    }
}
