//-----------------------------------------------------------------------------
//team navigation functions
//-----------------------------------------------------------------------------
$(document).ready(function(){
	$(".teamnavcontainer").hide();
	$("a.teamnavtoggle").click(function(){
		$(".teamnavcontainer").slideToggle("normal");
	});
});
//-----------------------------------------------------------------------------
//tabs functions
//-----------------------------------------------------------------------------
$(document).ready(function(){
	$("#tabnav a").click(function(event){
		event.preventDefault(); //prevent event when clicking on link
		$("#tabnav a").removeClass("selected"); //unselect all tabs; remove class "selected" from anchor elements
		$("#tabdivcontainer > *").css("display","none"); //hide all div childs within div; set display style to "none"
		$(this).addClass("selected"); //select clicked tab; add class "selected" to anchor element
		$($(this).attr("href")).css("display","block"); //show corresponding div of clicked tab
		$(this).blur(); //take focus off of clicked object
	});
});
//-----------------------------------------------------------------------------
//super fan form functions
//-----------------------------------------------------------------------------
$(document).ready(function(){
	$("#superfanformcontainer").hide();
	$("a#superfanform").click(function(){
		$("#superfanformcontainer").show();
		$(this).blur();
	});
});

//-----------------------------------------------------------------------------
//badge functions
//-----------------------------------------------------------------------------
function createCode()
{
	var code = ""; //holds HTML code for badge
	var name = document.getElementById("input_badgename").value; //variable for person' name
	var school = document.getElementById("input_badgeschool"); //variable for school object 
	var number = document.getElementById("input_badgenumber").value; //variable for jersey number
	var isJerseyChecked = document.getElementById("input_badgejersey").checked; //variable for if jersey number is checked
	
	//start building HTML code
	code += "<div style=\"background-image:url(http://media.pigskinreview.com/images/downloads/badge_background.gif); background-color:#121212; background-repeat:repeat-x; border:1px solid #404040; width:278px;\">\n";
	
	if(school.selectedIndex > 0)
	{
		code += "\t<a href=\"" + school.options[school.selectedIndex].value + "\" style=\"text-decoration:none;\">\n";
	}
	else
	{
		code += "\t<a href=\"http://www.pigskinreview.com\" style=\"text-decoration:none;\">\n";
	}
	
	code+= "\t\t<div style=\"color:#fff; cursor:pointer; font-family:arial,sans-serif; line-height:14px; overflow:hidden; text-align:center; width:278px;\">\n";
	
	//add number to code if checked
	if(isJerseyChecked == true)
	{
		code += "\t\t\t<div style=\"font-size:40px; font-weight:bold; margin-top:15px; padding:0px;\">" + number + "</div>\n";
	}
	
	//add peron's name
	if(name != "")
	{
		code += "\t\t\t<div style=\"font-size:22px; font-weight:bold; margin-top:20px; padding:0px;\">" + name + "</div>\n";
	}
	
	//add school name
	if(school.selectedIndex > 0)
	{
		code += "\t\t\t<div style=\"font-size:18px; margin-top:10px; padding:0px;\">" + school.options[school.selectedIndex].text + "</div>\n";
	}
	
	//add logo
	code += "\t\t\t<div style=\"margin:15px 0px; padding:0px;\"><img src=\"http://media.pigskinreview.com/images/downloads/badge_logo.gif\" border=\"0\"></div>\n";
	
	//end code
	code += "\t\t</div>\n\t</a>\n</div>";

	document.getElementById("badgecode").value = code;
}

function clearCode()
{
	document.getElementById("badgecode").value = "";
}
function updateName(inputId, outputId)
{
	clearCode();
	document.getElementById(outputId).innerHTML = document.getElementById(inputId).value;
}
function updateSchool(inputId, outputId)
{
	var school = document.getElementById(inputId);

	clearCode();
	
	if(school.selectedIndex > 0)
	{
		document.getElementById(outputId).innerHTML = school.options[school.selectedIndex].text;
	}
	else
	{
		document.getElementById(outputId).innerHTML = "";
	}
}
function updateNumber(checkId, inputId, outputId)
{
	clearCode();
	if(document.getElementById(checkId).checked == true)
	{
		document.getElementById(outputId).innerHTML = document.getElementById(inputId).value;
	}
}
function updateJersey(checkId, outputId)
{
	clearCode();
	if(document.getElementById(checkId).checked == true)
	{
		document.getElementById(outputId).style.display = "block";
	}
	else
	{
		document.getElementById(outputId).style.display = "none";
	}
}



//-----------------------------------------------------------------------------
//fantasy team profiles
//-----------------------------------------------------------------------------
// previous scores and upcoming games
var id1=new Array('ftkid0','ftkid1','ftkid2','ftkid3','ftkid4','ftkid5','ftkid6','ftkid7','ftkid8','ftkid9','ftkid10','ftkid11','ftkid12','ftkid13','ftkid14','ftkid15','ftkid16','ftkid17','ftkid18','ftkid19','ftkid20','ftkid21','ftkid22','ftkid23','ftkid24');

function switchid(id,arr){	
	hideallids(arr);
	showdiv(id);
}

function hideallids(arr){
	//var arr = arr;
	var a = eval(arr);
	//loop through the array and hide each element by id
	for (var i=0;i<a.length;i++){
		hidediv(a[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}