// Developped by rob.stoekenbroek@openit.demon.nl
var timeOut;
var piccnt, pichor;
var agendaStyle;
var newsStyle;
var monthName;
  monthName = Array("Jan","Feb","Mar","Apr","Mei","Jun","Jul","Aug","Sep","Okt","Nov","Dec");
var dayName;
  dayName = Array("Zo","Ma","Di","Wo","Do","Vr","Za");

var sepString = "&middot;&middot;&middot;&nbsp;&nbsp;"+
  "<img src='image/scr-bul.gif' align='top'><img src='image/scr-bul.gif' align='top'><img src='image/scr-bul.gif' align='top'>&nbsp;"

function enableTimeout() {
  window.clearTimeout(timeOut)
  timeOut = window.setTimeout("timedRefresh()",300);
}

function timedRefresh() {
//  parent.history.go(0);
// var SetMenu = "0"
//  parent.location.replace = 'index.html?' + parent.main.document.URL.substr(parent.main.document.URL.lastIndexOf("/")+1)
  RePos()
  resizeSlidingText()
//  parent.history.go(0)
}

function windowWidth() {
  if (window.innerWidth == null) {
    return document.body.clientWidth;}
  else {
    return window.innerWidth;}
}

function pageBegin(heading,number) {
  if((parent == self) & (self.name!='link')){
    location = 'index.html?' + document.URL.substr(document.URL.lastIndexOf("/")+1)
    return 0
  }
  else {
    if (number == undefined) {number = 0}
				parent.idxCurrent = number
    document.write("<base target='_self'></head><body>")
    if(heading != null) {
      document.write ("<H1 id='top'>" + heading + "</H1>")}
    if (document.location.search.length >2) {
      return 0}
    else {
      return document.location.search.substr(1)}
  }
}

function drawLine() {
  document.write ("<div class='center'>")
  document.write ("<br><a href='#top'><img class='flat' src='image/divider.gif' alt='top' width=100% height='2'></A>")
  document.write ("</div>")
}

function dividerLine(){
  wwidth = windowWidth()
  document.write('<img class="flat" src="image/divider.gif" alt="" width="' + (wwidth-50) + '" height="2">')
}

function drawFinal(whereTo) {
  document.write ("<div class='center'>")
  document.write ("<br><a href='" + whereTo + "'><img class='flat' src='image/final.gif' alt='top' width='200' height='4'></A>")
  document.write ("</div>")
}

function pageEnd(status,image,scroll) {
  if(parent.footer.logo != undefined) {
    if(image != null) {
      if (image != "") {
        parent.footer.logo.src = 'image/' + image}
      else {
        parent.footer.logo.src = 'image/logo-blank.gif'}
      }
    else {
      parent.footer.logo.src = 'image/logo-sgo.gif'
    }
  }
  if(scroll != null) {parent.titel.restartSlidingText(scroll)}
  if(status != null)
    {defaultStatus=status}
  else
    {defaultStatus=""}
  drawFinal('#top')
  document.write("</body></html>")
}

function randomOrder(maxVal){
  return Math.round(Math.random()* (maxVal-1) +1)
}

function dateUpdated(dateDisplay){
  date = new Date(dateDisplay);
  return(date.getDate() + "-" + monthName[(date.getMonth())] + "-" + date.getYear());
}

function liContact(name,naw,email){
  document.write ("<li>" + name + " &ndash; " + naw)
  if(email != null) {
    document.write (", <a href='mailto:" + email + "?subject=COVS Gouda'><img src='image/mailto.gif' alt='" + email + "' width='18' height='11' hspace='0' vspace='0' align='middle' style='border: none;'></a>")
  }
  document.write ("</li>")
}

function liAgendaStart(style) {
  agendaStyle = style
  document.write ("<table border='0' cellspacing='2' cellpadding='0'><tr align='left'><th width='110'>Datum</th><th>Activiteit</th></tr>")
}

