$(document).ready(function() {
	// $("ul#chapters li:last-child").css("margin-right","0")
	$("ul#chapters li").hover(
		function(){ // over
			$(this).animate({ paddingTop:"10px"})
			$(this).css("background","url(images/carrot.gif) bottom center no-repeat")
			$(this).children("span").fadeIn("slow")
		},
		function(){ // out
			$(this).animate({ paddingTop:"0px"})
			$(this).css("background","none")
			$(this).children("span").hide()
		}
	);	
	
	// Intro Animation
	$("#free_chapter").css("margin-top","-300px");
	$("#watch_this").css("margin-top","-200px");
	if(!$.browser.msie){
		$("ul#chapters li").css("margin-top","-100px");
		$("ul#chapters li").each(function (i) {
		    // store the item around for use in the 'timeout' function
		    var item = $(this); 
		    // execute this function sometime later:
		    setTimeout(function(){
		      item.animate({ marginTop: "0px"}, 700,"easeOutBack");
		    }, 200*i);
		    // each element should animate half a second after the last one.
		});
		setTimeout(function(){
			$("#free_chapter").animate({ marginTop: "0px"}, 2000, "easeOutElastic");
			$("#watch_this").animate({ marginTop: "-35px"}, 2000, "easeOutElastic");
		},3000)
	}
	else{
		setTimeout(function(){
			$("#free_chapter").animate({ marginTop: "0px"}, 2000, "easeOutElastic");
			$("#watch_this").animate({ marginTop: "-35px"}, 2000, "easeOutElastic");
		},1000)
	}
});

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

$.preLoadImages(
	"/images/pre_order_ro.png",
	"/images/watch_this_ro.png",
	"/images/free_chapter_ro.png"
);


