Date.prototype.getWeek = function() {
  var onejan = new Date(this.getFullYear(),0,1);
  return Math.ceil((((this - onejan) / 86400000) + onejan.getDay())/7);
}
var today = new Date();
var quizvrg = today.getWeek()+1;
if (quizvrg==54){quizvrg=1;}

var mailwin = null;
var albumwin= null;
var infowin = null;
var pzlwin  = null;

//De kleuren van de verschillende onderdelen
var bgnorm = '#FFCC00';//inactief tabblad
var bgkies = '#FFFFCC';//actief tabblad
var bgsub  = "#FFFFEE";//sub tabblad

//Breedte van de site wordt door de volgende drie waarden bepaald. BrtIn + BrtMenu = BrtOut
var BrtIn   = 525;
var BrtMenu = 175;
var BrtOut  = BrtIn + BrtMenu;

//De onderdelen voor het hoofdmenu
var Hcnt  = 8;
var Hlink = new Array("algemeen.html","opvang.html", "adres.html", "ledenag.php", "ledennew.html", "link.html", "fret.html", "leden/ledennews.php");
var Htitel= new Array("Informatie over de vereniging", "Informatie over de opvang", "Adressen van Bestuur, dierenartsen etc.", "Evenementen agenda", "Tal van verenigszaken, fotos, verhalen. etc", "links naar andere intressante sites", "Informatie over fretten", "Speciaal voor de leden van Frettig Gestoord");
var Hmenu = new Array("Vereniging", "Opvang", "Adressen", "Agenda", "Overige", "Links", "Fretten", "Leden");

var cnt     = 0;
var Reclame = 0;

//Wij willen het TOP scherm zijn, dus niet in een frame zitten
if (self != top) {top.location = self.location}

//Voeg de site toe aan de favorieten van de gebruiker
function fav(){
        var url= "http://www.frettiggestoord.nl"
        var title="Fretten vereniging Frettig Gestoord"
        window.external.AddFavorite(url,title)
}

//Maak een menu aan, de gegevens komen uit een drietal globale Array en een globale Variable
function submenu(indx){
        document.write('        <TABLE border="0" cellpadding="0" cellspacing="0">');
        document.write('        <TR valign=bottom>');
        document.write('          <TD width="4"></TD>');
        for(i=0; i<cnt; i++){
                document.write('          <TD height="2">');
                document.write('            <TABLE Height="20"  border="0" cellpadding="0" cellspacing="0">');
                document.write('              <tr><td></td><TD bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></TD><td></td></tr>');
                document.write('              <TR>');
                document.write('                <TD bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></TD>');
                document.write('                <TD bgcolor="');

                if ((indx-1)==i)
                        {document.write(bgsub);}
                else
                        {document.write(bgnorm);}
                document.write('" nowrap>&nbsp;&nbsp;&nbsp;<a href="'+link[i]+'" title="'+titel[i]+'" onMouseOver="window.status=\''+titel[i]+'\' ;return true">'+menu[i]+'</a>&nbsp;&nbsp;&nbsp;</TD>');
                document.write('                <TD bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></TD>');
                document.write('                </TR>');
                document.write('            </TABLE>');
                document.write('          </TD>');
                document.write('        <td width="2"></td>');
        }//for
        document.write('        </tr>');
        document.write('        </TABLE>');
}//submenu

//Maak een menu aan, de gegevens komen uit een drietal globale Array en een globale Variable
function Topmenu(indx){
        document.write('        <TABLE border="0" cellpadding="0" cellspacing="0">');
        document.write('        <TR valign=bottom>');
        document.write('          <TD width="4"></TD>');
        for(i=0; i<Hcnt; i++){
                document.write('          <TD height="2">');
                document.write('            <TABLE Height="20"  border="0" cellpadding="0" cellspacing="0">');
                document.write('              <tr><td></td><TD bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></TD><td></td></tr>');
                document.write('              <TR>');
                document.write('                <TD bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></TD>');
                document.write('                <TD bgcolor="');

                if ((indx-1)==i)
                        {document.write(bgkies);}
                else
                        {document.write(bgnorm);}
                document.write('" nowrap>&nbsp;&nbsp;&nbsp;<a href="'+Hlink[i]+'" title="'+Htitel[i]+'" onMouseOver="window.status=\''+Htitel[i]+'\' ;return true">'+Hmenu[i]+'</a>&nbsp;&nbsp;&nbsp;</TD>');
                document.write('                <TD bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></TD>');
                document.write('                </TR>');
                document.write('            </TABLE>');
                document.write('          </TD>');
                document.write('        <td width="2"></td>');
        }//for

        document.write('        </tr>');
        document.write('        </TABLE>');
}//Topmenu

