/* setTimeout ("setDocumentHeight()", 1000); */
function setDocumentHeight ()
{ document.getElementById ('overlay').style.height = document.body.scrollHeight + "px"; }

var __last_id = null;
var x;
var y;
var __i__;
var _location = null;
			
function startPreview (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;
	}
	
	_show ("overlay");
}

function clearOverlay ()
{
	stopPreview ();
}

function stopPreview ()
{
	if (BrowserDetect.browser == "Explorer" && BrowserDetect.version < 7)
	{
		clearInterval (__i__);
		window.location = _location;
	}
	
	_hide ("overlay");
	document.getElementById ("overlay_player").innerHTML = "";
}

function setPreviewRow (id)
{
	changeContainerClass ("row" + __last_id, "none");
	changeContainerClass ("row" + id, "video_highlight");
	__last_id = id;
}

function drawFlashPlayer (id, title)
{
	setPreviewRow (id);
	
	var d = document.getElementById ("player_title");
	d.innerHTML = title;
	clearOverlay ();
	startPreview ("#row" + id);
	
	var path = escape ("http://elfreebo.com/?module=get_video&id=" + id);
	s2 = new SWFObject('flash/flvplayer.swf','_player','428','350','7');
	s2.addVariable('width', '428');
	s2.addVariable('height', '350');
	s2.addParam('allowfullscreen','true');
	s2.addParam('enablejs','true');
	s2.addVariable('file',path);
	s2.addVariable('backcolor','0x7DA5E0');
	s2.addVariable('frontcolor','0xffffff');
	s2.addVariable('lightcolor','0xefefef');
	s2.addVariable('autostart','true');
	s2.addVariable('logo','images/video_logo.png');
	s2.addVariable('type','flv');
	s2.write('overlay_player');
	
	__last_id = id;
}

function drawFlashPlayer_inline (vid)
{
	try {
		var id = vid;
		
		// check for last id.
		if (__last_id)
		{
			changeContainerClass ("row" + __last_id, 'none');
			document.getElementById ("player_" + __last_id).innerHTML = "&nbsp;";
			_show ("container_" + __last_id);
			_hide ("player_" + __last_id);
		}

		_hide ("container_" + id);
		_show ("player_" + id);
		changeContainerClass ("row" + id, 'video_highlight');
		
		var path = escape ("http://elfreebo.com/?module=get_video&id=" + id);
		s2 = new SWFObject('flash/flvplayer.swf','player','130','118','7');
		s2.addVariable('width', '130');
		s2.addVariable('height', '118');
		s2.addParam('allowfullscreen','true');
		s2.addParam('enablejs','true');
		s2.addVariable('file',path);
		s2.addVariable('backcolor','0x7DA5E0');
		s2.addVariable('frontcolor','0xffffff');
		s2.addVariable('lightcolor','0xefefef');
		s2.addVariable('autostart','true');
		//s2.addVariable('logo','images/video_logo.png');
		s2.addVariable('type','flv');
		s2.write('player_' + id);
		
		__last_id = vid;
	} 
	catch (E)
	{ }
}

BrowserDetect.init();