﻿
function setActiveTab() {
    var aPath = window.location.pathname;
    aPath = aPath.toLowerCase();
    var sPage = aPath.substring(aPath.lastIndexOf('/') + 1);
    sPage = sPage.split(".", 1);
    if (sPage == "") { sPage = "default" };
    var currTabElem = document.getElementById("nav_" + sPage);
    var currTabTopElem = document.getElementById("menu_top");
//    window.alert(currTabElem + "-" + currTabTopElem);
    if (currTabElem != null) {
        //Load default photo for photo page
//        if (sPage == "photos") {
//            var objYear = document.getElementById("ctl00_content_objYear").value + "/img1"
//            Button1_onclick(objYear);
//        }
        currTabElem.setAttribute("class", "activeMenuItem");
        currTabElem.setAttribute("className", "activeMenuItem");
        currTabTopElem.setAttribute("class", sPage + "imgTop");
        currTabTopElem.setAttribute("className", sPage + "imgTop");
        return;

    }
    if (sPage == "photos") {
        var objYear = document.getElementById("ctl00_content_objYear").value + "/img1"
        Button1_onclick(objYear);
    }

}

var mPosition
var pActive = 0

function Button1_onclick(xValue) {
//    alert(xValue);
    $get(xValue).style.backgroundColor = "#ff6600"
    if (pActive != 0 && pActive != xValue) { $get(pActive).style.backgroundColor = "#FFFFFF" }
    pActive = xValue
//    window.alert(pActive);
    ret = PhotoService.getPhotoSlideNode(xValue, onComplete, hasError, timedOut)
    return (true);
}

function onComplete(result) {
    $get("photo_image").style.backgroundImage = "url('App_Images/" + result.niImage + "')"
    $get("photo_info").innerHTML = result.niInfo
}
function hasError(args) {
    alert("error")
}
function timedOut(args) {
    alert("Time out")
}

function photo_hl(xTarget) {
    if (xTarget != null) { 
        try
        {
        $get(xTarget).style.borderColor = "#FFFFFF"
        }
    catch (error) 
        {
//            window.alert("error");
        }      
        }
}

function photo_dim(xTarget) {
    if (xTarget != null) {
        try {
            $get(xTarget).style.borderColor = "#000000"

        }
        catch (error) {

        }
    }
}

function icon_swap_in(targetId) {
    document.getElementById(targetId).src = "App_Images/website/icon_pr_hov.jpg"
}

function icon_swap_out(targetId) {
    document.getElementById(targetId).src = "App_Images/website/icon_pr.jpg"
}



window.onload = setActiveTab;
