function addScript()
{
	 var obj=new JSONscriptRequest("http://cluster.leaguestat.com/lsconsole/json.php?client_code=" + client_code + "&league_code=" + league_code + "&teamId=" + teamId + "&teamSingle=" + teamId + "&type=" + type + "&forcedate=" + date);
	 obj.buildScriptTag(); // Build the script tag	 	 	
	 obj.addScriptTag(); // Execute (add) the script tag
}
	
function bork(data)
{
	 if(data==null)
	 {
	 	 alert('error');
	 }
	 else
	 {
		// SO
	 }
}

function load(configStr,dataToday,dataPre,dataTomorrow)
{
	var monthNames	= ["month","Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
	var vScore = hScore = 0;
	var arr = Num = Game = {};
	
	configArr = eval('(' + configStr + ')');

	arr			= eval('(' +dataToday + ')');
	//Num			= JSON.parse(arr.Num);
	if(arr.Num > 0)
	{
		Game = eval(arr.Game1);
		
		date=date.split('-');
		time=Game.ScheduledTime.split(':');
		d = monthNames[parseFloat(date[1])] +  " " + date[2] + ", " + date[0] + " " + time[0] + ":" + parseFloat(time[1]) + ":00";
		d = new Date(d);
		d = String(d).split(" ",3);
		
		var h1 = $('#scores h1');
		h1[0].innerHTML = d[0] + " " + d[1] + " " + d[2];
		h1[1].innerHTML = Game.ScheduledTime;
		
		
		var td = $('.score td');
		var th = $('.score th');
		
		td[0].innerHTML = Game.VisitingTeam.Code;
		td[7].innerHTML = Game.HomeTeam.Code;
	
		// PERIODS
		for(j=0;j< countProperties(Game.GoalsByPeriod);j++)
		{
			td[1+j].innerHTML = Game.GoalsByPeriod["Period"+(j+1)]["VisitingGoalCount"];
			td[8+j].innerHTML = Game.GoalsByPeriod["Period"+(j+1)]["HomeGoalCount"];
			
			if(j===3 ||j===4)
			{
				if(document.documentElement.className === 'ie')
				{
					th[j+1].style['display']='block';
					td[j+1].style['display']='block';
					td[j+8].style['display']='block';
				}
				else
				{
					th[j+1].style['display']='table-cell';
					td[j+1].style['display']='table-cell';
					td[j+8].style['display']='table-cell';
				}
			}
			vScore =	vScore+parseInt(Game.GoalsByPeriod["Period"+(j+1)]["VisitingGoalCount"]);
			hScore =	hScore+parseInt(Game.GoalsByPeriod["Period"+(j+1)]["HomeGoalCount"]);
	
			td[6].innerHTML 	= vScore;
			td[13].innerHTML 	= hScore;
		}
		if(Boolean(Game.GameSummaryUrl))
		{
			$("a.link:fisrt").attr('href',Game.GameSummaryUrl);
			var a = document.getElementsByTagName('a');
			for(k=0;k<a.length;k++)
			{
				if(a[k].className==='link') a[k].innerHTML= "Game Summary" ;
			}
		}
	}
	else
	{
		document.getElementById('scores').getElementsByTagName('h1')[0].innerHTML="No Games Today";
	}
}

function countProperties(obj) {
  var prop;
  var propCount = 0;
  
  for (prop in obj) {
    propCount++;
  }
  return propCount;
}
