// Popup Window (Centred)
// returns the size of the window.
function getWindowSize() {
	var w = 0, h = 0;
	if ( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		w = window.innerWidth;
		h = window.innerHeight;
	} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		w = document.documentElement.clientWidth;
		h = document.documentElement.clientHeight;
	} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		w = document.body.clientWidth;
		h = document.body.clientHeight;
	}
	return { width : w, height : h };
}
// returns the size of the page.
function getPageSize() {
	var w = 0, h = 0;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if ( test1 > test2 ) {
		// all but Explorer Mac
		w = document.body.scrollWidth;
		h = document.body.scrollHeight;
	} else {
		// Explorer Mac;
		// would also work in Explorer 6 Strict, Mozilla and Safari
		w = document.body.offsetWidth;
		h = document.body.offsetHeight;
	}
	//alert(document.getElementById("flashcontent").style.height);
	//alert(h);
	return { width : w, height : h };
}
// returns how much the page has been scrolled.
function getScrollOffset() {
	var x = 0, y = 0;
	if ( self.pageYOffset ) {
		// all except Explorer
		x = self.pageXOffset;
		y = self.pageYOffset;
	} else if ( document.documentElement && document.documentElement.scrollTop ) {
		// Explorer 6 Strict
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	} else if ( document.body ) {
		// all other Explorers
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	return { x : x, y : y };
}

// scroll the page vertically to the given position. 
function scrollPageVertical( p_y ) {
	moveDown( getScrollOffset().y, p_y );
}
function moveDown( p_position, p_y ) {
	var move = ( p_y - p_position) / 10;
	var point = Math.round( p_position + move );
	scrollTo( 0, point );
	//if ( Math.abs( point - p_y ) > 0 && p_position < point ) {
	if ( Math.abs( point - p_y ) > 0 && Math.abs( point - p_position ) > 0 ) {
		setTimeout( "moveDown(" + point + ", " + p_y + ")", 15 );
	}
}

// scroll the page to just below the header flash movie.
function scrollPastHeader() {
	var winSize = getWindowSize();
	var pageSize = getPageSize();
	var scrollToY = pageSize/2;
	//alert(winSize);
	scrollPageVertical( Math.max( 0, Math.min( scrollToY, pageSize.height - winSize.height + 5 ) ) );
}

// Called from the _level0 swf and reports the Stage height.
function setFlashHeight (p_height) {
	var winSize = getWindowSize();

	// Scroll the page to half way down:
//	scrollPageVertical((p_height - winSize.height) / 2);
	scrollPageVertical((1350 - winSize.height) / 2);
}

function popup(url,winname,w,h,feat)
{
	if (!(isNaN(w) || isNaN(h)))
	{
		var x=parseInt((screen.width-w)/2);
		var y=parseInt((screen.height-h)/2);
		if (x<0)	x=0;
		if (y<0)	y=0;
		
		if (feat!=null && feat!="")
		{
			feat=","+feat;
		}
		else
		{
			feat="";
		}
		feat="left="+x+",top="+y+",width="+w+",height="+h+feat;
	}
	window.open(url,winname,feat);
}
