function start_timer_to_reset_tabs(description){
	//wait 2 seconds before resetting the categories and tabs to their original state
	eval( description+"_timer_to_reset_tabs=setTimeout(\"reset_tabs('"+description+"')\",2000)" );
}

function reset_tabs(description){

	//Reset the select
	eval(description+"_selected_tabs=new Array()");
	
	description1=description;//"description1";
	
	if( eval( "typeof "+description1+"_originally_selected_categories!='undefined'" ) ){
		//return the categories and tabs to their original state - their original css classes
		for(a=0;a< eval(description1+"_originally_selected_categories.length") ;a++){
			document.getElementById( eval( description1+"_originally_selected_categories[a].split(';')[0]" ) ).className= eval( description1+"_originally_selected_categories[a].split(';')[1]" );
			//populate the array with the originally selected tabs (class isn't blank)
			if( eval( description1+"_originally_selected_categories[a].split(';')[0].split('_')[0]" )==description && eval( description1+"_originally_selected_categories[a].split(';')[0].split('_')[1]" ) =='tab'&& eval( description1+"_originally_selected_categories[a].split(';')[1]" ) !=''){
				//Initialize
				//description=eval ( description1+"_originally_selected_categories[a].split(';')[0].split('_')[0]" ) ;
				if( eval( "typeof "+description+"_selected_tabs=='undefined'" ) ){
					eval( description+"_selected_tabs=new Array()" );
				}
				eval( description+"_selected_tabs["+description+"_selected_tabs.length]="+description1+"_originally_selected_categories[a].split(';')[0]" );
			}
		}
	}
	
	//DEBUGGING
	//alert( "RESET "+description+" -- "+eval(description+"_selected_tabs") );
	
}

function highlight_selected_tab(id,new_class){

	description=id.split("_")[0];
	this_tab_level=id.split("_")[2];

	description1=description;//"description1";

	//halt the timer's countdown to reset the tabs
	if( eval( "typeof "+description+"_timer_to_reset_tabs!='undefined'" ) ){
		eval( "clearTimeout("+description+"_timer_to_reset_tabs)" );
	}

	//record the originally selected tabs and their associated classes
	//initialize the array to hold the selected tabs information
	if( eval( "typeof "+description+"_selected_tabs=='undefined'" ) ){
		eval( description+"_selected_tabs=new Array()" );
		//populate the array with the originally selected tabs
		for(a=0;a<document.all.length;a++){
			//if it's a tab and the class is blank
			if(document.all[a].id.split("_")[0]==description && document.all[a].id.split("_")[1]=="tab" && document.getElementById(document.all[a].id).className!=""){
				eval( description+"_selected_tabs[document.all[a].id.split('_')[2]]=document.all[a].id" );
			}
		}
		
		//DEBUGGING
		//alert( "HIGHLIGHT "+description+" -- "+eval( description+"_selected_tabs" ) );

		//also record all of the originally selected categories and tabs and their states/css classes
		eval ( description1+"_originally_selected_categories=new Array()" ) ;
		for(a=0;a<document.all.length;a++){
			if(  document.all[a].id.split("_").length>1 && ( (document.all[a].id.split("_")[1].split("/")[0]=="tab" && document.all[a].id.split("_")[0]==description) || (document.all[a].id.split("_")[0].split("/")[0]=="categories" && document.all[a].id.split("_")[0].split("/")[1]==description) ) ){
			eval ( description1+"_originally_selected_categories["+description1+"_originally_selected_categories.length]=document.all[a].id+';'+document.getElementById(document.all[a].id).className" ) ;
			}
		}
		
		//DEBUGGING
		//alert( "ORIGINALLY "+description+" -- "+eval(description1+"_originally_selected_categories") );
		
	}
	//unselect the previously selected tab if there is one and if the previously selected tab isn't the same as the currently selected tab
	if( eval( "typeof "+description+"_selected_tabs[this_tab_level]!='undefined'" ) ){
		
		//DEBUGGING
		//alert( eval(description+"_selected_tabs") );
		
		//deselect the selected tab for this level and everything below it eg. 1-3
		for(z=this_tab_level;z< eval( description+"_selected_tabs.length" ) ;z++){
			
			//DEBUGGING
			//alert(this_tab_level+" ... "+eval( description+"_selected_tabs[z]" ));
			
			document.getElementById( eval( description+"_selected_tabs[z]" ) ).className='';
		}
		//repopulate the array to match the selected tabs
		temp_array=new Array();
		for(z=0;z<=this_tab_level;z++){
		temp_array[z]=eval( description+"_selected_tabs[z]" );
		}
		eval( description+"_selected_tabs=temp_array" );
	}
	//highlight selected tab
	document.getElementById(id).className=new_class;
	eval( description+"_selected_tabs[this_tab_level]=id" );
}

function show_subcategories(specified_element,subcategory_elements){
	specified_element_level=eval(specified_element.split("_")[1]);
	subcategory_elements=subcategory_elements.split("|");
	for(a=0;a<subcategory_elements.length;a++){
		this_element=subcategory_elements[a];
		this_element_level=eval(this_element.split("_")[1]);
		//hide the non-specified subcategories
		if(this_element_level>=specified_element_level){
			document.getElementById(this_element).className="hide";
		}
	}
	//show the selected subcategories if they exist
	if(document.getElementById(specified_element)){
		document.getElementById(specified_element).className="show";
	}
}
