var call_function = null;
var last_over_item = null;
var original = null;
var window_forum = null;

function menu_item_over(over_item, img_select_prefix, img_normal_prefix){
	// Initialize the last over_item
	if(last_over_item == null)
		last_over_item = original;
	// Cancel the timer
	if(call_function != null)
		clearTimeout(call_function);
	if(over_item != last_over_item){
		// Set over_item as selected_color
		document.getElementById(over_item+"_left").src = img_select_prefix+"left.gif";
		document.getElementById(over_item+"_back").style.backgroundImage = 'url("'+img_select_prefix+'back.gif")';
		document.getElementById(over_item+"_right").src = img_select_prefix+"right.gif";
		// Set original as default_color
		document.getElementById(last_over_item+"_left").src = img_normal_prefix+"left.gif";
		document.getElementById(last_over_item+"_back").style.backgroundImage = 'url("'+img_normal_prefix+'back.gif")';
		document.getElementById(last_over_item+"_right").src = img_normal_prefix+"right.gif";
		// Show the submenu
		show_submenu(last_over_item, over_item);
		// Update the last over_item
		last_over_item = over_item;
	}
	// Launch the timer again
	call_function = self.setTimeout("reset_item_over('"+over_item+"', '"+img_select_prefix+"', '"+img_normal_prefix+"')", 3000);
}
function reset_item_over(over_item, img_select_prefix, img_normal_prefix){
	// Cancel the timer
	if(call_function != null)
		clearTimeout(call_function);
	if(original != over_item){
		// Reset original as selected_color
		document.getElementById(original+"_left").src = img_select_prefix+"left.gif";
		document.getElementById(original+"_back").style.backgroundImage = 'url("'+img_select_prefix+'back.gif")';
		document.getElementById(original+"_right").src = img_select_prefix+"right.gif";
		// Reset over_item as default_color
		document.getElementById(over_item+"_left").src = img_normal_prefix+"left.gif";
		document.getElementById(over_item+"_back").style.backgroundImage = 'url("'+img_normal_prefix+'back.gif")';
		document.getElementById(over_item+"_right").src = img_normal_prefix+"right.gif";
		// Show the right submenu
		show_submenu(over_item, original);
	}
	// Update the last over_item
	last_over_item = null;
}
function show_submenu(last_item, over_item){
	// Cancel the timer
	if(call_function != null)
		clearTimeout(call_function);
	// hide the last one
	if(document.getElementById("div_"+last_item))
		document.getElementById("div_"+last_item).style.visibility = 'hidden';
	// Show the new one
	if(document.getElementById("div_"+over_item))
		document.getElementById("div_"+over_item).style.visibility = 'visible';
}
function cancel_timeout(){
	if(call_function != null)
		clearTimeout(call_function);
}
function reactivate_timeout(img_select_prefix, img_normal_prefix){
	call_function = self.setTimeout("reset_item_over('"+last_over_item+"', '"+img_select_prefix+"', '"+img_normal_prefix+"')", 3000);
}
function open_forum(page){
	var link = "http://forum.motofavre.ch";
	var window_name = "window_forum";
	var window_params = "channelmode=yes,directories=no,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=no";
	if (page != '') {
		link += "/" + page;
	}
	if (!window_forum){
		window_forum = window.open(link, window_name, window_params);
	} else {
		if (window_forum.closed){
			window_forum = window.open(link, window_name, window_params);
		}
	}
	window_forum.focus();
}