// JavaScript Document
var last_top_level = null;
var ltt_timeout = 0;
var submenu_width = 200;
var last_arrow_td = null;
var info_div = null;

function clear_top_level(focusel)
{
	var linkid = '';
	var parentid = '';
	var parent = null;
	var flyup = null;
	var flydown = null;
	if(focusel) {
		linkid =  focusel.id;
		if(linkid)
		{
			parentid = linkid.substr(0, linkid.length-2);
			parent = document.getElementById(parentid);
			if(parent)
			{
				parent.style.backgroundColor = 'transparent';
				flyup = document.getElementById(parentid+'_top');
				flydown = document.getElementById(parentid+'_flydown');
				if(flyup)
				{
					flyup.style.display = 'none';	
				}
				if(flydown)
				{
					flydown.style.display = 'none';	
				}
			}
		}	
	}
}

function top_level_trigger(focusel)
{
	var linkid = focusel.id;
	var parentid = '';
	var parent = null;
	var flyup = null;
	var flydown = null;
	var locX = 0;
	var locY = 0;
	var re = find_right_edge();
	clear_top_level_timeout();
	clear_last_top_level();
	if(linkid)
	{
		parentid = linkid.substr(0, linkid.length-2);
		parent = document.getElementById(parentid);
		if(parent)
		{
			parent.style.backgroundColor = '#b9b4a5';
			flyup = document.getElementById(parentid+'_top');
			flydown = document.getElementById(parentid+'_flydown');
			if(flyup)
			{
				flyup.style.zIndex = 300;
				flyup.style.display = 'block';	
			}
			if(flydown)
			{
				if(parent.offsetHeight) locY += parent.offsetHeight;
				while(parent)
				{
					if(parent.offsetLeft) locX += parent.offsetLeft;	
					if(parent.offsetTop) locY += parent.offsetTop;
					parent = parent.offsetParent;
				}
				if((locX + submenu_width) > re) locX = re - submenu_width;
				flydown.style.left = locX + 'px';
				flydown.style.top = locY + 'px';
				flydown.style.zIndex = 300;
				flydown.style.display = 'block';
			}			
		}
	}	
	last_top_level = focusel;
}

function clear_last_top_level()
{
	clear_top_level(last_top_level);
}

function timeout_clear_last_top_level()
{
	clear_top_level_timeout();
	ltt_timeout = setTimeout('clear_last_top_level()', 1000);
}

function clear_top_level_timeout()
{
	if(ltt_timeout) clearTimeout(ltt_timeout);	
}

function find_right_edge()
{
	var mb = document.getElementById('main_bod');
	var rX = 0;
	if(mb)
	{
		if(mb.offsetWidth) rX += mb.offsetWidth;
		while(mb)
		{
			if(mb.offsetLeft) rX += mb.offsetLeft;
			mb = mb.offsetParent;
		}
	}
	return rX;
}

function product_info_hover(tr_obj)
{
	var tds = tr_obj.getElementsByTagName('td');
	var arrow_td = null;
	var tid = document.getElementById(tr_obj.id + '_info'); 
	for(var tdc=0; tdc<tds.length; tdc++)
	{
		if(tds[tdc].className == 'arrow_on' || tds[tdc].className == 'arrow_off') arrow_td = tds[tdc];	
	}
	if(arrow_td)
	{
		if(last_arrow_td) last_arrow_td.className = 'arrow_off';
		else if(document.getElementById('first_arrow')) document.getElementById('first_arrow').className = 'arrow_off';
		if(info_div) info_div.style.display = 'none';
		else document.getElementById('original_info').style.display = 'none';
		arrow_td.className = 'arrow_on';
		tid.style.display = 'block';
		last_arrow_td = arrow_td;
		info_div = tid;
	}
}

function impose_flyup(image_path, parent_positioner)
{
	var fi = document.getElementById('flyup_imposer');
	var pp = document.getElementById(parent_positioner);
	var relX = 0;
	release_flyup_imposition();
	if(image_path.length > 0 && fi && pp)
	{
		fi.innerHTML = '<div style="width:87px;height:87px;overflow:none;"><img src="'+image_path+'" + alt="" /' + '><'+'/div>';
		if(pp.offsetLeft) relX = pp.offsetLeft;
		pp = pp.offsetParent;
		while(pp)
		{
			if(pp.offsetLeft) relX += pp.offsetLeft;
			pp = pp.offsetParent;
		}
		fi.style.left = relX+'px';
		fi.style.top = '0px';
		fi.style.position = 'absolute';
		fi.style.zIndex = 305;
		fi.style.display = 'block';
		fi.style.overflow = 'hidden';
	}
}

function release_flyup_imposition()
{
	var fi = document.getElementById('flyup_imposer');
	fi.style.display = 'none';
}