//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function setListIndex(ListID, value) {
	var ListObj=document.getElementById(ListID);
	
	if (ListObj){
		ListObj.selectedIndex=0;		
		for(var i = 0; i < ListObj.length; i++) {
			if(ListObj[i].value == value){
				ListObj.selectedIndex = i;					
				break;
			}							
		}		
	}
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function popup(win_url,win_handle,x,y) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href=win_url;
	else
	{
   winhandle=window.open(win_url,win_handle,"menubar=no,resizable=yes,scrollbars=yes,status=no,width=" + x + ",height=" + y);   
   winhandle.focus();
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function profile(UID) 
{
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="../locker/profile.asp?uid=" + escape(UID);
	else
		window.open("../locker/profile.asp?uid=" + UID,"profile","menubar=no,scrollbars=no,status=no,width=508,height=398,resizable=no");
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function playerstats(TeamID) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="stats.asp?teamid=" + TeamID;
	else
	{
   winhandle=window.open("stats.asp?teamid=" + TeamID,"teaminfo","menubar=no,scrollbars=yes,status=no,width=770,height=440,resizable=yes");
   winhandle.focus();
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function playerprofile(TeamPlayerID) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="profile.asp?pid=" + TeamPlayerID;
	else
	{
   winhandle=window.open("profile.asp?pid=" + TeamPlayerID,"profile","menubar=no,scrollbars=yes,status=no,width=660,height=500,resizable=yes");
   winhandle.focus();
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function playerprofile_draft(PlayerID, Spot) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="profile_draft.asp?pid=" + PlayerID + "&spot=" + Spot;
	else
	{
   winhandle=window.open("profile_draft.asp?pid=" + PlayerID + "&spot=" + Spot,"profile","menubar=no,scrollbars=yes,status=no,width=660,height=420,resizable=yes");
   winhandle.focus();
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function scoreboard(LeagueID, DisplayDate, TimeofGame) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="scoreboard.asp?leagueid=" + LeagueID + "&date=" + DisplayDate + "&ampm=" + TimeofGame;
	else
	{
   winhandle=window.open("scoreboard.asp?leagueid=" + LeagueID + "&date=" + DisplayDate + "&ampm=" + TimeofGame,"leaguescores","menubar=no,scrollbars=yes,status=no,width=520,height=400");
   winhandle.focus();
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ir(InjuryID) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="ir.asp?injuryid=" + InjuryID;
	else
	{
   window.open("ir.asp?injuryid=" + InjuryID,InjuryID,"menubar=no,scrollbars=no,status=no,width=410,height=280,resizable=no");
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function boxscore(GameID,TeamFee) 
{
   window.open("../NBA/boxscore.asp?GameID=" + GameID + "&nomenu=1&teamfee=" + TeamFee,"boxscore","menubar=no,scrollbars=yes,status=no,width=725,height=480,resizable=yes");
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function pbp(GameID, Qtr, Bold) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="../nba/pbp.asp?bold=" + Bold + "&gameid=" + GameID + "&qtr=" + Qtr;
	else
	{
   winhandle=window.open("../nba/pbp.asp?bold=" + Bold + "&gameid=" + GameID + "&qtr=" + Qtr,"nbapbp","menubar=no,scrollbars=yes,status=no,width=620,height=470");
   winhandle.focus();
  }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function SwitchTeams(NewTeamID) 
{
	if (NewTeamID>0) window.location.href	= "manage.asp?teamid=" + NewTeamID;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ValidateNote()
{
  if (document.frmnotes.note.value.length > 250)
  {
    alert("Note is " + (document.frmnotes.note.value.length - 250) + " characters too long. 250 characters max.");
    document.frmnotes.note.focus();
    return (false);
  }
  
  if (document.frmnotes.note.value.indexOf('<') > -1)
  {
    alert("Invalid character '<' in note.");
    document.frmnotes.note.focus();
    return (false);
  }
  
  document.frmnotes.submit();
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ShowObj(ObjID, CookieVar) {
	var obj = document.all ? document.all[ObjID] :
			document.getElementById ? document.getElementById(ObjID) : null;
		
	obj.style.display='block';
	if (CookieVar.length>0) Set_Cookie("wispersisted", 'nba_' + CookieVar, 1);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function HideObj(ObjID, CookieVar) {
	var obj = document.all ? document.all[ObjID] :
			document.getElementById ? document.getElementById(ObjID) : null;
		
	obj.style.display='none';
	 
	if (CookieVar.length>0) Set_Cookie("wispersisted", 'nba_' + CookieVar, 0);	
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function SwapObj(ShowObjID, HideObjID) {
	ShowObj(ShowObjID,"");
	HideObj(HideObjID,"");
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function SwapState(CheckboxID, ObjID, CookieVar) {
	var cb = document.all ? document.all[CheckboxID] :
			document.getElementById ? document.getElementById(CheckboxID) : null;
			
	if (cb.checked==true) ShowObj(ObjID, CookieVar);
	else HideObj(ObjID, CookieVar);	
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Trim(sString){
	return LTrim(RTrim(sString));
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function RTrim(sString){
	while (sString.substring(sString.length-1, sString.length) == ' '){
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function LTrim(sString) {
	while (sString.substring(0,1) == ' '){
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function KB_Article(KBID) {
	if(navigator.appName.indexOf("WebTV")!=-1)
		window.location.href="../knowledgebase/KB_Article_Details.aspx?kbid=" + KBID;
	else
	{
   winhandle=window.open("../knowledgebase/KB_Article_Details.aspx?kbid=" + KBID,"KnowledgeBase","menubar=no,scrollbars=yes,status=no,width=780,height=500,resizable=yes");
   winhandle.focus();
  }
}