// JavaScript hcwinsum.js
// modified: August 28, 2010

// *** style switcher ***
// http://www.alistapart.com/articles/alternate/

var fly = 0.2
var today = new Date()
var cookie1 = readCookie("style")
var cookie2 = readCookie("last")
var cookie3 = readCookie("lock")
var title = cookie1 ? cookie1 : getPreferredStyleSheet()
var lastvisit = cookie2 ? new Date(cookie2) : "unknown"

if (lastvisit != "unknown")
  lastvisit = Math.round((today - lastvisit)/(24*60*60*1000))
setActiveStyleSheet(title)

function setActiveStyleSheet(title) {
  var i, a

  for (i = 0; (a = document.getElementsByTagName("link")[i]); i++)
    if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true
      if (a.getAttribute("title") == title)
        a.disabled = false
    }
}

function getActiveStyleSheet() {
  var i, a

  for (i = 0; (a = document.getElementsByTagName("link")[i]); i++)
    if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled)
      return a.getAttribute("title")
  return null
}

function getPreferredStyleSheet() {
  var i, a

  for (i = 0; (a = document.getElementsByTagName("link")[i]); i++)
    if (a.getAttribute("rel").indexOf("style") != -1
      && a.getAttribute("rel").indexOf("alt") == -1
      && a.getAttribute("title"))
      return a.getAttribute("title")
  return null
}

function createCookie(name, value, days) {
  if (days) {
    var date = new Date()
    date.setTime(date.getTime() + (days*24*60*60*1000))
    var expires = "; expires=" + date.toGMTString()
  }
  else
    var expires = ""
  document.cookie = name + "=" + value + expires + "; path=/"
}

function readCookie(name) {
  var nameEQ = name + "="
  var ca = document.cookie.split(';')

  for (var i = 0; i < ca.length; i++) {
    var c = ca[i]
    while (c.charAt(0) == ' ')
      c = c.substring(1, c.length)
    if (c.indexOf(nameEQ) == 0)
      return c.substring(nameEQ.length, c.length)
  }
  return null
}

window.onload = function(e) {
  var cookie = readCookie("style")
  var title = cookie ? cookie : getPreferredStyleSheet()

  setActiveStyleSheet(title)
  try { birthday(today) } catch(e) {}
}

window.onunload = function(e) {
  var title = getActiveStyleSheet()
  var date = new Date()

  createCookie("style", title, 30)
  if (cookie3)
    createCookie("last", date, 30)
  else 
    createCookie("lock", "on", 0.0005)
}

function getroot(depth) {
  var root = ""

  if (depth)
    root = '../' + getroot(depth - 1)
  return root
}

// *** validator ***

function showvalidator(depth) {
  var gif = "gifs/vh40.gif"
  var str = ''

  document.write('<a href="http://validator.w3.org/check?uri=referer">' +
    '<img border=0 src="' + getroot(depth) + gif +
    '" height="31" width="88" alt="Valid HTML 4.0!"></a><br>')
  if (lastvisit == "unknown")
    str += '<br>Laatste bezoek onbekend'
  else if (lastvisit == 1)
      str += '<br>Laatste bezoek<br>een dag geleden'
  else if (lastvisit > 1)
      str += '<br>Laatste bezoek<br>' + lastvisit + ' dagen geleden'
  document.write(str)
}

// *** picture ***

function showpicture(depth) {
  var gif = "gifs/logoklein.gif"

  document.write('<img src="' + getroot(depth) + gif + '" width="150" alt="clublogo">')
}

// *** sponsor ***

