﻿var mediumProductDivs = new Array();
var sliderProductDivs = new Array();
var thumbnailDivs = new Array();
var selectedProductDivIndex = 0;
var selectedSliderDivIndex = 0;
var selectedTabIndex = 0;

function AppendPopupQueryString(hRef)
{
    return hRef + "&pIndex=" + selectedProductDivIndex.toString() + "&tIndex=" + selectedTabIndex.toString();
}

function ShowPopup(targetHref, targetTitle, startWidth, startHeight, isResizeable)
{
    var left = (window.screen.width - startWidth) / 2;
    var top = (window.screen.height - startHeight) / 2;

    var childWindow = window.open(AppendPopupQueryString(targetHref), 'ProductFull', "width=" + startWidth + ",height=" + startHeight + ",resizable=" + isResizeable + ",left=" + left + ",top=" + top + ",scrollbars=1");
    childWindow.focus();
}

function ShowStaticPopup(targetHref, targetTitle, startWidth, startHeight, isResizeable) {
    var left = (window.screen.width - startWidth) / 2;
    var top = (window.screen.height - startHeight) / 2;

    var staticWindow = window.open(targetHref, targetTitle, "width=" + startWidth + ",height=" + startHeight + ",resizable=" + isResizeable + ",left=" + left + ",top=" + top + ",scrollbars=1");
    staticWindow.focus();
}

function HideMediumProductDivs()
{
    for (var i = 0; i < mediumProductDivs.length; i++) {
        var targetElement = document.getElementById(mediumProductDivs[i]);
        targetElement.style.display = "none";
    }
}

function ShowMediumProductDiv(imageIndex) {

    HideMediumProductDivs();

    selectedProductDivIndex = imageIndex;

    var targetElement = document.getElementById(mediumProductDivs[imageIndex]);
    targetElement.style.display = "inline";
}

function RollOverThumbnail(sender) {
    sender.className = "thumbnailHover";
}

function RollOffThumbnail(sender) {
    sender.className = "thumbnailOff";
}

function CloseMe() {
    self.close();
    window.opener.focus();
}

function SliderMove(sender) {
    var sliderVal = sender.value - 1;
    ShowSliderProductDiv(sliderVal);
}

function HideSliderProductDivs() {
    for (var i = 0; i < sliderProductDivs.length; i++) {
        var targetElement = document.getElementById(sliderProductDivs[i]);
        targetElement.style.display = "none";
    }
}

function ShowSliderProductDiv(imageIndex) {

    HideSliderProductDivs();

    selectedSliderDivIndex = imageIndex;

    var targetElement = document.getElementById(sliderProductDivs[imageIndex]);
    targetElement.style.display = "inline";
}