function NauticJavascriptAlert(){
	
    var name = 'nauticJavascriptAlert';
    var erroritems = new Array();

    //Validate if this Class is loaded
	this.check = function(){
		console.log('SCIPT : ' + name + ' loaded');
	};
	
    //Clearing the MessageboxView from the Sub-Messagelements
	this.clearView = function(){

		while( dojo.byId('messageblock').hasChildNodes() ){
			x = dojo.byId('messageblock').firstChild;
			dojo.byId('messageblock').removeChild(x);
		}
	};
	
	//Clearing the Textitem Array
	this.clearItems = function(){
		
		erroritems = new Array();
	};
	
    //Adding Textitemsto the Message Array
	this.addItem = function(text){
		
		erroritems.push(text);
	};
	//Single Call to Alert
	this.error = function(error){
	      this.addItem(error);
	      this.alertMe();
	};
	//Multiple Call to Alert
	this.errorFromArray = function(arr){
		this.addArray(arr);
		this.alertMe();
	};
	// Alert from String or Array
	this.Alarm = function(obj){
		if(dojo.isString(obj)){
			this.error(obj);
		}else{
			if(dojo.isArray(obj)){
				this.errorFromArray(obj);
			}
		}
	};
	
	// Adding a complete Array of items to the Textitem Array, overwriting the old Array
	this.addArray = function(arr){
		
		erroritems = arr;
		
	};
	
	this.hideMe = function(){
		nauticJsAlert.hide();
	};
	
	this.hasErrors = function(){
		return ( this.erroitems.length > 0 ) ? true : false;
	};
	
	//Bring the Alert into the View
	this.alertMe = function(){
		
		this.clearView();
		
		if(!this.hasErrors) return false;
		
		this._populate();
		nauticJsAlert.show();
		this.clearItems();
	};
	
	//Popluates The Messagebox with Listitems
	this._populate = function(){
		
		dojo.forEach(erroritems, function(item){
			if(dojo.isArray(item)){
				erroritems = item;
				this.alertMe();
				return false;
			}
			
			elem = document.createElement('li');
			
			img =  document.createElement('img');
			img.src = nauticonline.iconImportant;
			elem.appendChild(img);
			
			span = document.createElement('span');
			span.innerHTML = "&nbsp;&nbsp;"+ item;
			elem.appendChild(span);
			
			dojo.byId('messageblock').appendChild(elem);
		});
	};

}

nauticAlert = new NauticJavascriptAlert();
nauticAlert.check();
