/* - - - - - - - - - - - - - - - - - - - - - - -
 michal@bajer.net.pl
 2009-09-07
 2009-11-03
 2010-06-22
 - - - - - - - - - - - - - - - - - - - - - - - */
var xmlhttpList;
var timeRefreshList=60*1000;
var matchArray=new Array();
function loadDataList(norefresh){
xmlhttpList=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttpList=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttpList=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttpList!=null)
  {
         xmlhttpList.onreadystatechange=stateChangeList;
         xmlhttpList.open("GET",'/panel/plugins/live/ajax/list.php'+'?sessid='+sessid+cmsUrlDatetime(),true);
         xmlhttpList.send(null);
         
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
  if (norefresh==null){
  setTimeout('loadDataList()', timeRefreshList);
  }

}
function stateChangeList()
{
if (xmlhttpList.readyState==4)
  {// 4 = "loaded"
  if (xmlhttpList.status==200)
    {// 200 = "OK"
            if (xmlhttpList.responseText.length==0||xmlhttpList.responseText=='null'){
                return;
            }
            var l=unserialize(xmlhttpList.responseText);
            for(k in l){
                 id_live=l[k]['id_live'];

                 if (_('match'+id_live)==null){
                    o=LIVE_SZABLON_LISTA_MECZ;
                    o=o.replace(/{id_live}/g,id_live);
                    for(k1 in l[k]){
                      o=o.replace('{'+k1+'}',l[k][k1]);
                    }


                    _('liveList').innerHTML=_('liveList').innerHTML+
                        o;

                    matchArray[id_live]=l[k];
                 }
                 if (_('icon'+id_live)!=null){
                    if (l[k]['icon']!=null){
                       i=l[k]['icon'];
                       i=i.replace('ICON_IN_PROGRESS',ICON_IN_PROGRESS);
                       i=i.replace('ICON_CLOCK',ICON_CLOCK);
                       i=i.replace('ICON_START_1HALF',ICON_START_1HALF);
                       i=i.replace('ICON_END_1HALF',ICON_END_1HALF);
                       i=i.replace('ICON_START_2HALF',ICON_START_2HALF);
                       i=i.replace('ICON_END',ICON_END);
                       i=i.replace('ICON_END_2HALF',ICON_END_2HALF);
                       i=i.replace('ICON_START_1HALF_EXTRA',ICON_START_1HALF_EXTRA);
                       i=i.replace('ICON_END_1HALF_EXTRA',ICON_END_1HALF_EXTRA);
                       i=i.replace('ICON_START_2HALF_EXTRA',ICON_START_2HALF_EXTRA);
                       i=i.replace('ICON_END_2HALF_EXTRA',ICON_END_2HALF_EXTRA);
                       i=i.replace('ICON_GOAL',ICON_GOAL);
                       i=i.replace('ICON_GOAL_OWN',ICON_GOAL_OWN);
                       i=i.replace('ICON_GOAL_PENALTY',ICON_GOAL_PENALTY);
                       i=i.replace('ICON_YELLOW_CARD',ICON_YELLOW_CARD);
                       i=i.replace('ICON_RED_CARD',ICON_RED_CARD);
                       i=i.replace('ICON_YELLOW_CARD',ICON_YELLOW_CARD);
                       i=i.replace('ICON_YELLOW_RED_CARD',ICON_YELLOW_RED_CARD);
                       i=i.replace('ICON_ASSIST',ICON_ASSIST);
                       i=i.replace('ICON_SUBSTITUTION',ICON_SUBSTITUTION);
                       _('icon'+id_live).innerHTML=i;
                    }else{
                       _('icon'+id_live).innerHTML=ICON_IN_PROGRESS;
                    }
                 }
                 if (_('event'+id_live)!=null){
                     if (l[k]['lastEvent']!=null){
			minute=l[k]['lastEvent']['minute'];
                        _('event'+id_live).innerHTML=(minute!=null?minute+'\' ':'')+l[k]['lastEvent']['text'].replace(/\\/g,'');
                     }
                 }
                 if (_('host_goalscorers'+id_live)!=null){
                     hg='';
                     for(k2 in l[k]['host_goalscorers']){
                         hg=hg+'<div style="line-heigth:15px;">'+l[k]['host_goalscorers'][k2]['name']+' ';
                         for(k3 in l[k]['host_goalscorers'][k2]['minutes']){
                             hg=hg+l[k]['host_goalscorers'][k2]['minutes'][k3]+'\'';
                         }
                         hg=hg+'</div>';
                     }
                    _('host_goalscorers'+id_live).innerHTML=hg;
                 }
                 if (_('guest_goalscorers'+id_live)!=null){
                     hg='';
                     for(k2 in l[k]['guest_goalscorers']){
                         hg=hg+'<div style="line-heigth:15px;">'+l[k]['guest_goalscorers'][k2]['name']+' ';
                         for(k3 in l[k]['guest_goalscorers'][k2]['minutes']){
                             hg=hg+l[k]['guest_goalscorers'][k2]['minutes'][k3]+'\'';
                         }
                         hg=hg+'</div>';
                     }
                    _('guest_goalscorers'+id_live).innerHTML=hg;
                 }

            }
    }
  else
    {
    alert("Problem retrieving data:" + xmlhttpList.statusText);
    }
  }
}