//Maak de pagina gereed
function CreatePage(indx, subindx){
        CreateStartPage();
        CreateTopMenu(indx);
        CreateLeftMenu();
        CreateLopendeText(subindx);
}//createStartPage


//Begin van de pagina
function CreateStartPage(){
        document.write('<table border="0" width="'+BrtOut+'" height="100%" cellspacing="0" cellpadding="0">');
}//createStartPage


//menu TABBLAD, de index geeft aan welk blad gekozen is.
function CreateTopMenu(indx){
        document.write('  <tr height="1">');
        document.write('    <td colspan="3" height="1" bgcolor="#FF0000"><IMG height="1" src="" alt="" width="1"></td>');
        document.write('    <td colspan="2"></td>');
        document.write('  </tr>');
        document.write('  <tr height="10">');
        document.write('    <td width="1" bgcolor="#FF0000" ><IMG height="1" src="" alt="" width="1"></td>');
        document.write('    <td bgcolor="'+bgsub+'"></td>');
        document.write('    <td width="1" bgcolor="#FF0000" ><img src="" alt="" width="1" height="1"></td>');
        document.write('    <td valign="bottom">');
        Topmenu(indx);
        document.write('    </td>');
        document.write('    <!--Rechts leeg-->');
        document.write('    <td></td>');
        document.write('  </tr>');
}//CreateTopMenu


