//////////////////////////////////////////////////////////////
//  cgws.js  contains function cgws()  counts to gws match  //
//////////////////////////////////////////////////////////////

var  gwsq = '',  gwss = '',  gwsi = 0,  gwsh = [0, 0, 0, 0, 0];  // YYYY, MM, DD, hh, mm
var  gwswd = ['', 'Mo ', 'Di ', 'Mi ', 'Do ', 'Fr ', 'Sa ', 'So '],  gwsdd = '',  gwsdi = 0;
var  gwshu = 0,  gwstu = 0,  gwsxu = 0;  // utc milliseconds
var  gwsx = [0, 0];  // hours minutes remaining

function cgws()
{ this.document.open();
  gwss = '<div>Das Gr&uuml;nwalder ruft !!!</div>';  document.write(gwss);
  gwss = '<div id="u23">unterst&uuml;tzt unsere U-23!</div>';  document.write(gwss);
  gwss = '<div id="mdt">... ... ...</div>';  document.write(gwss);
  if  (gwf > 0)  { cgwsd(); };  //  flag gwf called from azdat.js
  document.close();  gwss = '';
}  // end cgws;
//
function ctermx()
{ var  cxarray = [x01, x02, x03, x04, x05, x06, x07, x08, x09, x10];
  gwss = '<hr /><h5>TERMINE</h5><hr />';
  for  (gwsi = 0;  gwsi < 10;  gwsi++)
  { gwsq = cxarray[gwsi];
    if  (gwsq.length > 1)
    { gwsq = '<p>'.concat(gwsq);  gwsq = gwsq.concat('</p>');  gwss = gwss.concat(gwsq); };
  };  // end for
  gwss = gwss.concat('<hr />');
  this.document.open();  document.write(gwss);  document.close();
  gwss = '';  gwsq = '';  cxarray = '';
}  // end ctermx;
//
function cgwsd()
{ var  tdate = new Date();
  gwstu = tdate.getTime();  // current time
  gwsi = gwstu / 60000;  gwsi = parseInt(gwsi);  gwsi = gwsi * 60000;
  gwstu = gwsi;  // normalized to full minutes
  gwsi = gws[2];  // year of match
  if  (gwsi < 2000)  { gwsi += 2000; };  gwsh[0] = gwsi;
  gwsh[1] = gws[1] - 1;  // month (0..11)
  gwsh[2] = gws[0]  // day (1..31)
  gwsh[3] = gws[3] - gwf;  // uct hour (gwf: summer/winter, 2/1)
  gwsh[4] = gws[4]  // minute
  gwsth = Date.UTC(gwsh[0], gwsh[1], gwsh[2], gwsh[3], gwsh[4], 0);
  gwstx = gwsth - gwstu;  // remaining ms; calc hr and min; leave if negative
  if  (gwstx >= 0)
  { gwsi = gwstx / 3600000;  gwsi = parseInt(gwsi);  gwsx[0] = gwsi;
    gwsi = gwstx / 60000;  gwsi = parseInt(gwsi);  gwsi =  gwsi % 60;  gwsx[1] = gwsi;
    gwss = 'Heimspiel in ';  gwss = gwss.concat(gwsx[0]);  gwss = gwss.concat(' h ');
    gwss = gwss.concat(gwsx[1]);  gwss = gwss.concat(' min');
    gwsq = document.getElementById('u23');  gwsq.firstChild.nodeValue = gwss;
    gwsdi = gws[5];  if  ((gwsdi < 1) || (gwsdi > 7))  { gwsdi = 0; };  gwsdd = gwswd[gwsdi];
    gwss = '* '.concat(gwsdd);  gwss = gwss.concat(gws[0]);  gwss = gwss.concat('. ');
    gwss = gwss.concat(gws[1]);  gwss = gwss.concat('. ');  gwss = gwss.concat(gws[2]);
    gwss = gwss.concat(' / ');  gwss = gwss.concat(gws[3]);  gwss = gwss.concat('.');
    if  (gws[4] < 10)  { gwss = gwss.concat('0'); };
    gwss = gwss.concat(gws[4]);  gwss = gwss.concat(' *');
    gwsq = document.getElementById('mdt');  gwsq.firstChild.nodeValue = gwss; }
  else  { return };  // end if
  gwsq = '';  window.setTimeout('cgwsd()', 120000);
}  // end cgwsd;

//////////////////////////////////////////////////////////////

