
  // ========================================
  // Handles functions that should run onload
  // ========================================
  
  function handleOnload(sSection) {
    
    // First check if the page is part of the complete frameset
    if (top.location == location) {
      top.location = 'index.php';
    } else if (sSection != '' && sSection != null) {
      loadBanner(sSection);
      sync_flash(sSection);
    }
    
  }


  // =========================================================
  // Reload the right frame (contains adremedy banner)
  // The home page uses other banner code than all other pages
  // =========================================================
  
  function loadBanner(sSection) {

    top.frame_right.location = 'right.php?section=' + sSection;

  }
  

  // ===========================================================================
  // Force images that appear more than once on the page, to load.
  // Otherwise they will not be shown sometimes in IE6 with SP1 (this is a bug).
  // ===========================================================================

  image01 = new Image();
  image02 = new Image();
  image03 = new Image();
  image04 = new Image();
  image05 = new Image();
  image06 = new Image();
  image07 = new Image();
  image08 = new Image();
  image09 = new Image();
  image10 = new Image();

  image01.src = "images/blanco.gif";
  image02.src = "images/bullet_01.gif";
  image03.src = "images/bullet_02.gif";
  image04.src = "images/bullet_02_disabled.gif";
  image05.src = "images/bullet_03.gif";
  image06.src = "images/bullet_03_disabled.gif";
  image07.src = "images/bullet_04.gif";
  image08.src = "images/bullet_04_disabled.gif";
  image09.src = "images/bullet_05.gif";
  image10.src = "images/bullet_05_disabled.gif";


  // ================
  // Common functions
  // ================

  function openWindow(theURL,winName,features) {
    window.open(theURL,winName,features);
  }

  function closeWindow() {
    window.close()
  }

  function focusWindow() {
    window.focus()
  }

  function previousPage() {
    history.go(-1)
  }

  function submitForm(formObj) {
    formObj.submit();
  }


  // =================================================================
  // Functions for syncing the flash header with pages
  //
  // Thanks to:
  // http://www.moock.org/webdesign/flash/fscommand/#javascripttoflash
  // =================================================================

  var movieName  = "flash_top"

  function sync_flash(section) {
    // only change head if it differs from the previous one...
    if (movieIsLoaded(thisMovie(movieName))) {
      section_current = section;
      section_previous = thisMovie(movieName).GetVariable("section");
      if (section_previous != section_current) {
        thisMovie(movieName).SetVariable("section", section);
        thisMovie(movieName).TGotoLabel("/head", section);
      }
      //thisMovie(movieName).Play();
    }
  }

  function thisMovie(movieName) {
    // IE and Netscape refer to the movie object differently.
    // This function returns the appropriate syntax depending on the browser.
    if (navigator.appName.indexOf ("Microsoft") !=-1) {
      // IE
      return top.frame_top.window[movieName];
    } else {
      // Netscape
      return top.frame_top.document[movieName];
    }
  }

  // Checks if movie is completely loaded.
  // Returns true if yes, false if no.
  function movieIsLoaded (theMovie) {
    // First make sure the movie's defined.
    if (typeof(theMovie) != "undefined") {
      // If it is, check how much of it is loaded.
      return theMovie.PercentLoaded() == 100;
    } else {
      // If the movie isn't defined, it's not loaded.
      return false;
    }
  }


  // ==============================
  // Other, site specific functions
  // ==============================
  
  // Opens slideshow in popup window
  function openSlideshow(model) {

    openWindow('model_slideshow.php?model=' + model, 'slideshow', 'status=no,width=320,height=440');

  }

  
  // Opens vote message in popup window
  function vote(model) {

    openWindow('model_vote.php?model=' + model, 'vote', 'status=no,width=320,height=220');

  }


  // Opens newsletter subscription form in popup window
  function openNewsletter() {

    openWindow('news_newsletter.php', 'newsletter', 'status=no,width=320,height=220');

  }


  // Refreshes the main model of the month window after voting
  function reloadOpener() {

    window.opener.location.reload();

  }


  // Populates month select field,
  // used in news_archive.php, model.php
  function setMonths(formObj, monthMin, monthMax, yearMin, yearMax) {
      
    var yearSelected  = formObj.year.value;

    if (yearSelected == 0) {
      
      formObj.month.disabled = true;
      
    } else {

      // Enable month select field
      formObj.month.disabled = false;

      // Define array with dutch month names
      var monthNames = new Array();
      monthNames[1]  = 'januari';
      monthNames[2]  = 'februari';
      monthNames[3]  = 'maart';
      monthNames[4]  = 'april';
      monthNames[5]  = 'mei';
      monthNames[6]  = 'juni';
      monthNames[7]  = 'juli';
      monthNames[8]  = 'augustus';
      monthNames[9]  = 'september';
      monthNames[10] = 'oktober';
      monthNames[11] = 'november';
      monthNames[12] = 'december';
  
      // First month to display for selected year
      if (yearSelected == yearMin)
        monthFrom = monthMin;
      else
        monthFrom = 1;
  
      // Last month to display for selected year
      if (yearSelected == yearMax)
        monthTo = monthMax;
      else
        monthTo = 12;
      
      // Remove current month options
      formObj.month.options.length = 1;
  
      // Add options to month select field
      j = 0;
      for(var i=monthFrom; i<=monthTo; i++) {
        j++;
        var no = new Option();
        no.value = i;
        no.text = monthNames[i];
        formObj.month.options[j] = no;
      }

    }

  }


  // Validates the contact form input
  function validateContact() {

    with (document.mainForm) {

      if (name.value.length==0) {
        alert('Vul s.v.p. je naam in.')
        name.focus();
        return false;
      } else if (email.value.length==0) {
        alert('Vul s.v.p. je e-mail adres in.')
        email.focus();
        return false;
      } else if (!isEmail(email.value)) {
        alert('Vul s.v.p. een geldig e-mail adres in.')
        email.focus();
        return false;
      } else if (reaction.value.length==0) {
        alert('Vul s.v.p. je reactie in.')
        reaction.focus();
        return false;
      }

      return true;

    } 
  
  }


  // Validates the subscribe form input
  function validateSubscribe() {

    with (document.mainForm) {
      
      /*
      genderSelected = false;
      for (i=0; i<gender.length; i++) {
        if (gender[i].checked) {
          genderSelected = true;
          break;
        }
      }
      
      sessionTypeSelected = false;
      for (i=0; i<gender.length; i++) {
        if (gender[i].checked) {
          sessionTypeSelected = true;
          break;
        }
      }
      */

      if (name_first.value.length==0) {
        alert('Vul s.v.p. je voornaam in.')
        name_first.focus();
        return false;
      } else if (name_last.value.length==0) {
        alert('Vul s.v.p. je achternaam in.')
        name_last.focus();
        return false;
      } else if (email.value.length==0) {
        alert('Vul s.v.p. je e-mail adres in.')
        email.focus();
        return false;
      } else if (!isEmail(email.value)) {
        alert('Vul s.v.p. een geldig e-mail adres in.')
        email.focus();
        return false;
      }

      return true;

    } 
  
  }
  
  // Validates the newsletter subscription form input
  function validateNewsletter() {

    with (document.mainForm) {

      if (email.value.length==0) {
        alert('Vul s.v.p. je e-mail adres in.')
        email.focus();
        return false;
      } else if (!isEmail(email.value)) {
        alert('Vul s.v.p. een geldig e-mail adres in.')
        email.focus();
        return false;
      }
      
      return true;

    } 
  
  }

  
  // Checks if string is a valid email-address
  function isEmail(s) {

    //////////////////////////////////////////////////
    //	<Email Validator>                           //
    // 	(c) 2003 Premshree Pillai                   //
    //	Written on: 29/04/03 (dd/mm/yy)             //
    //	http://www.qiksearch.com                    //
    //	http://premshree.resource-locator.com       //
    //	Email : qiksearch@rediffmail.com            //
    //////////////////////////////////////////////////
  	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
  	return(email.test(s));

  }
  
  function writeEmailLink(s1, s2, s3) {
   
    var s = s1 + '@' + s2 + '.' + s3;
    document.write('<a href="mailto:' + s + '">' + s + '</a>')
    
  }