/********************************************************************************************
 * <summary>
 * jQuery ready - where it all starts!
 * </summary>
 ********************************************************************************************/
$(document).ready(function() {		
	if ($('#jsnote').size()) {
		$('#jsnote').remove(); // Hides the "No Javascipt" note
	}
	if ($.browser.msie && $.browser.version < "7.0" ) {
		if ($('#ie6note').size()) {
			$('#ie6note').show(); // Shows the IE6 note
		}
	} else {
		initCaroussel();	
	}
	initQuickLinks();	
	pageLoad();
	fixIE();
});


/****************************************************************
 * <summary>
 * Common page load initialization
 * </summary>
 ***************************************************************/
function pageLoad() {
	if ($('.zebra').size()) {
		$('.zebra tr:even').addClass('even');
	}	

	$('p.easing').animate({height: '+=300px'}, 4000, 'easeInElastic');
	
	if ($('.tree strong').size()) {
		$('.tree strong').corner();
	}
}


/****************************************************************
 * <summary>
 * Common content load initialization
 * </summary>
 ***************************************************************/
function fixIE() {
	if ($.browser.msie && $.browser.version < "7.0" ) {
		//if ($('#logo').size()) {
		//	$('#logo').attr("src", "/wsb/browser/ie6/soccerchelsea.gif");
		//} 		
	}
}

/****************************************************************
 * <summary>
 * Sets up the Quicklinks
 * </summary>
 ***************************************************************/
function initQuickLinks() {
	if ($('ul.quick a').size()) {
		if (!$.browser.msie) {
			$("ul.quick a").before('<img src="/wsb/browser/splash/art/ball.png" style="position: relative; top: 16px; left:-10px" />');
		}

		$("ul.quick a").click(function() {
		  var href = $(this).attr("href"); // remember href
		  $(this).attr("href", "#"); // disable href - for animation
		  var w = $(document).width();
		  if (w > 420) {
		  	  w -= 420;
		  }
		  $('#intro').fadeOut(1000);
		  $('#caroussel').fadeOut(1000);
	      $('#banner img').animate({
		    right: w
		  }, 1000, function() {
		  	  window.location=href; 
		    // Animation complete.
		  });
		});
	}
	
}

/****************************************************************
 * <summary>
 * Initializes the photo caroussel
 * </summary>
 ***************************************************************/
function initCaroussel() {
	if ($('#ie6note').size()) { // && $('#ie6note').css('display') == 'block')) {
		if ($('#caroussel').size()) {
			var interval;
			$('#caroussel')
				.css("display", "block")
				.roundabout()
				.hover(
					function() {
						// oh no, it's the cops!
						clearInterval(interval);
					},
					function() {
						// false alarm: PARTY!
						interval = startCaroussel();
					}
				);
			
			// let's get this party started
			interval = startCaroussel();
	 	}
	}
}

/****************************************************************
 * <summary>
 * Starts the photo caroussel
 * </summary>
 ***************************************************************/
function startCaroussel() {
	return setInterval(function() {
		$('#caroussel').roundabout_animateToNextChild();
	}, 3000);
}




