function getWindowHeight() {
var windowHeight=0;
	if (typeof(window.innerHeight)=='number')
		windowHeight=window.innerHeight;
	else
		if (document.documentElement&&document.documentElement.clientHeight)
			windowHeight=document.documentElement.clientHeight;
		else if (document.body&&document.body.clientHeight)
			windowHeight=document.body.clientHeight;
	return parseInt(windowHeight);
}
function getWindowWidth() {
var windowWidth=0;
	if (typeof(window.innerWidth)=='number')
		windowWidth=window.innerWidth;
	else
		if (document.documentElement&&document.documentElement.clientWidth)
			windowWidth=document.documentElement.clientWidth;
		else if (document.body&&document.body.clientWidth)
			windowWidth=document.body.clientWidth;
	return parseInt(windowWidth);
}


function showlayer(videolayer,flashfile,flashwidth,flashheight){
	
	pagesize=getPageSize();
	
	var totalheight=getWindowHeight();
	var totalwidth=getWindowWidth();

	document.getElementById("fullscreen").style.display="inline";
	document.getElementById("fullscreen").style.width=(pagesize[0]-22)+"px";
	document.getElementById("fullscreen").style.height=pagesize[1]+"px";
	var videolayername="layer"+videolayer;
	var flashobjectname="flash"+videolayer;
	document.getElementById(videolayername).style.display="inline";
	
	if(videolayer=="video"){
	
		if (swfobject.hasFlashPlayerVersion("9")) {
	        var att = { data:flashfile, width:flashwidth, height:flashheight};
	        var par = { menu:"false" };
	        var myFlashContent = swfobject.createSWF(att, par, videolayer);
	    }
	
	}
	if(videolayer=="image"){
		
		document.getElementById('image').innerHTML='<img src="'+flashfile+'" border=0>';
	}
	
	//postop=(totalheight-flashheight)/3;
	//posleft=(totalwidth-flashwidth)/2;
	
	//document.getElementById(videolayername).style.top=postop+"px";
	//document.getElementById(videolayername).style.left=posleft+"px";
	
	positionvideo(videolayername,flashwidth,flashheight);
	
}


function positionvideo(videolayername,flashwidth,flashheight){
	pagesize=getPageSize();
	
	var totalheight=getWindowHeight();
	var totalwidth=getWindowWidth();
	
	postop=(totalheight-flashheight)/3;
	posleft=(totalwidth-flashwidth)/2;
	
	document.getElementById(videolayername).style.top=postop+"px";
	document.getElementById(videolayername).style.left=posleft+"px";

}


function hidelayer(videolayer){
	document.getElementById("fullscreen").style.display="none";
	videolayername="layer"+videolayer;
	document.getElementById(videolayername).style.display="none";
	
	swfobject.removeSWF(videolayer);
	
	var d = document.createElement("div");
	d.setAttribute("id", "video");
	document.getElementById("layervideo").appendChild(d);		
					
}
function adjustvideo(){
	if(document.getElementById("fullscreen").style.display=="inline"){
		pagesize=getPageSize();
		document.getElementById("fullscreen").style.width=pagesize[0]+"px";
		document.getElementById("fullscreen").style.height=pagesize[1]+"px";
	}
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
		
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


function maxvideo(){
	var totalheight=getWindowHeight();
	var totalwidth=getWindowWidth();

	
	pagesize=getPageSize();
	
	maxheigh=totalheight-2;
	document.getElementById("layervideo").style.width=(pagesize[0]-2)+"px";
	document.getElementById("layervideo").style.height=maxheigh+"px";
	document.getElementById("video").style.width=(pagesize[0]-2)+"px";
	document.getElementById("video").style.height=maxheigh+"px";
	document.getElementById("videocontrol").style.display="none";
	document.getElementById("layervideo").style.top="0px";
	document.getElementById("layervideo").style.left="0px";
}
function minvideo(flashwidth,flashheight){
	document.getElementById("layervideo").style.width=flashwidth+"px";
	document.getElementById("layervideo").style.height=flashheight+"px";
	document.getElementById("videocontrol").style.display="inline";
	document.getElementById("videocontrol").style.width=flashwidth+"px";
	document.getElementById("video").style.width=flashwidth+"px";
	document.getElementById("video").style.height=flashheight+"px";
	
	positionvideo("layervideo",flashwidth,flashheight);
}
