function ShowMovie( src, ratio ) {
	width = 640;
	height = parseInt(width * ratio);
	var w = window.open( "movie.php?src="+escape( src )+"&width="+width+"&height="+( height+36 ),
			"_blank", "width="+( width )+",height="+( height+44 )+",location=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no,resizable=yes" );
}

var ratio_4_3 = .75;
var ratio_16_9 = .5626;

function ShowMusic( src ) {
	var w = window.open( "music.php?src="+escape( src ),
			"_blank", "width=200,height=48,location=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no,resizable=yes" );
}


function ShowPlayer(file) {
	var playerPane = document.getElementById('player_pane');
	playerPane.style.display = 'block';
	var s1 = new SWFObject('player.swf','player','774','460','9');
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','file=media-files/'+file);
	s1.write('player');
	if (ShowPlayerCallback)
		ShowPlayerCallback();

		/*
	findPos(document.getElementById('body_inner'));
	var player = document.getElementById('player');
	player.style.position = 'absolute';
	player.style.top = curtop+'px';
	player.style.left = curleft+'px';*/
}

function HidePlayer() {
	var playerPane = document.getElementById('player_pane');
	playerPane.style.display = 'none';
	var player = document.getElementById('player');
	player.innerHTML = '';
}

function ShowMenu(prefix, index) {
	var i = 1;
	var item;
	var showItem = 0;
	while (item = document.getElementById(prefix+i)) {
		if (i == index)
			showItem = item;
		else
			item.style.display = 'none';
		i++;
	}
	
	if (showItem)
		showItem.style.display = 'block';
}

// http://www.quirksmode.org/dom/getstyles.html
function getStyle(el,styleProp)
{
	var x = el;
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

function ShowPlayerCallback() {
	var c = document.getElementById('close');
	c.style.right = '50%';
	setTimeout('moveClose()', 2000);
}

function moveClose() {
	var c = document.getElementById('close');
	var r = parseInt(getStyle(c, 'right'));
	var step = 10;
	if (r > 10) {
		if (r - step < 10)
			c.style.right = '10px';
		else {
			c.style.right = (r - step) + 'px';
			setTimeout('moveClose()', 10);
		}
	}
}

var curleft = curtop = 0;
function findPos(obj) {
	curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
}
