﻿window.onload = function () {

    setPage();

}

function extractPageName(hrefString) {
    var arr = hrefString.split('/');
    return (arr.length < 2) ? hrefString : arr[arr.length - 2].toLowerCase() +"/" + arr[arr.length - 1].toLowerCase();
}

function setActiveMenu(arr, crtPage) {
    if (crtPage.split('/')[0].indexOf(document.location.href.split('/')[2])==-1) {
        crtPage = document.location.href.split('/')[2] + "/" + crtPage.split('/')[0] + ".aspx";
    }
    var isHome = true;
    for (var i = 0; i < arr.length; i++) {
        if (extractPageName(arr[i].href) == crtPage ) {
            if (arr[i].parentNode.tagName != "DIV") {
                arr[i].className = "current";
                isHome = false;
            }
        }
    }
   if (isHome)
        arr[0].className = "current";


}

function setPage() {
    hrefString = document.location.href ? document.location.href : document.location;
    
    if (document.getElementById("dolphinnav") != null)
        setActiveMenu(document.getElementById("dolphinnav").getElementsByTagName("a"), extractPageName(hrefString));

}

function clickconf() {
    return confirm('Sei sicuro di voler eliminare questa NEWS?');
    
}
