/*
FILE:		fx.js
VERSION:	0.0.1
AUTHOR:		Andrew Real
COMPILED:	2011-04-18
COMMENTS:

	- Must be loaded with fx.js, system.js, and ajax.js
	- Must be inserted within HEAD element

*/
ui = {

	initialize : function() {

		system.addLoadEvent(fx.boot());
		system.addLoadEvent(ajax.boot());
		// not working yet ?
		window.onerror = function(m,u,l) {

			ui.alert(m);

			}

		},

	alert : function(m) {

		msg = m.msg || null;
		if (msg == null) return false;

		width = m.width || 300;
		height = m.height || 100;
		left = ui.getWidth()/2-(width/2)+"px";
		top = ui.getHeight()/2-(height/2)+"px";

		fx.makeElement({

			elementType		:	'div',
			elementParent	:	document.body,
			html			:	'',
			styles			:	{

				'position'			:	'absolute',
				'left'				:	left,
				'top'				:	top,
				'width'				:	width,
				'height'			:	height,
				'color'				:	'white',
				'backgroundColor'	:	'gray'

				},

			attr			:	{

				'id'		:	'alertWindowHolder'

				}

			});

		fx.makeElement({

			elementType		:	'div',
			elementParent	:	document.getElementById('alertWindowHolder'),
			html			:	'Alert',
			styles			:	{

				'border'	:	'1px solid black'

				},

			attr			:	{

				'id'		:	'alertWindowBanner'

				}

			});

		fx.makeElement({

			elementType		:	'div',
			elementParent	:	document.getElementById('alertWindowHolder'),
			html			:	msg,
			styles			:	{

				'borderLeft'	:	'1px solid black',
				'borderRight'	:	'1px solid black',
				'borderBottom'	:	'1px solid black'

				},

			attr			:	{

				'id'		:	'alertWindowContent'

				}

			});

		system.addClickEvent(document.getElementById('alertWindowHolder',function() {

			document.getElementById('alertWindowHolder').removeChild(getElementById('alertWindowContent'));
			document.getElementById('alertWindowHolder').removeChild(getElementById('alertWindowBanner'));
			document.body.removeChild(document.getElementById('alertWindowHolder'));

			}));

		},

	getWidth	:	function() {

		return document.body.clientWidth;

		},

	getHeight	:	function() {

		return document.body.clientHeight;

		}

	}