function showlogo(depth) {
  var i, j, gif1="gifs/dog.gif", gif2 = "gifs/18_3_110[1].gif"
  var sponsorLength = 7
  var cell1 = new Array(sponsorLength)
  var cell2 = new Array(sponsorLength)
  var linkURL = new Array(sponsorLength)
  var linkLogo = new Array(sponsorLength)

  linkURL[0] = sponsorLength
  linkURL[1] = "http://www.hockeycenter.nl/"
  linkURL[2] = "http://www.fortis.nl/"
  linkURL[3] = "http://www.rabobank.nl/particulieren/"
  linkURL[4] = "http://www.mazda6.nl/"
  linkURL[5] = "http://www.dtz.nl/"
  linkURL[6] = "http://maps.google.nl/maps?hl=nl&um=1&ie=UTF-8&q=visser+verdoes+winsum"
//  linkURL[2] = "http://www.flexibility.nl/"
//  linkURL[4] = "http://www.winsum.nl/"
//  linkURL[8] = "http://www.moekevaatstra.nl"
  linkLogo[0] = sponsorLength
  linkLogo[1] = "sponsor/HockeyCenter.jpg"
  linkLogo[2] = "sponsor/FortisBank.gif"
  linkLogo[3] = "sponsor/rabobanklogo.gif"
  linkLogo[4] = "sponsor/TerpstraMazda.gif"
  linkLogo[5] = "sponsor/Zadelhoff.gif"
  linkLogo[6] = "sponsor/VisserVerdoes.gif"
//  linkLogo[2] = "sponsor/flexibility.gif"
//  linkLogo[8] = "sponsor/moekevaatstra.gif"
//  linkLogo[4] = "sponsor/gemeentewinsum.gif"

  i = 1
  while (i < sponsorLength) {
    j = 1 + Math.floor(Math.random() * (sponsorLength - 1))
    if (linkURL[j] != "_selected!") {
      cell1[i] = linkURL[j]
      cell2[i] = linkLogo[j]
      linkURL[j] = "_selected!"
      i++
    }
  }
  document.write('<marquee scrollamount="2"' + 
    'onmouseover="this.stop()" onmouseout="this.start()">')
  document.write('<img src="' + getroot(depth) + gif1  + '" align="bottom" alt="emoticon">')
  for (i = 1; i < sponsorLength; i++)
    document.write('<a href="' + cell1[i] + '" target="sponsor"><img src="' + 
      getroot(depth) + cell2[i] + '" hspace="10" border="none"></a>')
  document.write(' &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; <img src="' +
    getroot(depth) + gif2  + '" align="bottom" alt="emoticon">')
  document.write('</marquee>')
}

// menu

function showmenu(depth, active) {
  var i
  var menuLength = 8
  var menuURL = new Array(menuLength)
  var menuText = new Array(menuLength)
  var aaaAction, aaaIcon, aaaMethod, aaaTitle

  title = getActiveStyleSheet()
  if (title == "printview") {
    document.write(
    'terug naar standaardweergave &nbsp;&nbsp;&nbsp;' +
    '<a href="#" onclick=setActiveStyleSheet("webview");location.reload(false)>' +
    '<img src="' + getroot(depth) +
    'gifs/print-off.png" border="none" alt="standaard weergave" title="standaardweergave"> </a>')
    return
  }

  menuURL[0] = menuLength
  menuURL[1] = "button0.html"
  menuURL[2] = "nieuws_10/nieuws_10_01/mededelingen.html"
//  menuURL[2] = "button1.html"
//  menuURL[3] = "button2.html"
  menuURL[3] = "button3.html"
  menuURL[4] = "button4.html"
  menuURL[5] = "button5.html"
  menuURL[6] = "button6.html"
  menuURL[7] = "button7.html"
  menuText[0] = menuLength
  menuText[1] = "hot news"
  menuText[2] = "programma"
  menuText[3] = "de club"
  menuText[4] = "veld"
  menuText[5] = "zaal"
  menuText[6] = "archief"
  menuText[7] = "links"

  aaaAction = (title == "webview") ? "aaaview" : "webview"
  aaaIcon = (title == "webview") ? "gifs/aaaview.png" : "gifs/webview.png"
  aaaMethod = 'setActiveStyleSheet("' + aaaAction + '");location.reload(false)'
  aaaTitle = (title == "webview") ? "weergave voor slechtzienden" : "standaardweergave" 
  document.write('<ul>')
  for (i = 1; i < menuLength; i++) {
    document.write('<li><a href="' + getroot(depth) + menuURL[i] + '"' )
    if (i == active)
      document.write(' id="activemenu"')
    document.write('>' + menuText[i] + '</a> ')
  }
  document.write(
    '<li title="printvriendelijke weergave">' +
    '<a href="#" onclick=setActiveStyleSheet("printview");location.reload(false)>' +
    '<img src="' + getroot(depth) + 'gifs/print-on.png" border="none" alt="printview"> </a>' +
    '<li title="' + aaaTitle + '"><a href="#" onclick=' + aaaMethod +
    '><img src="' + getroot(depth) + aaaIcon + '" border="none" alt="aaaview"> </a>' +
    '</ul>')
}

