var slideshow_interval;

$(document).ready(function(){
	
	$("li").hover(function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); });

	$("ul").each(function() {
		$(this).children("li:last").addClass('last');
	});

	$(".minheight").each(function() {
		if ($(this).height() < $(this).css('min-height').replace('px', '')) {
			$(this).height($(this).css('min-height'));
		}
	});


	$(".view-join .form-text, .webform-client-form .form-text").each(function() {
		$(this).addClass('autofill').attr('title', $(this).attr('value'));
	});

	$(".autofill").focus(function() {
		if ($(this).val() == $(this).attr('title')) { $(this).val(''); }
	}).blur(function() {
		if ($(this).val() == '') { $(this).val($(this).attr('title')); }
	});


	$("#edit-log").parents('.form-item').hide();

	$("span.email").each(function() {
		email = $(this).text().replace('(at)', '@');
		$(this).empty().append($("<a href='mailto:" + email + "' />").text(email));
	});


	$("input[type=button], input[type=submit]").addClass('button');




	$('.view-feature-slideshow .view-content').cycle({ 
	    fx:    'fade', 
	    speed:  1400,
	    timeout: 5000,
	    pager: '#slideshow_pager',
	    cleartype: true,
	    cleartypeNoBg: true,
	    delay: 500
	    
	    /* ,
	    after: function() {
		index = $(".view-home.view-display-id-page_1 > .view-content > div").index(this);
		$(".view-home.view-display-id-attachment_1 > .view-content > div").removeClass('current');		
		current = $(".view-home.view-display-id-attachment_1 > .view-content > div").get(index);
		$(current).addClass('current');
	    }*/
	});



	

	$(".splash_popup_close").click(function() {
		$(".view-meetsteve").hide('slow');
	});
	$("#splash_meet").click(function() {
		$(".view-meetsteve").hide();	
		$("#block-views-meetsteve-block_1 .view-meetsteve").show('slow');
	});
	$("#splash_events").click(function() {
		$(".view-meetsteve").hide();		
		$("#block-views-meetsteve-block_2 .view-meetsteve").show('slow');
	});
	$("#splash_doma").click(function() {
		$(".view-meetsteve").hide();		
		$("#block-views-meetsteve-block_3 .view-meetsteve").show('slow');
	});
	$("#splash_news").click(function() {
		$(".view-meetsteve").hide();		
		$("#block-views-meetsteve-block_4 .view-meetsteve").show('slow');
	});

	/*
	$(".front #webform-client-form-25").ajaxForm({
		beforeSubmit: function() {
			$("#edit-submitted-email-address").attr('readonly', 'readonly').addClass('readonly');
			$("#splash_join_button").hide();
			$("#splash_join_loading").show();
		},
		success: function() {
			$("#splash_join_loading").hide();
		
			alert("Thank you very much for joining our campaign. We'll be in touch with all the latest campaign news and events.");
		}
	});
	*/


	$("#home_bottom_left .block:first").addClass('current');
	$("#home_bottom_left .block h3").click(function() {
		$("#home_bottom_left .block").removeClass('current');
		$(this).parents('.block').addClass('current');
	});




});



function onYouTubePlayerReady() {
	$(".view-feature-slideshow embed, .view-feature-slideshow object").each(function() {
		this.addEventListener("onStateChange", "yt_player_click");
	});
}
function yt_player_click(state) {
	if (state == 1) {
		$(".view-feature-slideshow .view-content").cycle('pause');
	}
}



