/* local functions */

jQuery.noConflict();

(function($){
	$(function(){
		$('body').append('<div id="tooltip" style="display:none;"></div>');
		
		var $innovationen = $('#innovationen > div');
		$innovationen.filter(':not(:first)').hide().end();

		var $pager = $('#innovationen-pager > div');
		$pager.each(function(i){
			var $this = $(this);
			
			$this.children().removeAttr('title').attr('rel', $innovationen.filter(':eq(' + i + ')').children().filter('h1').text())
			.mouseover(function(event){
				$('#tooltip').css('position', 'absolute').css('left', event.pageX + 20).css('top', event.pageY + 20).text($(this).attr('rel')).show();
				return false;
			})
			.mouseout(function(){
				$('#tooltip').hide();
				return false;
			})
			.click(function(){
			  $innovationen.hide().filter(':eq(' + i + ')').show().end();
					  return false;
				 }).text(i + 1);
		});
/*
		var $unterwegs = $('#unterwegs-mit-bernds > div');
		$unterwegs.hide().end();
		var unterwegs_index = Math.round(Math.random() * ($unterwegs.length - 1));
		var unterwegs_timeout;
		
		var rotateImages = function() {
			do {
				new_index = Math.round(Math.random() * ($unterwegs.length - 1));
			} while (new_index == unterwegs_index);
			$unterwegs.eq(unterwegs_index).css('z-index', 2);
			$unterwegs.eq(new_index).css('z-index', 1).show();
			$unterwegs.eq(unterwegs_index).fadeOut('slow', function(){
				unterwegs_index = new_index;
				unterwegs_timeout = setTimeout(rotateImages, 10000);
			});
		}
		
		rotateImages();

		$('#unterwegs_next').click(function()
		{
			clearTimeout(unterwegs_timeout);
			rotateImages();
			return false;
		});
*/
	});
})(jQuery);