﻿
var currentVideo = 0;

function showBodyFlash() {
    //$("#moveableHeader").attr("style", " top:120px; left:284px;");
    $("#moveableHeader").attr("style", " top:120px; margin-left:250px;");
    $("#topicsDiv").css("width","136px").css("display", "block");
    $("#videoFlash").flash({
        src: videos[currentTopic][currentVideo]["Link"],
        width: 375,
        height: 199,
        wmode: 'transparent'
    });
    topicsAction = "none";
}
function hideBodyFlash() {
    $("#videoFlash").html("")
    //$("#moveableHeader").attr("style", "bottom:3px; right:130px;");
    $("#moveableHeader").attr("style", "top:576px; margin-left:250px; ");
    $("#topicsDiv").css("display", "none").css("width","0px");
    $("#video_container").css("width", "840px");
    topicsAction = "show";
}
var topicsAction = "none";
function showTopics() {
    if (topicsAction == "show") {
        $("#video_container").attr("style", "overflow:hidden;").animate({ width: "702" }, 750);
        $("#topicsDiv").css("display", "block").css("margin-left","840px").animate({ width: "136",marginLeft:"705" }, 750);
        topicsAction = "hide";
    } else {
        $("#video_container").animate({ width: "840" }, 750);
        $("#topicsDiv").animate({ width: "0", marginLeft: "840" }, 750, "", function() {
            $("#topicsDiv").css("display", "none").css("margin-left", "705px");
        });
        topicsAction = "show";   
    }

}

function makeSelectedTopNav(selectedDiv) {
    oldA = $("#topnav span.selected .sIFR-alternate a")
    oldA.removeClass("orange")
    $("#topnav span.selected .sIFR-alternate").html(oldA)
    temp = sIFR.getReplacementByFlashElement($("#topnav span.selected .sIFR-flash")[0])
    temp.replaceText($("#topnav span.selected .sIFR-alternate").html());

    $("#topnav span").removeClass("selected");

    $("#topnav #navspan" + selectedDiv).addClass("selected");
    newA = $("#topnav #navspan" + selectedDiv + " .sIFR-alternate a")
    $("#topnav #navspan" + selectedDiv + " .sIFR-alternate").html(newA)
    html = $("#topnav #navspan" + selectedDiv + " .sIFR-alternate").html();
    html = html.replace('<A', '<a').replace('<a class=""', '<a class="orange"')
    temp = sIFR.getReplacementByFlashElement($("#topnav #navspan" + selectedDiv + " .sIFR-flash")[0])
    temp.replaceText(html);
}

function switchParentTopic(parentTopic) {
    $("#videoFlash").html("");
    showBodyFlash();
    hideVideo();
    makeSelectedTopNav(parentTopic);
    currentParent = parentTopic;
    topicsListText = "";
    topicsCounter = 0;
    for (var i = 0; i < parentTopics[parentTopic].length; i = i + 1) {
        if (topicsCounter == 0) {
            topicsCounter = 1;
            currentTopic = parentTopics[parentTopic][i];
        }
        topicsListText = topicsListText + "<a href=\"javascript:changeVideoTopic(" + parentTopics[parentTopic][i] + ");swapThumb();\">" + videos[parentTopics[parentTopic][i]]["Title"] + " ></a><br/>"
    }
    $("#topicList").removeClass("sIFR-replaced").html(topicsListText);
    
    sIFR.replace(albatross, {
        selector: '#topicList',
        css: '.sIFR-root { font-size:10px; color: #999999; } .sIFR-root a {color:#999999; text-decoration:none;}.sIFR-root a:hover {color:#999999; text-decoration:none;}',
        wmode: 'transparent'
    });
    changeVideoTopic(currentTopic);
}

function swapThumb() {
    $("#proThumbnail").attr("src", videos[currentTopic][currentVideo]["Thumbnail"]);
}