﻿$(document).ready(function () {
	$(".displayImageOverlay").click(function () {
		DisplayImageOverlay($(this))
	});

	$(".closeImageOverlay").click(function () {
		HideImageOverlay()
	});

});

function DisplayImageOverlay(thisLinker) {
	//$(".ui-image-overlay").show();
	DisplayImage(thisLinker);
}

function DisplayImage(linker) {
	var fullSrc = linker.attr('fullSrc');
	var fullHeight = linker.attr('fullHeight');
	var fullWidth = linker.attr('fullWidth');

	window.open(fullSrc, 'viewImage', 'width=' + fullWidth + ',height=' + fullWidth + ',directories=0,fullscreen=0,menubar=0,resizable=1,scrollbars=0,toolbar=0,titlebar=0,location=0');

	/*
	var img = $('#imageOverlayImage');
	img.attr("alt", title);
	img.attr("src", "../Content/images/products/nexar_" + id + "_bg.png");
	img.attr("height", height);
	img.attr("width", width);
	setTimeout(PositionImageOverlay, 100);
	*/
}


function PositionImageOverlay() {
	var overlay = $("#image-overlay");
	var centerSection = $(".content");
	var header = $(".header");
	var effectiveScroll = header.height() - $(window).scrollTop();

	var centerLeft = (centerSection.width() - overlay.width() - 47) / 2;
	var centerTop = $(window).height() - effectiveScroll - overlay.height() - 10;

	if (centerTop < 0) { centerTop = 0; }
	if (centerLeft < 0) { centerLeft = 0; }
	overlay.show();
	overlay.css({
		left: centerLeft,
		top: centerTop,
		position: 'absolute',
		zIndex: 99999
	});

	var overlayShadow = $(".imageOverlayContentShadow");
	overlayShadow.show();
	overlayShadow.css({
		width: overlay.width(),
		height: overlay.height(),
		left: centerLeft + 2,
		top: centerTop + 2,
		position: 'absolute',
		zIndex: 99998
	});
}

function HideImageOverlay() {
	$(".ui-image-overlay").hide();
	$(".hide").hide();
}


