function loadVariantTableSorter(column, corder, hideHeader) {
	//if(column==null) column = 0;
	// extend the default setting to always include the zebra widget.
	$.tablesorter.defaults.widgets = ['zebra'];
	// extend the default setting to always sort on the first column
	$.tablesorter.defaults.sortList = [[column,corder]];
	//$.tablesorter.defaults.debug = true;

	// call the tablesorter plugin
	$("table").tablesorter({
        // pass the headers argument and assing a object
        headers: {
            // assign the secound column (we start counting zero)
            0: {
                // disable it by setting the property sorter to false
                sorter: false
            }
        }
    }); 
}
function loadTableSorter(column,corder) {
	//if(column==null) column = 0;
	// extend the default setting to always include the zebra widget.
	$.tablesorter.defaults.widgets = ['zebra'];
	// extend the default setting to always sort on the first column
	$.tablesorter.defaults.sortList = [[column,corder]];
	//$.tablesorter.defaults.debug = true;

	// call the tablesorter plugin
	$("table").tablesorter(); 
}
function loadTableNameSorter(name,column,corder) {
	//if(column==null) column = 0;
	// extend the default setting to always include the zebra widget.
	$.tablesorter.defaults.widgets = ['zebra'];
	// extend the default setting to always sort on the first column
	$.tablesorter.defaults.sortList = [[column,corder]];
	//$.tablesorter.defaults.debug = true;

	// call the tablesorter plugin
	$(name).tablesorter(); 
}

function loadmyteam(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getmyteamtable",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#myteams').html(data);
		}
	});
}

function getTargets(position) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayertargets",
		data: "position="+position,
		dataType: "html",
		success: function(data){
			$('#playertargets').html(data);
		}
	});
}

function getRestOfWay(position) {
	$.ajax({
		type: "GET",
		url: "/ajax/getrestofway",
		data: "position="+position,
		dataType: "html",
		success: function(data){
			$('#restoftheway').html(data);
			loadTableNameSorter("#tblRestofway",0,0);
		}
	});
}

function getCustomizedWeeklyProjections(position,week,boardid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getcustomizedweeklyprojections",
		data: "week="+week+"&position="+position+"&boardid="+boardid,
		dataType: "html",
		success: function(data){
			$('#weeklyprojections').html(data);
		}
	});
}

function getWeeklyProjections(position,week) {
	$.ajax({
		type: "GET",
		url: "/ajax/getweeklyprojections",
		data: "week="+week+"&position="+position,
		dataType: "html",
		success: function(data){
			$('#weeklyprojections').html(data);
		}
	});
}

function getWeeklyProjectionsTable(position,week) {
	$.ajax({
		type: "GET",
		url: "/ajax/getweeklyprojectionstable",
		data: "week="+week+"&position="+position,
		dataType: "html",
		success: function(data){
			$('#weeklyprojections').html(data);
		}
	});
}

function getontheclock() {
	var t = setTimeout("getontheclock()",40000);
	$.ajax({
		type: "GET",
		url: "/ajax/getontheclock",
		dataType: "html",
		success: function(data){
			$('#ontheclock').html(data);
		}
	});	
}

function getDraftPicksByRound(roundno) {
	$.ajax({
		type: "GET",
		url: "/ajax/getdraftpicksbyround",
		data: "roundno="+roundno,
		dataType: "html",
		success: function(data){
			$('#draftpicklist').html(data);
			loadTableSorter(0,0);
		}
	});
}

function getDraftPicksByTeam(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getdraftpicksbyteam",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#draftpickteamlist').html(data);
			loadTableSorter(0,0);
		}
	});
}

function loadPlayerManagerEditPanel($id) {

	$.ajax({
		type: "GET",
		url: "/ajax/getplayerentry",
		data: "id="+$id,
		dataType: "html",
		success: function(data){
			$('#editPanel').html(data);
		}
	});	
}

function loadDraftPickEditPanel($id) {
	$.ajax({
		type: "GET",
		url: "/ajax/getdraftpickentry",
		data: "id="+$id,
		dataType: "html",
		success: function(data){
			$('#editPanel').html(data);
		}
	});	
}

