// JavaScript Document

document.write ("<?php include('/xml/update.php') ?>");
    
//read XML doc
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
 // code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
  xmlDoc=document.implementation.createDocument("","",null);

}
else
{
alert('Your browser cannot handle this script');
}

if (xmlDoc!=null)
{ 
xmlDoc.async=false;
//read source name from parent document
//xmlDoc.load("/xml/"+trieda+".xml");
xmlDoc.load("/xml/SR_20.xml");


   
var x=xmlDoc.getElementsByTagName("row");
    
//generuj vypis//
    document.write ("<table width=550 border=0 cellspacing=0 cellpadding=5>");
    document.write ("<tbody>");
    document.write ("<tr>");
    document.write ("<th>Dres</th><th>Meno</th><th>Post</th><th>Narodený</th><th>Góly</th><th>Asistencie</th><th>Body</th></tr>");

var ary = new Array();
var maxValue = 0;

for (i=0;i<x.length;i++)
{  
  ary[i] = parseFloat((x[i].getElementsByTagName("body")[0].childNodes[0].nodeValue));
    
  if(ary[i]>maxValue){
   maxValue = ary[i];
  }
}


//najdi najlepsieho hraca

  
for (i=0;i<(x.length);i++)
{ 
    post = ((x[i].getElementsByTagName("post")[0].childNodes[0].nodeValue));
    points = ((x[i].getElementsByTagName("body")[0].childNodes[0].nodeValue));
    post = post.substr(0,1);
 
    document.write ("<tr");
    if(points==maxValue){
     document.write (" style='background:#ffcc00'");
    }
    if(post=="G"){
      document.write (" style='background:#cde5fe'"); 
    }
    document.write (">");
    
    
    document.write ("<td><span class=''>" + (x[i].getElementsByTagName("position")[0].childNodes[0].nodeValue) + "</span></td>");
    document.write ("<td><span style='text-align:left'><a target=_blank href=" + (x[i].getElementsByTagName("stats_url")[0].childNodes[0].nodeValue) + ">" + (x[i].getElementsByTagName("meno")[0].childNodes[0].nodeValue) + "</a></span></td>");
    document.write ("<td><span class=''>" + (x[i].getElementsByTagName("post")[0].childNodes[0].nodeValue) + "</span></td>");
    document.write ("<td><span class=''>" + (x[i].getElementsByTagName("narodeny")[0].childNodes[0].nodeValue) + "</span></td>");
    document.write ("<td><span class=''>" + (x[i].getElementsByTagName("goly")[0].childNodes[0].nodeValue) + "</span></td>");
          if ((x[i].getElementsByTagName("post")[0].childNodes[0].nodeValue)=="G"){
      document.write ("<td><span class=''>Úspešnosť</span></td>");
      points = 100*parseFloat((x[i].getElementsByTagName("body")[0].childNodes[0].nodeValue));
      document.write ("<td><span class=''>" + points + " %</span></td>");
          } else {
    document.write ("<td><span class=''>" + (x[i].getElementsByTagName("asistencie")[0].childNodes[0].nodeValue) + "</span></td>");
    document.write ("<td><span class=''>" + (x[i].getElementsByTagName("body")[0].childNodes[0].nodeValue) + "</span></td>");
    }
    document.write ("</tr>");
  }

 }
document.write("</tbody></table>");


