app.errlog = {
	
	init : function(){		
		//get the parent node
		if(!this.parent){this.parent = s$(app.opps_box);}
	},
	
	makeList : function(){		
		
			
		//create node
		if(!$('#note_list')){
			this.list = new sb.element({
				nodeName : 'ol',
				id : 'note_list'
			}).appendAfter(this.parent.firstChild);
		}else{
			this.list = s$('#note_list');
		}
		
		//attach event
		app.oopsseek = this.list.event('click', function(e){app.errlog.zoneIn(e)});
	},
	
	add : function(args){	
		
		if(!args.id || !args.message){
			return;
		}else{	
			
			
			//document.title += ' ' + args.id;
					
			//check for list
			if(!this.list){	
				this.makeList(); 
			}
			
			var booboo = $('#' + args.id);	
			
			var a = new sb.element({
					nodeName: 'a',
					href : '#',
					innerHTML: args.message,
					targ : args.targ
			});
				
			if(!booboo){								
				var li = new sb.element({ nodeName: 'li', id : args.id}).appendTo(this.list);									
				li.append(a);
			}else{					
				 a.replace(booboo.firstChild);
				 a = booboo.firstChild;
			}
			
			//blink
			this.blink(a);
				
			
			this.parent.css('display', 'block');
			window.scroll(0,0);
		}
	}, 
	
	blink : function(elm){
		
		elm = s$(elm);
		
		sb.include('sb.timer');		
		var temp = new sb.timer({
			seconds : .25,
			handler : function(){
				
				if(this.count <= this.max){
					elm.className = (elm.className == this.newclass)?'':this.newclass;
				}
				
			}
		});
		
		
		temp.newclass = "blink";
		temp.max = 5;
		temp.begin();
		
	},
	
	remove : function(id){
		
		var booboo = $('#' + id);
		
		//add flashy removal script here
		if(booboo){
			sb.dom.remove(booboo);
		}
		
		if(this.list){			
			if(this.list.innerHTML.trim() === ''){
				this.parent.css('display', 'none');
			}
		}
		
	}, 
	
	targs : [],
	
	zoneIn : function(e){
		sb.events.stopAndPrevent(e);
		var that = sb.events.target(e);		
		if(that.targ){
			if(that.targ.select){
				that.targ.select();	
			}
			
			that.targ.focus();
			
		}
		
	}
	
}