	/*	Dependencies:	jquery, element	*/

	function Alert_Class() {
		
		this.container = $(document.body);
		
		this.messageID = "msgBox";
		this.loaderID = "msgLoader";
		
		this._init();
	};
	
	/* Private Methods */
	
	Alert_Class.prototype._init = function() {
	
		this._create();
	
		this._applyPosition();
		
	};
	
	Alert_Class.prototype._create = function() {
		
		if ($("#" + this.loaderID).length == 0) {
			
			this._createContainer(this.loaderID, "loader");
			
		}
		
		if ($("#" + this.messageID).length == 0) {
		
			this._createContainer(this.messageID, "message");
			
		}
		
		this._createInnerMessage();
		
	};
	
	Alert_Class.prototype._createContainer = function(sID, sContainer) {
		
		this.container.append("<div id='" + sID + "'></div>");
			
		this[sContainer] = $("#" + sID);
			
		this[sContainer].hide();
		
	};
	
	Alert_Class.prototype._applyPosition = function() {
		
		var docBody = {
			width: $(document.body).width()
			, height: $(document.body).height()
		};
	
		var nW = (docBody.width*.45);
		
		var msgWidth = nW;
		
		var cssMessage = {
			"left": (docBody.width/2 - msgWidth/2)
			, "width": msgWidth
		};
		
		$(this.message).css(cssMessage);
	
	};
	
	Alert_Class.prototype._createInnerMessage = function() {
			
		var rContent = [];
		
		/* Title */		
		rContent.push('<div id="msgBoxTitle"></div>');
		
		/* Body */
		rContent.push('<div id="msgBoxContent"></div>');
		
		/* Footer */
		rContent.push('<div id="msgBoxFooter" class="hasLayout"></div>');
		
		this.message.append('<div id="messageContainer">' + rContent.join("") + '</div>');
		
		this._title = $("#msgBoxTitle");
		
		this._content = $("#msgBoxContent");
		
		this._footer = $("#msgBoxFooter");
		
		this._applyPosition();
		
	};
	
	Alert_Class.prototype._buildButtons = function(oArgs) {
		
		this._footer.html("");
		
		var sType;
		
		for (sType in oArgs) {
		
			var _oEl;
			
			_oEl = '<a href="javascript:void(0);" style="float: right; margin-left: 10px;" id="' + oArgs[sType].id + '" class="' + oArgs[sType].className + '"><span>' + oArgs[sType].label + '</span></a>&nbsp;';
		
			this._footer.append(_oEl);
			
			$("#" + oArgs[sType].id).bind("click", oArgs[sType].oData, oArgs[sType].actionFunc);
			
		}
		
	};
	
	Alert_Class.prototype._applyStyles = function(oArgs) {
		
		var sType;
		
		for (sType in oArgs) {
			
			var _msg = $("#" + sType);
			
			var i, len;
			
			for (i = 0, len = oArgs[sType]; i < len; i++) {
			
				_msg.css(oArgs[sType][i]);
				
			}			
			
		}
			
	};
	
	/* Public methods */
	
	Alert_Class.prototype.cssOverride = function(sElement, oCSS) {
		
		if (!/\#/g.test(sElement)) {
			sElement = "#" + sElement;
		}
		
		$(sElement).css(oCSS);
		
	};
	
	Alert_Class.prototype.display = function(oArgs) {
		
		var args = oArgs;
		
		if (args.title) {
			
			this._title.html(args.title);
				
		} else {
		
			this._title.html("Message Title:");
			
		}
		
		if (!args.displayTitle) {
			
			this._title.hide();	
		
		} else {
		
			this._title.show();	
		
		}
		
		if (args.content) {
			
			this._content.html(args.content);	
		
		} else {
			
			this._content.html("Message Content");	
			
		}
		
		if (args.contentFunction) {
			args.contentFunction();	
		}
		
		if (args.buttons) {
			
			this._buildButtons(args.buttons);
			
		} else {
			
			var oObj = {
				okay: {
					label: "Okay"
					, id: "okayBtn"
					, className: "buttonCancel"
					, oData: {ref: this}
					, actionFunc: function() {
						
						var args = arguments[0].data;
						
						args.ref.message.hide();
						
						args.ref.loader.hide();
					}
				}
			};
			
			this._buildButtons(oObj);
		
		}
		
		if (args.styles) {
			
			this._applyStyles(args.styles);			
		}
		
		this.loader.show();
		
		this.message.show();
				
	};
	
	Alert_Class.prototype.close = function() {
		this.loader.hide();
		this.message.hide();	
	};
	
	var msgBox = new Alert_Class();
	
	
	/*
		Example Use:
	
	msgBox.display({
	    title: "The Title 2:"
	    , displayTitle: false
	    , content: oElement.create("div", {}, "Element....")
	    , contentFunction: function() {
	    	$("div#msgBoxContent").bind("click", function() {
	    		alert("TEST");
	    	});
	    }
	    , buttons: {
	        okay: {
	            label: "Okay"
	            , id: "okayButton"
	            , className: "buttonCancel"
	            , oData: {ref: "okayButton"}
	            , actionFunc: function() {
				//alert(arguments[0].data.ref);
				msgBox.close();
	            }
	        }
	    }
	});
	
	*/