function loadPrjEditPanel($id) {
	$.ajax({
		type: "GET",
		url: "/ajax/getprojectionentry",
		data: "id="+$id,
		dataType: "html",
		success: function(data){
			$('#editPanel').html(data);
		}
	});	
}

function loadEditPanel($id) {
	$.ajax({
		type: "GET",
		url: "/ajax/getdynastyrankingentry",
		data: "id="+$id,
		dataType: "html",
		success: function(data){
			$('#editPanel').html(data);
		}
	});	
}

function getProfileListing($type,$position,$team,$lastname) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayerlisting",
		data: "type="+$type+"&position="+$position+"&teamid="+$team+"&lastname="+$lastname,
		dataType: "html",
		success: function(data){
			$('#profileresults').html(data);
			loadTableSorter(0,0);
		}
	});		
}

function adduseranswer(id,userid,pollid,answerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/adduseranswer",
		data: "id="+id+"&userid="+userid+"&pollid="+pollid+"&answerid="+answerid,
		dataType: "html",
		success: function(data){
		}
	});
}

function saveDynastyRankings(alldata) {
	$.ajax({
		type: "GET",
		url: "/ajax/modifyrankorder",
		data: "trows="+alldata,
		dataType: "html",
		success: function(data){
			alert("Rankings Saved");
			$('#rankingspaging').tableDnDUpdate();
			loadTableSorter(0,0);
		}
	});
}

function saveDepthChart(alldata) {
	$.ajax({
		type: "GET",
		url: "/ajax/modifydepthchart",
		data: "trows="+alldata,
		dataType: "html",
		success: function(data){
			alert("Depth Chart Saved");
			$('#teamdepthchart').tableDnDUpdate();
			loadTableSorter(0,0);
			//getTeamDepthChart(teamid);
		}
	});
}

function getAdminDynastyRankings(id,position,tier) {
	$.ajax({
		type: "GET",
		url: "/ajax/getAdmindynastyrankings",
		data: "id="+id+"&position="+position+"&tier="+tier,
		dataType: "html",
		success: function(data){
			$('#dynrankings').html(data);
			loadTableSorter(0,0);
		}
	});
}

function getDraftBoardResults(position,boardid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getgenerateddraftboard",
		data: "position="+position+"&boardid="+boardid,
		dataType: "html",
		success: function(data){
			$('#boardresults').html(data);
			loadTableSorter(0,1);
		}
	});
}

function getAdminPlayerProjections(position) {
	$.ajax({
		type: "GET",
		url: "/ajax/getadminplayerprojections",
		data: "position="+position+"&year=2009",
		dataType: "html",
		success: function(data){
			$('#playerprojections').html(data);
			loadTableSorter(0,1);
		}
	});
}
function getPlayerProjections(position) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayerprojections",
		data: "position="+position,
		dataType: "html",
		success: function(data){
			$('#playerprojections').html(data);
			loadTableNameSorter("#tblProjections",0,1);
		}
	});
}

function getRookieRankings(position,tier) {
	$.ajax({
		type: "GET",
		url: "/ajax/getrookierankings",
		data: "position="+position+"&tier="+tier,
		dataType: "html",
		success: function(data){
			$('#rookierankings').html(data);
			loadTableNameSorter("#tblRookie",0,0);
		}
	});
}

