/* ============================================================================
       site-wide jquery configuration for door-of-hope.org
============================================================================== */

jQuery(document).ready(function($){
	/* font replacements with Cufon
	==============================================================================
	Cufon.set('fontFamily', 'Mido');
	Cufon.replace('#main_menu a');
	Cufon.replace('#banner #banner_content p');
	Cufon.replace('#home_widget h2');
	Cufon.replace('#home_widget h3');
	Cufon.replace('#footer_container .widget h2');
	Cufon.replace('#sub_banner .banner_heading');
	Cufon.replace('#sub_content h1');
	Cufon.replace('#sub_content h1 span', {color: '-linear-gradient(#0096d4, #1e5c99)'});
	Cufon.replace('#sub_content h2');
	Cufon.replace('#sub_sidebar_widget h2.widget_title');
	Cufon.replace('#sub_sidebar .child_pages li a', {hover: true});
	
	Cufon.now(); // fix ie flicker*/
	
	/* featured slider for homepage
	============================================================================== */
	$("#jController").jFlow({
		slides: "#jSlides",
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		width: "830px",
		height: "239px",
		duration: 800,
		auto: true,
		prev: ".jFlowPrev", // must be class, use . sign
		next: ".jFlowNext" // must be class, use . sign
	});
	
	$('#jSlides').css({'display': 'block'}); /* dont show when loading, but show once loaded */
	
	
	/* hope network dropdown animation
	============================================================================== */
	$('#cb_network').hover(function(){
		$('#cb_network #links').slideDown('medium');
	}, function(){
		$('#cb_network #links').slideUp('medium');
	});
	//$('#btn_network').click(function () {
	//	$('#links').slideToggle('medium');
	//});
	
	$('p br.spacer_').remove(); // remove annoying space insertion by TinyMCE
	
	
	/* resources tab
	============================================================================== */
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});
	
	/* default textfield values for comments form
	============================================================================== */
	$('#comment').defaultValue();
	$('#author').defaultValue();
	$('#email').defaultValue();
	$('#url').defaultValue();
});