﻿// JavaScript Document
function AddLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function initMouseOver(overobject) {
    if (overobject.className != "showme") {
        if (document.getElementById('isSelected') != null) {
            document.getElementById('isSelected').parentNode.className = "";
            document.getElementById('isSelected').className = "";
        }
        overobject.className = "showme";
        overobject.firstChild.className = "selected";
    }
}

function initMouseOut(outobject) {
    if (document.getElementById('isSelected') == null) {
        outobject.className = "";
        outobject.firstChild.className = "";
    }
    else {
        if (document.getElementById('isSelected').parentNode != outobject) {
            document.getElementById('isSelected').parentNode.className = "liSelected";
            document.getElementById('isSelected').className = "selected";
            outobject.className = "";
            outobject.firstChild.className = "";
        }
        else {
            outobject.className = "liSelected";
        }
    }
}

var oldID = "notset";
function headlineClick(z) {
    if (oldID != document.getElementById("description" + z)) {
        document.getElementById("imageFrame").src = imageArray[z];
        document.getElementById("description" + z).style.display = "block";
        if (oldID != "notset") {
            oldID.style.display = "none";
        }
        oldID = document.getElementById("description" + z);
    }
    else if (oldID = document.getElementById("description" + z)) {
        document.getElementById("description" + z).style.display = "none";
        oldID = "notset";
    }

}

function loadImages() {
    var headlineArea = document.getElementById("Headlines");
    var z;
    peopleNames = "";
    if (headlineArea) {
        for (z in headlineArray) {
            peopleNames = peopleNames + "<p onClick='headlineClick(" + z + ")'>" + headlineArray[z] + "</p><div id='description" + z + "' style='display:none;' class='pushright' >" + descArray[z] + "</div>";
            headlineArea.innerHTML = peopleNames;
            z = z++;
        }
    }
}
AddLoadEvent(loadImages);
