<!--

var expand_buffer = new Array();
var xmlHttp;
var continent_id=0;
var previous=0;
var state=0;
var mine=0;

function biglive_expand_all()
{
  for(var i=0;i<expand_buffer.length;i++)
  {
    if (expand_buffer[i])
    {
      if (expand_buffer[i][0]==1) { biglive_expand('goalers',i); }
      else if (expand_buffer[i][1]==1) { biglive_expand('redcards',i); }
      else if (expand_buffer[i][2]==1) { biglive_expand('yellowcards',i); }
      else if (expand_buffer[i][3]==1) { biglive_expand('experts',i); }
    }
  }
}

function expand_button_change(button,game,table_name)
{
   var temp;

   // deactivate all buttons and enable one if needed
   if (continent_id==0)
   {
     temp = document.getElementById('button' + game + '_1');
     if (temp && temp.id!=button.id) { temp.className='expand_button'; }
   }
   
   temp = document.getElementById('button' + game + '_2');            
   if (temp.id!=button.id) { temp.className='expand_button'; }

   temp = document.getElementById('button' + game + '_3');            
   if (temp.id!=button.id) { temp.className='expand_button'; }

   temp = document.getElementById('button' + game + '_4');            
   if (temp.id!=button.id) { temp.className='expand_button'; }
  
   
   if (button.className=='expand_button_down') { button.className='expand_button'; }
   else if (button.className=='expand_button') { button.className='expand_button_down'; }


   // deactivate all tables and enable one if needed
   temp = document.getElementById('table_goalers' + game);
   temp.style.display='none';
   temp = document.getElementById('table_experts' + game);
   if (temp)
   {
     temp.style.display='none';
   }
   temp = document.getElementById('table_redcards' + game);
   temp.style.display='none';
   temp = document.getElementById('table_yellowcards' + game);

   temp = document.getElementById('table_' + table_name + game);
   if (button.className=='expand_button_down') { temp.style.display='block'; }
   else { temp.style.display='none'; }
}

/** reset buffer before setting one of them as true **/
function buffer_reset(game)
{
  expand_buffer[game][0]=0;
  expand_buffer[game][1]=0;
  expand_buffer[game][2]=0;
  expand_buffer[game][3]=0;
}

function biglive_expand(type,game)
{
  var button;

  if (! expand_buffer[game]) 
  {
    expand_buffer[game] = new Array();
    expand_buffer[game][0] = 0;
    expand_buffer[game][1] = 0;
    expand_buffer[game][2] = 0;
    expand_buffer[game][3] = 0;    
  }
  else {
    buffer_reset(game);
  }

  if (type=='goalers')
  {
    button = document.getElementById('experts' + game);           
    if (button)
    {
      button.style.display='none';
    }
    button = document.getElementById('redcards' + game);          
    button.style.display='none';
    button = document.getElementById('yellowcards' + game);         
    button.style.display='none';
    button = document.getElementById('goalers' + game);
    if (button.style.display=='none')
    {
      button.style.display='block';
      expand_buffer[game][0]=1;
    }
    else {
      button.style.display='none';
      expand_buffer[game][0]=0;
    }
  }
  else if (type=='redcards')
  {
    button = document.getElementById('experts' + game);      
    if (button) 
    {    
      button.style.display='none';
    }
    button = document.getElementById('goalers' + game);    
    button.style.display='none';
    button = document.getElementById('yellowcards' + game);         
    button.style.display='none';
    button = document.getElementById('redcards' + game);
    if (button.style.display=='none')
    {
      expand_buffer[game][1]=1;
      button.style.display='block';
    }
    else {
      expand_buffer[game][1]=0;
      button.style.display='none';
    }
  }
  else if (type=='yellowcards')
  {
    button = document.getElementById('experts' + game);           
    if (button)
    {
      button.style.display='none';
    }
    button = document.getElementById('goalers' + game);    
    button.style.display='none';
    button = document.getElementById('redcards' + game);          
    button.style.display='none';
    button = document.getElementById('yellowcards' + game);
    if (button.style.display=='none')
    {
      expand_buffer[game][2]=1;
      button.style.display='block';
    }
    else {
      expand_buffer[game][2]=0;
      button.style.display='none';
    }
  }
  else if (type=='experts')
  {
    button = document.getElementById('goalers' + game);
    if (button) { button.style.display='none'; }
    button = document.getElementById('redcards' + game);
    if (button) { button.style.display='none'; }
    button = document.getElementById('yellowcards' + game);
    if (button) { button.style.display='none'; }
    button = document.getElementById('experts' + game);
    if (button && button.style.display=='none')
    {
      expand_buffer[game][3]=1;
      button.style.display='block';
    }
    else {
      expand_buffer[game][3]=0;
      button.style.display='none';
    }
  }
}