//Het linker menu met logo en zoekmogelijkheid
function CreateLeftMenu(){
        document.write('  <tr>');
        document.write('    <td width="1" bgcolor="#FF0000" ><IMG height="1" src="" alt="" width="1"></td>');
        document.write('    <td bgcolor="'+bgsub+'" valign="top" width="'+BrtMenu+'">');
        document.write('      <table border="0" width="175" height="100%">');
        document.write('        <tr>');
        document.write('          <td align="center" height="145">');
        document.write('            <a href="index.html"><img src="images/layout/logo.gif" alt="Fretten vereniging Frettig gestoord" WIDTH="150" HEIGHT="143" border="0"></a>');
        document.write('          </td>');
        document.write('        </tr>');
        document.write('        <tr>');
        document.write('          <td height="10">&nbsp;</td>');
        document.write('        </tr>');
        document.write('        <tr>');
        document.write('          <td align="center" height="10">');
        document.write('              <img src="images/layout/tline.gif" alt="lijntje" WIDTH="140" HEIGHT="6">');
        document.write('              </td>');
        document.write('        </tr>');
        document.write('        <tr align="left" height="100">');
        document.write('          <td>');
        document.write('            <table border="0" width="85%" align="right"><tr><td align="left" valign="top">');
        document.write('                <a href="site.html" title="Informatie over deze site" onMouseOver="window.status=\'Informatie over deze site\' ;return true"><b>S</b>iteinfo</a><br>');
        document.write('                <a href="discussiebord.html" title="discussiebord over fretten" onMouseOver="window.status=\'Een discussiebord over fretten\' ;return true"><b>D</b>iscussiebord</a><br>');

//        document.write('                <a href="quiz.html" title="Een Quiz over fretten" onMouseOver="window.status=\'Een Quiz\' ;return true"><b>Q</b>uiz</a>&nbsp;&nbsp;<a href="javascript:toggelquiz();" title="Zet de Quiz aan of uit" >');
//        if ((GetCookie("noquiz") == null) || (GetCookie("noquiz") == "")){
//          document.write('[Uit]');}
//          else {
//          document.write('[Aan]');}
//        document.write('</a><br>');

        document.write('                <a href="plattegr.html" title="De hele site overzichtelijk" onMouseOver="window.status=\'Een plattegrond van deze hele site\' ;return true"><b>P</b>lattegrond</a><br>');
//        document.write('                <a href="gastenboek.html" title="Gastenboek" onMouseOver="window.status=\'Lees en teken het gastenboek\' ;return true"><b>G</b>astenboek</a><br>');
        document.write('                <a href="faq.php" onclick="javascript:MailWindow()" title="Vragen over fretten en de vereniging" onMouseOver="window.status=\'Stel vragen over de vereniging en over fretten\' ;return true"><b>V</b>ragen <img src="images/layout/vraag.gif" border="0" align="top"></a><br>');
        document.write('            </td></tr></table>');
        document.write('          </td>');
        document.write('              </tr>');
        document.write('              <tr>');
        document.write('          <td align="center" height="10">');
        document.write('            <img src="images/layout/bline.gif" alt="lijntje" WIDTH="140" HEIGHT="6">');
        document.write('          </td>');
        document.write('        </tr>');
        document.write('        <tr>');
        document.write('          <td align="center" height="100">');
        document.write('              <form method="get" action="http://search.atomz.com/search/">');
        document.write('                <img src="images/layout/zoek.gif" alt="Zoek" align="left" width="49" height="10"><br>');
        document.write('                <table border="0" width="150">');
        document.write('                <tr>');
        document.write('                  <td NOWRAP>&nbsp;&nbsp;');
                                             SetSize();
        document.write('                  </td>');
        document.write('                  <td>');
        document.write('                    <input type="image" border="0" src="images/layout/go.gif" name="Zoek" align="left" alt="Klik om zoeken te starten" width="24" height="17"></td>');
        document.write('                  <td>');
        document.write('                </tr>');
        document.write('                <tr>');
        document.write('                  <td align="right" colspan="2">');
        document.write('                    <a href="zoek.html" title="zoek met meer mogelijkheden" onMouseOver="window.status=\'Zoek met meer mogelijkheden\' ;return true">Uitgebreid zoeken...</a><br>');
        document.write('                  </td>');
        document.write('                </tr>');
        document.write('                </table>');
        document.write('                <input type="hidden" name="sp-a" value="sp1001c096">');
        document.write('              </form>');

//Donatie
//        if (Reclame == 1){
//          document.write('<br><a href="#" onClick="mbetaal(\'id=192145\');return false;"><img src="http://www.mollie.nl/partners/images/donatieknop-7.gif" alt="Doneer" border="0"></a><br />');}
//winkel
//        document.write('              <br><a href="winkel.html" title="Webwinkel Frettig Gestoord" onMouseOver="window.status=\'Webwinkel Frettig Gestoord\' ;return true"><img src="images/layout/wwfg.jpg" width="145" border="0" Alt="Webwinkel Frettig Gestoord"></a><br><br>');
//Vermist/gevonden
        document.write('              <br><a href="dbvg.html" title="Database vermist en gevonden" onMouseOver="window.status=\'Vermiste en gevonden fretten\' ;return true"><img src="images/layout/vermistsml.jpg" width="149" height="36" border="0" Alt="Database voor vermiste en gevonden fretten"></a><br>');
//RSS
        document.write('              <br><a href="rss.html"><img src="images/layout/rss2.png" alt="RSS" border="0"></a>');
//Forum
        document.write('              <br><br><a href="discussiebord.html" title="Frettig gestoord Discussiebord" onMouseOver="window.status=\'Discussiebord\' ;return true"><img src="images/layout/fgbb.gif" width="100" height="46" border="0" Alt="Discussiebord Frettig Gestoord"></a><br><br>');
//Hopefarm
        document.write('              <br><a href="http://www.hopefarms.nl" target="dl" title="Hope Farms" onMouseOver="window.status=\'Hope Farm Frettenvoeding\' ;return true"><img src="images/layout/hope-splash_logo.gif" width="145" border="0" Alt="Hope Farm"></a><br><br>');
//Lot voor Dieren
        document.write('              <br><a href="http://www.dierenlot.nl" target="dl" title="Dierenlot" onMouseOver="window.status=\'Dierenlot\' ;return true"><img src="images/layout/dierenlot.gif" width="120" border="0" Alt="Dierenlot"></a><br><br>');

        document.write('          </td>');
        document.write('        </tr>');
        document.write('        <tr>');
        document.write('          <td valign="bottom" align="center">');


// Creative Commons Licentie
        document.write('<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.0/nl/" target="license"><img alt="Creative Commons Licentie" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a><br />');
        document.write('<span class="KLEIN"><a class="KLEIN" rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.0/nl/">Creative Commons Licentie</a></span>');
// /Creative Commons Licentie

        document.write('            <br><span class="KLEIN"><br><i>Laatste wijziging: '+ document.lastModified + '</i></span><br>');
        document.write('          </td>');
        document.write('        </tr>');
        document.write('      </table>');
        document.write('    </td>');
        document.write('    <td width="1" bgcolor="#FF0000" >');
        document.write('        <img src="images/layout/redot.gif" alt="" width="1" height="1">');
        document.write('    </td>');
}//CreateLeftMenu


