﻿function InitialiseZoom()
{
	var options_ = {
		  zoomWidth: 350,
		  zoomHeight: 350,
		  position: "bottom",
		  title: false,
		  xOffset: 0
	  };
	  $(".jqzoom_").attr("href", "images/main_hr.jpg");
	  $(".jqzoom_").jqzoom(options_);	
}

$(function()
{
    // initialise colorbox
        $(".colorbox").colorbox();
		$(".video").colorbox();
        
    // initialise jqzoom
        var options = {
            zoomWidth: 433,
            zoomHeight: 433,
            position: "left",
            title: false
        };
		
	    $("._Image").removeClass("enlarge");
        if ($("._Image").attr("enlarge") == "1")
        {
            $("._Image").addClass("enlarge");
            $("#lnkenlarge").css("display", "");
        }
        
        $("._Image").removeClass("zoom");
        if ($("._Image").attr("zoom") == "1")
        {
            $("._Image").addClass("zoom");
            $("#lnkzoom").css("display", ""); 
        }
               
        var _yOff = parseInt($("._Image").attr("yoff"));
		var _xOff = parseInt($("._Image").attr("xoff"));
        $.extend(options, { xOffset: _xOff + 12, yOffset: -_yOff - 6 });
        if (_yOff > 0)
        {
            $("._Image").css("margin-top", _yOff + "px"); 
			$("._Image").css("margin-left", "0px");
        }
		if (_xOff > 0)
        {
            $("._Image").css("margin-top", "0px");
			$("._Image").css("margin-left", _xOff + "px");
        }
        $(".enlarge").colorbox({href:"/images/products/large/" + $("._Main").attr("title") + "_1.jpg"});
        $(".zoom").jqzoom(options);
        
        
        $("._Thumb").click(function()
        {
            $("._Image").unbind();            
            $("._Main").attr("src", "/images/products/medium/" + $(this).attr("title"));
            $("._Image").attr("href", "/images/products/xlarge/" + $(this).attr("title"));
            
            $("._Image").removeClass("enlarge");
            if ($(this).attr("enlarge") == "1")
            {
                $("._Image").addClass("enlarge");
                $("#lnkenlarge").css("display", "");
            }
            else
            {
                $("#lnkenlarge").css("display", "none");
            }
                        
            $("._Image").removeClass("zoom");
            if ($(this).attr("zoom") == "1")
            {
                $("._Image").addClass("zoom");
                $("#lnkzoom").css("display", "");
            }
            else
            {
                $("#lnkzoom").css("display", "none");   
            } 
                                                
            var _yOff = parseInt($(this).attr("yoff"));
			var _xOff = parseInt($(this).attr("xoff"));
            $.extend(options, { xOffset: _xOff + 12, yOffset: -_yOff - 6 });
            if (_yOff > 0)
            {
                $("._Image").css("margin-top", _yOff + "px");
				$("._Image").css("margin-left", "0px");
            }
			if (_xOff > 0)
            {
                $("._Image").css("margin-top", "0px");
				$("._Image").css("margin-left", _xOff + "px");           
            }
            $(".enlarge").colorbox({href:"/images/products/large/" + $(this).attr("title")});
            $(".zoom").jqzoom(options);
        });  
});