$(function() {
	Cufon.replace('#contents h2 span',{
			fontFamily: 'Margaret',
			fontSize: 42,
			onBeforeReplace: function(){
				$('#contents h2 span').css({backgroundPosition:'right bottom',fontSize:'42px',height:'50px',padding:'0 0.35em 0 0.25em',position:'relative',top:'-20px'});
			},
			onAfterReplace: function(){
				$('#contents h2').addClass('cufon');				
			}
	});
	$('.datepicker,.datepick').datepicker();
	$("a.fancybox").fancybox({
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'frameWidth': 600,
		'frameHeight': 480
	});
	$('a.new').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	offers();
	booking();
});

function offers(){
	var offers = $("ul.sidebar-offers li:gt(0)");
	var index = 0;
	offers.hide();
	
	setInterval(function(){
		$("ul.sidebar-offers li:eq("+(index-1)+")").hide("slow");
		if(index>offers.length) index=0;
		$("ul.sidebar-offers li:eq("+(index)+")").show("slow");
		index++;
	},6000);
	
}

function booking(){
	var quickbooking = $('#quickbooking');	
	if(quickbooking.length>0){
		var date = $.datepicker.formatDate('dd/mm/yy', new Date());
		var datepicker = $('<input type="text" class="date" name="ArrivalDate" />').val(date).datepicker({
			dateFormat: 'dd/mm/yy'
		});
		quickbooking.find('.days').parent().append(datepicker);
		quickbooking.find('.days, .month').remove();
	}
}
