// JavaScript Document
var last_hd_pop = null;
var hdp_timer = 0;
var last_flyouts = Array();
var fo_timeout = 0;

function hd_pop(hd_pop_id, calling_el)
{
	var this_hd_pop = document.getElementById(hd_pop_id);
	var cex = 0;
	var cey = 0;
	if(this_hd_pop && calling_el)
	{
		cancel_hd_pop_out()
		if(last_hd_pop != null) last_hd_pop.style.display = 'none';
		cex = calling_el.offsetLeft + 86;
		cey = calling_el.offsetTop + calling_el.offsetHeight + 6;
		calling_el = calling_el.offsetParent;
		while(calling_el)
		{
			cex += calling_el.offsetLeft;
			cey += calling_el.offsetTop;
			calling_el = calling_el.offsetParent;
		}		
		this_hd_pop.style.position = 'absolute';
		this_hd_pop.style.left = cex+'px';
		this_hd_pop.style.top = cey+'px';
		this_hd_pop.style.display = '';
		last_hd_pop = this_hd_pop;
	}
}//end of hd_pop

function hdd_pop(hd_pop_id, calling_el)
{
	var this_hd_pop = document.getElementById(hd_pop_id);
	var cex = 0;
	var cey = 0;
	if(this_hd_pop && calling_el)
	{
		cancel_hd_pop_out()
		if(last_hd_pop != null) last_hd_pop.style.display = 'none';
		cex = calling_el.offsetLeft - 309;
		cey = calling_el.offsetTop - 216;
		calling_el = calling_el.offsetParent;
		while(calling_el)
		{
			cex += calling_el.offsetLeft;
			cey += calling_el.offsetTop;
			calling_el = calling_el.offsetParent;
		}		
		this_hd_pop.style.position = 'absolute';
		this_hd_pop.style.left = cex+'px';
		this_hd_pop.style.top = cey+'px';
		this_hd_pop.style.display = '';
		last_hd_pop = this_hd_pop;
	}
}//end of hd_pop

function cancel_hd_pop_out()
{
	clearTimeout(hdp_timer);	
}

function hd_pop_out()
{
	cancel_hd_pop_out();
	hdp_timer = setTimeout('hd_pop_close()', 1500);	
}

function hd_pop_close()
{
	if(last_hd_pop != null) last_hd_pop.style.display = 'none';
	last_hd_pop = null;
}

function flyout(flyout_id, referencing_div)
{
	clearTimeout(fo_timeout);
	var fo = document.getElementById('flyout_'+flyout_id);
	var child_of_current_flyout = false;
	var last_flyout = null;
	if(last_flyouts.length > 0) last_flyout = last_flyouts[last_flyouts.length-1];
	if(last_flyout && referencing_div && referencing_div.offsetParent == last_flyout)
	{
		child_of_current_flyout = true;
	}
	if(last_flyout && !child_of_current_flyout)
	{
		clear_flyout();	
	}	
	if(fo && referencing_div)
	{
		var anote = referencing_div.getElementsByTagName('a');
		if(anote.length > 0) referencing_div = anote[0];
		var rx = referencing_div.offsetWidth;
		var ry = 0;
		var rel = referencing_div;
		if(rel)
		{
			rx += rel.offsetLeft;
			ry = rel.offsetTop;
			while(rel.offsetParent)
			{
				rel = rel.offsetParent;
				rx += rel.offsetLeft;
				ry += rel.offsetTop;
			}
		}
		fo.style.position = 'absolute';
		fo.style.left = rx+'px';
		fo.style.top = ry+'px';
		fo.style.display = '';
		last_flyouts[last_flyouts.length] = fo;
	}
}

function flyout_out()
{
	fo_timeout = setTimeout('clear_flyout()',3000);
}

function clear_flyout()
{
	for(var fc=0; fc<last_flyouts.length; fc++)
	{
		last_flyouts[fc].style.display = 'none';	
	}
	last_flyouts = Array();
}