function supportsDOM() {
    var returnValue = false;
    if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
        returnValue = true;
    }
    return returnValue;
}

function tagHasClass(theTag, theClass) {
    var returnValue = false;
    var allClasses = theTag.className.split(" ");
    for (var i = 0; i < allClasses.length; i++) {
        if (allClasses[i] == theClass) {
            returnValue = true;
        }
    }
    return returnValue;
}

function Markup(Obj, param) {
    var buttonState = true;
    for (var j = 0; j < Obj.length; j++) {
        if (Obj[j].id == param && Obj[j].className == "text-button pushed") {
            buttonState = false;
            Obj[j].className = "text-button";

            break;
        }
        else if (Obj[j].id == param && Obj[j].className != "text-button pushed") {
            Obj[j].className = "text-button pushed";
        }
        else Obj[j].className = "text-button";
    }
    return buttonState;
}

function changeLinks(linkID) {
    if (!supportsDOM) {
        return false;
    }
    var itemList = document.getElementById("itemsGroups");
    var itemLinks = itemList.getElementsByTagName("a");
    var listLinks = document.getElementsByClassName("text-button");
    var pos;
    var BState = Markup(listLinks, linkID);
    for (var i = 0; i < itemLinks.length; i++) {
        itemLinks[i].style.fontWeight = "normal";
        itemLinks[i].style.color = "#555";

        if (tagHasClass(itemLinks[i], linkID) && BState) {
            itemLinks[i].style.color = "#043DBC";
            itemLinks[i].style.fontWeight = "bold";
        } else if(!BState){itemLinks[i].style.color = "#043DBC";}
    }
    return false;
}

/*function ChangeClassName(menuLinks, num){
 for(var i = 0; i < menuLinks.length; i++) {
 if(menuLinks[i].className != 'text-button pushed' && menuLinks[i].id == num) {menuLinks[i].addClassName('pushed');}
 else menuLinks[i].className = "text-button";
 }
 }*/

function addLinkClick() {
    if (!supportsDOM) {
        return false;
    }
    var menuList = document.getElementById("featuresGroups");
    var menuLinks = menuList.getElementsByTagName("a");
    for (var i = 0; i < menuLinks.length; i++) {
        menuLinks[i].onclick = function() {
            return changeLinks(this.id)
        };
        //menuLinks[i].onclick = function(){ ChangeClassName(menuLinks, this.id); return changeLinks(this.id);};
    }
}

function doFunctions() {
    addLinkClick();
}