// JavaScript Document
function showMatch(){
	xmlhttp = null;
	if(window.XMLHttpRequest)
	{
	xmlhttp = new XMLHttpRequest();	
	}
	else if(window.ActiveXObject)
	{
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");			
	}
	
	if(xmlhttp != null)
	{
	xmlhttp.onreadystatechange = state_Change;
	xmlhttp.open("GET",'../others/matchlist.xml',true);
  	xmlhttp.send(null);		
	}
	else {alert("Your browser does not support XMLHTTP.");}	
}

function state_Change()
{
	if (xmlhttp.readyState == 4)
	{
	 if (xmlhttp.status == 200)	
	 {
	  x = xmlhttp.responseXML.documentElement.getElementsByTagName("matchlist");
	  totMatch = x.lenth; 
	  xyValueHtml = totMatch;
	  //alert(totMatch)
	  for(i= 0; i<totMatch ; i++)  {
		  var mDate = x[i].getElementsByTagName("matchdate");
		 // var mVenue= x[i].getElementsByTagName("matchvenue");
		  var oTeam = x[i].getElementsByTagName("opponent-team");
		  var oLogo = x[i].getElementsByTagName("opponent-logo");
		  var mDateValue = mDate[0].firstChild.nodeValue;
		 // var mVenueValue= mVenue[0].firstChild.nodeValue;
		  var oTeamValue = oTeam[0].firstChild.nodeValue;
		  var oLogoValue = oLogo[0].firstChild.nodeValue;		  
		  }
	 }	
	}	
}


var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null) 
{
xmlDoc.async=false;
var xmlPath = "../others/matchlist.xml";
xmlDoc.load(xmlPath);
var x=xmlDoc.getElementsByTagName("match");	
}

var i= 0;
var count = 0;
function showMatch(){
	var totMatch = x.length;
	//alert(totMatch);
	if(i<totMatch){
		setTimeout('getFromxml('+i+')',2000);
		i = i+1;
	}
	if(count==totMatch){
		i = 0;
		count = 0;
		showMatch();
	}
}

function getFromxml(i){

  var mDate = x[i].getElementsByTagName("matchdate");
  //var mVenue= x[i].getElementsByTagName("matchvenue");
  var oTeam = x[i].getElementsByTagName("opponent-team");
  var oLogo = x[i].getElementsByTagName("opponent-logo");
  var mDateValue = mDate[0].firstChild.nodeValue;
  //var mVenueValue= mVenue[0].firstChild.nodeValue;
  var oTeamValue = oTeam[0].firstChild.nodeValue;
  var oLogoValue = oLogo[0].firstChild.nodeValue;		  
  
  var opoLogo = document.getElementById("oplogo");  
  opoLogo.src = oLogoValue;
  opoLogo.alt = oTeamValue;
  opoLogo.title = oTeamValue;
  document.getElementById("mdate").innerHTML = mDateValue;
  //document.getElementById("mvenue").innerHTML = mVenueValue;
	
	count+=1;
  showMatch();
}