function getMedia()
{
	return document.getElementById("mediacontainer");
}

function showMedia(b)
{
	var m = getMedia();
	if (m)
	{
		if (b)
			m.style.display = "block";
		else
			m.style.display = "none";
	}

	var mw = document.getElementById("mediawindow");
	if (mw)
		mw.innerHTML = "";	// remove video
}

function getViewportHeight()
{
	// determine the window size (not the document size) to the best of our ability
	if ( typeof( window.innerHeight ) == 'number' )
	{
		//Non-IE
  		return window.innerHeight;
	}
	else if ( document.documentElement &&
			( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
    	//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	}
	else if ( document.body &&
			( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return document.body.clientHeight;
  }
}

function getViewportWidth()
{
	// determine the window size (not the document size) to the best of our ability
	if ( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
  		return window.innerWidth;
	}
	else if ( document.documentElement &&
			( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
    	//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	}
	else if ( document.body &&
			( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return document.body.clientWidth;
  }
}

function setMediaSize(w,h)
{
	var m = getMedia();
	if (m)
	{
		var mcX, mcY;
  		//var cw = document.body.clientWidth;
  		//var ch = document.body.clientHeight;

  		var cw = getViewportWidth();
  		var ch = getViewportHeight();

		// document.body works only w/o a doctype.  use document.documentElement
		if (w>cw)
			// if the desired media size exceeds the visible space, align top/left
			mcX = 0;
		else
  			mcX = ((cw-w)/2) + document.documentElement.scrollLeft;

		if (h>ch)
			// if the desired media size exceeds the visible space, align top/left
			mcY = 0;
		else
	  		mcY = ((ch-h)/2) + document.documentElement.scrollTop;

	 	mcX -= 8;
	 	mcY -= 8;
	 	//alert(ch + "," + h + "," + mcY);

  		m.style.left = mcX + "px";
  		m.style.top = mcY + "px";
  		m.style.width = w + "px";
  		m.style.height = h + "px";
  		m.style.zIndex = "2";
	}
}





function playVideo(fn,w,h)
{
	setMediaSize(w,h);
	showMedia(true);
	var s1 = new SWFObject('video/player.swf','player',565,340,'9');
	s1.addParam('autostart', 'true' );
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('flashvars','skin=video/skins/snel.swf&autostart=true&file='+fn);

	//document.getElementById("mediawindow").style.width="565px";
	//document.getElementById("mediawindow").style.height="340px";

	s1.write('mediawindow');
	return false;
}

