function changeFrame(iFrameId, frameFilePath, textimonialDivId, textimonialCategories) {
    document.getElementById(iFrameId).src = frameFilePath;
    setTextimonial(textimonialDivId, textimonialCategories);
}

function changeWinFrame(frameFilePath) {
    changeFrame("windowsFrame", frameFilePath, "textimonialDiv", "windows");
}


function removeThumbBorderHighlight() {
    var thumbPicDiv = document.getElementById("thumbPicDiv");
    var thumbPicIndex = 0;
    for (thumbPicIndex = 0; thumbPicIndex < thumbPicDiv.childNodes.length; thumbPicIndex++) {
        if (thumbPicDiv.childNodes.item(thumbPicIndex).nodeName == "IMG") {
            thumbPicDiv.childNodes.item(thumbPicIndex).style.borderColor = "#ccc";
        }
    }
}

function findMaxPicHeight() {
    var largePicDiv = document.getElementById("largePicDiv");
    var picCtr;
    var maxPicHeight = 0;
    for (picCtr = 0; picCtr < largePicDiv.childNodes.length; picCtr++) {
        if (largePicDiv.childNodes.item(picCtr).nodeName == "IMG") {
            if (largePicDiv.childNodes.item(picCtr).height > maxPicHeight) {
                maxPicHeight = largePicDiv.childNodes.item(picCtr).height;
            }
        }
    }
    return maxPicHeight;
}
function changePic(newPicId, thumbPic) {
    var visiblePic = document.getElementById("visiblePic");
    var newPic = document.getElementById(newPicId).cloneNode(true);
    var largePicDiv = document.getElementById("largePicDiv");
    var maxPicHeight = 500;//findMaxPicHeight();
    newPic.id = "visiblePic";
    newPic.style.position = "static";
    newPic.style.visibility = "visible";
    largePicDiv.replaceChild(newPic, visiblePic);
    largePicDiv.style.marginBottom = maxPicHeight - newPic.height + "px";

    removeThumbBorderHighlight();
    if (thumbPic != null) {
        thumbPic.style.borderColor = "#006e77";
    }
}
function changeVid(vidName, vidWidth, vidHeight, autoPlay) {
    var vidObj;
    if (vidWidth == null) {
        vidWidth = 352;
    }
    if (vidHeight == null) {
        vidHeight = 240;
    }
    if (autoPlay == null) {
        autoPlay = false;
    }
    try {
	    vidObj = "<embed src=\"/media/flash/FLVPlayer_Progressive.swf\" wmode=\"transparent\" flashvars=\"&MM_ComponentVersion=1&skinName=/media/flash/Halo_Skin_1&streamName=" + vidName + "&autoPlay=" + autoPlay + "&autoRewind=" + autoPlay + "\" quality=\"high\" scale=\"noscale\" width=\"" + vidWidth + "\" height=\"" + vidHeight + "\" name=\"FLVPlayer\" salign=\"LT\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" />";
	    document.getElementById("vidDiv").innerHTML = vidObj;
	}
	catch (e) {
	    alert(e.message);
	}
}
function changeDoc(picPath) {
    try {
        document.getElementById("DocLink").href = picPath;
        document.getElementById("Doc").src = picPath;
    }
    catch (e) {
        alert("Document not found");
    }
}
function openFullSizePic(picSrc, backgroundImage, picWidth, picHeight) {
    var images = document.getElementsByTagName("img");
    var fullSizePic = document.createElement("img");
    var previousButton = document.createElement("input");
    var nextButton;
    var fullSizePicNodes = new Array();
    var currentNode;
    var imgCtr;
    var nodeCtr = 0;
    for (imgCtr = 0; imgCtr < images.length; imgCtr++) {
        if (images.item(imgCtr).className.search("full_size_pic") != -1) {
            if (images.item(imgCtr).alt.search(picSrc) != -1) {
                currentNode = nodeCtr;
            }
            fullSizePicNodes[nodeCtr++] = imgCtr;
        }
    }
    if (fullSizePicNodes.length > 1) {
        previousButton.style.width = "100px";
        previousButton.style.height = "40px";
        previousButton.type = "button";
        previousButton.value = "Previous";
        previousButton.style.zIndex = "1000";
        previousButton.style.position = "fixed";
        if (navigator.userAgent.search("MSIE 6") >= 0) {
            previousButton.style.position = "absolute";
        }
        previousButton.style.top = screen.height / 4 + "px";
        previousButton.style.cursor = "pointer";
        nextButton = previousButton.cloneNode(true);
        //previousButton.style.left = "20px";
        nextButton.value = "Next";
        //nextButton.style.right = "20px";

        previousButton.onclick = function() {
            if (nextButton.disabled) {
                nextButton.disabled = false;
                nextButton.style.cursor = "pointer";
            }
            currentNode--;
            if (currentNode <= 0) {
                currentNode = 0;
                previousButton.disabled = true;
                previousButton.style.cursor = "default";
            }
            fullSizePic.src = images.item(fullSizePicNodes[currentNode]).alt;
        };
        previousButton.onmouseover = function() {
            previousButton.focus();
        }
        nextButton.onmouseover = function() {
            nextButton.focus();
        }
        nextButton.onclick = function() {
            if (previousButton.disabled) {
                previousButton.disabled = false;
                previousButton.style.cursor = "pointer";
            }
            currentNode++;
            if (currentNode >= fullSizePicNodes.length - 1) {
                currentNode = fullSizePicNodes.length - 1;
                nextButton.disabled = true;
                nextButton.style.cursor = "default";
            }
            fullSizePic.src = images.item(fullSizePicNodes[currentNode]).alt;
        };
        if (navigator.appName == "Microsoft Internet Explorer") {
            previousButton.dblclick = previousButton.onclick;
            nextButton.dblclick = nextButton.onclick;
        }
        document.body.appendChild(previousButton);
        document.body.appendChild(nextButton);
        if (currentNode <= 0) {
            currentNode = 0;
            previousButton.disabled = true;
            previousButton.style.cursor = "default";
        }
        if (currentNode >= fullSizePicNodes.length - 1) {
            currentNode = fullSizePicNodes.length - 1;
            nextButton.disabled = true;
            nextButton.style.cursor = "default";
        }
    
    }
    fullSizePic.setAttribute("src", picSrc);
    if (picWidth != null) {
        fullSizePic.width = parseInt(picWidth);
    }
    if (picHeight != null) {
        fullSizePic.height = parseInt(picHeight);
    }
    fullSizePic.setAttribute("alt", "Click to close");
    fullSizePic.style.zIndex = "1000";
    //fullSizePic.style.border = "8px ridge #ccc";
    fullSizePic.style.cursor = "pointer";
    fullSizePic.style.position = "absolute";
    fullSizePic.style.top = "50px";
    if (fullSizePic.height < screen.height && fullSizePic.height != 0 && navigator.userAgent.search("MSIE 6") < 0) {
        fullSizePic.style.position = "fixed";
        fullSizePic.style.padding = "4px";
        fullSizePic.style.border = "1px solid black";
        fullSizePic.style.backgroundColor = "white";
        //fullSizePic.style.top = "0px";
        fullSizePic.style.top = screen.height / 4 - fullSizePic.width / 4 + "px";
    }

    if (fullSizePic.width == 0) {
        fullSizePic.width = 871;
    }
    fullSizePic.style.left = screen.width / 2 - fullSizePic.width / 2 + "px";
    try {
        previousButton.style.left = (parseInt(fullSizePic.style.left) - parseInt(previousButton.style.width) * 1) + "px";
        nextButton.style.left = (parseInt(fullSizePic.style.left) + parseInt(fullSizePic.width)) + "px";
    }
    catch (e) {
        alert(e.message);
    }
    
    fullSizePic.onclick = function() {
        closeFullSizePic(this, previousButton, nextButton);
    };
    try {
        addShadowCover(null, null, backgroundImage);
    }
    catch (e) {
        //Shadow Cover not included
    }
    document.body.appendChild(fullSizePic);
}
function closeFullSizePic(fullSizePic, previousButton, nextButton) {
    try {
        document.body.removeChild(previousButton);
        document.body.removeChild(nextButton);
    }
    catch (e) { 
    }
    document.body.removeChild(fullSizePic);
    try {
        deleteShadowCover();
    }
    catch (e) { 
        //no shadow cover
    }
}

