$(document).ready(function() {	
	$('#slideshow DIV:first-child').css({opacity:0.0}).addClass('active').animate({opacity: 1.0}, 500);
	var n = $('#slideshow > DIV').size();
    if(n > 1) playSlideshow = setInterval('slideSwitch()', 5000);
	$('#slideshow').hover(function() { clearInterval(playSlideshow); }, function() { if(n > 1) playSlideshow = setInterval('slideSwitch()', 5000); });	
	$('#tabs').tabs({ selected: 0 });
	$('button, input:submit').button();
	$('.openDialog').dialog({
		autoOpen: false,
		modal: true,
		width: 375,
	});
	$('.responseDialog').dialog({
		closeOnEscape: false,
		open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
		autoOpen: true,
		modal: true,
		width: 375,
	});
	$('.dialog').click(function() {
			$('.openDialog').dialog('open');
	});
	$('.mp3').jmp3();
	$(".gallery a[rel^='lightbox']").prettyPhoto({theme:'facebook'});
});
function slideSwitch() {
    var $active = $('#slideshow DIV.active');
    if ($active.length == 0) $active = $('#slideshow DIV:last');
    var $next =  $active.next().length ? $active.next() : $('#slideshow DIV:first');
	$active.css({opacity:1.0}).addClass('last-active').animate({opacity:0.0}, 1000);
	$next.css({opacity:0.0}).addClass('active').animate({opacity:1.0}, 1000, function() { $active.removeClass('active last-active'); });
}
/***
*  jMP3 v0.2.1 - 10.10.2006 (w/Eolas fix & jQuery object replacement)
* an MP3 Player jQuery Plugin (http://www.sean-o.com/jquery/jmp3)
* by Sean O
***/
jQuery.fn.jmp3 = function(passedOptions){
	// hard-wired options
	var playerpath = "http://rockchurchupc.com/podcast/";		// SET THIS FIRST: path to singlemp3player.swf

	// passable options
	var options = {
		"filepath": "http://rockchurchupc.com/podcast/",		// path to MP3 file (default: current directory)
		"backcolor": "",									// background color
		"forecolor": "68a4ab",								// foreground color (buttons)
		"width": "120",										// width of player
		"repeat": "no",										// repeat mp3?
		"volume": "100",									// mp3 volume (0-100)
		"autoplay": "false",								// play immediately on page load?
		"showdownload": "true",								// show download button in player
		"showfilename": "false"								// show .mp3 filename after player
	};

	// use passed options, if they exist
	if (passedOptions) {
		jQuery.extend(options, passedOptions);
	}

	// iterate through each object
	return this.each(function(){
		// filename needs to be enclosed in tag (e.g. <span class='mp3'>mysong.mp3</span>)
		var filename = options.filepath + jQuery(this).html();
		// do nothing if not an .mp3 file
		var validfilename = filename.indexOf(".mp3");
		if (validfilename == -1) { return false; }
		// build the player HTML
		var mp3html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		mp3html += 'width="' + options.width + '" height="20" ';
		mp3html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
		mp3html += '<param name="movie" value="' + playerpath + 'singlemp3player.swf?';
		mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
		mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
		mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" />';
		mp3html += '<param name="wmode" value="transparent" />';
		mp3html += '<embed wmode="transparent" width="' + options.width + '" height="20" ';
		mp3html += 'src="' + playerpath + 'singlemp3player.swf?'
		mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
		mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
		mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" ';
		mp3html += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		mp3html += '</object>';
		// don't display filename if option is set
		if (options.showfilename == "false") { jQuery(this).html(""); }
		jQuery(this).prepend(mp3html+"&nbsp;");

		// Eolas workaround for IE (Thanks Kurt!)
		if(jQuery.browser.msie){ this.outerHTML = this.outerHTML; }
	});
};

