﻿
var ImageExtension = "jpg";
var ExpandExtension = "-expand";

function expandBar(id) {
    var children = $('#bars').children()
    var type2 = id.split('-');

    for (var i = 0; i < children.length; i++) {
        var type = children[i].id.split('-');
        if (type[1] == 'content') {
            if (type[2] == type2[2] && $('#bar-content-' + type2[2]).css('display') == "none") {
                $('#' + children[i].id).slideDown('fast', function () { });

            } else {
                $('#' + children[i].id).slideUp('fast', function () { });
            }
        }
        if (type[1] == 'head') {
            if (type[2] == type2[2] && $('#bar-content-' + type2[2]).css('display') == "none") {
                var imgSrc = $('#' + children[i].id + ' > img').attr('src').split('.');
                $('#' + children[i].id + ' > img').attr('src', imgSrc[0] + ExpandExtension + '.' + ImageExtension);
            } else {
                var imgSrc = $('#' + children[i].id + ' > img').attr('src')
                $('#' + children[i].id + ' > img').attr('src', imgSrc.replace(ExpandExtension, ''));
            }

        }

    }

}

function collapseBars() {

    var children = $('#bars').children()
    for (var i = 0; i < children.length; i++) {
        var type = children[i].id.split('-');
        if (type[1] == 'content') {
            $('#' + children[i].id).slideUp('fast', function () { });

        }
        if (type[1] == 'head') {
            var imgSrc = $('#' + children[i].id + ' > img').attr('src')
            $('#' + children[i].id + ' > img').attr('src', imgSrc.replace(ExpandExtension, ''));
        }

    }

}


