var lastid = 0;
$(document).ready(function() {
//$(document).pngFix(); 

		$('#weather').innerfade({
			animationtype: 'fade',
			speed: 1000,
			timeout: 2000,
			type: 'sequence',
			containerheight: '1em'
		});	
		$('#flash_events').innerfade({
			animationtype: 'slide',
			speed: 1000,
			timeout: 2000,
			type: 'sequence',
			containerheight: '120px'
		});
		$("a[rel='gallery']").colorbox({transition:"fade"});
		$('#headimg').innerfade({
			animationtype: 'fade',
			speed: 1000,
			timeout: 5000,
			type: 'sequence',
			containerheight: '210px'
		});
		$('#wedding_functions').innerfade({
			animationtype: 'fade',
			speed: 500,
			timeout: 5000,
			type: 'sequence',
			containerheight: '150px'
		});
		$(".iframe").colorbox({width:"510px", height:"400px", iframe:true});
		$("a[rel='hole1']").colorbox({transition:"fade"});
		
		
		$('#subscribe').ajaxForm({ beforeSubmit:  validateSubscribe, success: subscribeResponse });		
		$('#contact_us').ajaxForm({ beforeSubmit:  validateContact, success: contactResponse });
		$('#christmas_party').ajaxForm({ beforeSubmit:  validateChristmas, success: christmasResponse });
		
		
			
		
	$('li.top').hover(function() { $('ul', this).css('display', 'block'); }, function() { $('ul', this).css('display', 'none'); });

	$("#gaming_tick").click(function(e){
		if ($("#gaming_tick").is(':checked')){
			$(".gaming_note").show()
		}else{
			$(".gaming_note").hide()
		}
	});

	$("#next_whats_on").click(function(e){
		e.preventDefault();
		if ($("#whatson li").size()>ecount){
		$("#whatson").animate({"top": "-=184px"}, "slow");

	}else{
		$("#next_whats_on").hide()
	}
	
	ecount++;
	ecount++;


	})		   
setTimeout("runBubble()",2000)
});
function runBubble(){
		
		$("#notify").animate({ top: "30px", opacity: "1" })
}
function validateChristmas(){
	if ($("#name").val()==""){
		$("#name").focus()
		alert('Please enter your name')
		return false;
	}
	if (!isValidEmail($("#email").val())){
		$("#email").focus()
		alert('Please correct your email address')
		return false;
	}
	if (!$('#news').is(':checked')&&!$('#promo_news').is(':checked')&&!$('#wining').is(':checked')&&!$('#gaming').is(':checked')){
			    alert('To enter, you must subscribe to at least one newsletter.')
			return false;
	}
}
var ecount=2;
function isValidEmail(str) { 
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str)){
	return false
	}else{
		return true
	}
}

function validateContact(){
	if ($("#name").val()==""){
		$("#name").focus()
		alert('Please enter your name')
		return false;
	}
	if (!isValidEmail($("#email").val())){
		$("#email").focus()
		alert('Please correct your email address')
		return false;
	}
	if ($("#message").val()==""){
		$("#message").focus()
		alert('Please enter your message')
		return false;
	}
}
function contactResponse(){
	$('#contact_us').html("<p>Thank you, your email has been sent.</p>")
}
function christmasResponse(){
	$('#christmas_party').html("<p>Thank you, you're in the running.</p>")
}
function validateSubscribe(){
	if ($("#name").val()==""){
		$("#name").focus()
		alert('Please enter your name')
		return false;
	}
	if (!isValidEmail($("#email").val())){
		$("#email").focus()
		alert('Please correct your email address')
		return false;
	}
}
function subscribeResponse(){
	$("#subscribe").html("<h2>Thank you</h2><p>You're now subscribed.</p>")
}