// JavaScript Document



// Collection functions



var whostaysopen = '';

var oldheader = '';

var oldmenu = '';



var lastlightup = '';

var lastlightuphdr = '';



var menuopen = '';



function beingdragged(target, targethdr)

{

	try

	{	  	

		$("theInfo").style.visibility = "hidden";			

	}

	catch (err)

	{

	   alert("beingdragged:"+err);

	}



	return;



}





function lightupshell(target, targetheader, onoff)

{

   	try

	{

		if (onoff)

		{

			$(target).style.background = "#EEEEEE";

			$(targetheader).style.visibility = "visible";										

		}

		else

		{

		  	if (whostaysopen != target) 

		  	{

				$(target).style.background = "";

			  	$(targetheader).style.visibility = "hidden";			  	

			}

		}

	}

	catch (err)

	{

	   alert("lightupshell:" + err);

	}

  	return; 

}



function showmenu(topref, toprefheader)

{

  	try

	{	  	

		the_menu = document.getElementById("theMenu");	

		the_toprefheader = document.getElementById(toprefheader);	

		

		if (the_menu.style.visibility == "visible")

		{

		  	closemenu(topref, toprefheader);

		}				

		

	  	whostaysopen = topref;

	  	oldheader = toprefheader;

	  	oldmenu = topref;

	  	

	  	var alignprop = '';

	  	var leftbullet = '';

		var rightbullet = '';

		  

		//left or right side display?

		if ( (getElementPosition(topref).left + 160) > (document.body.clientWidth - 200))

		{

		  	//left-side

		  	the_menu.style.top = ((getElementPosition(topref).top) + 7)+"px";		

			the_menu.style.left = (getElementPosition(topref).left - 139)+"px";		

			alignprop = 'left';

			

			leftbullet = '&nbsp;&raquo;&nbsp;';			

			rightbullet = '';

			

			var menutext = '<p align="left" style="padding-top:1px;margin-top:1px;">&nbsp;<b style="cursor:pointer;" onClick="exitmenu(\'' + topref + '\', \'' + toprefheader + '\');">x</b></p>';

		}

		else

		{

		  	//right-side

		  	the_menu.style.top = ((getElementPosition(topref).top) + 7)+"px";		

			the_menu.style.left = (getElementPosition(topref).left + 120)+"px";		

			alignprop = 'right';

			

			leftbullet = '';

			rightbullet = '&nbsp;&laquo;';

			

			var menutext = '<p align="right" style="padding-top:1px;margin-top:1px;"><b style="cursor:pointer;" onClick="exitmenu(\'' + topref + '\', \'' + toprefheader + '\');">x</b></p>';

		}

	  	

	  	//make these constants...

		menutext = menutext + '<div class="menuelement" align="'+alignprop+'">'+leftbullet+'delete from playlist'+rightbullet+'</div></p>';

		menutext = menutext + '<div class="menuelement" align="'+alignprop+'">'+leftbullet+'copy to folder'+rightbullet+'</div></p>';

		menutext = menutext + '<div class="menuelement" align="'+alignprop+'">'+leftbullet+'move to to folder'+rightbullet+'</div></p>';				

	  	menutext = menutext + '<div class="menuelement" align="'+alignprop+'"><br /></div></p>';

	  	

		//document.getElementById("theMenuText").innerHTML = menutext;

		$("theMenuText").innerHTML = menutext;		

		the_toprefheader.style.background = "#99CCFF";		//"#99CCCC";

		

		the_menu.style.visibility = "visible";				

		the_menu.style.display = "";					

		

		menuopen = true;

	}

	catch (err)

	{

	   alert("showmenu:" + err);

	}

  	return; 

}



//called from the 'x' in the menu

function exitmenu(topref, toprefheader)

{

  	try

	{	

	  	if (!menuopen)

	  	{

	  	  	return;

	  	}

		  

		$("theMenu").style.visibility = "hidden";					  		  	

				

		$(topref).style.background = "";

		$(toprefheader).style.visibility = "hidden";			  	

		$(toprefheader).style.background = "";			

		

		$(oldheader).style.background = "";

		$(oldheader).style.visibility = "hidden";

		

		$(oldmenu).style.background = "";		  	

				

		whostaysopen = '';

		oldheader = '';

		oldmenu = '';



		menuopen = false;		

	  	

	}

	catch (err)

	{

	   exitmenu("closemenu:" + err);

	}

  	return; 

}



//called when another menu instance is opened

function closemenu(topref, toprefheader)

{

  	try

	{	

	  	if (!menuopen)

	  	{

	  	  	return;

	  	}

		

		if(topref == oldmenu)

	  	{

	  		return;

	  	}

	  	

	  	$("theMenu").style.visibility = "hidden";					  		  	

				

		$(topref).style.background = "";

		$(toprefheader).style.visibility = "hidden";			  	

		$(toprefheader).style.background = "";			

		

		$(oldheader).style.background = "";

		$(oldheader).style.visibility = "hidden";

		

		$(oldmenu).style.background = "";		  	

				

		whostaysopen = '';

		oldheader = '';

		oldmenu = '';

		

		menuopen = false;

				

	}

	catch (err)

	{

	   alert("closemenu:" + err);

	}

  	return; 

}