// BLACK KNAVE SITE FUNCTIONS 2009-2010
// COPYRIGHT BENJAMIN SHRIMPTON 2009-2010

$(document).ready(function(){
						   
//call FACEBOXon a tage with rel of facebox				   
$('a[rel*=facebox]').facebox();

//calls FancyBox on any a tag with a class of fancybox
$("a.fancybox").fancybox(); 

//thumbs change opacity on hover
$("div.topstory-thumbs").fadeIn("fast");
$("div.topstory-thumbs img").animate({opacity: 0.6});
$("div.topstory-thumbs img").hover(function(){$(this).animate({
												opacity: 1.0
												},"fast")}, 
												function(){$(this).animate({ 
											  opacity:0.6
												},"fast")});

// HIDE ALL DIVS THAT NEED TO BE HIDDEN FIRST.
/*$("#ellen-info, #ellen-footer, #ben-info, #ben-footer, #peter-info, #peter-footer,#jeff-info, #jeff-footer, .show-link, .bloggers-footer-info, #skip").hide();*/

//ROUND ALL CORNERS USING 'JQUERY CORNERS' PLUGIN
//NOT WORKING OPERA AND IE, NEED TO FIX IT.
//$('.rounded').corners("10px");
//$('.roundedMenu').corners("20px transparent bottom");
//$('.roundedMegaMenu').corners("8px transparent bottom-left bottom-right");
//$('.roundedCap').corners("20px transparent top-left top-right");
//$('.roundedHeading').corners("10px transparent");

////////////////////////////////////////  MEGA MENU /////////////////////////////////////////////////////
//Div is positioned off the screen by the style sheet first, and Juwery takes opacity to zero here.
//Note that the div is nested into the header container.

$("#mega-menu").css({'z-index' : '0'}).animate({opacity:0.0,});
	// This slides the div down into view, and brings opacity to 95%
$("#mega-menu-trigger a").hover(function(){
			$("#mega-menu").css({'z-index' : '12000'}).animate({opacity: 0.95,
																top: '50px',
																left: '0px'
																});
															});
	//this closes mega-menu by sliding it back to its origional position and taking opacity back to zero
$("#outer-wrapper, .input-wrap1, .input-wrap2, #twitter-trigger").hover(function(){
							 $("#mega-menu").css({'z-index' : '0'}).animate({
							  opacity: 0, 
							  top: '-5000px',
							  left: '0px'
								  });
								});
//closes mega-menu by user actively clicking the "close" button
//note this does exactly the same as above but uses a click, not hover.
$(".close-mega-menu a").click(function(){
									   $("#mega-menu").css({'z-index' : '0'}).animate({
										opacity: 0, 
										 top: '-5000px',
									  	left: '0px'
										});
									});

////////////////////////////////  END MEGA MENU FUNCTIONS ////////////////////////////////////

// TWITTER DIV SHOW AND HIDE FUNCTS
$("#twitter-trigger").click(function(){
									   $("#twitter-feed-wrapper").css({'z-index' : '20000'}).animate({
										opacity: 0.95, 
										 top: '50px',
									  	left: '278px'
										});
									});
$("a#close-twitter-feed").click(function(){
									   $("#twitter-feed-wrapper").css({'z-index' : '0'}).animate({
										opacity: 0.0, 
										 top: '-500px',
									  	left: '0px'
										});
									});


//Home hover append text funct
$("li#home-button a").hover(function(){
								$(this).empty().append('Go To Home'); 
									}, function () {
								$(this).empty().append("Black Knave");
									});

///post hover fadein class
//$(".post").hover(function(){$("this").addClass("post-selected")});


// TOP SLIDESHOW PARAMETERS
		$('#slideshow-wrapper').fadeIn(3000);
		$('#slideshow').cycle({ 
		fx:'scrollHorz', 
		timeout:6000, 
		pause: '1',
		speed: 1000, //INCREASE FOR SLOWER TRANSITION
		prev: '#slideshow-back',
		next: '#slideshow-next',
		pager: '#slideshow-nav',
		//FUNCTION CONTROLS CAPTIONS
		//before: function() { 
      	//$('#caption').html(this.alt);},
		});

// BLOGGERS SIDEBAR
//Find the button with class of '.info' and fade it in and out on hover
//".info" should be given CSS of 'display:none' in style sheet
$(".bloggers-wrapper").hover(function(){
									  $(this).children(".info").fadeIn();
									  },
									function(){
										$(this).children(".info").fadeOut("slow");
										});

// click the info button to toggle down the footer div which has css of 'display:none'
$("#ellen-info").click(function(){
$("#ellen-footer").slideToggle("slow");
$(this).toggleClass("active");
});

$("#ellen-info").toggle(function(){
$(this).addClass("active").empty().append('Close'); 
}, function () {
$(this).removeClass("active").empty().append("Who's this?");
});

//BEN FUNCT	  
$("#ben-info").click(function(){
$("#ben-footer").slideToggle("slow");
$(this).toggleClass("active");
});

$("#ben-info").toggle(function(){
$(this).addClass("active").empty().append('Close'); 
}, function () {
$(this).removeClass("active").empty().append("Who's this?");
});

//PETER FUNCT
$("#peter-info").click(function(){
$("#peter-footer").slideToggle("slow");
$(this).toggleClass("active");
})

$("#peter-info").toggle(function(){
$(this).addClass("active").empty().append('Close'); 
}, function () {
$(this).removeClass("active").empty().append("Who's this?");
});

//JEFF FUNCT
$("#jeff-info").click(function(){
$("#jeff-footer").slideToggle("slow");
$(this).toggleClass("active");
})

$("#jeff-info").toggle(function(){
$(this).addClass("active").empty().append('Close'); 
}, function () {
$(this).removeClass("active").empty().append("Who's this?");
});	  	  
// END BLOGGERS FUNCTIONS  /////////////////////////////

// SUBSCRIBE PROMPT fade in and out
$(".input-wrap1 input").focus(function(){
$("#subscribe-prompt").fadeIn();
});
$(".input-wrap1 input").blur(function(){
$("#subscribe-prompt").fadeOut();
});



//ARTICLES heading SHOW LINK
$("#articles-heading").hover(function(){$("#articles-link").fadeIn("fast");},
function(){$("#articles-link").fadeOut("fast");});

//HOVER SHOW "SKIP TO NEXT SLIDE" ON SLIDESHOW
$("#slideshow-nav-wrap").hover(function(){$("#skip").fadeIn("fast");},
function(){$("#skip").fadeOut("fast");})


//MAKES FOOTER LINKS GLOW ON MOUSEOVER
//this takes the opacity down on doc-ready, ready to be animate up to 100% opacity
$(".gc").animate({opacity: 0.7,});
//THIS FUNBCT TAKES THE OPACITY UP AND BACK DOWN ON ROLL OVER, ROLL OUT
$(".gc").hover(function(){$(this).animate({opacity: 1.0,},"fast")}, function(){$(this).animate({opacity: 0.7},"slow")});


// blows up thumb image on hover
$(".gc a img, .gc a iframe").hover(function(){$(this).css({'z-index': '12000'}).animate({
												width: '298px',
												height: '198px',
												},"fast")}, 
												function(){$(this).css({'z-index': '1000'}).animate({ 
											  width: '46px',
											  height: '46px',
												},"fast")});


//.POST DIV, CHANGE BG COLOR ON HOVER
$("div.post").hover(function(){$(this).css({'background' : '#fff url(http://www.blackknave.com/2010_css_pics/apple-bkg.png) repeat-x 0 -80px'},1000);}); 

//function(){
//$(this).css({'background' : '#fff'});
//});


//FADE IN THE READMORE LINK ON POSTS
$("div.post").hover(function(){
							 $(this).children("a.read-more").fadeIn();
							 });
							  
//CONTROLS TOOL TOP SPECS							
	$('.category ul li').tooltip({top: 0,right: 0});						  
	$('.info').tooltip({left: -50});
	//$('#logo h1 a').tooltip({});
	//$('a').tooltip({});

	
// Blows up thumb image on hover of Bloggers Picture on Posts
$("ul li.author-icon img").hover(function(){$(this).css({
'z-index': '1000',
'padding':'3px',
'border':'solid 2px #ddd',
'background':'#fff',
}).animate({
	width: '50px',
	height: '50px',
	},"fast")}, 
function(){$(this).css({
	'z-index': '0',
	'padding':'0px',
	'border':'solid 1px #ddd',
}).animate({ 
	width: '16px',
	height: '16px',
	},"fast")});

	
//DROP SHADOWS CALL THESE LAST AS THEY SLOW EVERYHTIGN DOWN
//$("div#rss-feed").dropShadow({});//sets up selected class


//ROUNDED CORNERS IE REMOVES THE BORDERS, SO CURRENTLY NOT BEIGN USED
//$(".ad-wrapper-120-120, #rss-feed-wrapper").corner("10px");
//$("#body-content-inner").corner("15px");


// PAUSE PLUGIN BY SIMON (http://stackoverflow.com/questions/251204/delay-jquery-effects)
$.fn.pause = function(duration) {
    $(this).animate({ dummy: 1 }, duration);
    return this;
	};
	//CALL THE PAUSE FUNTION ON AN ELEMENT, DELAYS THE EFFECT.
	$("div#footer-menu").pause(3000).fadeIn("slow");

Shadowbox.init();

}); //end doc ready, end all functions


