$(function(){

/* hide content */
    $('#rightContent').css('display','none');
    $('#sidebarBuy').css('display','none');
    $('#sidebarInfo').css('display','none');
    
	
	$('.slides').nivoSlider({
        effect:'fold', //Specify sets like: 'fold,fade,sliceDown'
        slices:1,
        animSpeed:1000, //Slide transition speed
        pauseTime:8000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav:true, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
    
/****** book random roation ******/    
    $num = '1';
    $book = '.book-'
    $('.minibook').each(function(){
	    $bookNum = $book + $num;
	    var r=Math.floor(Math.random()*30)-20;
		$($bookNum).css({    
	   		'-moz-transform':'rotate('+r+'deg)',
	    	'-webkit-transform':'rotate('+r+'deg)',
	    	'transform':'rotate('+r+'deg)'   
	    });
	    $num ++;
    });
   
    	$('#rightContent').fadeIn(3000, 'easeOutQuart');
    	$('#sidebarBuy').fadeIn(2000, 'easeOutQuart');
    	$('#sidebarInfo').fadeIn(3000, 'easeOutQuart');
    
    $('.moreInfo').click(function(){
    	$(this).parent().next().toggle(1000);
    });
    
    $('.minibook').hover(function(){
    	$('#sidebar #summary').fadeOut(300, summaryFaded);
    	$url = $(this).children('a').attr('href');
    	function summaryFaded(){
	    	$('#sidebar #summary').css('display','none');
			$('#sidebar #summary').load($url + " #summary", pageLoaded);	
		};	
		function pageLoaded(){
			$('#sidebar #summary').fadeIn(300);
		};	
    },function(){
    });
    
    $('#homeSplash div').css('display','none').fadeIn(2000);
    $('#homeSplash').css('display','none').fadeIn(1000);
    
    
    /* homepage sounds */
	
	$('#h1').hover(function(){
	    	$('embed').remove();
	    	$('body').append('<embed src="public/themes/wolf/js/sounds/twist.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h2').hover(function(){
	    	$('embed').remove();
	    	$('body').append('<embed src="public/themes/wolf/js/sounds/pageFumble.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h3').hover(function(){
	    	$('embed').remove();
	    	$('body').append('<embed src="public/themes/wolf/js/sounds/pageTurn.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h4').hover(function(){
	    	$('embed').remove();
	    	$('body').append('<embed src="public/themes/wolf/js/sounds/yeah.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h5').hover(function(){
	    	$('embed').remove();
	    	$('body').append('<embed src="public/themes/wolf/js/sounds/scribble.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h6').hover(function(){
    	$('embed').remove();
    	$('body').append('<embed src="public/themes/wolf/js/sounds/toot.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h7').hover(function(){
    	$('embed').remove();
    	$('body').append('<embed src="public/themes/wolf/js/sounds/cutebroop.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	//push
	
	$('#h8').hover(function(){
    	$('embed').remove();
    	$('body').append('<embed src="public/themes/wolf/js/sounds/paperTear.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h9').hover(function(){
    	$('embed').remove();
    	$('body').append('<embed src="public/themes/wolf/js/sounds/MouthPop.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
	
	$('#h11').hover(function(){
    	$('embed').remove();
    	$('body').append('<embed src="public/themes/wolf/js/sounds/SNESstartup.mp3" autostart="true" hidden="true" loop="false">');
		}, function(){
	});
});
