﻿//toggle the more button to display/hide secondary menu items
//view-more.onclick = toggle_visibility("more-items");

//var x = document.getElementById('view-more');
//x.onclick = toggle_block;

function toggle_block(targetId, textId, startText, altText) {
    if (document.getElementById) {
        var target = document.getElementById(targetId);
        var href = document.getElementById(textId);
        if (target.style.display == 'block') {
            target.style.display = 'none';
            href.innerHTML = startText;
        }
        else {
            target.style.display = 'block';
            href.innerHTML = altText;
        }
    }
}

// this function swaps the source for an img tag
function toggle_block__src_image(targetId, textId, startText, altText, arrowId, startImg, altImg) {
    if (document.getElementById) {
        var target = document.getElementById(targetId);
        var href = document.getElementById(textId);
        var arrow = document.getElementById(arrowId);
        var domain = document.domain;
        var imagePath = "http:\\" + domain + "/images/site/";
        if (target.style.display == 'block') {
            target.style.display = 'none';
            href.innerHTML = startText;
            arrow.src = imagePath + startImg;
        }
        else {
            arrow.src = imagePath + altImg;
            target.style.display = 'block';
            href.innerHTML = altText;
        }
    }
}

// this function swaps the background image style for the anchor tag
function toggle_block_bg_image(targetId, textId, startText, altText, arrowId, startImg, altImg) {
    if (document.getElementById) {
        var target = document.getElementById(targetId);
        var href = document.getElementById(textId);
        var arrow = document.getElementById(arrowId);
        var domain = document.domain;
        var imagePath = "http:\\" + domain + "/images/site/";
        if (target.style.display == 'block') {
            target.style.display = 'none';
            href.innerHTML = startText;
            arrow.style.backgroundImage = startImg; 
        }
        else {
             arrow.style.backgroundImage = altImg;
             arrow.src = imagePath + altImg;
            target.style.display = 'block';
            href.innerHTML = altText;
        }
    }
}

// this function swaps the background image style for the anchor tag
function toggle_filter(arrowId, targetId) {
    if (document.getElementById) {
        var domain = document.domain;
        var imagePath = "http:\\" + domain + "/images/site/";
        var arrow = document.getElementById(arrowId);
        var target = document.getElementById(targetId);
        if (target.style.display == 'block') {
            target.style.display = 'none';
            arrow.style.backgroundImage = imagePath + startImg;
        }
        else {
            arrow.style.backgroundImage = altImg;
            arrow.src = imagePath + altImg;
            target.style.display = 'block';
            href.innerHTML = altText;
        }
    }
}

function togglemenus(menuid, targetid) {
    if (menuid.className == "collapsable") {
        menuid.className = "expandable";
    } else {
    menuid.className = "collapsable"; 
    }

    var whichtarget = document.getElementById(targetid);
    if (whichtarget.className == "menushown") {
        whichtarget.className = "menuhidden";
    } else {
        whichtarget.className = "menushown";
    }

}

function ShowMoreFilters(node, tag, searchClass, replaceClass, linkClass) {

    var nodeElement = document.getElementById(node);
    var elements = nodeElement.getElementsByTagName(tag);
    
    for (var i = 0; i < elements.length; i++) {

        // show all the more link
        if (elements[i].className == searchClass) {
            elements[i].className = replaceClass;
        }

        // hide the see more link
        if (elements[i].className == linkClass) {
            elements[i].className = 'more';
        }
    }
}





