/** 
 * Main page announce
 */

if(typeof(window['_$']) !== 'function')
{
	function _$(id){
		return document.getElementById(id);
	}
}

/**
 * Size of DIV: 394x334, 480x284, 490x301,
 */
function showVideoPlayer(file, title, href)
{
	var divPlayer  = _$('anons_player');

	var sizePlayerWidth  = 384;
	var sizePlayerHeight = 288;

	var sizeWidth  = sizePlayerWidth + 10;
	var sizeHeight = sizePlayerHeight + 29;

	if(href === undefined || href =='')
		href = 'javascript:void(0)';

	_$('anons_title').innerHTML = title;
	_$('anons_title').href		  = href;

	if(_$('player_flv'))
	  cleanNode( _$('player_flv'));
	// 480x272, 470x255
	var so = new SWFObject('/js/mediaplayer.swf','mpl', sizePlayerWidth, sizePlayerHeight,'7');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','true');
	so.addVariable('width', sizePlayerWidth);
	so.addVariable('height', sizePlayerHeight);
	so.addVariable('wmode','opaque');
	so.addVariable('backcolor','0xCA006C');
	so.addVariable('frontcolor','0xFFFFFF');
	so.addVariable('lightcolor','0xFFFFFF');
	so.addVariable('screencolor','0xCA006C');
	so.addVariable('autostart','true');
	so.addVariable('volume','50');
//	so.addVariable('repeat','true');
	so.addVariable('image','/img/player_logo.gif');
	so.addVariable('file', file);
	so.write('player_flv');

	var oBody = document.getElementsByTagName("body")[0];
	var wnd_height = window.innerHeight;
        var top = toInt(window.pageYOffset || document.documentElement.scrollTop) + ((wnd_height>327) ? Math.round((wnd_height-327)/2) : (wnd_height>0) ? 0 : 200 );
	//divPlayer.style.top  = toInt(toInt(oBody.clientHeight)/2) + toInt(oBody.scrollTop) - toInt(sizeHeight/2) + 'px';
	divPlayer.style.top  = top + 'px';
	divPlayer.style.left = toInt(toInt(oBody.clientWidth)/2) + toInt(oBody.scrollLeft) - toInt(sizeWidth/2) + 'px';
	divPlayer.style.display = 'block';

  var theHandle = document.getElementById("player_move");
  var theRoot   = document.getElementById("anons_player");
  Drag.init(theHandle, theRoot);
}

function closeVideoPlayer()
{
	_$('anons_player').style.display = 'none';
	cleanNode( _$('player_flv'));
}

function toInt(value)
{
	return parseInt(value, 10);
}

function cleanNode(dest)
{
	while (dest.firstChild)
			dest.removeChild(dest.firstChild);
}
