function SimpleJSTab_Tab_OnMouse(e)
{
	// make sure we get the event for both IE and firefox
	if (!e) var e = window.event;

	// initialize
	var sender;
	
	// determine where we can get the objected that fired the event and
	// save it as the "sender"
	if(e.target)
	{
		sender = e.target;
	}
	else
	{
		if(e.type == "mouseout")
			sender = e.fromElement;
		else if(e.type == "mouseover")
			sender = e.toElement;
	}
	
	// determine tabdisplay full group name
	if(sender.id)
	{
		sender_tab_group_name = sender.id.substring('tabdisplay_'.length, sender.id.lastIndexOf('_tab'));
		sender_is_active = (sender.className.lastIndexOf('tab_active') != -1?true:false);
		sender_current_tab_num = sender.id.substring('tabdisplay_'.length + sender_tab_group_name.length + '_tab'.length, sender.id.length);
		
		//alert(sender_current_tab_num);
		if(sender_is_active)
		{
			if(e.type == "mouseout")
				sender.className = 'tabdisplay_'+sender_tab_group_name+'_tab_active'+sender_current_tab_num;
			else
				sender.className = 'tabdisplay_'+sender_tab_group_name+'_tab_active'+sender_current_tab_num+'_mouseover';
		}
		else
		{
			if(e.type == "mouseout")
				sender.className = 'tabdisplay_'+sender_tab_group_name+'_tab_inactive'+sender_current_tab_num;
			else
				sender.className = 'tabdisplay_'+sender_tab_group_name+'_tab_inactive'+sender_current_tab_num+'_mouseover';
		}
	}
	//tabdisplay_testtab_tab_active3_mouseover
	//tabdisplay_testtab_tab_inactive1_mouseover
}


function SimpleJSTab_Show(tabdisplay_name, tab_num)
{
	var total_tab_count = document.getElementById('simplejstabdisplay_' + tabdisplay_name + '_max_count').value;
	
	new_tab_code = 'tabdisplay_' + tabdisplay_name + '_tab' + tab_num;
	new_body_code = 'tabdisplay_' + tabdisplay_name + '_body' + tab_num;
	
	// make all the tabs and bodies inactive
	for(var i=1; i<=total_tab_count; i++)
	{
		var current_tab_code = 'tabdisplay_' + tabdisplay_name + '_tab' + i;
		var current_body_code = 'tabdisplay_' + tabdisplay_name + '_body' + i;

		// deactivate tab
		var current_tab_element = document.getElementById(current_tab_code);
		var current_class_name = 'tabdisplay_' + tabdisplay_name+'_tab_inactive' + i;
		current_tab_element.className = current_class_name;
		
		current_tab_element.onmouseout = SimpleJSTab_Tab_OnMouse;
		if (current_tab_element.captureEvents) current_tab_element.captureEvents(Event.MOUSEOUT);
/*
		for(var childIndex = 0; childIndex < current_tab_element.childNodes.length; childIndex++)
		{
			try
			{
				if(current_tab_element.childNodes[childIndex].onmouseout)
				current_tab_element.childNodes[childIndex].onmouseout = SimpleJSTab_Tab_OnMouse;
				if (current_tab_element.childNodes[childIndex].captureEvents) current_tab_element.childNodes[childIndex].captureEvents(Event.MOUSEOUT);
			}
			catch (e)
			{
			}
		}
*/

		current_tab_element.onmouseover = SimpleJSTab_Tab_OnMouse;
		if (current_tab_element.captureEvents) current_tab_element.captureEvents(Event.MOUSEOVER);
		for(var childIndex = 0; childIndex < current_tab_element.childNodes.length; childIndex++)
		{
			try
			{
				current_tab_element.childNodes[childIndex].onmouseover = SimpleJSTab_Tab_OnMouse;
			}
			catch (e)
			{
				//alert(1);
			}
			
			try
			{
				current_tab_element.childNodes[childIndex].captureEvents(Event.MOUSEOVER);
			}
			catch (e)
			{
				//alert(2);
			}
		}
		
		// deactive body
		document.getElementById(current_body_code).className = 'tabdisplay_' + tabdisplay_name+'_body_inactive';
	}

	// activate new tab
	var new_tab_element = document.getElementById(new_tab_code);
	var new_class_name = 'tabdisplay_' + tabdisplay_name+'_tab_active' + tab_num;
	new_tab_element.className = new_class_name;

	var handler_name = 'tabdisplay_' + tabdisplay_name+'_handler_' + tab_num;
	if(eval("typeof("+handler_name+");") == 'function')
		eval("tabdisplay_"+tabdisplay_name+"_handler_"+tab_num+"();");

	// show new body
	document.getElementById(new_body_code).className = 'tabdisplay_' + tabdisplay_name+'_body_active' + tab_num;

}
