/*------------------------------------------------------------------------------------------------------
    Toggles element's display value
    Input: any number of element id's
--------------------------------------------------------------------------------------------------------*/
function toggleDisp(){
    for (var i=0;i<arguments.length;i++){
        var d = $(arguments[i]);
        if(d.style.display == 'none')
            d.style.display = 'block';
        else{
            d.style.display = 'none';
        };
    };
};
/*------------------------------------------------------------------------------------------------------
    Toggles tabs - Closes any open tabs, and then opens current tab
    Input:  1.                          The number of the current tab
                    2.  (optional)  The number of the tab to leave open
                    3.  (optional)  Pass in true or false whether or not to animate the open/close of the tabs
--------------------------------------------------------------------------------------------------------*/
function toggleTab(num,opennum,animate){
    numelems = $$('.tabContent').length;
    if($('tabContent'+num).style.display == 'none'){
        for(var i=1;i<=numelems;i++){
            if((opennum == null) || (opennum != i)){
                var temph = 'accordion'+i;
                var h = $(temph);
                if(!h){
                    var h = $('accordionActive');
                    h.id = temph;
                };
                var tempc = 'tabContent'+i;
                var c = $(tempc);
                if(c.style.display != 'none'){
                    if (animate || typeof animate == 'undefined'){
                        // Open and close tabs one after another:
                        // Effect.toggle(tempc,'blind',{duration:0.5, queue:{scope:'menus', limit: 3}});
                        // Open and close tabs simultaneously:
                        Effect.toggle(tempc,'blind',{duration:0.5});
                    }else{
                        toggleDisp('tabContent'+num);
                    };
                };
            };
        };
        var h = $('accordion'+num);
        if(h){
            h.id = 'accordionActive';
        };
        h.blur();
        var c = $('tabContent'+num);
        c.style.marginTop = '2px';
        if(animate || typeof animate == 'undefined'){
            // Open and close tabs one after another:
            // Effect.toggle('tabContent'+num,'blind',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
            // Open and close tabs simultaneously:
            Effect.toggle('tabContent'+num,'blind',{duration:0.5});
        }else{
            toggleDisp('tabContent'+num);
        };
    };
};