// Custom Script for CJP.org 2-17-2012

$(document).ready(function() {

	// Dropdown Navigation on hover
	$("#linkListSub1 li").hover(function() {
		
		$(this).find("ul").slideDown(150).show();
	}, function() {
		$(this).find("ul").slideUp(200);
	});
	
	
	
	
	//Adding "Search CJP" in input box
	$('.search').attr('value', 'Search CJP');

	
	// Homepage search bar clear on focus
	$('.search').each(function() {

       var default_value = this.value;

       $(this).focus(function(){
               if(this.value == default_value) {
                       this.value = '';
               }
       });

       $(this).blur(function(){
               if(this.value == '') {
                       this.value = default_value;
               }
		});
	});
	
	
	
	
	
	// Homepage tabs for Events and News
	
	$("ul.tabs li").click(function() {
	
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();
		
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false
	
	});
	
	$(".paging li").css({ opacity : 0.8 });
	
	
	
	
	// SideNav Accordion
	$("#linkListSub3>ul>li>a").mouseover(function()
    {
		$(this).parent().siblings().find("ul").slideUp("slow");
		$(this).parent().find("ul").slideDown(800);	
		
		$(this).parent().siblings().find("#navArrow").css("background-image","url(http://www.cjp.org/display_image.aspx?ID=360220)");
		$(this).parent().find("#navArrow").css("background-image","url(http://www.cjp.org/display_image.aspx?ID=360219)");	
	});
	


    //Hide And show Toggle Bar animation
    //Hide (Collapse) the toggle containers on load
    $(".toggleContainer").hide();

    //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
    $("a.trigger").click(function() {
       var $this = $(this),
        $container = $('#ctl00_ContentPlaceHolder1_supportingElements'); // Takes care of the issue where the outer container doesn't expand with the box.
    if($this.hasClass('active')) {
        $container.height($container.data('height'));
    }
    else {
        $container.data('height', $container.height()).css('height', 'auto');
    }
    $(this).toggleClass("active").next().slideToggle("slow");
	$(this).text($(this).text() == 'Collapse' ? 'Expand' : 'Collapse'); // Toggles the text from expand to Collapse

	
    return false; //Prevent the browser jump to the link anchor/Prevent the browser jump to the link anchor
    });

});





