var $toolboxes;
var active_toolbox = 0;
jQuery(function(){
    $toolboxes = jQuery('div.toolbox_handle');

        $toolboxes.click(function(e){
            if (active_toolbox != 0) hideBox();
			if(jQuery(e.target).hasClass('toolbox_handle')){ //not sure why I put this in

            jQuery(jQuery(e.target).children()[0]).show();
            active_toolbox = jQuery(e.target).children()[0];
		}
	});
	if(jQuery('div.toolbox_container').length > 0){
        jQuery('a.toolbox_opener').css('display', 'inline');
        if(document.cookie.indexOf('tb=1') != -1) toolbox_toggle(jQuery('a.toolbox_opener')[0]);
    }
 });

function toolbox_toggle(e){
    //$toolboxes.toggle(); //took a long time on big pages
    if(jQuery('a.toolbox_opener').data.showing == 1){
        $toolboxes.css({'visibility':'hidden'});
        jQuery('a.toolbox_opener').data.showing = 0;
        document.cookie = 'tb=0; ';
    } else {
        $toolboxes.css({'visibility':'visible'});
        jQuery('a.toolbox_opener').data.showing = 1;
        document.cookie = 'tb=1; ';
    }
    if (active_toolbox != 0) hideBox();
    jQuery(e).attr('title', jQuery(e).attr('title')[0] =='S'? 'Hide Toolboxes': 'Show Toolboxes');
}
function hideBox(){
    jQuery(active_toolbox).hide();
    }

