var pos = 0;

function ticker() {
	if(jQuery('#nws_inner').height()+pos >= 480) pos = pos-240;
	else pos = 0;
	
	jQuery('#nws_inner').animate({ 
		marginTop: pos
	}, 1000, function() {
		setTimeout(function(){
			ticker();
		}, 8000);
	});	
}

jQuery(document).ready(function($) {

	if ($.browser.safari) {
		$('#NWS').css('margin-left','19px');
		$('#NWS ul li').css('line-height','5px');
	}
	
	pos = parseInt( Math.random() *  ($('#nws_inner').height()/240) )*-240;
	$('#nws_inner').css('marginTop',pos).fadeIn(500);
	$('#HEADER_IMGS .small').fadeIn(2000);
	$('#HEADER_IMGS .large').fadeIn(2000);
	$('#FOOTER_IMGS .footer').fadeIn(2000);
	setTimeout(function(){
		ticker();
	}, 5000);
	
	$("#arrival").datepicker({
		buttonImage: 'http://diehls-hotel.de/wp-content/themes/hotel/icons/cal.png',
		buttonImageOnly: true,
		showOn: 'both',
		minDate: 0,
		onSelect: function() {
			$("#departure").datepicker('option', 'minDate', $("#arrival").datepicker('getDate'));
		}
	});
	$("#departure").datepicker({
		buttonImage: 'http://diehls-hotel.de/wp-content/themes/hotel/icons/cal.png',
		buttonImageOnly: true,
		showOn: 'both'
	});
	
	if($("#arrival2")) {
		$("#arrival2").datepicker({
			buttonImage: 'http://diehls-hotel.de/wp-content/themes/hotel/icons/cal2.png',
			buttonImageOnly: true,
			showOn: 'both',
			minDate: 0,
			onSelect: function() {
				$("#departure2").datepicker('option', 'minDate', $("#arrival2").datepicker('getDate'));
			}
		});
		$("#departure2").datepicker({
			buttonImage: 'http://diehls-hotel.de/wp-content/themes/hotel/icons/cal2.png',
			buttonImageOnly: true,
			showOn: 'both'
		});
	}
});