function liAgenda(theDate,theMonth,theYear,text){
  todaysDate = new Date();
  actionDate = new Date(theYear,theMonth-1,theDate);
  futureEvent = Number(actionDate-todaysDate) >= 0.0

  if (futureEvent || agendaStyle != 'future') {
    document.write ("<tr valign='top'><td>" + dayName[actionDate.getDay()] + " " + actionDate.getDate() + " " + monthName[actionDate.getMonth()])
    if (todaysDate.getFullYear() != actionDate.getFullYear()) {
      document.write (" " + actionDate.getFullYear())
    }
    document.write ("</td><td>" + text + "</td></tr>")
  }
}

function liAgendaEnd() {
  document.write ("</table>")
}

function mailTO(email) {
  if(email != "") {
    return "Email: <a href='mailto:" + email + "'</a>" + email + "</a>"
  }
  else {
    return ""
  }
}

function telNumber(number) {
  if(number != "") {
    return "Tel.: " + number + "&nbsp;&nbsp;"
  }
  else {
    return ""
  }
}

function imgPortret(alias) {
  if(alias != "") {
    return "<img src='portret/" + alias + ".jpg' alt='' width='60' height='80' class='framed'>"
  }
  else {
    return "&nbsp;"
  }
}

function liContactStart() {
  document.write ("<table width='80%' border='0' cellspacing='0' cellpadding='0'>")
}

function liContact(naam,adres,telefoon,emailadres,alias) {
  if(alias != "") {
    document.write("<a href=#" + alias + ">") }
  document.write("<tr><td width='90%' valign='bottom'><h3><a name='" + alias + "'>" + naam + "</a></h3</td>")
  document.write("<td height='85' rowspan='2'>" + imgPortret(alias) + "</td></tr>")
  document.write("<tr><td valign='top'>" + adres + "<br>" + telNumber(telefoon) + mailTO(emailadres) + "</td></tr>")
}

function liName(naam) {
  document.write("<tr><td valign='top'><h3>" + naam + "</h3</td></tr>")
}

function liContactEnd() {
  document.write ("</table>")
}

function itemDate(theDate) {
  return dayName[theDate.getDay()] + " " + theDate.getDate() + " " + monthName[theDate.getMonth()] + " " + theDate.getFullYear()
}

function newsStart(style) {
  newsStyle = style
}

function newsItem(starting,ending,head,leader) {
  todaysDate = new Date();
  startingDate = new Date(starting.substr(4,4),starting.substr(2,2)-1,starting.substr(0,2));
  endingDate = new Date(ending.substr(4,4),ending.substr(2,2)-1,ending.substr(0,2));
//  validItem = (Number(todaysDate-startingDate) >= 1.0) && (Number(endingDate-todaysDate) >= 1.0)

  if (newsStyle != 'current') {
    validItem = true}
		else {
    validItem = Number(endingDate-todaysDate) >= 1.0}
  if (validItem) {
    document.write ("<h2>" + head + "</h2>")
    document.write (itemDate(startingDate) + "&nbsp;&ndash;&nbsp;")
    document.write (leader + "<a href='" + starting + ".html?" + head + "'><img src='image/meer.gif' alt='lees verder' width=15 height=10 border=0 align='middle'></a>")
  }
}

function newsItemBack(text) {
var message = ''
if(text != null) {
    message = text }
  else {
    message = 'terug naar het overzicht'
  }
  document.write ("<a href='javascript:history.back()'><img src='image/terug.gif' alt='" + message + "' width=15 height=10 border=0 align='middle'></a>")
}

function showNote() {
  document.write ("<a href='regel08.html#bijz'><img src='image/note.gif' alt='Tenzij vallend onder Bijzondere Omstandigheden' width=15 height=10 border=0 align='middle'></a>")
}


// Return string padded with leading zeroes
function pZ(num, totalLen) {
var numStr = num.toString() // Initialize return value as string
var numZeros = totalLen - numStr.length // Calculate no. of zeros
  if (numZeros > 0) {
    for (var i = 1; i <= numZeros; i++) {numStr = "0" + numStr}
  }
  else {
    numStr = numStr.substr(Math.abs(numZeros),totalLen)
		}
		return numStr
}

