/*
File: jquery.config.js
Copyright: (c) 2010 Brand Rich Media
Author: Brandon Neil Richards
Author URI: http://www.brandrichmedia.com/
*/
// callback functions

function vidcarousel(carousel) {
		
		$('#scroll-down').bind('click', function() {
		    carousel.next();
		    return false;
		    });

		$('#scroll-up').bind('click', function() {
			carousel.prev();
		    return false;
		    });
    
};

$(function() 
{
		// jquery.cycle.min.js
		$('#rotator .slides').cycle({
			fx:     'fade', 
	    	timeout: 7500,
	 		pause: 1,
			prev: '.prev',
			next: '.next'
		});
		//media center scroller
		$('#vidcarousel').jcarousel({
			initCallback: vidcarousel,
			buttonNextHTML: null,
			buttonPrevHTML: null,
		    vertical: true,
		    scroll: 1
		});
		//media center replace video
		$('.series-list a').click(function(){
		        var entryID = $(this).attr('rel');
		        $('#fvideo').load("http://www.visitcalvary.com/media/series-entry/"+entryID+" #thevideo");
				return false;
		    });
		
		
		// content tabs
		var tabContainers = $('#newhere,#service-times,#get-connected,#latest-series,#latest-sermons, #bulletin,#community');
				
		$('.tab_nav a,.main_nav a').click(function () {
			tabContainers.hide().filter(this.hash).show();
	        $('.tab_nav a,.main_nav a').parent().removeClass('selected');
	        $(this).parent().addClass('selected');
				return false;
			}).filter(':first').click();
		
		// remove input text
		$('.rmv').click(function() {
			if (this.value == this.defaultValue) {
				this.value = '';
			}
		});
		
		$('.rmv').blur(function() {
			if (this.value == '') {
				this.value = this.defaultValue;
			}
		});
		
		//open windows without embedding target="_blank"				
		$('a[rel="external"]').each(function() {
			$(this).attr('target', '_blank');
		});
		
		//make sermon box clickable
		$(".video-container").click(function(){
		      window.location = $(this).children().find(".thehref").attr("href")
		   });
		
		//toggle sermon series summary
		$('.series-summary').hide();
		$(".series-container").click(
		  function () {
			$(this).siblings().children('.series-summary').slideUp().parent().css("background-color", "#EAEAEC");
			$(this).css("background-color", "#FFFFFF");
		    $(this).children('.series-summary').slideDown(600);
		});
		
		
		//toggle archives
		$("#2011").siblings().hide();
		//toggle the componenet
		$("#2011").click(function()
		{
			$(this).siblings().slideToggle(600);
		});

		//add hand icon to event selectors
		$('.archive dt,.series-container,.video-container').hover(function() 
		{
			$(this).addClass('hand');
		}, function() {
			$(this).removeClass('hand');
		});
		

});
