/*
	General browser detection and positioning.
	
*/

var isNavigator, isIE
var coll = ""
var styleObj = ""

if( parseInt( navigator.appVersion) >= 4 )
{
	if( navigator.appName == "Netscape" )
	{
		isNavigator = true
	}
	else
	{
		isIE = true;
		coll = "all.";
		styleObj = ".style";		
	}
}


function GetInsideWindowWidth()
{
	if( isNavigator )
	{
		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 GetInsideWindowHeight()
{
	if( isNavigator )
	{
		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 GetWindowScrollX()
{
	if( isNavigator )
	{
		return window.pageXOffset;
	}
	else
	{
		if ( !document.documentElement.scrollLeft )
			return document.body.scrollLeft;
    else
			return document.documentElement.scrollLeft;		
	}
}


function GetWindowScrollY()
{
	if( isNavigator )
	{
		return window.pageYOffset;
	}
	else
	{
		if ( !document.documentElement.scrollTop )
			return document.body.scrollTop;
    else
			return document.documentElement.scrollTop;		
	}
}


function GetObjWidth( obj )
{
	if( isNavigator )
	{
		return obj.clientWidth;
	}
	else
	{
		return obj.clientWidth;
	}
}


function GetObjHeight( obj )
{
	if( isNavigator )
	{
		return obj.clientHeight;
	}
	else
	{
		return obj.clientHeight;
	}
}


function MoveTo( obj, x, y )
{
	if( isNavigator )
	{	
		obj.style.position = "absolute";
		obj.style.top = y + 'px';
		obj.style.left = x + 'px';	
	}
	else
	{
		obj.style.position = "absolute";
		obj.style.top = y;
		obj.style.left = x;	
	}
}


function CenterObj( obj )
{
	var x = Math.round( (GetInsideWindowWidth() / 2) - (GetObjWidth( obj ) / 2) + GetWindowScrollX() )
	var y = Math.round( (GetInsideWindowHeight() / 2) - (GetObjHeight( obj ) / 2) + GetWindowScrollY() )
		
	MoveTo( obj, x, y );
}



function Show( elementId )
{
	var panel = document.getElementById( elementId );
	CenterObj( panel );
	
	Controls_Hide();

	var opacity = new fx.Opacity( panel, {duration: 200} );
	opacity.hide();
	opacity.toggle();
}


function Hide( elementId )
{
	var panel = document.getElementById( elementId );
	var opacity = new fx.Opacity( panel, {duration: 200} );
	opacity.toggle();
}