function indexSpelregels() {
document.write("Terug naar de 17 (spel)regels.")
document.write("<a href='regel00.html'>")
document.write("<img src='image/terug.gif' alt='spelregeloverzicht' width='15' height='10' border='0' align='middle'></a>")
}

function idxListEntries(start,width,name,entries) {
var idxNumber
	 idxStart = start;
  idxWidth = width;
  idxName = name;
	 for (i=0; i<entries.length; i++) {
    if  (entries[i] != undefined) {idxTitle = entries[i]}
				else {idxTitle = ""}
    idxNumber = idxStart+i
				if (idxNumber != parent.idxCurrent) {
  				document.write(" <a href='javascript:idxGo(" + idxNumber +",\"" + idxName + 
		  		pZ(idxNumber,idxWidth) + ".html\")' title='" + idxTitle + "'>" + eval(idxNumber) + "</a>")
						}
    else {
				  document.write(" " + idxNumber)
				}
	 }
}

function idxGo(number,dest) {
//  parent.idxCurrent = number
  location = dest;
}
function listJaargangen() {
var history = new Array(25)
		document.write("Naar jaargang.")
		document.write("<a href='javascript:history.back()'>")
		document.write("<img src='image/terug.gif' alt='terug' width='15' height='10' border='0' align='middle'></a>")
  idxListEntries(1985,4,"jaargang",history)
}
function listRegels(){
var spelregels = new Array (
		"Het speelveld",
		"De bal",
		"Het aantal spelers",
		"Uitrusting van de spelers",
		"De scheidsrechter",
		"Assistent-scheidsrechters",
		"Duur van de wedstrijd",
		"Begin en hervatting van het spel",
		"De bal in en uit het spel",
		"Hoe er wordt gescoord",
		"Buitenspel",
		"Overtredingen en onbehoorlijk gedrag",
		"De vrije schoppen",
		"De strafschop",
		"De inworp",
		"De doelschop",
		"De hoekschop")
		document.write("Naar andere (spel)regel.")
		document.write("<a href='javascript:history.back()'>")
		document.write("<img src='image/terug.gif' alt='terug' width='15' height='10' border='0' align='middle'></a>")
  idxListEntries(1,2,"regel",spelregels)	
}

function setCookie(name, value, expire) {
  document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

function getCookie(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { // if there are any cookies
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length // set index of beginning of value
      end = document.cookie.indexOf(";", offset) // set index of end of cookie value
      if (end == -1) end = document.cookie.length
      return unescape(document.cookie.substring(offset, end)) 
		  }
		}
}

function vraagGo(vervolg) {
//  vraag.location = "http://openit.demon.nl/diagonaal/vragen.asp?" + vervolg
  vraag.location = "http://stoekenbroek.com/diagonaal/vragen.php?" + vervolg
}


function initPage() {
var iw;
  piccnt=0; pichor=0;
  
  if (window.innerWidth == null) {
    iw=document.body.clientWidth - 200;
  }
  else {
  iw=window.innerWidth - 200;
  }
  pichor = parseInt(iw/95);
  return true;
}

function showPhoto(file) {
  location = "foto.html?" + file;
}

function showThumb(file) {
  if (piccnt%pichor==0) {
    document.write ("<tr align='center' valign='top'>");
  }
  piccnt = piccnt+1;
  document.write ("<td><font size='-2'>" + file +"</font><br><A HREF=\"javascript:showPhoto('" + file + ".jpg')\"><IMG class='framed' onClick=\"showPhoto('" + file + ".jpg')\" alt='Vergroting...' src='fotos/klein/" + file + ".jpg'></A></td>")
  if (piccnt%pichor==0) {
    document.write ("</tr>");
  }
}

function initBody() {
  document.write("<body onResize='initPage()'>")
  document.write("<A NAME='top'></A>")
  defaultStatus = 'Muisklik toont vergroting, klik dan nogmaals om terug te gaan naar de reportage'
}


