﻿function ActivateTab(e) {
    var TabHeads = e.parentNode.parentNode.getElementsByTagName("LI");
    var FormSubmitUrl = document.location.href;
    if (FormSubmitUrl.toUpperCase().indexOf("AT=") == -1) {
        FormSubmitUrl += ((FormSubmitUrl.indexOf("?") == -1) ? "?" : "") + "At=" + e.rev;
    }
    var Params = (FormSubmitUrl.split("?").length > 1) ? FormSubmitUrl.split("?")[1].split("&") : "";
    var NewUrl = FormSubmitUrl.split("?")[0] + "?";
    for (var i = 0; i < Params.length; i++) {
        if (i > 0) {
            NewUrl += "&";
        }
        NewUrl += Params[i].split("=")[0] + "=";
        if (Params[i].split("=")[0].toUpperCase() == "AT") {
            NewUrl += e.rev;
        }
        else {
            NewUrl += Params[i].split("=")[1];
        }

    }

    document.getElementsByTagName("FORM")[0].action = NewUrl;
 
    for (var i = 0; i < TabHeads.length; i++) {
        if (e.parentNode == TabHeads[i]) {
            TabHeads[i].className = 'active';
            //document.getElementById("Div" + TabHeads[i].getElementsByTagName("A")[0].rev).style.display = "block";
        }
        else {
            var Anchors = TabHeads[i].getElementsByTagName("A");
            if (Anchors.length > 0) {
                TabHeads[i].className = '';
                //document.getElementById("Div" + Anchors[0].rev).style.display = "none";
            }
        }
    }
}


function initTabs(ActiveTabRev, ContainerID, TabHeadContainerID) {
    var Container = document.getElementById(ContainerID);
//    var Divs = Container.getElementsByTagName("Div");
//    for (var i = 0; i < Divs.length; i++) {
//        if (Divs[i].id == ("Div" + ActiveTabRev))
//            Divs[i].style.display = "block";
//        else if (Divs[i].id != "")
//            Divs[i].style.display = "none";
//    }

    var TabHeadContainer = document.getElementById(TabHeadContainerID);
    var Heads = TabHeadContainer.getElementsByTagName("LI");

    for (var i = 0; i < Heads.length; i++) {
        if (Heads[i].getElementsByTagName("A").length > 1) {
            if (Heads[i].getElementsByTagName("A")[0].rev == ActiveTabRev) {
                Heads[i].className = "fl tab active";
            }
            else {
                Heads[i].className = "fl tab2 inactive";
            }
        }
    }
}

