
/**
 * Nadat een pagina volledig ingeladen is, alvast de grote versies van de foto's
 * inladen in de cache.
 */
function preloadImage(pImgObj, pImgSrc) {
	if (document.images) {
		eval(pImgObj + ' = new Image()');
		eval(pImgObj + ".src = '" + pImgSrc + "'");
	}
}

/**
 * Een array van foto's inladen in de cache.
 */
function preloadImages() { //v3.0
    if(document.images) {
        if (!document.imageArray) {
            document.imageArray = new Array();
        }
        var i;
        var j = document.imageArray.length;
        var lArguments = preloadImages.arguments;
        for(i=0; i < lArguments.length; i++) {
            if (lArguments[i].indexOf("#") != 0) {
                document.imageArray[j] = new Image;
                document.imageArray[j].src = lArguments[i];
                j++;
            }
        }
    }
}

/**
 * De aangeklikte preview versie afbeelden.
 * In IE6 inclusief filter effect.
 * @param pImageName   De naam van het plaatje waarop de nieuwe foto afgebeeld moet worden.
 * @param pImageSrc    De src van de af te beelden foto.
 * @param pDescription De beschrijving in de titel attribute.
 */
function changeImageSrc(pImageName, pImageSrc, pDescription) {
	if (document.images) {

	    var lImage = findObject(pImageName);
	    if (lImage) {

	        // Filter toepassen?
	        if (lImage.filters && browser.isIE6up) {
	            var filterFunction = 'progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1,wipestyle=1,motion=forward,duration=0.5)';
	            lImage.style.filter=filterFunction;
	            if (lImage.filters && lImage.filters[0]) {
	                lImage.filters[0].Apply();
	                lImage.filters[0].Play();
	            }
	        }
	        lImage.src = pImageSrc;
		    lImage.title = pDescription;
		}
		// Controleer ook op een caption div met de beschrijving
		var lCaption = findObject('caption');
		if (lCaption && lCaption.innerHTML) {
		    lCaption.innerHTML=pDescription;
		}
	}
}

/**
 * Print emailadres mbv JavaScript zodat deze verborgen blijft
 * voor email spiders. (tbv SPAM)
 * @param theUser      De naam van de gebruiker (het eerste deel voor de @)
 * @param theDomain    De domainnaam
 * @param theTopDomain Het laatste deel van de domeinnaam
 */
function printEmail(theUser, theDomain, theTopDomain) {
  var at  = "@";
  var dot = ".";
  document.write('<a href="mailto:' + theUser + at  + theDomain + dot + theTopDomain + '">');
  document.write(theUser + at  + theDomain + dot + theTopDomain);
  document.write('</a>');
}

/** Een terug verwijzing afbeelden, alleen als er ook terug gebladerd kan worden. */
function displayGoBack(pDescription) {
    if (window.history) {
        if (window.history.length > 1) {
            document.write('<a href="Javascript:goBack()">' + pDescription + '</a>');
        }
    }
}

/** Een terug verwijzing afbeelden, alleen als er ook terug gebladerd kan worden. */
function displayGoBackN(pOffset, pDescription) {
    if (window.history) {
        if (window.history.length > pOffset) {
            document.write('<a href="Javascript:goBackN(' + pOffset +')">' + pDescription + '</a>');
        }
    }
}

/**
 * Een stap terug. In Mozilla is de history niet leesbaar (om veiligheidsredenen)
 */
function goBack() {
    if (window.history)
        window.history.go(-1);
    else
        window.back();
}

/**
 * Een of meerdere stappen terug in de geschiedenis.
 */
function goBackN(n) {
    if (window.history)
        window.history.go(n*-1);
    else
        history.go(n*-1);
}


function popup( url ) {
	window.open(url, "_blank","toolbar=no,location=no,menubar=no,scrollbars=yes,width=467,height=460,resizeable=yes,status=yes");
}

