/**
 *
@access public
@return void
 **/



function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function toggleLayer(ID) {

		var sectionId = document.getElementById(ID);

		if (sectionId.style.display == '')
			{
			sectionId.style.display = 'none';
			var ImgSrc = document.getElementById("i" + ID);
			ImgSrc.src = "images/plus.gif";
			}

		else
			{
			sectionId.style.display = '';
			var ImgSrc = document.getElementById("i" + ID);
			ImgSrc.src = "images/minus.gif";
			}

}


function toggleLayerWithText(ID, LANG, TYPE, NUMBER) {

	var sectionId = document.getElementById(ID);

	if (sectionId.style.display == '') {

		sectionId.style.display = 'none';

		var AnchorTxt = document.getElementById("a" + ID);

		switch(LANG){
			case "EN":
				switch (TYPE) {
					case "PICT":
						AnchorTxt.innerHTML = "Show pictures ("+NUMBER+")";
						break;
					case "FILE":
						AnchorTxt.innerHTML = "Show files ("+NUMBER+")";
						break;
					case "COMM":
						AnchorTxt.innerHTML = "Show comments ("+NUMBER+")";
						break;
					default:
				} // end switch EN->TYPE
				break;
			case "NL":
				switch (TYPE) {
					case "PICT":
						AnchorTxt.innerHTML = "Toon afbeeldingen ("+NUMBER+")";
						break;
					case "FILE":
						AnchorTxt.innerHTML = "Toon bestanden ("+NUMBER+")";
						break;
					case "COMM":
						AnchorTxt.innerHTML = "Toon berichten ("+NUMBER+")";
						break;
					default:
						break;
				} // end switch NL->TYPE
				break;
			default:
				switch (TYPE) {
					case "PICT":
						AnchorTxt.innerHTML = "Show pictures ("+NUMBER+")";
						break;
					case "FILE":
						AnchorTxt.innerHTML = "Show files ("+NUMBER+")";
						break;
					case "COMM":
						AnchorTxt.innerHTML = "Show comments ("+NUMBER+")";
						break;
					default:
				} // end switch default->TYPE
				break;
		} // switch
	}

	else {
		// toggle the display
		sectionId.style.display = '';

		var AnchorTxt = document.getElementById("a" + ID);

		// Update the text
		switch(LANG){
			case "EN":
				switch (TYPE) {
					case "PICT":
						AnchorTxt.innerHTML = "Hide pictures ("+NUMBER+")";
						break;
					case "FILE":
						AnchorTxt.innerHTML = "Hide files ("+NUMBER+")";
						break;
					case "COMM":
						AnchorTxt.innerHTML = "Hide comments ("+NUMBER+")";
						break;
					default:
				} // end switch EN->TYPE
				break;
			case "NL":
				switch (TYPE) {
					case "PICT":
						AnchorTxt.innerHTML = "Verberg afbeeldingen ("+NUMBER+")";
						break;
					case "FILE":
						AnchorTxt.innerHTML = "Verberg bestanden ("+NUMBER+")";
						break;
					case "COMM":
						AnchorTxt.innerHTML = "Verberg berichten ("+NUMBER+")";
						break;
					default:
				} // end switch NL->TYPE
				break;
			default:
				switch (TYPE) {
					case "PICT":
						AnchorTxt.innerHTML = "Hide pictures ("+NUMBER+")";
						break;
					case "FILE":
						AnchorTxt.innerHTML = "Hide files ("+NUMBER+")";
						break;
					case "COMM":
						AnchorTxt.innerHTML = "Hide comments ("+NUMBER+")";
						break;
					default:
						break;
				} // end switch default->TYPE
				break;
		} // switch LANG
	} // end else
} // end function

function skiptoinput(ID) {
		var sectionId = document.getElementById(ID + "_input");
		sectionId.focus();
}

function popImage(imageURL,imageTitle){
	// The following *excellent* script is taken from http://www.howtocreate.co.uk
	// It's from the 'perfect popups' section. It automatically resizes the popup
	// window to the size of the image that is loaded within.
	//
	// I've added a rightclick-disable script and a image-toolbar disabler to this
	// script. It is indicated clearly with tabs what I added.
	//
	// If you want to use this script at your website, be sure to check the
	// Terms and Conditions-section at http://www.howtocreate.co.uk.

	// Pop-up script

	//really not important (the first two should be small for Opera's sake)
	PositionX = 10;
	PositionY = 10;
	defaultWidth  = 600;
	defaultHeight = 400;

	//kinda important
	var AutoClose = false;

	//don't touch

	var imgWin = window.open('','_blank','menubar=1,toolbar=yes,scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);

	if( !imgWin ) { return true; } //popup blockers should not cause errors

	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+'function resizeWinTo() {\n'+
	'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
	'var oH = document.images[0].height, oW = document.images[0].width;\n'+
	'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
	'window.doneAlready = true;\n'+ //for Safari and Opera
	'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
	'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
	'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
	'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
	'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
	'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
	'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
	'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
	'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
	'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
	'}\n'+

	'<\/script>'+
				// The line beneath disables the "imagetoolbar" for IE6+.
				'<META HTTP-EQUIV="imagetoolbar" CONTENT="no"> \n'+
	'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+			(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;">'))+
	'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+			(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}

//*******************************************************************
//** SMR_RESIZE_MOD: START CODE *************************************
//*******************************************************************

/* This is a script I got somewhere from the web 
	A big thanks to the makers!
	
	The SMR_resize function is to resize images after they loaded to
	the width defined in the var SMR_confMaxDim.
	
	The SMR_setLink is to create a hyperlink to the image.
*/

function SMR_resize(obj) {
   // The maximum allowed width of a picture. 
   SMR_confMaxDim = 530; // pixels

   thisWidth = obj.width;
   thisHeight = obj.height;

   if(thisWidth > thisHeight) thisMaxDim = thisWidth;
   else thisMaxDim = thisHeight;

   if(thisMaxDim > SMR_confMaxDim) {
      thisMinDim = Math.round((((thisWidth > thisHeight)?thisHeight:thisWidth) * SMR_confMaxDim) / thisMaxDim);

      if(thisWidth > thisHeight) {
         thisWidth = SMR_confMaxDim;
         thisHeight = thisMinDim;
      } else {
         thisHeight = SMR_confMaxDim;
         thisWidth = thisMinDim;
      }
   } // if(thisMaxDim > SMR_confMaxDim)

   obj.height = thisHeight;
   obj.width = thisWidth;
}
function SMR_setLink(obj) {
   thisInnerHtml = obj.innerHTML;
   tmpArray = thisInnerHtml.split(' src=\"');
   tmpArray = tmpArray[1].split('"');
   obj.href = tmpArray[0];
}
//*******************************************************************
//** SMR_RESIZE_MOD: END ********************************************
//*******************************************************************



