function getMedia()
{
	return document.getElementById("p_frame");
}

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 = document.documentElement.scrollLeft;
		else
  			mcX = ((cw-w)/2) + document.documentElement.scrollLeft;

		if (h>ch)
			// if the desired media size exceeds the visible space, align top/left
			mcY = document.documentElement.scrollTop;
		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);
	// yt sizes are 320x265, 425x344, 480x385, 640x505
	var s1 = new SWFObject('/gallery/videos/player.swf','player',512,416,'9');
	s1.addParam('autostart', 'false' );
	s1.addParam('allowfullscreen','true');
	s1.addParam('allowscriptaccess','always');
	s1.addParam('wmode','transparent');
	s1.addParam('flashvars','skin=gallery/videos/skins/snel.swf&autostart=false&wmode=transparent&file='+fn);

	//document.getElementById("mediawindow").style.width="565px";
	//document.getElementById("mediawindow").style.height="340px";

	s1.write('mediawindow');
	return false;
}

