(function($){
	$(function(){
		
		$('input.date').each(function(){
			jQuery(this).datepicker({
				dateFormat: "DD, dd MM yy",
				constrainInput: true,
				minDate: new Date(),
				maxDate: '+1y',
				gotoCurrent: true,
				hideIfNoPrevNext: true,
				showButtonPanel: true,
				showOtherMonths: true,
				closeText:'Close',
			});
		});
		
		$('div.gallery').jqSlideshow({shownumbers:false});
		
		if($('#overlay').get(0)){
			startimer = setInterval(animateStars, 1800);
			setTimeout(fadeIntro, 60000);
			$('#overlay').bind('click', function(){ fadeIntro(); return false; });
		}
		
 });
var startimer;
var current = null;
var key = null;
	
function animateStars(){
	while(key == current){
		key = Math.floor(Math.random()*6);
	}
	current = key;
	var star = $('#star'+(key+1));
	if(star.get(0)){
		var w = star.width();
		var h = star.height();
		var nw = Math.floor(w/1.02);
		var nh = Math.floor(h/1.02);
		var p = star.position();
		var t = p.top + ((w-nw)/2);
		var l = p.left + ((h-nh)/2);
		star.animate({width: nw, height: nh, top:t, left:l, opacity: 0.6}, 700).animate({width: w, height: h, opacity: 1, top:p.top, left:p.left}, 700);
	}
}
function fadeIntro(){
	$('#overlay').fadeOut();
}
})(jQuery);
