﻿
//change theme
function createMenu() {
    if (document.getElementById) {
        if (document.getElementById("ctl00_fwRoot_fwContent_fwMenu_uxM")) {
            var menu = document.getElementById("ctl00_fwRoot_fwContent_fwMenu_uxM");
            var liList = menu.getElementsByTagName("li");
            for(i=0; i<liList.length; i++)
            {
                // markere parent
                if(liList[i].className.indexOf("Current") > -1)
                {
                    if(liList[i].parentNode.parentNode.tagName == "li")
                    {
                        liList[i].parentNode.parentNode.className = "Current Top";
                    } 
                }

                // sjekk for undermeny
                sublist = liList[i].getElementsByTagName("ul");
                if(sublist.length > 0)
                {
                    if(liList[i].className == "")
                    {
                        liList[i].className = "Parent";
                    }
                    else
                    {
                        liList[i].className += " Parent Top";
                    }
                }   
            }
        }
    }
}

function openSubMenu(tagA) {
    var parent = tagA.parentNode;
    var ulList = parent.getElementsByTagName("ul");
    var d = tagA.getElementsByTagName("div");
    if(!ulList || ulList.length <= 0)
    {
        return;
    }

    for (iUl = 0; iUl < ulList.length; iUl++)
    {
        var ul = ulList[iUl];

        if (ul.style.display == 'none' || ul.style.display == "") {
            ul.style.display = 'block';
            d[0].className = "expand";
            tagA.className = "active";
        }
        else {
            ul.style.display = 'none';
            d[0].className = "colapse";
            tagA.className = "";
        }
    }
}

function setTopMenu() {
    var topMenu = document.getElementById("TopMenu");
    var liList = topMenu.getElementsByTagName("li");
    if (!liList || liList.length <= 0) {
        return;
    }

    liList[0].className = "first";
    liList[liList.length - 1].className = "last";
}
//change theme
/*----------------------------------------------------------------------------------*/
autoSlideImage = function(timeDelay, strItemSelector) {
    var tsec;
    var curindex = 0;
    var maxindex = 0;
    maxindex = $(strItemSelector + " .item").length;
    autochange($(strItemSelector + " .item:eq(" + curindex + ")"));
    function autochange(obj) {
        $(obj).fadeIn(800, function() {
            tsec = setTimeout(function() {
                $(strItemSelector + " .item:eq(" + curindex + ")").fadeOut(500, function() {
                    curindex++;
                    if (curindex == maxindex) curindex = 0;
                    autochange($(strItemSelector + " .item:eq(" + curindex + ")"));
                });
            }, timeDelay);
        });
    }
};

