/*------------------------------------------------------------------
[Global Javascript]

Copyright: Codefor 2009
Client: Fuzion
Project: Fuzion blog
Created by: Adam Foster
Last Updated: 03 - 11 - 09
-------------------------------------------------------------------*/

Cufon.replace('h2')('h3')('#posts h1', { hover: true });

$j = jQuery.noConflict();

/* When dom is ready ----------------------------------------------*/

$j(document).ready(function(){
	
	init();
	hoverStates();
	if($j('media')) mediaGo();
});

/* Init -----------------------------------------------------------*/

function init(){
	$j('body').addClass('js');
	$j('a[rel="external"]').attr("target", "_blank");
	Cufon.now();	
}

/* Nav hover states -----------------------------------------------*/

function hoverStates() {
	
	$j('#nav p:not(.selected)').children('span').css({ display: 'block', opacity: 0 })
	
	$j('#nav p:not(.selected)').hover(
		function(){
			$j(this).children('span').stop().animate({opacity:1}, 250, "easeInOutQuad");
		},
		function(){
			$j(this).children('span').stop().animate({opacity:0}, 350, "easeInOutQuad");
		}
	);

}

/* Media */

function mediaGo () {
		
	$j('#thumbs li').children('a').click(function (e) {
		e.preventDefault();
		$j("#thumbs .selected").removeClass("selected");
		$j(this).parent().addClass("selected");
		var tHREF = $j(this).attr("href");
		$j('#screenshot img').fadeOut('fast', function() {
			$j('#screenshot').empty();
			$j('#screenshot').append("\<img src='"+tHREF+"'\/>");
			$j('#screenshot img').css({opacity: 0}).stop().animate({opacity: 0},1000).animate({opacity: 1},300, "easeInOutQuad");
		});
	});
	
}
