﻿// Since we are using a referenced javascript file,
// and the controls are dynamically generated,
// the AdditionalImagesControl will register a javascript
// array with the dynamic info we need
// Array Name: additionalImagesJSVars
// 0 => rootThumbnailPath
// 1 => rootImagePath
// 2 => asp:Panel ControlID that holds all of the thumbnails
// 3 => the full size image ClientID

function swapImage() {
    var fullSizeImage = this["fullSize"];
    var source = this["newSource"];
    var alternate = this["newAlternate"];
    fullSizeImage.src = source;
    fullSizeImage.alt = alternate;
}

function fixHovers() {
    if (additionalImagesJSVars != null) {
        var rootThumbnailPath = additionalImagesJSVars[0];
        var rootImagePath = additionalImagesJSVars[1];
        var parentID = additionalImagesJSVars[2];
        var fullSizeID = additionalImagesJSVars[3];

        var fullSize = document.getElementById(fullSizeID);
        var parentObject = document.getElementById(parentID);
        if (parentObject != null) {
            var links = parentObject.getElementsByTagName("A");
            for (var i = 0; i < links.length; i++) {
                var link = links[i];
                var images = link.getElementsByTagName("IMG");
                if (images != null && images.length > 0) {
                    var img = images[0];
                    var src = new String(img.src);
                    src = src.replace(rootThumbnailPath, rootImagePath);

                    link["fullSize"] = fullSize;
                    link["newSource"] = src;
                    link["newAlternate"] = img.alt;
                    link.onmouseover = swapImage;
                }
            }
        }
    }
}

function popUp360(filePath, Width360, Height360) {
    var page = window.open(filePath, 'WINDOW360', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=' + Width360 + ',height=' + Height360);
    page.focus();
    return false;
}
