var hide_timer;
var sm_item_height = 27;
var open_flag;
var myimages=new Array()

function preloadimages()
{
	for (i=0;i<preloadimages.arguments.length;i++)
	{
		var im = new Image();
		im.src=site_url+'/images/'+preloadimages.arguments[i];
		myimages.push(im);
	}
}
preloadimages('rm_sel.gif','pipe_vert.gif','affil_arrow_left-on.gif','affil_arrow_right-on.gif');

function fhide(menu_id)
{
	var popup;
	if(menu_id == 'all')
		popup = $("[id^='popup_']");
	else
		popup = $("#popup_"+menu_id);
	popup.find("td>div").stop().animate({height: '1px'},500)
		.queue(function(){
			popup.remove();
			$(this).dequeue();
		});
	$(".right_menu_sel").not('#current').attr('class','right_menu');
	open_flag = false;
}
$(document).ready(function(){
	$("#t_rm").bind('mouseleave',function(){
		clearTimeout(hide_timer);
		fhide('all');
	});
	$(".right_menu").bind("mouseenter",function(){
		if($("#popup_"+this.id).attr('id'))
			return;
		$(this).attr('class','right_menu_sel');
		clearTimeout(hide_timer);
		if(sm_html[this.id])
		{
			if($("#popup_"+(this.id-1)).attr('id') && sm_html[this.id].cnt<sm_html[this.id-1].cnt)
				height = sm_item_height * sm_html[this.id-1].cnt;
			else
				height = sm_item_height * sm_html[this.id].cnt;
			$(this).parent().parent().parent().parent().parent().after(sm_html[this.id].html);
		}
		$(".right_menu_sel").not(this).not('#current').attr('class','right_menu');
		if(!(($("#popup_"+(this.id-1)).attr('id') && !sm_html[this.id]) || open_flag))
		{
			open_flag = false;
			$("[id^='popup_']").not("#popup_"+this.id).find("div").stop().animate({height: '1px'},500)
				.queue(function(){
					$(this).parent().parent().remove();
					$(this).dequeue();
				});
		}
		else
			open_flag = true;
		if(sm_html[this.id])
			$("#popup_"+this.id+">td>div").stop().animate({height: height+'px'},500);
	}).bind("mouseleave",function(){
		hide_timer = setTimeout("fhide("+this.id+")",500);
	});
});