function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
  {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
  }
  catch (e)
  {
    //Internet Explorer
    try
    {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }

  return xmlHttp;
}

function biglive_init()
{
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }
}

function biglive_connect()
{ 
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }
  
  if (continent_id>0)
  {
    var url="/biglive_ajax_world.pl?continent=" + continent_id + '&previous=' + previous + state + "&date=" + new Date().getTime();;
  }
  else
  {
    if (mine==1)
    {
      state += '&mine=1';
    }
    
    var url='/biglive_ajax.pl?' + 'previous=' + previous + state + '&date=' + new Date().getTime();;
//    var url='/biglive_ajax_test.pl?' + 'previous=' + previous + state + '&date=' + new Date().getTime();;
  }

  xmlHttp.onreadystatechange=biglive_data;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function biglive_connect_score()
{ 
  if (xmlHttp==null)
  {
    alert ("Browser does not support HTTP Request");
    return false;
  }
  
  if (continent_id>0)
  {
    var url="/biglive_ajax_world.pl?continent=" + continent_id + '&previous=' + previous + state + "&date=" + new Date().getTime();;
  }
  else
  {
    if (mine==1)
    {
      state += '&mine=1';
    }
    
    var url='/biglive_ajax.pl?' + 'previous=' + previous + state + '&date=' + new Date().getTime();;
//    var url='/biglive_ajax_test.pl?' + 'previous=' + previous + state + '&date=' + new Date().getTime();;

  }

  xmlHttp.onreadystatechange=biglive_score;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function biglive_interval()
{
  //window.setInterval("biglive_init();biglive_connect();biglive_data();",300000); // 5 minutes
  window.setInterval("biglive_init();biglive_connect_score();biglive_score();",10000); // 3 seconds
}

function biglive_load(continent,prev,state_temp,mine_temp)
{
  continent_id=continent;
  previous=prev;
  
  if (state_temp==1)
  {
    state='&started=1';
  }
  else if (state_temp==2)
  {
    state='&begin=1';
  }
  else if (state_temp==3)
  {
    state='&ended=1';
  }
  else {
    state='';
  }
  
  if (mine_temp==1)
  {
    mine=1;
  }
  
  biglive_init();
  biglive_connect();
  biglive_data();
  biglive_interval();

  //setTimeout("biglive_init();biglive_connect();biglive_data();",2500);
}

function biglive_data() 
{ 
  var array = new Array();
  var backref = new Array();
  var scores = new Array();
  var name,value;
  var game;
  var data='';
  
  var page = document.getElementById('page');
  var status = document.getElementById('status');
  var d = new Date();
  
  status.innerHTML = 'התעדכן לאחרונה: ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
  var league_id,league_name,expert_league_id,expert_league_name;
  var team_home,team_away,team_home_english,team_away_english;
  var home_score,away_score,home_score_half,away_score_half;
  var serial,hour,minute;
  var goalers,yellowcards,redcards;
  var experts_1,experts_x,experts_2;
  var league_print=0;
  var home_logo,away_logo;
  var sport_id;
  var expand_button_class,table_style;
  var goals_update;
  var highlight='';
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    var str = xmlHttp.responseText;
    array = str.split("<INPUT");

    for(var i=1;i<array.length;i++)
    {
      backref = array[i].match("name=(.+?)\s*value=(.+?)\">");
      name = backref[1];
      value = backref[2];   
      
      name = name.replace(/"/g,"");
      value = value.replace(/"/g,"");

      if (name.match("games"))
      {
        game=value;
      }
      else if (name.match("serial_" + game))
      {
        serial=value;
      }
      else if (name.match("sport_id_" + game))
      {
        sport_id=value;
      }
      else if (name.match("expert_league_id_" + game))
      {
        if (expert_league_id != value)
        {
          expert_league_id = value;
        }
        else {
          continue;
        }
      }
      else if (name.match("expert_league_name_" + game))
      {
        if (expert_league_name != value)
        {
          expert_league_name = value;
        }
        else {
          if (! league_print) { continue; }
        }

        if (sport_id==45)
        {
          data += '<TD class="basketball" style="padding-right:30px"><IMG src="/images/basketball.png" height="25px"></TD>';
          data += '<TD class="basketball" nowrap style="width:150px;padding-right:10px" valign="middle">'
            + expert_league_name 
            + '</TD>'
            + '</TR></TABLE></TD></TR>'
            + '<TR><TD colspan="6"><IMG src="/images/biglive_headline2.png" border="0"></TD></TR>';        
        }
        else {
          data += '<TD class="football" style="padding-right:30px"><IMG src="/images/football.png" height="25px"></TD>';
          data += '<TD class="football" nowrap style="width:150px;padding-right:10px" valign="middle">'
            + expert_league_name 
            + '</TD>'
            + '</TR></TABLE></TD></TR>'
            + '<TR><TD colspan="6"><IMG src="/images/biglive_headline2.png" border="0"></TD></TR>';
        }
      }
      else if (name.match("league_id_" + game))
      {
        if (league_id != value)
        {
          league_id = value;
        }
        else {
          continue;
        }
      }
      else if (name.match("league_name_" + game))
      {
        if (league_name != value)
        {
          league_name = value;
          league_print=1;
        }
        else {
          league_print=0;
          continue;
        }

        if(expert_league_name)
        {
          data += '<TR><TD colspan="6" style="line-height:5px;background-color:#fefacb;"></TD></TR>';
        }
        
        if (sport_id==45)
        {
          data += '<TR>'
            + '<TD colspan="6"><TABLE><TR><TD class="basketball" nowrap style="padding-right:30px">'
            + league_name 
            + '<\/TD>';
        }
        else
        {
          data += '<TR>'
            + '<TD colspan="6"><TABLE><TR><TD class="football" nowrap style="padding-right:30px">'
            + league_name 
            + '<\/TD>';
        }
      }
      else if (name.match("team_home_logo_" + game))
      {
        home_logo=value;
      }
      else if (name.match("team_away_logo_" + game))
      {
        away_logo=value;
      }      
      else if (name.match("team_home_english_" + game))
      {
        team_home_english = value;
      }      
      else if (name.match("team_home_" + game))
      {
        team_home = value;
        quarter_set=0;
        data += '<TR><TD colspan="6"><TABLE style="background-color:#fbbc48;"><TR>'
          + '<TD class="info" nowrap>';

        if (continent_id==0)
        {
          data += '<A href="/game/info/'
          + game
          + '/'
          + team_home
          + '/'
          + team_away
          + '/טבלאות הליגה/1.html" '
          + 'target="_blank">'
          + '<IMG src="/images/info.gif" border="0" alt="מידע על ספורט" title="מידע על ספורט">'
          + '</A>';
        }
        
        if (expert_league_name)
        {
          data += '&nbsp;&nbsp;'
            + '<A href="/crowd/specialties/'
            + expert_league_name
            + '/'
            + expert_league_id
            + '.html"'
            + 'target="_blank">'
            + '<img src="/images/tip.gif" border="0" alt="הזמן טיפים" title="הזמן טיפים">'
            + '</A>';
        }

        data += '</TD>'
          + '<TD id="team_home' + game + '" class="teams" style="width:135px" ' + highlight + '>'
          + '&nbsp;&nbsp;<IMG class="logo" src="/pics/'
          + home_logo
          + '" style="position:fixed;">';

        if(team_home_english==1)
        {
          data += '&nbsp;&nbsp;<SPAN>'
               + team_home
               + '</SPAN></TD>';
        }
        else {
          data += '<SPAN style="position:relative;left:-5px;top:-5px">'
               + team_home
               + '</SPAN></TD>';
        }
      }
      else if (name.match('goals_update_' + game))
      {
        goals_update = value; 
        if(goals_update==1)
        {
          highlight = 'style="background-color:e0401e;"';
        }
        else {
          highlight = '';
        }
      }
      else if (name.match("home_score_" + game))
      {
        home_score = value;
//        if (! home_score) { home_score='--'; }
        data += '<TD id="score_home' + game + '" class="score" ' + highlight + '>' + home_score + '</TD>';
        scores[game] = home_score
      }        
      else if (name.match("team_away_english_" + game))
      {
        team_away_english = value;
      }      
      else if (name.match("team_away_" + game))
      {
        team_away = value;
        data += '<TD id="team_away' + game + '" class="teams" style="width:146px;" ' + highlight + '>'
        + '&nbsp;&nbsp;<IMG class="logo" src="/pics/'
        + away_logo
        + '" style="position:fixed;">';

        if (team_away_english==1)
        {
          data += '&nbsp;&nbsp;<SPAN valign="top">'
               + team_away
               + '</SPAN></TD>';    
        }
        else {    
          data += '<SPAN style="position:relative;left:-5px;top:-5px" valign="top">'
               + team_away
               + '</SPAN></TD>';
        }
      }
      else if (name.match("away_score_" + game))
      {
        away_score = value;
        data += '<TD id="score_away' + game + '" class="score" ' + highlight + '>' + away_score + '</TD>';
      }  
      else if (name.match("goalers1_" + game))
      {
        goalers = '<TABLE style="border:solid 1px #decd47">'
        + '<TR>'
        + '<TD colspan="2" class="goalers_box_right">המבקיעים</TD>'
        + '<TD colspan="2" class="goalers_box_left">המבקיעים</TD>'
        + '</TR>'
        + '<TR><TD colspan="2" class="goalers_box_body">' + value + '</TD>';          
      }
      else if (name.match("goalers2_" + game))
      {
        goalers += '<TD colspan="2" class="goalers_box_body">' + value + '</TD></TR></TABLE>';
      }
      else if (name.match("yellowcards1_" + game))
      {
        yellowcards = '<TABLE style="border:solid 1px #decd47">'
        + '<TR>'
        + '<TD colspan="2" class="yellow_box_right">כרטיסים צהובים</TD>'
        + '<TD colspan="2" class="yellow_box_left">כרטיסים צהובים</TD>'
        + '</TR>'
        + '<TR><TD colspan="2" class="yellow_box_body">' + value + '</TD>';   
      }
      else if (name.match("yellowcards2_" + game))
      {
        yellowcards += '<TD colspan="2" class="yellow_box_body">' + value + '</TD></TR></TABLE>';
      }
      else if (name.match("redcards1_" + game))
      {
        redcards = '<TABLE style="border:solid 1px #decd47">'
        + '<TR>'
        + '<TD colspan="2" class="red_box_right">כרטיסים אדומים</TD>'
        + '<TD colspan="2" class="red_box_left">כרטיסים אדומים</TD>'
        + '</TR>'
        + '<TR><TD colspan="2" class="yellow_box_body">' + value + '</TD>';  
      }
      else if (name.match("redcards2_" + game))
      {
        redcards += '<TD colspan="2" class="red_box_body">' + value + '</TD></TR></TABLE>';
      }
      else if (name.match("experts_1_" + game))
      {
        experts_1 = value;
      }
      else if (name.match("experts_x_" + game))
      {
        experts_x = value;
      }
      else if (name.match("experts_2_" + game))
      {
        experts_2 = value;
      }
      else if (name.match("hour_" + game))
      {
        hour = value;
      }
      else if (name.match("minute_" + game))
      {
        minute = value;
        if (minute==100)
        {
          data += '<TD id="minute' + game + '" class="result">תוצאה סופית</TD></TR>';
        }
        else if (minute==101)
        {
          data += '<TD id="minute' + game + '" class="result">תוצאה סופית(פנדלים)</TD></TR>';
          }
          else if (minute==102)
          {
            data += '<TD id="minute' + game + '" class="result">תוצאה סופית(הארכה)</TD></TR>';
          }
          else if (minute==103)
          {
            data += '<TD id="minute' + game + '" class="result">תוצאת מחצית</TD></TR>';
          }    
          else if (minute==104)
          {
            data += '<TD id="minute' + game + '" class="result">המשחק נדחה</TD></TR>';
          }       
          else if (minute==105)
          {
            data += '<TD id="minute' + game + '" class="result"><FONT style="color:black;padding-left:2px;">' + hour + '</FONT></TD></TR></TABLE></TD></TR>';
          }
          else if (minute==106)
          {
            data += '<TD id="minute' + game + '" class="result">הארכה</TD></TR>';
          }
          else if (minute==107)
          {
            data += '<TD id="minute' + game + '" class="result">פנדלים</TD></TR>';
          }
          else if (minute) {
            data += '<TD id="minute' + game + '" class="result">דקה ' + minute + ' <IMG src="/images/lamp.gif" class="lamp"></TD></TR>';
          } // end of inner minute conditions

          if (minute && (minute!=105 && minute!=104))
          {
              // EXPERTS BUTTON
              if (expand_buffer[game] && expand_buffer[game][3]==1) 
              { 
                expand_button_class='expand_button_down';
              }
              else { expand_button_class='expand_button'; }

              data += '<TR><TD id="extra' + game + '" colspan="6" class="extra" nowrap>'
              + '<TABLE width="350px"><TR>';

              if (continent_id==0)
              {
                data += '<TD id="button' + game + '_1" class="'
                     + expand_button_class
                     + '" OnClick="expand_button_change(this,' + game + ',\'experts\');biglive_expand(\'experts\','
                     + game
                     + ');">מומחי הליגה</TD>';
              }
              else {
                data += '<TD id="button' + game + '_1">&nbsp;</TD>';                
              }
              
              // GOALERS BUTTON
              if (expand_buffer[game] && expand_buffer[game][0]==1) { expand_button_class='expand_button_down'; }
              else { expand_button_class='expand_button'; }
              
              data += '<TD id="button' + game + '_2" class="'
              + expand_button_class
              + '" OnClick="expand_button_change(this,' + game + ',\'goalers\');biglive_expand(\'goalers\','
              + game
              + ');">מבקיעים</TD>';

              // RED CARDS BUTTON
              if (expand_buffer[game] && expand_buffer[game][1]==1) { expand_button_class='expand_button_down'; }
              else { expand_button_class='expand_button'; }
                            
              data += '<TD id="button' + game + '_3" class="'
              + expand_button_class
              + '" OnClick="expand_button_change(this,' + game + ',\'redcards\');biglive_expand(\'redcards\','
              + game
              + ');">כרטיסים אדומים</TD>';

              // YELLOW CARD BUTTON
              if (expand_buffer[game] && expand_buffer[game][2]==1) { expand_button_class='expand_button_down'; }
              else { expand_button_class='expand_button'; }

              data += '<TD id="button' + game + '_4" class="'
              + expand_button_class
              + '" OnClick="expand_button_change(this,' + game + ',\'yellowcards\');biglive_expand(\'yellowcards\','
              + game
              + ');">כרטיסים צהובים</TD>'
              + '</TR></TABLE>';

              // EXPERTS TABLE       
              if (expand_buffer[game] && expand_buffer[game][3]==1) { 
                table_style='display:block;';
              }
              else { table_style='display:none;'; }
                     
              data += '<TABLE id="table_experts' + game + '" style="'
              + table_style + ';">'
              + '<TR><TD height="10px"></TD></TR>' 
              + '<TR><TD colspan="5" class="extra_box" nowrap id="experts'
              + game
              + '" style="'
              + table_style
              + ';">'
              + '<TABLE style="border:solid 1px #decd47"><TR>'
              + '<TD class="crown_box_right">1</TD>'
              + '<TD class="crown_box_middle">X</TD>'
              + '<TD class="crown_box_left">2</TD></TR>'
              + '<TR><TD class="crown_box_body">' + experts_1 + '</TD>'
              + '<TD class="crown_box_body">' + experts_x + '</TD>'
              + '<TD class="crown_box_body">' + experts_2 + '</TD>'
              + '</TR>'
              + '</TABLE></TD></TR>'
              + '<TR><TD height="10px"></TD></TR>' 
              + '</TABLE>';

              // GOALERS TABLE
              if (expand_buffer[game] && expand_buffer[game][0]==1) { 
                table_style='display:block;';
              }
              else { table_style='display:none;'; }
              
              data += '<TABLE id="table_goalers' + game + '" style="'
              + table_style
              + ';">'
              + '<TR><TD height="10px"></TD></TR>' 
              + '<TR><TD colspan="5" class="extra_box" nowrap id="goalers'
              + game
              + '" style="'
              + table_style
              + ';" align="center">'
              + goalers
              + '</TD></TR>'
              + '<TR><TD height="10px"></TD></TR>' 
              + '</TABLE>';
              
              // RED CARDS TABLE
              if (expand_buffer[game] && expand_buffer[game][1]==1) { 
                table_style='display:block;';
              }
              else { table_style='display:none;'; }
              
              data += '<TABLE id="table_redcards' + game + '" style="'
              + table_style
              + ';">'    
              + '<TR><TD height="10px"></TD></TR>'          
              + '<TR><TD colspan="5" class="extra_box" nowrap id="redcards'
              + game
              + '" style="'
              + table_style
              + ';"'
              + ' align="center">'
              + redcards
              + '</TD></TR>'
              + '<TR><TD height="10px"></TD></TR>' 
              + '</TABLE>';

              // YELLOW CARDS TABLE              
              if (expand_buffer[game] && expand_buffer[game][2]==1) { 
                table_style='display:block;';
              }
              else { table_style='display:none;'; }

              data += '<TABLE id="table_yellowcards' + game + '" style="'
              + table_style
              + ';">'
              + '<TR><TD height="10px"></TD></TR>' 
              + '<TR><TD colspan="5" class="extra_box" nowrap id="yellowcards'
              + game
              + '" style="'
              + table_style
              + ';"'
              + ' align="center">'
              + yellowcards
              + '</TD></TR>'
              + '<TR><TD height="10px"></TD></TR>' 
              + '</TABLE>'
              + '</TD></TR>';
          }
          else if (minute && (minute==105 || minute==104)) 
          {
              data += '<TR><TD id="extra' + game + '" colspan="6" class="extra" nowrap style="display:none;">&nbsp;</TD></TR>';
          }
        } // end of minute condition
        else if (name.match("quarter7_" + game) && value && ! quarter_set)
        {
          quarter_set=1;
          data += '<TD id="minute' + game + '" class="result">תוצאה סופית</TD></TR>';
        }            
        else if (name.match("quarter5_" + game) && value && ! quarter_set)
        {
          quarter_set=1;
          data += '<TD id="minute' + game + '" class="result">הארכה</TD></TR>';
        }                
        else if (name.match("quarter4_" + game) && value && ! quarter_set)
        {
          quarter_set=1;
          data += '<TD id="minute' + game + '" class="result">תוצאה סופית</TD></TR>';
        }
        else if (name.match("quarter3_" + game) && value && ! quarter_set)
        {
          quarter_set=1;
          data += '<TD id="minute' + game + '" class="result">רבע רביעי</TD></TR>';
        }
        else if (name.match("quarter2_" + game) && value && ! quarter_set)
        {
          quarter_set=1;
          data += '<TD id="minute' + game + '" class="result">רבע שלישי</TD></TR>';
        }
        else if (name.match("quarter1_" + game) && value && ! quarter_set)
        {
          quarter_set=1;   
          data += '<TD id="minute' + game + '" class="result">רבע שני</TD></TR>';
        }
        else if (name.match("quarter6_" + game) && value && ! quarter_set)
        {
          quarter_set=1;   
          data += '<TD id="minute' + game + '" class="result">רבע ראשון</TD></TR>';
        }        
        else if (name.match("quarter0_" + game) && value && value==1 && ! quarter_set)
        {
          quarter_set=1;
          data += '<TD id="minute' + game + '" class="result"><FONT style="color:black;">' + hour + '</FONT></TD></TR>';
        }
    }

    if(data=='') 
    {  
      data = '<TR><TD style="font-size:14px;line-height:40px;" bgcolor="fdfee4">אין משחקים בקטגוריה זו.</TD></TR>';
    }

    page.innerHTML = '<TABLE class="borders">' 
      + data 
      + '</TABLE>';
  }
  
  delete(array);
  delete(backref);
  return true;
}


function biglive_score() 
{ 
  var array = new Array();
  var backref = new Array();
  var name,value;
  var game,hour;
  var data='';
  var div;
  
  var minute;
  var goalers,yellowcards,redcards;
  var experts_1,experts_x,experts_2;
  var quarter_set=0;
  
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  { 
    var str = xmlHttp.responseText;
    array = str.split("<INPUT");

    for(var i=1;i<array.length;i++)
    {
      backref = array[i].match("name=(.+?)\s*value=(.+?)\">");
      name = backref[1];
      value = backref[2];   
      
      name = name.replace(/"/g,"");
      value = value.replace(/"/g,"");

      if (name.match("games"))
      {
        game=value;
        quarter_set=0;
      }
      else if (name.match("home_score_" + game))
      {
        div = document.getElementById('score_home' + game);
        div.innerHTML = value;
      }          
      else if (name.match("away_score_" + game))
      {
        div = document.getElementById('score_away' + game);
        div.innerHTML = value;
      }
      else if (name.match("goalers1_" + game))
      {
        goalers = '<TABLE style="border:solid 1px #decd47">'
        + '<TR>'
        + '<TD colspan="2" class="goalers_box_right">המבקיעים</TD>'
        + '<TD colspan="2" class="goalers_box_left">המבקיעים</TD>'
        + '</TR>'
        + '<TR><TD colspan="2" class="goalers_box_body">' + value + '</TD>';          
      }
      else if (name.match("goalers2_" + game))
      {
        goalers += '<TD colspan="2" class="goalers_box_body">' + value + '</TD></TR></TABLE>';
      }
      else if (name.match("yellowcards1_" + game))
      {
        yellowcards = '<TABLE style="border:solid 1px #decd47">'
        + '<TR>'
        + '<TD colspan="2" class="yellow_box_right">כרטיסים צהובים</TD>'
        + '<TD colspan="2" class="yellow_box_left">כרטיסים צהובים</TD>'
        + '</TR>'
        + '<TR><TD colspan="2" class="yellow_box_body">' + value + '</TD>';   
      }
      else if (name.match("yellowcards2_" + game))
      {
        yellowcards += '<TD colspan="2" class="yellow_box_body">' + value + '</TD></TR></TABLE>';
      }
      else if (name.match("redcards1_" + game))
      {
        redcards = '<TABLE style="border:solid 1px #decd47">'
        + '<TR>'
        + '<TD colspan="2" class="red_box_right">כרטיסים אדומים</TD>'
        + '<TD colspan="2" class="red_box_left">כרטיסים אדומים</TD>'
        + '</TR>'
        + '<TR><TD colspan="2" class="yellow_box_body">' + value + '</TD>';  
      }
      else if (name.match("redcards2_" + game))
      {
        redcards += '<TD colspan="2" class="red_box_body">' + value + '</TD></TR></TABLE>';
      }
      else if (name.match("experts_1_" + game))
      {
        experts_1 = value;
      }
      else if (name.match("experts_x_" + game))
      {
        experts_x = value;
      }
      else if (name.match("experts_2_" + game))
      {
        experts_2 = value;
      }
      else if (name.match("hour_" + game))
      {
        hour = value;
      }
      else if (name.match('goals_update_' + game))
      {
        goals_update = value; 
        if (goals_update==1)
        {
          div = document.getElementById('team_home' + game);
          div.style.backgroundColor='e0401e';
          div = document.getElementById('team_away' + game);
          div.style.backgroundColor='e0401e';
          div = document.getElementById('score_home' + game);
          div.style.backgroundColor='e0401e';
          div = document.getElementById('score_away' + game);
          div.style.backgroundColor='e0401e';
        }
        else {
          div = document.getElementById('team_home' + game);
          div.style.backgroundColor='fcf6b9';
          div = document.getElementById('team_away' + game);
          div.style.backgroundColor='fcf6b9';
          div = document.getElementById('score_home' + game);
          div.style.backgroundColor='fcf6b9';
          div = document.getElementById('score_away' + game);
          div.style.backgroundColor='fcf6b9';        
        }
      }
      else if (name.match("minute_" + game))
      {
        minute = value;
        div = document.getElementById('minute' + game);
        if (minute==100)
        {
          div.innerHTML = 'תוצאה סופית';        
        }
        else if (minute==101)
        {
          div.innerHTML = 'תוצאה סופית(פנדלים)';    
        }
        else if (minute==102)
        {
          div.innerHTML = 'תוצאה סופית(הארכה)';    
        }
        else if (minute==103)
        {
          div.innerHTML = 'תוצאת מחצית';    
        }    
        else if (minute==104)
        {
          div.innerHTML = 'המשחק נדחה';    
        }       
        else if (minute==105)
        {
          div.innerHTML = hour;    
        }
        else if (minute==106)
        {
          div.innerHTML = 'הארכה';    
        }
        else if (minute==107)
        {
          div.innerHTML = 'פנדלים';    
        }
        else if (minute) {
          div.innerHTML = 'דקה ' + minute + ' <IMG src="/images/lamp.gif" class="lamp">';    
        } // end of inner minute conditions
          
        if (minute && (minute!=105 && minute!=104))
        {
          div = document.getElementById('extra' + game);
       //   if (div && div.style.display!='block')
       //   {
       //     div.style.display='block';
       //   }
    
       //   div.style.textAlign='right';
          
          // EXPERTS BUTTON
          if (expand_buffer[game] && expand_buffer[game][3]==1) 
          { 
            expand_button_class='expand_button_down';
          }
          else { expand_button_class='expand_button'; }

          data = '<TABLE width="350px"><TR>';

          if (continent_id==0)
          {
            data += '<TD id="button' + game + '_1" class="'
            + expand_button_class
            + '" OnClick="expand_button_change(this,' + game + ',\'experts\');biglive_expand(\'experts\','
            + game
            + ');">מומחי הליגה</TD>';
          }
          else {
            data += '<TD id="button' + game + '_1">&nbsp;</TD>';                
          }
              
          // GOALERS BUTTON
          if (expand_buffer[game] && expand_buffer[game][0]==1) { expand_button_class='expand_button_down'; }
          else { expand_button_class='expand_button'; }
              
          data += '<TD id="button' + game + '_2" class="'
          + expand_button_class
          + '" OnClick="expand_button_change(this,' + game + ',\'goalers\');biglive_expand(\'goalers\','
          + game
          + ');">מבקיעים</TD>';

          // RED CARDS BUTTON
          if (expand_buffer[game] && expand_buffer[game][1]==1) { expand_button_class='expand_button_down'; }
          else { expand_button_class='expand_button'; }
                            
          data += '<TD id="button' + game + '_3" class="'
          + expand_button_class
          + '" OnClick="expand_button_change(this,' + game + ',\'redcards\');biglive_expand(\'redcards\','
          + game
          + ');">כרטיסים אדומים</TD>';

          // YELLOW CARD BUTTON
          if (expand_buffer[game] && expand_buffer[game][2]==1) { expand_button_class='expand_button_down'; }
          else { expand_button_class='expand_button'; }

          data += '<TD id="button' + game + '_4" class="'
          + expand_button_class
          + '" OnClick="expand_button_change(this,' + game + ',\'yellowcards\');biglive_expand(\'yellowcards\','
          + game
          + ');">כרטיסים צהובים</TD>'
          + '</TR></TABLE>';

          // EXPERTS TABLE       
          if (expand_buffer[game] && expand_buffer[game][3]==1) { 
            table_style='display:block;';
          }
          else { table_style='display:none;'; }
                     
          data += '<TABLE id="table_experts' + game + '" style="'
          + table_style + ';">'
          + '<TR><TD height="10px"></TD></TR>' 
          + '<TR><TD colspan="5" class="extra_box" nowrap id="experts'
          + game
          + '" style="'
          + table_style
          + ';">'
          + '<TABLE style="border:solid 1px #decd47"><TR>'
          + '<TD class="crown_box_right">1</TD>'
          + '<TD class="crown_box_middle">X</TD>'
          + '<TD class="crown_box_left">2</TD></TR>'
          + '<TR><TD class="crown_box_body">' + experts_1 + '</TD>'
          + '<TD class="crown_box_body">' + experts_x + '</TD>'
          + '<TD class="crown_box_body">' + experts_2 + '</TD>'
          + '</TR>'
          + '</TABLE></TD></TR>'
          + '<TR><TD height="10px"></TD></TR>' 
          + '</TABLE>';
  
          // GOALERS TABLE
          if (expand_buffer[game] && expand_buffer[game][0]==1) { 
            table_style='display:block;';
          }
          else { table_style='display:none;'; }
              
          data += '<TABLE id="table_goalers' + game + '" style="'
          + table_style
          + ';">'
          + '<TR><TD height="10px"></TD></TR>' 
          + '<TR><TD colspan="5" class="extra_box" nowrap id="goalers'
          + game
          + '" style="'
          + table_style
          + ';" align="center">'
          + goalers
          + '</TD></TR>'
          + '<TR><TD height="10px"></TD></TR>' 
          + '</TABLE>';
              
          // RED CARDS TABLE
          if (expand_buffer[game] && expand_buffer[game][1]==1) { 
            table_style='display:block;';
          }
          else { table_style='display:none;'; }
              
          data += '<TABLE id="table_redcards' + game + '" style="'
          + table_style
          + ';">'    
          + '<TR><TD height="10px"></TD></TR>'          
          + '<TR><TD colspan="5" class="extra_box" nowrap id="redcards'
          + game
          + '" style="'
          + table_style
          + ';"'
          + ' align="center">'
          + redcards
          + '</TD></TR>'
          + '<TR><TD height="10px"></TD></TR>' 
          + '</TABLE>';

          // YELLOW CARDS TABLE              
          if (expand_buffer[game] && expand_buffer[game][2]==1) { 
            table_style='display:block;';
          }
          else { table_style='display:none;'; }

          data += '<TABLE id="table_yellowcards' + game + '" style="'
          + table_style
          + ';">'
          + '<TR><TD height="10px"></TD></TR>' 
          + '<TR><TD colspan="5" class="extra_box" nowrap id="yellowcards'
          + game
          + '" style="'
          + table_style
          + ';"'
          + ' align="center">'
          + yellowcards
          + '</TD></TR>'
          + '<TR><TD height="10px"></TD></TR>' 
          + '</TABLE>';

//          if (game==23856) { alert(data); }
          div.innerHTML = '';
          div.innerHTML = data;
          div.style.display='block';
        }
        else if (minute && (minute==105 || minute==104)) 
        {
          div = document.getElementById('extra' + game);
          if(div.style.display!='none')
          {
            div.style.display='none';
          }
        }
      } // end of minute condition
      else if (name.match("quarter7_" + game) && value && ! quarter_set)
      {
        quarter_set=1;
        div = document.getElementById('minute' + game);
        div.innerHTML = 'תוצאה סופית';            
        data += '<TD id="minute' + game + '" class="result">תוצאה סופית</TD></TR>';
      }            
      else if (name.match("quarter5_" + game) && value && ! quarter_set)
      {
        quarter_set=1;
        div = document.getElementById('minute' + game);
        div.innerHTML = 'הארכה';     
      }                
      else if (name.match("quarter4_" + game) && value && ! quarter_set)
      {
        quarter_set=1;
        div = document.getElementById('minute' + game);
        div.innerHTML = 'תוצאה סופית';   
      }
      else if (name.match("quarter3_" + game) && value && ! quarter_set)
      {
        quarter_set=1;
        div = document.getElementById('minute' + game);
        div.innerHTML = 'רבע רביעי';   
      }
      else if (name.match("quarter2_" + game) && value && ! quarter_set)
      {
        quarter_set=1;
        div = document.getElementById('minute' + game);
        div.innerHTML = 'רבע שלישי';   
      }
      else if (name.match("quarter1_" + game) && value && ! quarter_set)
      {
        quarter_set=1;   
        div = document.getElementById('minute' + game);
        div.innerHTML = 'רבע שני';   
      }
      else if (name.match("quarter6_" + game) && value && ! quarter_set)
      {
        quarter_set=1;   
        div = document.getElementById('minute' + game);
        div.innerHTML = 'רבע ראשון';   
      }        
      else if (name.match("quarter0_" + game) && value && value==1 && ! quarter_set)
      {
        quarter_set=1;
        div = document.getElementById('minute' + game);
        div.innerHTML = '<FONT style="color:black;">' + hour + '</FONT>';   
      }
    }
  }
  
  delete(array);
  delete(backref);
  return true;
}
-->
