var tools = {
	debugMode: false,
	analytics: false,
	
	is_array : function(value) {
		if (typeof value === 'object' && value && value instanceof Array) {
			return true;
		}
		return false;
	},
	
	in_array: function(array, value) {
	
		tools.log(array);
	
		var ret = false;
		
		for(var i = 0; i < array.length; i++) {
			tools.log(array[i]);
			if(array[i] == value) {
				ret = true
			};
		}
		
		return ret;
	},
	
	str_replace : function(needle, replace, haystack) {		
		if (this.is_array(needle)) {
			for(i=0; i < needle.length; i++) {
				haystack = haystack.split(needle[i]).join(replace[i]);
			}
		}
		else {
			haystack = haystack.split(needle).join(replace);
		}
		return haystack;
	},
	
	sizeOf: function(obj) {
		var size = 0;
		
		for(k in obj) {
			size++;
		}
		
		return size;
	},
	
	hashes: {
		
		oldhash: '',
		
		//für alte browser: prüfen, ob sich der hash geändert hat
		checkHash: function() {
			if (window.location.hash != this.oldHash) {
				this.oldHash = window.location.hash;
				//if(typeof(console) != 'undefined') {console.log(window.location.hash)}
				tools.hashes.processNewHash();
			}
		},

		//aktuellen hash verarbeiten
		processNewHash: function() {
			animations.showLoader();
			if(tools.analytics) {
				 _gaq.push(['_trackPageview', window.location.hash.replace(/#/, '')]);
			}
			tools.navigation.setActive(window.location.hash.replace(/#/, ''));
			xajax_showContent(window.location.hash.replace(/#/, ''));
		}
	},
	
	updateMetaTitle: function(str) {
		$('title').html(str);
	},
	
	navigation: {
		setActive: function(hash) {
		
			// Alle Activen reseten
			this.resetActive();			
		
			// Anhand des Hashes rekursiv alle Punkte im Baum aktiv setzen
			var items = hash.split('/');
			for(key in items) {
				if(key > 1) {
					if($("a[href$='/"+items[key]+"/']").parent('li').size() > 0) {
						$("a[href$='/"+items[key]+"/']").parent('li').addClass(animations.config.navigation.active);
					} else {
						$("a[href$='/"+items[key]+"/']").addClass(animations.config.navigation.active);
					}
				}
			}
			
			animations.colorFade($('#metanavi .'+animations.config.navigation.active), '#fff', false);
			$('#navigation .'+animations.config.navigation.active + ' .bg').stop().animate({opacity: 1});
		},
		
		resetActive: function() {
			
			animations.colorFade($('#metanavi .'+animations.config.navigation.active), '#999', false);
			$('#navigation .'+animations.config.navigation.active + ' .bg').stop().animate({opacity: 0});
			$('.'+animations.config.navigation.active).removeClass(animations.config.navigation.active);
		}
	},
	
	log: function(what) {
		if (this.debugMode && typeof(console) != 'undefined') {
			console.log(what);
		}
	},
	
	date_filter: function(data, target) {
		
	}
}
