// Script for full game list dropdown
function changeLoc(obj){
	location.href=obj.value;
}
$(document).ready(function() {
	var selectedPollChoice = null;
   // Game Selection tabs
   if($("#gameSelectionTabs").length > 0) {
	   $("#gameSelectionTabs").find("a").each(function() {
			$(this).removeAttr('href');
			$(this).click(function() {
				var clickedTab = $(this).attr('id');
				$("#gameSelectionTabs").find("a").each(function() {
						$(this).attr('class', 'tab');	
						if($(this).attr('id') == clickedTab) {
							$(this).attr('class', 'tab active');
						}
				});
				$("#gameSelectionTabContent").find("div").each(function() {
						if($(this).attr('class') == "gameSelectionContent") {
							$(this).css({display: 'none'});	
							if($(this).attr('title') == clickedTab) {
								$(this).css({display: 'block'});	
							}
						}
				});
			});
	   });
   }
   // Poll
   if($("#pollModule").length > 0) {
		$("#pollModule ul.pollOptions input:radio[@name='pollChoice']").click(function() {
			selectedPollChoice = $(this).attr('value');
		});
		$("#pollSubmit").click(function() {
			if(selectedPollChoice == null) {
				alert('You must select an option first!');
			} else {
				$.ajax({
				   type: "POST",
				   url: "/modules_new/code/poll.php",
				   data: "action=submitPoll&selected="+selectedPollChoice+"&pollId="+$('#pollModule #pollId').attr('value'),
				   success: function(data){
					 $("#pollModule div.PanelContent").html(data);
				   }
				 });
			}
		});
   }

 });