$(document).ready(function() {
	
			// I hate image-maps. 
	
			$("area[rel^='prettyPhoto']").prettyPhoto({show_title: false, theme : 'dark_rounded'});
			$("a[rel^='prettyPhoto']").prettyPhoto({show_title: false, theme : 'dark_rounded'});
			
			
			// For click-and-hide FAQ's scattered around the website
			
			$('.question').click( function () {
				$('.smallgroups_faq').find('.currentSelection').slideUp(500).addClass('hideanswer');
				$(this).next('.answer').removeClass('hideanswer').slideDown(500).addClass('currentSelection');
			});
			
			$('.flink').click( function () {
				$('#frcontent').find('.currentSelection').slideUp(500).addClass('hideanswer');
				$(this).next('.answer').removeClass('hideanswer').slideDown(500).addClass('currentSelection');
			});

			$('.archiveclick').click( function () { 
				$('#contentbox-repeat').find('.currentSelection').slideUp(500).addClass('hideanswer');
				$(this).next('.answer').removeClass('hideanswer').slideDown(500).addClass('currentSelection');
			});
			
			// This is for the staff page
			// Makes use of the jquery plugin Cycle
			
			$('.changehover img').hover( 
				function() {
					if( $(this).hasClass(':not(highlighted)') ) {
						this.src = this.src.replace("-nohover","-hover");
					}
				},
				function() {
					if( $(this).hasClass(':not(highlighted)') ) {
						this.src = this.src.replace("-hover","-nohover");
					}
				}
			);
			
			$("#staffpics img").mouseup( function() { this.src = this.src.replace("-press","-hover"); }).mousedown( function() { this.src = this.src.replace("-hover","-press");});
			
			$('#staffbios').cycle({
				timeout : 0,
				speed : 500,
				startingSlide : 0,
				fx: 'shuffle'
			});
			
			$('.s1').click( function () {
				$('#staffbios').cycle(2);
				return false;
			});
			
			$('.s2').click( function () {
				$('#staffbios').cycle(4);
				return false;
			});
			
			$('.s3').click( function () {
				$('#staffbios').cycle(6);
				return false;
			});
			
			$('.s4').click( function () {
				$('#staffbios').cycle(8);
				return false;
			});
			
			$('.s5').click( function () {
				$('#staffbios').cycle(10);
				return false;
			});
			
			$('.s6').click( function () {
				$('#staffbios').cycle(12);
				return false;
			});

			preloader();

			// For Twitter feed

			$('#news_ticker').marquee();
			
			$.getJSON("http://twitter.com/statuses/user_timeline.json?screen_name=thechurchonstyr&count=4&callback=?",
			 		function(data){
						$.each(data, function(i,item){
							ct =  item.text;
							ct = ct.replace(/http:\/\/\S+/g, "<a href='$&' target='_blank'>$&</a>");
						    ct = ct.replace(/\s(@)(\w+)/g, "@<a href='http://twitter.com/$2' target='_blank'>$2</a>");
						    ct = ct.replace(/\s(#)(\w+)/g, "#<a href='http://search.twitter.com/search?q=%23$2' target='_blank'>$2</a>");
							$("#tickerupdates").append( "<img src='images/churchc.png' />" + ct );
			 		});
			 });

			// For next live service

			var newYear = new Date();
			newYear = new Date(2010 , 12, 8, 18);
			$('#countdown').countdown({ until: newYear,
										alwaysExpire: true,
										expiryText: '<div class="over">Click <a href="media/livestreaming.php">here</a> to watch live now!</div>'
			});
});	

$(window).load( function() {
	 $('#slider').cycle({
 			fx: 'cover',
 			timeout : 6000,
 			speed : 300,
 			pager : '#slidercount'
	});
});
