$(function() {

	$('#heading #bilder td.empty').remove();


	/** 
	 * Mouse Coordinator
	 * Display two arrow which follow the mouse cursor
	 * ------------------------------------------------------------------*/
	// Path and name (relative to document root)
	var arrowTop = 'files/theme/img/arrow_top.png';
	var arrowLeft = 'files/theme/img/arrow_left.png';
	
	// Append images
	$('#wrapper').append('<img src="'+arrowTop+'" id="mc-top"><img src="'+arrowLeft+'" id="mc-left">');
	
	// Mousemove
	$('body').mousemove(function(e) {
		var pageWidth = $(document).width();
		var pageHeight = $(document).height();
		if (e.pageX < pageWidth-15) {
			$('#mc-top').css('left', e.pageX);
		}
		if (e.pageY < pageHeight-15) {
			$('#mc-left').css('top', e.pageY);
		}		
	});


	/** 
	 * Fancybox
	 * Show images in a fancybox
	 * ------------------------------------------------------------------*/	
	$('a[rel*=lightbox\\[]').fancybox({
		'titleShow': false
	});
	

	/** 
	 * Sortables
	 * Sortable cols on home page
	 * ------------------------------------------------------------------*/
	$('#p-home #content #home').sortable({
		// Wenn letztes Element dragged, zweitletztes margin-right: 0;
		start: function(event, ui) {			
			var indexNum = $(ui.item).index();
			if (indexNum == 3) {
				$('#p-home #content #home .col:eq(2)').css('margin-right', 0);		
			}
		},
		stop: function(event, ui) {
			var indexNum = $(ui.item).index();
			$('#p-home #content #home .col').css('margin-right', '54px');
			$('#p-home #content #home .col:eq(3)').css('margin-right', '0');
		}		
	});
	
	
	/** 
	 * IE Warning
	 * Show a IE warning if a users uses IE < 9
	 * ------------------------------------------------------------------*/	
	if ($.browser.msie && $.browser.version < 9) {
		// Include warning
		var warning = '<div id="warning"><p>Sie verwenden einen <strong>veralteten Browser</strong>. Bitte laden Sie sich die neue Version ' +
			'<a href="http://windows.microsoft.com/de-DE/internet-explorer/products/ie/home">direkt von Microsoft</a>.</p></div>';
		$('body').prepend(warning);			
		// Animate warning
		$('#warning').animate({
			height: '20px'
		}, 1000, function() {
			// Animation complete.
		});	
	}
	


	
});


$(window).load(function() {
    $('#slider').nivoSlider({
		controlNav: false,
		effect: 'boxRain'
		
	});
});
