//--Definieer object Uitslag----------------------------------------------------
function objUitslag (strDatum, strUitslag, aftr_V, aftr_T)
// pnt_1V, pnt_1T, pnt_2V, pnt_2T, pnt_3V, pnt_3T, pnt_4V, pnt_4T
{arrUitslag=strUitslag.split(',');
 this.puntenVoor =parseInt(arrUitslag[0]) + parseInt(arrUitslag[2]) + parseInt(arrUitslag[4]) + parseInt(arrUitslag[6]);
 this.puntenTegen=parseInt(arrUitslag[1]) + parseInt(arrUitslag[3]) + parseInt(arrUitslag[5]) + parseInt(arrUitslag[7]);
 this.SetPuntV=0;
 this.SetPuntT=0;

 if (strDatum<'20090801')
   {if (parseInt(arrUitslag[0])<25 && parseInt(arrUitslag[1])<25)
      {this.SetPuntV+=0.5;this.SetPuntT+=0.5;}
    else if (parseInt(arrUitslag[0])>parseInt(arrUitslag[1]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
    if (parseInt(arrUitslag[2])<25 && parseInt(arrUitslag[3])<25)
      {this.SetPuntV+=0.5;this.SetPuntT+=0.5;}
    else if (parseInt(arrUitslag[2])>parseInt(arrUitslag[3]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
    if (parseInt(arrUitslag[4])<25 && parseInt(arrUitslag[5])<25)
      {this.SetPuntV+=0.5;this.SetPuntT+=0.5;}
    else if (parseInt(arrUitslag[4])>parseInt(arrUitslag[5]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
    if (parseInt(arrUitslag[6])<25 && parseInt(arrUitslag[7])<25)
      {this.SetPuntV+=0.5;this.SetPuntT+=0.5;}
    else if (parseInt(arrUitslag[6])>parseInt(arrUitslag[7]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
   }
 else
   // Wijziging reglement per seizoen 2009/2010
   // Er worden geen halve punten meer toegekend. 
   {if (parseInt(arrUitslag[0])>parseInt(arrUitslag[1]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
    if (parseInt(arrUitslag[2])>parseInt(arrUitslag[3]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
    if (parseInt(arrUitslag[4])>parseInt(arrUitslag[5]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
    if (parseInt(arrUitslag[6])>parseInt(arrUitslag[7]))
      {this.SetPuntV++;} else {this.SetPuntT++;}
   }
 // Extra aftrek
 if (aftr_V != '')
   {this.SetPuntV-=parseInt(aftr_V);}
 if (aftr_T != '')
   {this.SetPuntT-=parseInt(aftr_T);}
}

function testObjUitslag ()
{Resultaat=new objUitslag(20091001, '25,15,25,18,25,10,10,25', 1 , 0);
 Resultaat=new objUitslag(20091001, '25,15,25,18,25,10,10,25', 0 , 0);
 alert('voor: ' + Resultaat.SetPuntV + ' tegen: '  + Resultaat.SetPuntT);
}

//--Sorteer kolommen in Wedstrijd-----------------------------------------------
function sortWedstrijdRonde (a, b)
{if (a[1] > b[1])
   {return 1;}
 else if (a[1] < b[1])
   {return -1;}
 else
   {return 0;}
}

function sortWedstrijdWeek (a, b)
{if (a[2] > b[2])
   {return 1;}
 else if (a[2] < b[2])
   {return -1;}
 else
   {return 0;}
}

function SortWedstrijd (col)
{if (Wedstrijd.length > 0)
   {if (col==1) Wedstrijd.sort(sortWedstrijdRonde);
    if (col==2) Wedstrijd.sort(sortWedstrijdWeek);
   }
}

//--Sorteer kolommen in WedsCat1------------------------------------------------
function sortWedsCat1Ronde (a, b)
{if (parseInt(a[0]) > parseInt(b[0]))
   {return 1;}
 else if (parseInt(a[0]) < parseInt(b[0]))
   {return -1;}
 else
   {return 0;}
}

function sortWedsCat1Speeldatum (a, b)
{if (parseInt(a[4]) > parseInt(b[4]))
   {return 1;}
 else if (parseInt(a[4]) < parseInt(b[4]))
   {return -1;}
 else
   {return 0;}
}

function SortWedsCat1 (col)
{if (WedsCat1.length > 0)
   {if (col==1) WedsCat1.sort(sortWedsCat1Ronde);
    if (col==2) WedsCat1.sort(sortWedsCat1Speeldatum);
   }
 ShowWedsCat1();
 VulWedsLocDefault();
}

//--Sorteer kolommen in WedsCat3------------------------------------------------
function sortWedsCat3Ronde (a, b)
{if (parseInt(a[0]) > parseInt(b[0]))
   {return 1;}
 else if (parseInt(a[0]) < parseInt(b[0]))
   {return -1;}
 else
   {return 0;}
}

function sortWedsCat3Rang (a, b)
{if (parseInt(a[5]) > parseInt(b[5]) || (parseInt(a[5]) == parseInt(b[5]) && a[8] > b[8]))
   {return 1;}
 else if (parseInt(a[5]) < parseInt(b[5]) || (parseInt(a[5]) == parseInt(b[5]) && a[8] < b[8]))
   {return -1;}
 else
   {return 0;}
}

function sortWedsCat3Punten (a, b)
{if (parseFloat(a[6]) * 100000 + parseInt(a[7]) * 100 + parseInt(a[0]) < parseFloat(b[6]) * 100000 + parseInt(b[7]) * 100 + parseInt(b[0]))
   {return 1;}
 else if (parseFloat(a[6]) * 100000 + parseInt(a[7]) * 100 + parseInt(a[0]) > parseFloat(b[6]) * 100000 + parseInt(b[7]) * 100 + parseInt(b[0]))
   {return -1;}
 else
   {return 0;}
}

function sortWedsCat3Datum (a, b)
{if (parseInt(a[9]) > parseInt(b[9]))
   {return 1;}
 else if (parseInt(a[9]) < parseInt(b[9]))
   {return -1;}
 else
   {return 0;}
}

function SortWedsCat3 (col)
{if (col==1) WedsCat3.sort(sortWedsCat3Datum);
 if (col==2) WedsCat3.sort(sortWedsCat3Rang);
 if (col==3) WedsCat3.sort(sortWedsCat3Punten);
 ShowWedsCat3();
}

//--Drag and drop --------------------------------------------------------------
// Zie ook de website http://nofunc.org/Drag_Drop/
function $(v)
{return(document.getElementById(v)); }
function agent(v)
{return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function xy(e,v)
{return(v?(agent('msie')?event.clientY+document.body.scrollTop:e.pageY):(agent('msie')?event.clientX+document.body.scrollTop:e.pageX)); }
function dragOBJ(d,e)
{function drag(e)
   {if(!stop) { d.style.top=(tX=xy(e,1)+oY-eY+'px'); d.style.left=(tY=xy(e)+oX-eX+'px'); } }
 var oX=parseInt(d.style.left),oY=parseInt(d.style.top),eX=xy(e),eY=xy(e,1),tX,tY,stop;
 document.onmousemove=drag;
 document.onmouseup=function() {stop=1; document.onmousemove=''; document.onmouseup='';}
};

//------------------------------------------------------------------------------
function DatumNaarStr (datIn)
{// DatIn is een string met format 20090930
 if (datIn=='') return '';
 var datInput=new Date();
 aMaand=datIn.substr(4,2);
 aMaand--;
 datInput.setFullYear(datIn.substr(0,4), aMaand, datIn.substr(6,2));
 var weekdag=new Array(7);
 weekdag[0]="zo";
 weekdag[1]="ma";
 weekdag[2]="di";
 weekdag[3]="wo";
 weekdag[4]="do";
 weekdag[5]="vr";
 weekdag[6]="za";
 aDagNaam=weekdag[datInput.getDay()];
 if (datInput.getDate() < 10)
   {aDagNum='0' + datInput.getDate();}
 else
   {aDagNum=datInput.getDate();}
 if (datInput.getMonth() < 9)
   {aMthNum='0' + (datInput.getMonth() + 1);}
 else
   {aMthNum=(datInput.getMonth() + 1);}
 return aDagNaam + ' ' + aDagNum + '-' + aMthNum + '-' + datInput.getFullYear();
}

//------------------------------------------------------------------------------
function DatumNaarDDMM (datIn)
{// DatIn is een string met format 20090930
 if (datIn=='') return '';
 var datInput=new Date();
 aMaand=datIn.substr(4,2);
 aMaand--;
 datInput.setFullYear(datIn.substr(0,4), aMaand, datIn.substr(6,2));
 if (datInput.getDate() < 10)
   {aDagNum='0' + datInput.getDate();}
 else
   {aDagNum=datInput.getDate();}
 if (datInput.getMonth() < 9)
   {aMthNum='0' + (datInput.getMonth() + 1);}
 else
   {aMthNum=(datInput.getMonth() + 1);}
 return aDagNum + '-' + aMthNum;
}

function GetWedsLocatie (i)
{aAdres=Team.ZaalNaw(i);

 aTijden='';
 if (Team.TijdWedstrijd(i)!='')
   aTijden+='Wedstrijd: <b>' + Team.TijdWedstrijd(i) + '</b><br />';
 if (Team.TijdInspelen(i)!='')
   aTijden+='Inspelen: ' + Team.TijdInspelen(i) + '<br />';
 if (Team.TijdOpen(i)!='')
   aTijden+='Zaal open: ' + Team.TijdOpen(i) + '<br />';
 aTijden=aTijden.substr(0, aTijden.length - 6);
 if (aAdres==''&&aTijden=='')
   {result='';}
 else
   {result='<table class="childtable" border="1"><tr bgcolor="siena" color="yellow">';
    result+='<th colspan="2" nowrap style="text-align:left">Team ' + Team.Naam(i) + ' speelt op ' + Team.Speeldag(i).toLowerCase() + '</th></tr>'
    result+='<tr><td bgcolor="white" nowrap style="text-align:left;vertical-align:top;"><div class="zaaladres">' + aAdres + '</div></td><td bgcolor="white" nowrap valign="top"><div class="zaaladres">' + aTijden + '</div></td></tr>';
    if (Team.ZaalOpmerking(i) != '')
      {result+='<tr><td colspan="2" bgcolor="white" style="text-align:left"><div class="zaaladres">' + Team.ZaalOpmerking(i) + '</div></td></tr>';}
    result+='</table>';
   }
 return result;
}

function VulWedsLocatie (inTeam)
{strWedsLocatie=GetWedsLocatie (inTeam);
 if (strWedsLocatie!=document.getElementById('divWedsLocatie').innerHTML)
  {document.getElementById('divWedsLocatie').innerHTML=strWedsLocatie;}
}

function VulWedsLocDefault ()
{if (strWedsLocatieDefault=='')
   {aDatum=WedsCat1[0][4]; j=0;
    for (i in WedsCat1)
      {if (WedsCat1[i][4] <= aDatum)
         {aDatum=WedsCat1[i][4];j=i;}}
    strWedsLocatieDefault=GetWedsLocatie (WedsCat1[j][3]);
   }
 if (strWedsLocatieDefault!=document.getElementById('divWedsLocatie').innerHTML)
   {document.getElementById('divWedsLocatie').innerHTML=strWedsLocatieDefault;}
}

function VulSetstanden (i)
{arrUitslag=Wedstrijd[i][7].split(',');
 aStreep = '<span class="smallspace2"> - </span>'
 return '<table border="0"><tr>' +
        '<td class="setstand123">' + arrUitslag[0] + aStreep + arrUitslag[1] + '</td>' +
        '<td class="setstand123">' + arrUitslag[2] + aStreep + arrUitslag[3] + '</td>' +
        '<td class="setstand123">' + arrUitslag[4] + aStreep + arrUitslag[5] + '</td>' +
        '<td class="setstand4">'   + arrUitslag[6] + aStreep + arrUitslag[7] + '</td></tr></table>';}

   // Array Uitslag
   //  0 = ronde
   //  1 = team thuis
   //  2 = team uit
   //  3 = datum gespeeld
   //  4 = set 1 punten thuis
   //  5 = set 1 punten uit
   //  6 = set 2 punten thuis
   //  7 = set 2 punten uit
   //  8 = set 3 punten thuis
   //  9 = set 3 punten uit
   // 10 = set 4 punten thuis
   // 11 = set 4 punten uit
   // 12 = puntaftrek team thuis
   // 13 = puntaftrek team uit
   // 14 = commentaar

function VulUitslagen ()
{WedsCat1=new Array();
 WedsCat2=new Array();
 WedsCat3=new Array();
 DatumNu=strVandaag;
 telCat1=-1;
 telCat2=-1;
 telCat3=-1;
 for (i in Stand)
   {if (Stand[i][10] == 'J')
     {TeamNum=i;}}
 for (i in Wedstrijd)
   {if (Wedstrijd[i][3] == TeamNum || Wedstrijd[i][4] == TeamNum)
      {if (Wedstrijd[i][3] == TeamNum)
         {aWedstrijdWaar = 'T';
          aTeamTegen = Wedstrijd[i][4];
         }
       else
         {aWedstrijdWaar = 'U';
          aTeamTegen = Wedstrijd[i][3];
         }
       for (j in Stand)
         {if (Stand[j][11] == aTeamTegen)
            {aRankTegenStander=parseInt(j)+1;}}

       if (Wedstrijd[i][0] == '1') // Geplanned
         {
          telCat1++;
          WedsCat1[telCat1]=new Array(0);
          WedsCat1[telCat1][0]=Wedstrijd[i][1];               // Ronde
          WedsCat1[telCat1][1]=Team.Naam(Wedstrijd[i][3]);    // Naam Team Thuis
          WedsCat1[telCat1][2]=Team.Naam(Wedstrijd[i][4]);    // Naam Team Uit
          WedsCat1[telCat1][3]=Wedstrijd[i][3];               // Nummer Team Thuis
          WedsCat1[telCat1][4]=Wedstrijd[i][6];               // Speeldatum yyyymmdd
          WedsCat1[telCat1][5]=DatumNaarStr(Wedstrijd[i][6]); // Speeldatum dd-mm-yyyy
          WedsCat1[telCat1][6]=aRankTegenStander;             // Ranking
          WedsCat1[telCat1][7]=aWedstrijdWaar;                // Thuis / Uit
          WedsCat1[telCat1][8]=Wedstrijd[i][10];              // Commentaar
         }
    
       if (Wedstrijd[i][0] == '2') // Gespeeld, uitslag onbekend
         {
          telCat2++;
          WedsCat2[telCat2]=new Array(0);
          WedsCat2[telCat2][0]=Wedstrijd[i][1];               // Ronde
          WedsCat2[telCat2][1]=Team.Naam(Wedstrijd[i][3]);    // Naam Team Thuis
          WedsCat2[telCat2][2]=Team.Naam(Wedstrijd[i][4]);    // Naam Team Uit
          WedsCat2[telCat2][3]=Wedstrijd[i][3];               // Nummer Team Thuis
          WedsCat2[telCat2][4]=Wedstrijd[i][6];               // Speeldatum yyyymmdd
          WedsCat2[telCat2][5]=DatumNaarStr(Wedstrijd[i][6]); // Speeldatum dag dd-mm-yyyy
          WedsCat2[telCat2][6]=aRankTegenStander;             // Ranking
          WedsCat2[telCat2][7]=aWedstrijdWaar;                // Thuis / Uit
          WedsCat2[telCat2][8]=Wedstrijd[i][10];              // Commentaar
         }
    
       if (Wedstrijd[i][0] == '3') // Gespeeld, uitslag bekend
         {Resultaat = new objUitslag (Wedstrijd[i][6], Wedstrijd[i][7], Wedstrijd[i][8], Wedstrijd[i][9]);
          if (Wedstrijd[i][3] == TeamNum)
            {aWaarGespeeld = 'T';
             aSetVoor   = Resultaat.puntenVoor;
             aSetTegen  = Resultaat.puntenTegen;
             aSetSaldo  = parseInt(aSetVoor) - parseInt(aSetTegen);
             aSetPunt   = Resultaat.SetPuntV;
             aSetPuntV  = Resultaat.SetPuntV;
             aSetPuntT  = Resultaat.SetPuntT;
						 aTeamTegen = Wedstrijd[i][4];
            }
          else
            {aWaarGespeeld = 'U';
             aSetVoor   = Resultaat.puntenTegen;
             aSetTegen  = Resultaat.puntenVoor;
             aSetSaldo  = parseInt(aSetVoor) - parseInt(aSetTegen);
             aSetPunt   = Resultaat.SetPuntT;
             aSetPuntV  = Resultaat.SetPuntV;
             aSetPuntT  = Resultaat.SetPuntT;
						 aTeamTegen = Wedstrijd[i][3];
            }
          for (j in Stand)
            {if (Stand[j][11] == aTeamTegen)
               {aRankTegenStander=parseInt(j)+1;}}

          telCat3++;
          WedsCat3[telCat3]=new Array(0);
          WedsCat3[telCat3][0]=Wedstrijd[i][1];               // Ronde
          WedsCat3[telCat3][1]=Team.Naam(Wedstrijd[i][3]);    // Thuis
          WedsCat3[telCat3][2]=Team.Naam(Wedstrijd[i][4]);    // Uit
          WedsCat3[telCat3][3]=aSetPuntV + ' - ' + aSetPuntT; // Uitslag
          WedsCat3[telCat3][4]=VulSetstanden(i);              // Setstanden
          WedsCat3[telCat3][5]=aRankTegenStander;             // Ranking
          WedsCat3[telCat3][6]=aSetPunt;                      // Punten
          WedsCat3[telCat3][7]=aSetSaldo;                     // Saldo
          WedsCat3[telCat3][8]=aWedstrijdWaar;                // Thuis / Uit
          WedsCat3[telCat3][9]=Wedstrijd[i][6];               // Speeldatum yyyymmdd
          WedsCat3[telCat3][10]=DatumNaarDDMM(Wedstrijd[i][6]); // Speeldatum dag dd-mm
         }
      }
   }

 strWedsLocatieDefault='';
 aLeftTop = (/msie/i.test(navigator.userAgent)) ? 53 : 67;   // Indien IE dan 53, de rest 67
 aLeftPos = (/msie/i.test(navigator.userAgent)) ? 260 : 450; // Indien IE dan 260, de rest 450
 result='<table border="0" class="parenttable"';

 if (WedsCat1.length > 0)
   result+='<tr class="parenttableheader"><td colspan="3">&nbsp;</td></tr>' +
           '<tr><td width="8px"></td><td class="parentheader">Nog te spelen door ' + Team.Naam(TeamNum) + '</td><td width="8px"></td></tr>' +
           '<tr><td></td><td align="left" valign="top" style="text-align:left;"><div id="divWedsGeplanned"></div></td><td></td></tr>';

 if (WedsCat2.length > 0)
   result+='<tr class="parenttableheader"><td colspan="3">&nbsp;</td></tr>' +
           '<tr><td width="8px"></td><td class="parentheader">Niet verwerkte uitslagen van ' + Team.Naam(TeamNum) + '</td><td width="8px"></td></tr>' +
           '<tr><td></td><td align="left" valign="top" style="text-align:left;"><div id="divWedsZoUitslag"></div></td><td></td></tr>';

 if (WedsCat3.length > 0)
   result+='<tr class="parenttableheader"><td colspan="3">&nbsp;</td></tr>' +
           '<tr><td width="8px"></td><td class="parentheader">Gespeelde wedstrijden van ' + Team.Naam(TeamNum) + '</td><td width="8px"></td></tr>' +
           '<tr><td></td><td align="left" valign="top" style="text-align:left;"><div id="divWedsGespeeld"></div></td><td></td></tr>';

 result+='<tr class="parenttablefooter"><td colspan="3" class="parentfooter"></td></tr></table>' +
         '<div id="divWedsLocatie" style="position: absolute; top:' + aLeftTop +'; left:' + aLeftPos +'; cursor:move;" onmousedown="dragOBJ(this,event); return false;"></div>';
 document.getElementById("Overzicht").innerHTML=result;
 document.getElementById("divComment").style.display='none';
 document.getElementById("divUitslag").style.display='none';

 if (WedsCat1.length > 0) {SortWedsCat1 (2);}
 if (WedsCat2.length > 0) {ShowWedsCat2 ();}
 if (WedsCat3.length > 0) {SortWedsCat3 (1);}
}

// Wedstrijden die nog geplanned zijn
function ShowWedsCat1 ()
{if (WedsCat1.length > 0)
   {aTelComm=0;
    for (i in WedsCat1)
      if (WedsCat1[i][8]!='') {aTelComm++;}
    resWedsCat1='<table class="childtable" border="1" >' +
                '<tr bgcolor="siena" color="yellow">';
    //alert('Aantal='+ WedsCat1.length);
    if (WedsCat1.length > 1)
      {resWedsCat1+='<th><a href="" onClick="SortWedsCat1(1);return false;">Rnd</a></th>' +
                    '<th align="left">Thuis</th>' +
                    '<th align="left">Uit</th>' +
                    '<th nowrap><a href="" onClick="SortWedsCat1(2);return false;">Te spelen op</a></th>';}
    else
      {resWedsCat1+='<th>Rnd</th>' +
                    '<th align="left">Thuis</th>' +
                    '<th align="left">Uit</th>' +
                    '<th nowrap="nowrap">Te spelen op</th>';}
    resWedsCat1+=(aTelComm>0) ? '<th>Opmerking</th></tr>' : '</tr>';
    //alert('Geteld commentaar: ' + aTelComm);
    for (i in WedsCat1)
      {kleur=(i % 2 == 0) ? '#FFFFFF' : '#F5F6FB';
       resWedsCat1+='<tr bgcolor="' + kleur + '" onMouseOver="VulWedsLocatie(' + WedsCat1[i][3] + ');" onMouseOut="VulWedsLocDefault();">' +
                    '<td>' + WedsCat1[i][0]+'</td>' +
                    '<td nowrap="nowrap" style="text-align:left">' + WedsCat1[i][1] + '</td>' +
                    '<td nowrap="nowrap" style="text-align:left">' + WedsCat1[i][2] + '</td>' +
                    '<td style="text-align:right">' + WedsCat1[i][5] + '</td>';
       resWedsCat1+=(aTelComm>0) ? '<td style="text-align:left">' + WedsCat1[i][8] + '</td></tr>' : '</tr>';
      }
    resWedsCat1+='</table>';
    document.getElementById("divWedsGeplanned").innerHTML=resWedsCat1;
   }
}

// Wedstrijden die wel gespeeld zijn, maar waarvan nog geen uitslag bekend is
function ShowWedsCat2 ()
{if (WedsCat2.length > 0)
   {aTelComm=0;
    for (i in WedsCat2)
      if (WedsCat2[i][8]!='') {aTelComm++;}
    resWedsCat2='<table class="childtable" border="1"><tr bgcolor="siena" color="yellow">';
    //alert('Aantal='+ WedsCat2.length);
    //if (WedsCat2.length > 1)
    //  {resWedsCat2+='<th><a href="" onClick="SortWedsCat2(1);return false;">Rnd</a></th>' +
    //                '<th align="left">Thuis</th>' +
    //                '<th align="left">Uit</th>' +
    //                '<th><a href="" onClick="SortWedsCat2(2);return false;">Gespeeld op</a></th>';}
    //else
    {resWedsCat2+='<th>Rnd</th>' +
                  '<th align="left">Thuis</th>' +
                  '<th align="left">Uit</th>' +
                  '<th>Gespeeld op</th>';}
    resWedsCat2+=(aTelComm>0) ? '<th>Opmerking</th></tr>' : '</tr>';
    for (i in WedsCat2)
      {kleur=(i % 2 == 0) ? '#FFFFFF' : '#F5F6FB';
       resWedsCat2+='<tr bgcolor="' + kleur + '"><td>' + WedsCat2[i][0]+'</td>' +
                    '<td nowrap="nowrap" style="text-align:left">' + WedsCat2[i][1] + '</td>' +
                    '<td nowrap="nowrap" style="text-align:left">' + WedsCat2[i][2] + '</td>' +
                    '<td style="text-align:right">' + WedsCat2[i][5] + '</td>';
       resWedsCat2+=(aTelComm>0) ? '<td style="text-align:left">' + WedsCat2[i][8] + '</td></tr>' : '</tr>';
      }
    resWedsCat2+='</table>';
    document.getElementById("divWedsZoUitslag").innerHTML=resWedsCat2;
   }
}

// Wedstrijden die al gespeeld zijn
function ShowWedsCat3 ()
{if (WedsCat3.length > 0)
   {if (WedsCat3.length > 1)
      resWedsCat3='<table class="childtable" border="1"><tr bgcolor="siena" color="yellow">' + // #FF0000
                  '<th><a href="" onClick="SortWedsCat3(1);return false;">Datum</a></th>' +
                  '<th align="left">Thuis</th>' +
                  '<th align="left">Uit</th>' +
                  '<th>Uitslag</th>' +
                  '<th>Setstanden</th>' +
                  '<th><a href="" onClick="SortWedsCat3(2);return false;">Rang</a></th>' +
                  '<th><a href="" onClick="SortWedsCat3(3);return false;">Punten</a></th>' +
                  '<th>Saldo</th>' +
                  '</tr>';
    else
      resWedsCat3='<table class="childtable" border="1"><tr bgcolor="siena" color="yellow">' + // #FF0000
                  '<th>Datum</th>' +
                  '<th align="left">Thuis</th>' +
                  '<th align="left">Uit</th>' +
                  '<th>Uitslag</th>' +
                  '<th>Setstanden</th>' +
                  '<th>Rang</th>' +
                  '<th>Punten</th>' +
                  '<th>Saldo</th>' +
                  '</tr>';
    for (i in WedsCat3)
      {kleur=(i % 2 == 0) ? '#FFFFFF' : '#F5F6FB';
       resWedsCat3+='<tr bgcolor="' + kleur + '"><td>' + WedsCat3[i][10]+'</td>' +
                    '<td nowrap="nowrap" style="text-align:left">' + WedsCat3[i][1] + '</td>' +
                    '<td nowrap="nowrap" style="text-align:left">' + WedsCat3[i][2] + '</td>' +
                    '<td style="text-align:center">' + WedsCat3[i][3] + '</td>' +
                    '<td style="text-align:left" nowrap>' + WedsCat3[i][4] + '</td>' +
                    '<td>' + WedsCat3[i][5] + '</td>' +
                    '<td>' + WedsCat3[i][6] + '</td>' +
                    '<td>' + WedsCat3[i][7] + '</td>' +
                    '</tr>';
      }
    resWedsCat3+='</table>';
    document.getElementById("divWedsGespeeld").innerHTML=resWedsCat3;
  }
}

function ShowAlleWedstrijden ()
{resWedstrijd='';
 if (Wedstrijd.length>0)
   {var aWeek = '';
    var aTel=0;
    SortWedstrijd (2);
    resWedstrijd='<table class="alleweds" border="0">';
    for (i in Wedstrijd)
      {if (Wedstrijd[i][2] != aWeek)
         {if (aWeek != '') resWedstrijd+='<tr><td colspan="5">&nbsp;</td></tr><tr><td colspan="5">&nbsp;</td></tr>';
          resWedstrijd+='<tr><td colspan="5" class="redtitle">Programma / Uitslagen week ' + Wedstrijd[i][2] + '</td></tr>';
          resWedstrijd+='<tr><td width="120" class="redhead">Thuis</td><td width="6">&nbsp;</td><td width="120" class="redhead">Uit</td><td width="42" class="reduitslag">Uitslag</td><td width="280">&nbsp;</td></tr>';
          aWeek=Wedstrijd[i][2];
          aTel = 0;
         }
       aTel++;
       kleur=(aTel % 2 == 0) ? '#FFFFFF' : '#FFCCFF';
       resWedstrijd+='<tr bgcolor="' + kleur + '">' +
                     '<td class="redcomic">' + Team.Naam(Wedstrijd[i][3]) + '</td>' +
                     '<td class="redcomic">-&nbsp;</td>' +
                     '<td class="redcomic">' + Team.Naam(Wedstrijd[i][4]) + '</td>';
       if (Wedstrijd[i][0]=='1')
         {resWedstrijd+='<td class="reduitslag">&nbsp;</td>' +
                        '<td class="redsetstand">' + DatumNaarStr(Wedstrijd[i][6]) + '</td></tr>';
         }
       if (Wedstrijd[i][0]=='2')
         {resWedstrijd+='<td class="reduitslag">&nbsp;</td>' +
                        '<td class="redsetstand">' + Wedstrijd[i][10] + '</td></tr>';
         }
       if (Wedstrijd[i][0]=='3')
         {Resultaat = new objUitslag (Wedstrijd[i][6], Wedstrijd[i][7], Wedstrijd[i][8], Wedstrijd[i][9]);
          resWedstrijd+='<td class="reduitslag" nowrap="nowrap">' + Resultaat.SetPuntV + ' - ' + Resultaat.SetPuntT + '</td>' +
                        '<td class="redsetstand" nowrap="nowrap">' + VulSetstanden(i) + '</td></tr>';
         }
      }
    resWedstrijd+='</table>'
   }
 document.getElementById("Team").innerHTML='';
 document.getElementById("Stand").innerHTML=resWedstrijd;
 document.getElementById("Overzicht").innerHTML='';
 document.getElementById("divComment").style.display='none';
 document.getElementById("divUitslag").style.display='none';
}

