$(document).ready(function(){
	// Inserts the current date into the banner after the logo
	var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
	var d = new Date();
 	$("<p id='getDate'></p>").insertAfter("#banner p");
 	$("#banner #getDate").html(d_names[d.getDay()] + ", " + m_names[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear());
						   
	// Opens a link into a new window if it has a 'rel=external' tag applied
	$("a[rel='external'], a[class='external'], #newsFront a, #footer a:not([href*='psnextra']), .iconLinks a").click(function(){
		window.open(this.href);
		return false;
	});
	
	$("a[rel='external'][title], a[class='external'][title]").click(function(){
		pageTracker._trackPageview('/clicks/' + $(this).attr("title"));					 
	});
	
	$(".submitSearch").click(function(){
		$(this).parent().parent().parent().submit();	
		return false;
	});
	
	$("ul#featuredStories li a").hover(function(){
		$("ul#featuredStories li a").removeClass("selected");
		$($(this)).addClass("selected");
		$("div.selected").removeClass("selected").hide();
		$("div#" + $(this).attr('id')).addClass("selected").show();
		return false;
	}).click(function(){
		window.location=$($(this).attr('href'));
	});
	
	$("#quiz label:not([title]) input").click(function(){
		$("#quiz").fadeOut(function(){
			$("#incorrectAnswer").fadeIn();
		});
	});	
	
	$("#quiz label[title] input").click(function(){
		$("#quiz").fadeOut(function(){
		$("#correctAnswer").fadeIn();
		});
	});
	
	$("#poll label input").live('click',function(){
		$("#pollForm").submit();
		$("#poll label input").attr("disabled","disabled");
	}); 
	
	$("#pollForm").submit(function(){
		$("#pollForm").load("x5.xml?answerid=" + $("#poll label input:checked").attr("value") + " #poll");
		document.cookie = 'poll=taken;'
		return false;
});
});

// Function that accepts parameters from XSL to load videos
function loadVideo(thisDiv,swfFile,vidWidth,vidHeight,flashVideo,loadImage){
	$(thisDiv).flash({
		swf: swfFile,
		width: vidWidth,
		height: vidHeight,
		wmode: 'transparent',
		allowfullscreen: 'true',
		allowscriptaccess: 'always',
		flashvars: { plugins: 'gapro-1&gapro.accountid=UA-547614-4', file: '../../../media/' + flashVideo, image: 'images/' + loadImage }
	});
	$(thisDiv + " p").hide();
}
