function drawPlaylist (loc)
{
	if (BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7)
	{
		x = 0;
		y = document.body.scrollTop;
		window.scrollTo (x, y);
		__i__ = setInterval ("window.scrollTo (" + x + ", " + y + ")", 1000);
		_location = loc;
	}
						
	_hide ("overlay");
	_show ("playlist_overlay");
}

function hidePlaylist ()
{
	if (BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7)
	{
		clearInterval (__i__);
		window.location = _location;
	}
	
	_hide ("overlay");
	_hide ("playlist_overlay");
	clearOverlay ();
}

function addToPlaylist (playlist)
{
	var vid = __last_id;
						
	asyncPostRequest ("?module=AddToPlaylist&id=" + vid + "&playlist=" + playlist, "addToPlaylist_callback", "");
	hidePlaylist ();
}

function addToPlaylist_callback (request)
{
	return;
}

function createPlaylist (playlist_name)
{
	var vid = __last_id;
	asyncPostRequest ("?module=CreatePlaylist&playlist_name=" + playlist_name, "createPlaylist_callback", "");
}

function createPlaylist_callback (request)
{
	var id = trim (request.xmlhttp.responseText);	                				
	var s = document.getElementById ("playlist");
	var name = document.getElementById ("createNew");
	
	var node = document.createElement ("option");
	node.setAttribute ('value', id);
	node.appendChild (document.createTextNode(name.value));
	s.appendChild (node);
	
	s.selectedIndex = (s.length - 1);
	s.defaultSelected = (s.length - 1);
	name.value = "";
	
	addToPlaylist (id);
	hidePlaylist ();
}