/****************************************************************
	Project:     Eidix Labs :: Platform
	Copyright:   2008 Eidix Labs (http://eidix.com/)
	Author:      James Linden (jl@eidix.com)
	Filename:    sys/inc/lib_spatial.js
	Created:     2008-09-27 11:00 EST
****************************************************************/

function window_width() {
	var i = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		i = window.innerWidth;
	}
	else if( document.documentElement && document.documentElement.clientWidth ) {
		i = document.documentElement.clientWidth;
	}
	else if( document.body && document.body.clientWidth ) {
		i = document.body.clientWidth;
	}
	return( i );
}

function window_height() {
	var i = 0;
	if( typeof( window.innerHeight ) == 'number' ) {
		i = window.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight ) {
		i = document.documentElement.clientHeight;
	}
	else if( document.body && document.body.clientHeight ) {
		i = document.body.clientHeight;
	}
	return( i );
}

function window_center_left( p_width ) {
	return( parseInt( window_width() / 2 ) - parseInt( p_width / 2 ) );
}

function window_center_top( p_height ) {
	return( parseInt( window_height() / 2 ) - parseInt( p_height / 2 ) );
}

function node_center( p_id, p_width, p_height ) {
	var o = document.getElementById( p_id );
	if( o != null ) {
		o.style.top = window_center_top( p_height ) + 'px';
		o.style.left = window_center_left( p_width ) + 'px';
		o.style.height = p_height + 'px';
		o.style.width = p_width + 'px';
	}
}
