﻿var openItems = 0;

expandableToggle = function(expandable, image, countAction) {
    if (typeof countAction == 'undefined')
        countAction = true;

    if ((typeof (expandable) != "undefined") && (typeof (expandable.parentNode) != "undefined" && (expandable != null)) && (expandable.parentNode != null)) {
        var parent = expandable.parentNode;
        var items = parent.getElementsByTagName('div');
        var item;
        var i = 0;
        var theImage;
        for (i = 0; i < items.length; i++) {
            if (item == null && (items[i].className == "expandable_content" || items[i].className == "expandable_link_content")) {
                item = items[i];
                if (item.style.display != "block") {
                    parent.className += " expandable_opened_item";
                    item.style.display = "block";


                    //switch image

                    theImage = document.getElementById(image);
                    theImage.src = "/images/buttons/double-blue-arrow-down.jpg";
                    if (countAction)
                        openItems++;


                }
                else {
                    parent.className = "expandable_item";
                    item.style.display = "none";


                    //switch image
                    imageStr = "div" + i + "IMG";
                    theImage = document.getElementById(image);
                    theImage.src = "/images/buttons/double-blue-arrow-right.jpg";
                    if (countAction)
                        openItems--;
                }
                break;
            }
        }
    }
    return false;
}