function create_carpet(){
	var the_text = '<table border="0" cellpadding="2" cellspacing="0">';
	var the_chapter = '';
	var the_table_width = 4;
	var the_cell_counter = 0;
	for(j=0;j<TBS_elements.length;j++){
	//for(j=0;j<21;j++){
		var slide_array = TBS_elements[j].split('|');
		if(the_chapter == slide_array[3]){
			the_text = the_text + '<th valign="top"><a href="html/' + slide_array[0] + '.htm"><img src="icons/' + slide_array[0] + '.jpg" width="180" height="120" border="1" vspace="1"></a><br>'  + slide_array[1] + '</th>';
			the_cell_counter = the_cell_counter + 1;
			if(the_cell_counter>=the_table_width){
				the_text = the_text + '<tr></tr>';
				the_cell_counter = 0;
			}
		}
		else{
			if(the_cell_counter > 0){
				for(k=1;k<(the_table_width - the_cell_counter);k++){
					the_text = the_text + '<th></th>';
				}
			the_text = the_text + '</tr>';
			}
			the_text = the_text + '<tr><td colspan="' + the_table_width + '" BGCOLOR="#d3d3d3"><h3>' + slide_array[3] + '</h3></td></tr><tr><th valign="top"><a href="html/' + slide_array[0] + '.htm"><img src="icons/' + slide_array[0] + '.jpg" width="180" height="120" border="1" vspace="1"></a><br>'  + slide_array[1] + '</th>';
			the_cell_counter = 1;
		}
		the_chapter = slide_array[3];
	}
	var the_text = the_text + '</table>';
	return the_text;
}

var the_current_chapter = '';
var menu_onoroff = location.search.substring(1,2);

function menu_on_off(currentFilename){
	if(menu_onoroff == '1'){
		document.location.href = currentFilename + '.htm?0';
	}
	else{
		document.location.href = currentFilename + '.htm?1';
	}
}

function create_toc(){
	var the_text = '';
	if(menu_onoroff == '1'){
		var the_chapter = '';
		for(i=0;i<TBS_elements.length;i++){
			var slide_array = TBS_elements[i].split('|');
			if((the_chapter == the_current_chapter) && (slide_array[3] == the_current_chapter)){
				the_text = the_text + '- <a href="html/' + slide_array[0] + '.htm?1">' + slide_array[1] + '</a><br>';
			}
			else if(the_current_chapter == slide_array[3]){
				the_text = the_text + '<b>' + slide_array[3] + '</b><br>- <a href="html/' + slide_array[0] + '.htm?1">' + slide_array[1] + '</a><br>';
			}
			else if(the_chapter != slide_array[3]){
				the_text = the_text + '<b><a href="html/' + slide_array[0] + '.htm?1">' + slide_array[3] + '</a></b><br>';
			}
			the_chapter = slide_array[3];
		}
	}
	return the_text;	
}
