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

Copyright: Pumpkin Games 2010
Project: Pumpkin Games
Created by: Paul Cunningham
Last Updated: 13/04/2010 
-------------------------------------------------------------------*/

Cufon.replace('h1')('h2')('h3')('#nav a', { hover: true })('.btn', { hover: true })('.postNav a', { hover: true })('#commentform label');

$j = jQuery.noConflict();

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

$j(document).ready(function(){
	init();
	hoverStates();
	if($j('#mediaViewer')) mediaGo();	
	
	$j('#gamesGallery').galleryView({
		panel_width: 807,
		panel_height: 340,
		transition_speed: 1000,
		transition_interval: 4000,
		frame_width: 180,
		pause_on_hover: true,
		show_filmstrip: false
	});
	
	getTwitters('tweet', { 
		id: 'PumpkinGames', 
		count: 5, 
		enableLinks: true, 
		ignoreReplies: true, 
		clearContents: true,
		template: '<p class="tweetdate">%time%</p><p>%text%</p>' 
	});  
});

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

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

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

function hoverStates() {
	
	$j('#nav li:not(.current_page_item):not(.current_page_parent)').hover(
		function(){
			$j(this).children('a').stop().animate({paddingTop:"46px", backgroundColor: "#000"}, 150, "easeInOutQuad");
			//$j(this).children('a').stop().animate({paddingTop:"46px", backgroundColor: "#C1272D"}, 150, "easeOutBounce");
		},
		function(){
			$j(this).children('a').stop().animate({paddingTop:"36px", backgroundColor: "black"}, 150, "easeInOutQuad");
		}
	);

}

/* Media ----------------------------------------------------------*/

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