/** 
 * @projectDescription	Description
 * @author 	Matt Hobbs
 * @version 	0.1 
 */
if (window.Cufon) {
	Cufon.replace('#mainNav .page_item a', {hover: true});
	Cufon.replace('h1, h2, h3, h4, h5, h6, .mapStatsRow p', {hover: true});
}

jQuery(function($){
	//Open social media links in a new window (urghh!)
	$("#socialHead a, #socialFoot a").click(function(){window.open(this.href); return false;});
	
	if($("#countDown", document.getElementById("header")).length){
		var d = new Date("June 15, 2010 08:00:00");
		$('#cdInner').countdown({
			until: d,
			format: 'dHMS',
			layout: '<span class="countdown_section"><span class="countdown_amount">{dnn}</span><span class="label">{dl}</span></span> <span class="countdown_section"><span class="countdown_amount">{hnn}</span><span class="label">{hl}</span></span> <span class="countdown_section"><span class="countdown_amount">{mnn}</span><span class="label">{ml}</span></span> <span class="countdown_section seconds"><span class="countdown_amount">{snn}</span><span class="label">{sl}</span></span>'
		});
	}
	
	/**
	 * Homepage
	 */
	if($("body").is(".home")){
		var tabHTML = "<ul id='sTab'><li><a href='/'>Sponsors</a></li></ul>";
		$("#keyImage").before(tabHTML);
		
		//Move content to correct place
		$sponsor = $("#sponsorsContainer");
		//Visibility 'hack' due do IE7- messing up multiple relative containers
		$sponsor.hide().appendTo("#keyImage").show().css({"zIndex": -20, "visibility": "hidden"});
		
		$anchor = $("#sTab a", document.getElementById('content'));
		$anchor.toggle(function(){
			$anchor.addClass("active");
			$sponsor.css({"zIndex": 20, "visibility": "visible"});
			return false;
		},
		function(){
			$anchor.removeClass("active");
			$sponsor.css({"zIndex": -20, "visibility": "hidden"});
			return false;
		});
	}
	
	//Hacky way of opening main gallery
	if($(".ngg-galleryoverview").length){
		$(".entry-content p a").click(function(){
			var link = $(".ngg-gallery-thumbnail-box:first a").get(0);
			Shadowbox.open(link);
			return false;
		});
	}
});