// *** submenu1 ***

function showsubmenu1(depth, active, title) {
  var i, gif="gifs/29_1_20[1].gif"
  var submenu1Length = 9
  var submenu1URL = new Array(submenu1Length)
  var submenu1Text = new Array(submenu1Length)

  submenu1URL[0] = submenu1Length
  submenu1URL[1] = "mededelingen.html"
  submenu1URL[2] = "programma.html"
  submenu1URL[3] = "fluiten.html"
  submenu1URL[4] = "kantinedienst.html"
  submenu1URL[5] = "uitslagen.html"
  submenu1URL[6] = "verslagen.html"
  submenu1URL[7] = "jeugdhonk.html"
  submenu1URL[8] = "club/training.html"
  submenu1Text[0] = submenu1Length
  submenu1Text[1] = "mededelingen"
  submenu1Text[2] = "wedstrijden"
  submenu1Text[3] = "fluiten"
  submenu1Text[4] = "kantinedienst"
  submenu1Text[5] = "uitslagen"
  submenu1Text[6] = "verslagen"
  submenu1Text[7] = "jeugdhonk"
  submenu1Text[8] = "training"

  document.write('<a name="" id="noclick">' + title + '</a> ')
  for (i = 1; i < submenu1Length; i++) {
    if (i == 8)
      document.write('<a href="' + getroot(depth) + submenu1URL[i] + '" target="winsum"' )
    else
      document.write('<a href="' + submenu1URL[i] + '"' )
    if (i == active)
      document.write(' id="activesubmenu"')
    document.write('>' + submenu1Text[i])
    if (i == 7)
      document.write(' &nbsp; <img src="' + getroot(depth) + gif +
        '" border="0" align="middle" alt="emoticon">')
    document.write('</a> ')
  }
  if (Math.random() < fly)
    document.write('<br><img src="' + getroot(depth) + 'gifs/vliegje.gif" alt="fly">')
}

// *** submenu 2 ***

//function showsubmenu2(depth, active) {
//  var i
//  var submenu2Length = 6
//  var submenu2URL = new Array(submenu2Length)
//  var submenu2Text = new Array(submenu2Length)

//  submenu2URL[0] = submenu2Length
//  submenu2URL[1] = "button2.html"
//  submenu2URL[2] = "bestuur/aanmelden.html"
//  submenu2URL[3] = "bestuur/contributie.html"
//  submenu2URL[4] = "bestuur/adressen.html"
//  submenu2URL[5] = "bestuur/beleidsplan.html"
//  submenu2Text[0] = submenu2Length
//  submenu2Text[1] = "bestuur"
//  submenu2Text[2] = "aanmelden als lid"
//  submenu2Text[3] = "contributie"
//  submenu2Text[4] = "adressen"
//  submenu2Text[5] = "beleidsplan"

//  for (i = 1; i < submenu2Length; i++) {
//    document.write('<a href="' + getroot(depth) + submenu2URL[i] + '"' )
//    if (i == active)
//      document.write(' id="activesubmenu"')
//    document.write('>' + submenu2Text[i] + '</a> ')
//  }
//}

// *** submenu 3 ***

