
jQuery.fn.centerH = function ()
{
	this.css("position","absolute");
//	var left = Math.max( 0, (this.parent().outerWidth() - this.outerWidth())/2 + this.parent().scrollLeft() );
	var left = Math.max( 0, ($(window).width() - this.outerWidth())/2 + $(window).scrollLeft() );
	this.css("left", left + "px");
	return this;
}

jQuery.fn.centerV = function ()
{
	this.css("position","absolute");
	var top  = Math.max( 0, (this.parent().outerHeight() - this.outerHeight())/2 + this.parent().scrollTop() );
//	var top  = Math.max( 0, ($(window).height() - this.outerHeight())/2 + $(window).scrollTop() );
	this.css("top",  top + "px");
	return this;
}


function arrangePage()
{
	// center root div from side-to-side
	$('#root').centerH();
	// center NavigationBar from side-to-side in its container (root)
	$('div').has( 'a[onMouseOver*="NavigationBar"]' ).last().centerH();
}

function initialize()
{
	auPreload();
	initMouseEvents();
}

$(document).ready(function(){arrangePage();initialize();});
$(window).resize(function(){arrangePage();});

