﻿// For TitleImages
function ChangeImage(senderID, timeout) {
    var image = $get(senderID);
    startWith++;
    if (startWith == images.length) startWith = 0;
    var src = image.src;
    var base = src.substring(0, src.lastIndexOf("/"));
    image.src = base + images[startWith];
    image.alt = descriptions[startWith];
    image.title = descriptions[startWith];
    imageShowTimer = setTimeout('ChangeImage("' + senderID + '",' + timeout + ')', timeout);
}

// For PictureGallery
function ChangeBigPicture(senderID, controlId, imageName) {
    resetImageBackGroundColor(senderID);
    var sender = $get(senderID);
    sender.style.borderColor = "black";
    var image = $get(controlId);
    var src = image.src;
    var base = src.substring(0, src.lastIndexOf("/") + 1);
    image.src = base + "Thumbnail.ashx?width=690&name=" + imageName
    image.alt = sender.alt;
    image.title = sender.title;
}

function getNextImage(controlId, subjectName) {
    var image = $get(controlId);
    var src = image.src;
    var base = src.substring(0, src.lastIndexOf("/") + 1);
    image.src = base + "Thumbnail.ashx?width=700&name=" + SQHIWSImageShow.GetNextImage(subjectName, image.src);
}

// Reset back ground color for the last selected image
function resetImageBackGroundColor(senderID) {

    var sender = $get(senderID);
    oCollection = sender.parentNode;
    var children = oCollection.childNodes; //get the child nodes
    var childrenCount = children.length;
    for (var i = 0; i < childrenCount; i++) {
        var child = children[i];

        if (child.nodeType == '1') //if the node is an element
        {
            child.style.borderColor = "#E6E4E4";
        }
    }
}

if (typeof (Sys) != 'undefined') Sys.Application.notifyScriptLoaded();


