$(document).ready(function() {
	WritersContest.initialize();
});

var WritersContest = (function() {
	var self = {
		"initialize": function() {
			$("body").append($("<div id='flash_container'></div>"));
			
			/* Event listeners */
			$("a.external").live("click",function() {
				window.open(this.href);
				return false;
			});
			$("div#nav a.active").live("click",function() {
				return false;
			});
			
			/* Sound rollovers */
			$("a.winner").live("mouseenter", function() {
				self.writeFlash('flash_container', $(this).attr("rel"));
				$(this).parent().addClass("hover", 500);
				return false;
			});
			$("a.winner").live("mouseleave", function() {
				$(this).parent().removeClass("hover", 300);
				return false;
			});
		},
		"writeFlash": function(id, file) {
			document.getElementById(id).innerHTML = '<embed src="'+file+'" autoplay=true width="1" height="1" hidden pluginspage="http://www.apple.com/quicktime/download/">';
		}
	};
	return self;
})();
