
	jQuery.noConflict();

	var listSlider = {
		slideDelay: 12000,
		blindSpeed: 500,
		elmSelector: '.changer',
		lists: [],
		current: 0,
		
		initialize: function() 
		{
			if (jQuery(this.elmSelector).length == 0) return;
						
			var self = this;
			this.lists = jQuery(this.elmSelector).each(function(i, elm) { if (i > 0) jQuery(this).hide(); });
			window.setInterval(function() { self.animateList(); }, this.slideDelay);
		},
		
		animateList: function()
		{
			jQuery(this.lists[this.current]).slideUp(this.blindSpeed);
			this.current++;
			if (this.current >= this.lists.length) this.current = 0;
			jQuery(this.lists[this.current]).delay(this.blindSpeed).slideDown(this.blindSpeed);
		}
	};
	
	var seminarQuickSearch = {
		storage: [],
		initialize: function() {
			var self = this;
			if (jQuery('#seminarIndex').length == 0) return;
			
			//hide all existing blocks
			jQuery('#seminarIndex .seminarIndexItem').hide();
			jQuery('#seminarIndex .results').hide();
						
			//set event on textbox
			jQuery('#seminarIndex input[name="quicksearch"]').bind('keyup', function() {
				var searchStr = jQuery.trim(jQuery(this).val()).split(' ');
				var results = 0;
				
				jQuery('#seminarIndex .seminarIndexItem').each(function(i, elm) {
					var textToSearch = '';
					var matches = 0;
					
					//get all text
					jQuery(elm).find('.index').each(function(i, elm) {
						textToSearch += jQuery(elm).text() + ' ';						
					});
					
					//console.log(textToSearch);
					
					//check if all words are found within one block
					for (var w = 0; w < searchStr.length; w++)
					{
						if (jQuery.trim(searchStr[w]) == '') break;
						var expr = new RegExp('(' + escape(searchStr[w]) + ')', 'ig');
						if (expr.test(textToSearch)) matches++;
					}
					
					//console.log('Matches: ' + matches);
					
					//show them if matches equals word count
					if (matches > 0 && matches == searchStr.length)
					{
						results++;
						
						jQuery(elm).show();
						jQuery(elm).find('.index').each(function(i, elm) {
							var text = jQuery(elm).text();
							
							for (var w = 0; w < searchStr.length; w++)
							{
								var expr = new RegExp('(' + escape(searchStr[w]) + ')', 'ig');
								text = text.replace(expr, '###$1###');
							}
							
							text = text.replace(/###(.*?)###/g, '<strong>$1</strong>');
							jQuery(elm).html(text);
						});
					}
					else
					{
						jQuery(elm).hide();
					}
				});
				
				jQuery('#seminarIndex .results .searchStr').text(searchStr.join(' '));
				jQuery('#seminarIndex .results .resultCount').text(results);
				jQuery('#seminarIndex .results').show();
				
				if (jQuery.trim(searchStr.join(' ')) == '')
				{
					jQuery('#seminarIndex .results').hide();
				}
			});	
		}
	}
	
	jQuery(document).ready(function() {
		listSlider.initialize();
		seminarQuickSearch.initialize();
	});
	
	RegExp.escape = function(text) {
		return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
	}