//Begin van het lopende tekst gedeelte
function CreateLopendeText(subindx){
        document.write('    <td bgcolor="'+bgsub+'" width="'+BrtIn+'" valign="top">');
        document.write('        <table border="0" height="100%" width="100%" cellspacing="0" cellpadding="0">');
        document.write('        <tr height="1">');
        document.write('          <td height="1" bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></td>');
        document.write('        </tr>');
        document.write('        <tr valign="top">');
        document.write('          <td bgcolor="'+bgsub+'">');
        document.write('            <table bgcolor="'+bgkies+'" border="0" heigth="100%" width="100%" cellspacing="0" cellpadding="0" >');
        document.write('                <tr><td colspan="2" height="10">&nbsp;</td></tr>');
        document.write('                <tr><td width="5"></td><td>');

//dit is de ruimte waar het tweede tabblad komt en op de index pagina leeg is
        if (cnt>0){submenu(subindx);}

        document.write('                </td></tr>');
        document.write('                <tr><td></td><td colspan="2" height="1" bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></td></tr>');
        document.write('            </table>');

        document.write('        <table border="0" height="100%" width="100%" cellspacing="0" cellpadding="0">');
        document.write('        <tr><td bgcolor="'+bgkies+'" width="5"></td>');
        document.write('          <td width="1" bgcolor="'+bgnorm+'"><img src="" alt="" width="1" height="1"></td><td valign="top">');

        document.write('          <table border="0" heigth="100%" width="100%" cellspacing="8" cellpadding="0" >');
        document.write('            <tr><td valign="top">');

}//CreateLopendetekst

//HIER STAAT OP DE PAGINA DE LOPENDE TEKST

//Het einde van de pagina
function CreateEndPage(){
        document.write('            </td></tr></table>');
        document.write('          </td></tr>');
        document.write('        </table>');
        document.write('      </td></tr>');
        document.write('    </table>');
        document.write('    <td width="1" bgcolor="'+bgnorm+'" ><IMG height="1" src="" alt="" width="1"></td>');
        document.write('  </tr>');
        document.write('  <tr height="1">');
        document.write('    <td colspan="3" height="1" bgcolor="#FF0000"><IMG height="1" src="" alt="" width="1"></td>');
        document.write('    <td colspan="2" height="1" bgcolor="'+bgnorm+'"><IMG height="1" src="" alt="" width="1"></td>');
        document.write('  </tr>');
        document.write('</table>');


        document.write('<IFRAME SRC="cnt.php" width="0" height="0" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></IFRAME>');

}//CreateEndPage



//Zorg dat het invulboxje voor de zoekmachine zowel in netscape als explorer netjes staat
function SetSize(){
        if (window.navigator.appName=='Netscape') {        //Netscape
                document.write('<input size="6" name="sp-q">');}
        else{                                                //Explorer
                document.write('<input size="13" name="sp-q">');}
}


//open een nieuw browserwindow met de puzzel
function puzzel(){
    pzlwin = window.open('puzzel.html','Schuifpuzzel', 'width=350,height=450,resizable=1,menubar=0,scrollbars=0,top=30,left=30')
    self.name = 'defret'
}


//Open een nieuw browserwindow met gallerie.html
function AlbumWindow(Album){
    albumwin = window.open('gallerie.html'+Album,'fotoalbum', 'width=583,height=553,resizable=0,menubar=0,scrollbars=0,top=30,left=30')
    self.name = 'defret'
}

//Open een nieuw browserwindow met mailwin.htm
function MailWindow(){
    mailwin = window.open('mailwin.html','Stuur_een_bericht', 'width=365,height=320,resizable=1,menubar=0,scrollbars=0,top=30,left=30')
    self.name = 'defret'
}

function error(){
    mailwin = window.open('error.html','Stuur_een_bericht', 'width=360,height=320,resizable=1,menubar=1,scrollbars=1,top=30,left=30')
    self.name = 'defret'
}

