Lib = {
	tmpImg : null,
	
	TYPE : {
		ERROR : 0,
		REDIRECT : -1,
		SUCCESS : 1,
		FATAL_ERROR : -2,
		AUTOCOMPLETE : -3
	},
	
	BLOCKUITYPE : {
		LOADING : 0,
		MESSAGE : 1,
		DISABLED : 2
	},
	
	setMessageBox : function(id, message, className) {
		$(id).css('display','')	
					.empty()
					.addClass(className)
					.html(message)
					.fadeIn(100);
		
	},
	
	clearMessageBox : function(id) {
		$(id).css('display','none').empty();					
		
	},
	
	
	 
	transferUI : function(obj1, obj2, ms) {
		$(obj1).effect("transfer", { to: obj2 }, ms);		
	},
		
     
	 
	
	blockUI : function(myId, status, type, message) {
		//return;//**************************************************************************
		message = message ? message : 'No msg.'; 
		type = type ? type : Lib.BLOCKUITYPE.LOADING;
		
	 
		
		if (!status) {
			
			$(myId).attr('disabled', '');
			$(myId).unblock();
			
		} else {			
			
			$(myId).attr('disabled', true);
			
			switch (type) {
				case Lib.BLOCKUITYPE.DISABLED:
					$(myId).block({
						message : null,
						overlayCSS:  { 
					        opacity: '0.6',
					        background: '#F6F6F6'
					    }
					});
				break;
				case Lib.BLOCKUITYPE.MESSAGE:
					$(myId).block({
						message : message,
						overlayCSS:  { 
					        opacity: '0.6',
					        background: '#F6F6F6'
					    },
					    css: { 
				            border: 'none', 
				            padding: '20px', 
				            backgroundColor: '#000', 
				            '-webkit-border-radius': '5px', 
				            '-moz-border-radius': '5px', 
				            opacity: .5, 
				            color: '#fff' 
					    }
					});		   
				break;
				default:
					$(myId).block({
						message : null,
						overlayCSS:  { 
					        opacity: '0.6',
					        background: '#F6F6F6 url(/css/img/loading-overlay.gif) no-repeat 50% 50%'
					    }
					});
				break;			
			}
		}
    },    
    
    
    
    
	
	
	Json : {
		handleResponse : function(data) {
			if (data.type == 'error') {
				return Lib.TYPE.ERROR;
			} else if (data.type == 'redirect') {
				Lib.blockUI('body', true,'Bitte warten, Lib.BLOCKUITYPE.MESSAGE,Sie werden weitergeleitet...');				
				window.location = data.location;
				return Lib.TYPE.REDIRECT;
			} else if (data.type == 'autocomplete') {			
				return Lib.TYPE.AUTOCOMPLETE;
			} 

			return Lib.TYPE.SUCCESS;
		}
	},
	
	
	
	Confirm : function(msg) {
		return confirm(msg);
	},
	
	Tools : {
		unHtmlspecialchars  : function(s) {
			return s.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&').replace(/&quot;/g, '"');
		},
		
		Object : {
			clone : function(o) {
				var nO = (o instanceof Array) ? [] : {};
				for (i in o) {
					if (o[i] && typeof o[i] == "object") {
						nO[i] = this.clone(o[i]);
					} else 
						nO[i] = o[i];
				}
				return nO;
			},
		
			toString : function(a) {
				var s = '';
				for (var i in a) {
					s += i+'=';
					if (typeof a[i] == 'object')
						s += this.toString(a[i]);
					else
						s += a[i];
					s += '&';
				}
				return s;
			},
		
			compare : function(a, b) {
				return this.toString(a) == this.toString(b);
			},
		
			current : function(o) {
				for (var a in o) 
					return o[a];
				return null;
			}
		}
	},
	
    
    _initNyroModal: function() {
    	if ($.nyroModalSettings != undefined) {
			$.nyroModalSettings({
				bgColor: '#ddd',
				type: 'iframe',
				bgColor: '#000000',
				width: 5,
				height: 5,
				windowResize: true,
				titleFromIframe: false,
				forceType: 'iframe'
			}); 
    	}
    	$('.nyroModal').nyroModal();
    },
    
    
	_init : function() {
		for (var name in this) {
			if ( typeof(this[name].init) != 'undefined'){
				this[name].init();
			}
		}
	},
	
	init : function() {
		this._initNyroModal();
		this.tmpImg = new Image();
		this.tmpImg.src = '/css/img/blind.png';
	
		this._init();
		

		/*
		jQuery('#navigation').accordion({ 
		    active: false, 
		    navigation: true, 
		    
		});
		*/ 

	}
	
	
};