function pop( url, width, height ) { 
	window.open(url, "_blank","toolbar=no,location=no,menubar=no,scrollbars=yes,width="+width+",height="+height+",resizeable=yes,status=yes");
}

function Prefresh () {
	parent.window.opener.location.reload();
}

/* Forceer altijd een scrollbalk in Mozilla */
function setScrollbarVisible() {
    // In de html moet een div aanwezig zijn:
    // <div id="mozscroll">&nbsp;</div>
    if (browser.isGecko) {
        var scrolldiv = findObject('mozscroll');
        scrolldiv.style.position='absolute';
        scrolldiv.style.top='0px';
        scrolldiv.style.bottom='-1px';
        scrolldiv.style.visibility='hidden';
    }
}

// Browser Detect  v2.1.6
// documentation: http://www.dithered.com/javascript/browser_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase();

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1);
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1);
   this.isIcab        = (ua.indexOf('icab') != -1);
   this.isAol         = (ua.indexOf('aol') != -1);
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );

   // browser version
   this.versionMinor = parseFloat(navigator.appVersion);

   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }

   this.versionMajor = parseInt(this.versionMinor);

   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);

   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);

   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);

   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);

   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetect();

/**
 * Zoek een object aan de hand van z'n id in een HTML pagina.
 * Zie: http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=15
 */
function findObject( oName, oFrame, oDoc ) {

    if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else {
        oDoc = window.document; } }

    //check for images, forms, layers
    if( oDoc[oName] ) { return oDoc[oName]; }

    //check for pDOM layers
    if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }

    //check for DOM layers
    if( oDoc.getElementById && oDoc.getElementById(oName) ) {
        return oDoc.getElementById(oName); }

    //check for form elements
    for( var x = 0; x < oDoc.forms.length; x++ ) {
        if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }

    //check for anchor elements
    //NOTE: only anchor properties will be available,
    //NOT link properties!
    for( var x = 0; x < oDoc.anchors.length; x++ ) {
        if( oDoc.anchors[x].name == oName ) {
            return oDoc.anchors[x]; } }

    //check for any of the above within a layer in layers browsers
    for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) {
        var theOb = MWJ_findObj( oName, null, oDoc.layers[x].document );
            if( theOb ) { return theOb; } }

    //check for frames, variables or functions
    if( !oFrame && window[oName] ) { return window[oName]; }
    if( oFrame && oFrame[oName] ) { return oFrame[oName]; }

    //if checking through frames, check for any of the above within
    //each child frame
    for( var x = 0; oFrame && oFrame.frames &&
      x < oFrame.frames.length; x++ ) {
        var theOb = MWJ_findObj( oName, oFrame.frames[x],
          oFrame.frames[x].document ); if( theOb ) { return theOb; } }

    return null;
}

  // Creeer een gestreepte tabel
  // this function is needed to work around
  // a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }

 function stripe(id) {

    // the flag we'll use to keep track of
    // whether the current row is odd or even
    var even = false;

    // if arguments are provided to specify the colours
    // of the even and odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";

    // Wordt getElementById ondersteund? (IE >= 5)
    // (Voorkom dat IE4 aangeeft dat er een javascript fout is)
    if (!document.getElementById) {
        return;
    }

    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }

    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {

     // find all the &lt;tr&gt; elements...
      var trs = tbodies[h].getElementsByTagName("tr");

      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        // avoid rows that have a class attribute
        // or backgroundColor style
        if (! trs[i].style.backgroundColor) { //! hasClass(trs[i]) &&

          // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");

          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {

            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! mytd.style.backgroundColor) { //! hasClass(mytd) &&

              mytd.style.backgroundColor =
                even ? evenColor : oddColor;

            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }

  // Alle tabellen die mogelijk gestreept moeten worden.
  // Net bestaande tabellen worden genegeerd.
  function doStripe() {

      stripe('detailstable', '#ffffff', '#f0f3fa');
  }
