﻿var g_strips = new Array();
var g_strip_activated = 0;
var g_script_running = 0;
var g_menu_owner;




function _link(label, url)
{
	this.label = label;
	this.url = url;
}


function _strip(width)
{
	this.width = width;
	this.links = new Array();
}




function menu_hor_set_menu_owner(ownerName)
{
	g_menu_owner = ownerName;
}


function menu_hor_add_strip(width)
{
	var stripIdx = g_strips.length;
	g_strips[stripIdx] = new _strip(width);
}


function menu_hor_add_link(label, url)
{
	var strip = g_strips[g_strips.length - 1];
	if(strip == null) return;
	
	var link = new _link(label, url);
	strip.links[strip.links.length] = link;
}


function menu_hor_get_html(divName, stripIdx)
{
	var html = '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>';
	
	if(stripIdx < 0)
	{
		html += '<td>&nbsp;</td>';
	}
	else
	{
		for(i = 0; i < stripIdx; i++)
		{
			html += '<td width="' + g_strips[i].width + '"></td>';
		}
		html += '<td ' + '" onMouseOver="menu_hor_activate_strip(\'' + divName + '\', ' + stripIdx + ', 0);" onMouseOut="menu_hor_deactivate_strip();"' + '>';
		for(j = 0; j < g_strips[i].links.length; j++)
		{
			html += '<a href="' + g_strips[i].links[j].url + '">' + g_strips[i].links[j].label + '</a>&nbsp;&nbsp;&nbsp;';
		}
		html += '</td>';
	}
	
	html += '</tr></table>';
	
	return html;
}


function menu_hor_activate_strip(divName, stripIdx, updateHtml)
{
	if(updateHtml == 1)
	{
		document.getElementById(divName).innerHTML = menu_hor_get_html(divName, stripIdx);
	}
	
	if(stripIdx >= 0)
	{
		g_strip_activated = 1;
		
		if(g_script_running == 0)
		{
			g_script_running = 1;
			window.setTimeout(menu_hor_script, 5000, divName);
		}
	}
	else
	{
		g_strip_activated = 0;
	}
}


function menu_hor_deactivate_strip()
{
	g_strip_activated = 0;
}


function menu_hor_script(divName)
{
	if(g_strip_activated == 0)
	{
		document.getElementById(g_menu_owner).innerHTML = menu_hor_get_html(g_menu_owner, -1);
		g_script_running = 0;
	}
	else
	{
		g_script_running = 1;
		window.setTimeout(menu_hor_script, 5000, g_menu_owner);
	}
}