function getDynastyRankings(position,tier) {
	$.ajax({
		type: "GET",
		url: "/ajax/getdynastyrankings",
		data: "position="+position+"&tier="+tier,
		dataType: "html",
		success: function(data){
			$('#dynrankings').html(data);
			loadTableNameSorter("#tblDynasty",0,0);
		}
	});
}
function getDynastyRankingsDetail(position,tier) {
	$.ajax({
		type: "GET",
		url: "/ajax/getdynastyrankingdetail",
		data: "position="+position+"&tier="+tier,
		dataType: "html",
		success: function(data){
			$('#dynrankings').html(data);
			loadTableSorter(0,0);
		}
	});
}
function getPlayerNote(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayernote",
		data: "playerid="+playerid,
		dataType: "html",
		success: function(data){
			$('#').html(data);
		}
	});
}
function getPlayerProfile(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayerprofile",
		data: "id="+playerid,
		dataType: "html",
		success: function(data){
			$('#tabresults').html(data);
		}
	});
}
function getPlayerRogueBits(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayerroguebit",
		data: "id="+playerid,
		dataType: "html",
		success: function(data){
			$('#tabresults').html(data);
		}
	});
}
function getPlayerContract(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayercontract",
		data: "id="+playerid,
		dataType: "html",
		success: function(data){
			$('#tabresults').html(data);
		}
	});
}
function getPlayerProjection(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayerprojection",
		data: "id="+playerid,
		dataType: "html",
		success: function(data){
			$('#tabresults').html(data);
		}
	});
}
function getPlayerStats(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayerstats",
		data: "id="+playerid,
		dataType: "html",
		success: function(data){
			$('#tabresults').html(data);
		}
	});
}
function getPlayerGameLogs(playerid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayergamelogs",
		data: "id="+playerid,
		dataType: "html",
		success: function(data){
			$('#tabresults').html(data);
		}
	});
}
function getGameLog(playerid,season) {
	$.ajax({
		type: "GET",
		url: "/ajax/getgamelog",
		data: "id="+playerid+"&season="+season,
		dataType: "html",
		success: function(data){
			$('#gameresults').html(data);
		}
	});
}

function getTeamProfile(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getteamprofile",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#teamtabresults').html(data);
		}
	});
}
function getTeamRogueBits(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getteamroguebit",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#teamtabresults').html(data);
		}
	});
}
function getTeamRoster(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getteamroster",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#teamtabresults').html(data);
		}
	});
}
function getTeamDepthChart(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getteamdepthchart",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#teamtabresults').html(data);
			loadTableSorter(0,0);
		}
	});
}
function getTeamDraftPicks(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getteamdraftpicks",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#teamtabresults').html(data);
		}
	});
}
function getTeamSchedule(teamid) {
	$.ajax({
		type: "GET",
		url: "/ajax/getteamschedule",
		data: "teamid="+teamid,
		dataType: "html",
		success: function(data){
			$('#teamtabresults').html(data);
		}
	});
}

function getPositionRankings(position,year) {
	$.ajax({
		type: "GET",
		url: "/ajax/getpositionrankings",
		data: "position="+position+"&year="+year,
		dataType: "html",
		success: function(data){
			$('#posrankings'+year).html(data);
			loadTableSorter(0,0);
		}
	});
}

function getPlayerTable(position,type) {
	$.ajax({
		type: "GET",
		url: "/ajax/getplayertable",
		data: "type="+type+"&position="+position,
		dataType: "html",
		success: function(data){
			$('#playertable').html(data);
			loadTableSorter(0,0);
		}
	});
}

function goTeamPage(teamid) {
	window.location = "/nfl/teampage?teamid="+teamid;
}

function opennewwindow(url,name)
{	
	var newWin = window.open( url, 'newWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=500,height=500');

} 

function getCalcResults(rec1,rec2,rec3,rec4,rec5,rec6,rec7,giv1,giv2,giv3,giv4,giv5,giv6,giv7) {
	$.ajax({
		type: "GET",
		url: "/ajax/getcalcresults",
		data: "rec1="+rec1+"&rec2="+rec2+"&rec3="+rec3+"&rec4="+rec4+"&rec5="+rec5+"&rec6="+rec6+"&rec7="+rec7+"&giv1="+giv1+"&giv2="+giv2+"&giv3="+giv3+"&giv4="+giv4+"&giv5="+giv5+"&giv6="+giv6+"&giv7="+giv7,
		dataType: "html",
		success: function(data){
			$('#calcresults').html(data);
		}
	});	
}

function checkCalculator(formvalue) {
	if (!trim($(formvalue).value>0)||!trim($(formvalue).value<190)) {
		alert("Please enter a number between 1 and 190.");
		$(formvalue).clear();
		return false;
	}
	return true;
}