function showsubmenu3(depth, active) {
  var i
  var submenu3Length = 11
  var submenu3URL = new Array(submenu3Length)
  var submenu3Text = new Array(submenu3Length)

  submenu3URL[0] = submenu3Length
  submenu3URL[1] = "button3.html"
  submenu3URL[2] = "club/route.html"
  submenu3URL[3] = "club/adressen.html"
  submenu3URL[4] = "club/aanmelden.html"
  submenu3URL[5] = "club/contributie.html"
  submenu3URL[6] = "club/organisatie.html"
  submenu3URL[7] = "club/taken.html"
  submenu3URL[8] = "club/activiteiten.html"
  submenu3URL[9] = "club/kunstgrasveld.html"
  submenu3URL[10] = "club/training.html"
//  submenu3URL[11] = "club/beleidsplan.html"
  submenu3Text[0] = submenu3Length
  submenu3Text[1] = "over de club"
  submenu3Text[2] = "route"
  submenu3Text[3] = "adressen"
  submenu3Text[4] = "aanmelden als lid"
  submenu3Text[5] = "contributie"
  submenu3Text[6] = "organisatie"
  submenu3Text[7] = "taken"
  submenu3Text[8] = "activiteiten"
  submenu3Text[9] = "kunstgrasveld"
  submenu3Text[10] = "training"
//  submenu3Text[11] = "beleidsplan"

  for (i = 1; i < submenu3Length; i++) {
    document.write('<a href="' + getroot(depth) + submenu3URL[i] + '"' )
    if (i == active)
      document.write(' id="activesubmenu"')
    document.write('>' + submenu3Text[i] + '</a> ')
  }
  if (Math.random() < fly)
    document.write('<br><img src="' + getroot(depth) + 'gifs/vliegje.gif" alt="fly">')
}

// *** submenu 4 ***

function showsubmenu4(depth, active) {
  var i
  var submenu4Length = 9
  var submenu4URL = new Array(submenu4Length)
  var submenu4Text = new Array(submenu4Length)

  submenu4URL[0] = submenu4Length
  submenu4URL[1] = "button4.html"
  submenu4URL[2] = "team-dames/dames.html"
  submenu4URL[3] = "team-veteranen/veteranen.html"
  submenu4URL[4] = "team-veterinnen/veterinnen.html"
  submenu4URL[5] = "team-a/a.html"
  submenu4URL[6] = "team-b/b.html"
  submenu4URL[7] = "team-d/d.html"
  submenu4URL[8] = "team-f/f.html"
//  submenu4URL[9] = "team-veteranen/winter-veteranen.html"
  submenu4Text[0] = submenu4Length
  submenu4Text[1] = "veldhockey"
  submenu4Text[2] = "dames"
  submenu4Text[3] = "veteranen"
  submenu4Text[4] = "veterinnen"
  submenu4Text[5] = "a-team"
  submenu4Text[6] = "b-team"
  submenu4Text[7] = "d-team"
  submenu4Text[8] = "f-team"
//  submenu4Text[9] = "veteranen/winter"

  for (i = 1; i < submenu4Length; i++) {
    document.write('<a href="' + getroot(depth) + submenu4URL[i] + '"' )
    if (i == active)
      document.write(' id="activesubmenu"')
    document.write('>' + submenu4Text[i] + '</a> ')
  }
  if (Math.random() < fly)
    document.write('<br><img src="' + getroot(depth) + 'gifs/vliegje.gif" alt="fly">')
}

// *** submenu 5 ***

