/* Author: David Ray

*/

jQuery(window).focus(function(){jQuery.fx.off = false;}); jQuery(window).blur(function(){jQuery.fx.off = true;}); 
jQuery(document).ready(function() {


jQuery("a[id^=view_more_]").each(function(index2,el2) {

		jQuery(this).click(function(event){
	
		var id	=	el2.id;
		var substrs = id.split('view_more_');
		jQuery("#div_less_"+substrs[1]).slideUp(1);
		jQuery("#div_more_"+substrs[1]).slideDown('slow');
		event.preventDefault();
	});

});


jQuery("a[id^=view_less]").each(function(index2,el2) {
	
		jQuery(this).click(function(event){
		var id	=	el2.id;
		var substrs = id.split('view_less_');
		jQuery("#div_less_"+substrs[1]).slideDown(1);
		jQuery("#div_more_"+substrs[1]).slideUp('slow');
		event.preventDefault();
	});
});


jQuery("[id^=reply-title]").each(function(index2,el2) {
	
		var id	=	el2.id;
		var substrs = id.split('reply-title_');
		var id		=	substrs[1];
		jQuery(this).click(function(event){
		
		jQuery("#your_response_"+id).slideToggle();
		jQuery("#comment_div_"+id).slideToggle();

	});

});


	/*
	jQuery(".your_response , #commentform").hide();
	
	jQuery("h3#reply-title").click(function(event){
		jQuery(".your_response , #commentform").slideToggle();
		event.preventDefault();
	});
	
*/	
	
	jQuery('#coda-slider-1').codaSlider({
		dynamicTabsPosition: "bottom",	
		autoHeight: false,
		dynamicArrows: false,
		autoSlide: true,
		autoSlideInterval: 4000,
		autoSlideStopWhenClicked: true
	});
	
	/* BLOG REEL TABS */
	jQuery("#jasonReel, #otherReel").hide();
	
	
	jQuery("#boxMenu nav a").click(function(event){
		var hideReel = jQuery(".active a").attr('href');
		jQuery(hideReel).hide();
		jQuery(".active").removeClass("active");
		
		
		jQuery(this).parent().addClass("active");
		var curReel = jQuery(this).attr('href');
		// jQuery("#blogFeed ul").hide();
		jQuery(curReel).fadeIn();
		return false;
	});
	
	// TWITTER MENU
	jQuery("#twit-mention").hide();
	
	jQuery("#a_mentions").click(function(event){
		jQuery("#twit-feed").hide();
		jQuery("#twit-mention").show();
		event.preventDefault();
	});
		
	jQuery("#a_twitter").click(function(event){
	
		jQuery("#twit-feed").show();
		jQuery("#twit-mention").hide();
	
		event.preventDefault();

	});
		

		
	jQuery(".quickMenuList").hide(); 
	jQuery(".quickMenuList:first").show();
	
    jQuery("#quickMenu nav li a").click(function(){
		jQuery('#quickMenu nav li').removeClass("current");
		jQuery(this).parent().addClass("current");
		var currentTab = jQuery(this).attr('href');
		jQuery(".quickMenuList").hide();
		jQuery(currentTab).fadeIn();
		return false;
	});
	
		
	jQuery("#quickExpand").toggle(
		function() {
			var currList = jQuery('.current a').attr('href');
			var listHeight = 0;
			jQuery(currList).children().each(function() {
				listHeight += jQuery(this).outerHeight();
			});
			jQuery(currList).animate({height:listHeight}, 200);
			jQuery(this).css("background-position","0 -16px");
		}, 
		function() {
			var currList = jQuery(".current a").attr("href");
			jQuery(currList).animate({height:245}, 200);
			jQuery(this).css("background-position","0 0");
		}
	);
	
	jQuery("#archiveMenu .expand").toggle(
		function() {
			var closeSection = jQuery(this).parent().siblings("section");
			var sHeight = jQuery(closeSection).children().outerHeight(true);
			jQuery(closeSection).animate({height:sHeight}, 200);
			jQuery(this).css("background-position","-18px -16px");
			
		},
		function() {
		var closeSection = jQuery(this).parent().siblings("section");
		jQuery(closeSection).animate({height:276}, 200);
			jQuery(this).css("background-position","-18px 0");
		}
	);

	jQuery("#contribMenu .expand").toggle(
		function() {
			var sHeight = jQuery(".author-list").outerHeight(true);
			alert(sHeight);
			var closeSection = jQuery(this).parent().siblings("section");
			// var sHeight = jQuery(closeSection).children().outerHeight(true);
			jQuery(closeSection).animate({height: (sHeight + 21)}, 200);
			jQuery(this).css("background-position","0 -16px");
			
		},
		function() {
		var closeSection = jQuery(this).parent().siblings("section");
		jQuery(closeSection).animate({height:250}, 200);
			jQuery(this).css("background-position","0 0");
		}
	);
	

});