///////////////////////////////////////////////////////////////////////
//Code voor de floating layer. Deze bevat de quiz.
  isIE  = document.all;
  isNN  = !document.all&&document.getElementById;
  isN4  = document.layers;
  isHot = false;

  function ddInit(e){
    topDog=isIE ? "BODY" : "HTML";
    whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");
    hotDog=isIE ? event.srcElement : e.target;
    while (hotDog.id!="MoveArea"&&hotDog.tagName!=topDog){
      hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
    }
    if (hotDog.id=="MoveArea"){
      offsetx=isIE ? event.clientX : e.clientX;
      offsety=isIE ? event.clientY : e.clientY;
      nowX=parseInt(whichDog.style.left);
      nowY=parseInt(whichDog.style.top);
      ddEnabled=true;
      document.onmousemove=dd;
    }
  }

  function dd(e){
    if (!ddEnabled) return;
    whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
    whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
    return false;
  }

  function hideMe(){
    SetCookie("quiz", "open", null, "/", null, false);
    whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");
    if (isIE||isNN) whichDog.style.visibility="hidden";
    else if (isN4) document.theLayer.visibility="hidden";//hide
  }

  function showMe(){
    whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");
    if (isIE||isNN) whichDog.style.visibility="visible";
    else if (isN4) document.theLayer.visibility="show";
  }

  document.onmousedown=ddInit;
  document.onmouseup=Function("ddEnabled=false");
//einde floating layer
///////////////////////////////////////////////////////////////////////

//Als er een nieuwe quizvraag is dan moet het venster weer getoond worden
//Dit gebeurt door het cookie noquiz te verwijderen
//dit cookie bevat het nummer van de laatste quizvraag
if (GetCookie("noquiz") != quizvrg){
  SetCookie("noquiz", "", null, "/", null, false);}

//Open venster met een quizvraag of antwoord
function quiz(){
  if ((GetCookie("noquiz") == null) || (GetCookie("noquiz") == "")){
    if ((GetCookie("quiz") == null)|| (GetCookie("quiz") == "")){
        showMe();}}
}

//Schakel Quizvragen aan of uit
function toggelquiz(){
  var expdate = new Date();

  expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365));
  //als het cookie er niet is zet het dan anders verwijder het
  if ((GetCookie("noquiz") == null) || (GetCookie("noquiz") == "")){
    SetCookie("noquiz", quizvrg ,expdate , "/", null, false);}
  else{
    SetCookie("noquiz", "", null, "/", null, false);
    SetCookie("quiz", "", null, "/", null, false);}
  location.reload(0);
}//toggelquiz


//Knipper de border van een tabel
var base_time = new Date();

function KnipperIt() {
  var memory = document.getElementById("memory").style.border;
  current_time = new Date();
  add_time = (current_time.getTime()-base_time.getTime())/1000;
  add_time = Math.round(add_time);

  if(add_time >= 2) {
    if(memory  == 'white 2px solid') { document.getElementById("memory").style.border = 'solid red 2px';}
    else { document.getElementById("memory").style.border = 'white 2px solid';}}
    if(add_time <= 5) { ident = setTimeout("KnipperIt()", 100);}
    else { document.getElementById("memory").style.border = 'solid #FFFFCC 2px';}
}


//Functie's voor het lezen en schrijven van cookies
function getCookieVal (offset){
        var endstr = document.cookie.indexOf (";", offset);
                if (endstr == -1)
                        endstr = document.cookie.length;
                return unescape(document.cookie.substring(offset, endstr));
}


//Dit verzend een mail naar het opgegeven adres op het frettiggestoord domein.
function MailTo(adres, subject){

  location = "mailto:" + adres + "@" + "frettiggestoord.nl?subject=" + subject;

}


function GetCookie (name){
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen){
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg)
                        return getCookieVal (j);
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0)
                        break;}
        return null;
}


function SetCookie (name, value){
        var argv = SetCookie.arguments;
        var argc = SetCookie.arguments.length;
        var expires = (2 < argc) ? argv[2] : null;
        var path = (3 < argc) ? argv[3] : null;
        var domain = (4 < argc) ? argv[4] : null;
        var secure = (5 < argc) ? argv[5] : false;
        document.cookie = name + "=" + escape (value) +
     ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
}