function showsubmenu5(depth, active) {
  var i
  var submenu5Length = 2
  var submenu5URL = new Array(submenu5Length)
  var submenu5Text = new Array(submenu5Length)

  submenu5URL[0] = submenu5Length
  submenu5URL[1] = "button5.html"
  submenu5URL[2] = ""
  submenu5URL[3] = ""
  submenu5URL[4] = ""
  submenu5URL[5] = ""
  submenu5URL[6] = ""
  submenu5Text[0] = submenu5Length
  submenu5Text[1] = "zaalhockey"
  submenu5Text[2] = "b1-team meisjes"
  submenu5Text[3] = "b1-team jongens"
  submenu5Text[4] = "b2-team jongens"
  submenu5Text[5] = "c-team"
  submenu5Text[6] = "e-team"

  for (i = 1; i < submenu5Length; i++) {
    document.write('<a href="' + getroot(depth) + submenu5URL[i] + '"' )
    if (i == active)
      document.write(' id="activesubmenu"')
    document.write('>' + submenu5Text[i] + '</a> ')
  }
  if (Math.random() < fly)
    document.write('<br><img src="' + getroot(depth) + 'gifs/vliegje.gif" alt="fly">')
}

// *** submenu 6 ***

function showsubmenu6(depth, active) {
  var i
  var submenu6Length = 8
  var submenu6URL = new Array(submenu6Length)
  var submenu6Text = new Array(submenu6Length)

  submenu6URL[0] = submenu6Length
  submenu6URL[1] = "button6.html"
  submenu6URL[2] = "archief/programma-archief.html"
  submenu6URL[3] = "archief/jaarverslag.html"
  submenu6URL[4] = "archief/notulen.html"
  submenu6URL[5] = "archief/fotos.html"
  submenu6URL[6] = "archief/krantenknipsels.html"
  submenu6URL[7] = "archief/kunstgras.html"
  submenu6Text[0] = submenu6Length
  submenu6Text[1] = "overzicht"
  submenu6Text[2] = "programma's"
  submenu6Text[3] = "jaarverslag"
  submenu6Text[4] = "notulen alv"
  submenu6Text[5] = "foto's"
  submenu6Text[6] = "krantenknipsels"
  submenu6Text[7] = "kunstgras-saga"

  for (i = 1; i < submenu6Length; i++) {
    document.write('<a href="' + getroot(depth) + submenu6URL[i] + '"' )
    if (i == active)
      document.write(' id="activesubmenu"')
    document.write('>' + submenu6Text[i] + '</a> ')
  }
  if (Math.random() < fly)
    document.write('<br><img src="' + getroot(depth) + 'gifs/vliegje.gif" alt="fly">')
}

// *** submenu 7 ***

function showsubmenu7(depth, active) {
  var i
  var submenu7Length = 9
  var submenu7URL = new Array(submenu7Length)
  var submenu7Text = new Array(submenu7Length)

  submenu7URL[0] = submenu7Length
  submenu7URL[1] = "button7.html"
  submenu7URL[2] = "links/route-veld.html"
  submenu7URL[3] = "links/route-zaal.html"
  submenu7URL[4] = "links/spelregel.html"
  submenu7URL[5] = "links/hockeybond.html"
  submenu7URL[6] = "links/andere-clubs.html"
  submenu7URL[7] = "links/overig.html"
  submenu7URL[8] = "http://www.hcwinsum.nl/stats/"
  submenu7Text[0] = submenu7Length
  submenu7Text[1] = "buienradar"
  submenu7Text[2] = "route veld"
  submenu7Text[3] = "route zaal"
  submenu7Text[4] = "spelregels"
  submenu7Text[5] = "hockeybond"
  submenu7Text[6] = "andere clubs"
  submenu7Text[7] = "overige links"
  submenu7Text[8] = "web-bezoek"

  for (i = 1; i < submenu7Length; i++) {
    if (i == 8)
      document.write('<a href="' + submenu7URL[i] + '" target="winsum"')
    else
      document.write('<a href="' + getroot(depth) + submenu7URL[i] + '"')
    if (i == active)
      document.write(' id="activesubmenu"')
    document.write('>' + submenu7Text[i] + '</a> ')
  }
  if (Math.random() < fly)
    document.write('<br><img src="' + getroot(depth) + 'gifs/vliegje.gif" alt="fly">')
}

// end of hcwinsum.js
