var rotateTimer;

$(function() {
	// Javascript selectors
	$('.jcarousel-skin-duc li a, .alt li a').click(function() {
		var parent_ul = $(this).parent().parent();
		
		$('li.selected', parent_ul).removeClass('selected');
		$(this).parent('li').addClass('selected');
		
		return false;
	});
	
	// Self Labeling Form Fields
	$('input[rel]').label_fields();

	// Link Emails
	$('.email').defuscate();
});

function playTracker(obj) { 
	clearTimeout(rotateTimer); 
}

function setVideo(file, image, path) {
	if (path == undefined) path = '/media/uploads/';
	
	var player = document.getElementById('video-player');	
	
	var obj = {
		file:path+file,
		image:path+image,
		title:""
	};

	player.sendEvent("LOAD",obj);
	//player.sendEvent("PLAY");

	player.addViewListener("PLAY","playTracker");
		
	return false;
}

$(function() {
});

function join_list(form) {
	if (form.email.value != form.confirm_email.value) {
		alert('It looks like you entered your email address differently in the two boxes, double check and try again.');
	} else {
		$.get('/home/join_list/'+escape(form.name.value)+'/'+escape(form.email.value))
		$('#footer').html('<p>Thank you for joining the Denver United Church mailing list.</p>');
	}
	
	return false;
}

$(document).ready(function() {
	// Carousels
	jQuery('.jcarousel-skin-duc').jcarousel({wrap: 'both'});
	
});
