	function Browser(){
	  this.uA = navigator.userAgent.toLowerCase();
	  this.aN = navigator.appName.toLowerCase();
	  this.iE = this.aN.indexOf('microsoft') != -1 ? 1 : 0;
	  this.mac =  this.uA.indexOf('mac') != -1 ? 1 : 0;
	  this.win = this.uA.indexOf('windows') != -1 ? 1 : 0;
	  this.safari =  this.uA.indexOf('webkit') != -1 ? 1 : 0;
	  this.opera =  this.uA.indexOf('opera') != -1 ? 1 : 0;    
	  this.mozilla = this.aN.indexOf('netscape') != -1 && !this.safari ? 1 : 0;
	  this.winMozilla = this.mozilla && this.win ? 1 : 0;
	  this.winIE = this.iE && this.win && !this.opera ? 1 : 0;
	  this.winIE6Down = this.winIE && parseInt(this.uA.split('msie ')[1].substring(0,1)) <= 6 ? 1: 0;
	  this.macIE = this.iE && this.mac ? 1 : 0;
	};

	var browser = new Browser();
	
	function startLightbox(boxwidth, boxheight, content){
		if(browser.winIE){
			if(boxheight > document.documentElement.clientHeight-80)	{
				boxheight = document.documentElement.clientHeight-80;
				document.getElementById('lightbox').style.left=((document.body.clientWidth - boxwidth)/2)+'px' ;
				document.getElementById('lightbox').style.top=((document.documentElement.clientHeight - boxheight)/2 + document.documentElement.scrollTop)+'px';
			}else{
				document.getElementById('lightbox').style.left=((document.body.clientWidth - boxwidth)/2)+'px' ;
				document.getElementById('lightbox').style.top=((document.documentElement.clientHeight - boxheight)/2 + document.documentElement.scrollTop)+'px';
			}
		}else{
			if(boxheight > window.innerHeight-80)	{
				boxheight = window.innerHeight-80;
			document.getElementById('lightbox').style.left=((window.innerWidth - boxwidth)/2)+'px' ;
			document.getElementById('lightbox').style.top=((window.innerHeight - boxheight - 40)/2 + window.pageYOffset)+'px';
			}else{
				document.getElementById('lightbox').style.left=((window.innerWidth - boxwidth)/2)+'px' ;
				document.getElementById('lightbox').style.top=((window.innerHeight - boxheight)/2 + window.pageYOffset)+'px';
			}
		}
		document.getElementById('lightbox').innerHTML=content;
		if(document.getElementById('screenshot')){
			document.getElementById('screenshot').style.width=boxwidth+'px';
			document.getElementById('screenshot').style.height=(boxheight-50)+'px';
		}
		document.getElementById('lightbox').style.width=boxwidth+'px';
		document.getElementById('lightbox').style.height=boxheight+'px';
		document.getElementById('lightbox').style.display="block";
		//alert(boxwidth+' X '+boxheight+"\n"+content);
	}
	function stopLightbox(){
		document.getElementById('lightbox').style.display='none';
	}
	function startDemo(location, width, height){
		if(browser.winIE){
			window.open("_media/_swf/"+location, width+height,'width='+(width+20)+',height='+(height+20));
		}else{
			/*alert('check');*/
			startLightbox(width, height+50, '<a href="javascript:stopLightbox();">sluiten</a><br/><br/><div id="demoBlock"></div>');
			var so = new SWFObject("_media/_swf/"+location, "demo", width, height, "9", "#000");
			so.write("demoBlock");
		}
	}
	function startScreenshot(location, width, height){
		if(browser.winIE){
			var boxheight = document.documentElement.clientHeight-80
		}else{
			var boxheight = window.innerHeight-80;
		}
		var scale = (boxheight-80)/height;
		height = Math.round(height * scale);
		width = Math.round(width * scale);
		var screenshotHTML = '<div id="close"><a href="javascript:stopLightbox();">sluiten</a></div><div id="screenshot" style="width:'+width+';heigth:'+height+';background-image:url(\'/getFile.php?id='+location+'&amp;width='+width+'\')"></div>';
		startLightbox(width+20, height+80, screenshotHTML);
	}
	
	function startGallery(galleryArray, index){
		var fileId = galleryArray[index][0];
		var width = galleryArray[index][1];
		var height = galleryArray[index][2];
		
		if(browser.winIE){
			var boxHeight = document.documentElement.clientHeight-80
			var boxWidth = document.documentElement.clientWidth-80
		}else{
			var boxHeight = window.innerHeight-80;
			var boxWidth = window.innerWidth-80;
		}
		
		var scaleX = boxWidth/width;
		var scaleY = boxHeight/height;
		width = Math.round(width * scaleX)-80;
		height = Math.round(height * scaleY)-80;
		//alert(width+':'+height);
		
		var arrayStr = '[';
		for(var i=0;i<galleryArray.length;i++){
			if(i!=0){
				arrayStr += ',';
			}
			arrayStr += '[';
			arrayStr += galleryArray[i][0]+','+galleryArray[i][1]+','+galleryArray[i][2];
			arrayStr += ']';
		}
		arrayStr += ']';
		
		var screenshotHTML = '<div class="buttons">';
		if(index>0){
			screenshotHTML += '<div style="float:left;"><a href="javascript:startGallery('+arrayStr+', '+(index-1)+')">vorige</a></div>';
		}
		if(index!=(galleryArray.length-1)){
			screenshotHTML += '<div style="float:right;"><a href="javascript:startGallery('+arrayStr+', '+(index+1)+')">volgende</a></div>';
		}
		screenshotHTML += '</div><div id="screenshot" style="width:'+width+';heigth:'+height+';background-image:url(\'/getFile.php?id='+fileId+'&amp;height='+height+'\')"></div><div class="buttons" style="float:right"><a href="javascript:stopLightbox();">sluiten</a></div>';
		startLightbox((height/3)*4+80, height+60, screenshotHTML);
	}
	
	/*
  	<script type="text/javascript">
		// <![CDATA[
		var so = new SWFObject("/2006/shell.swf?playerxml=/2006/flvplayer.xml", "shell", "760", "427", "9", "#000");
    so.addParam("videoplay", "true");
    so.addParam("wmode", "transparent");
		so.write("ria");
		// ]]>
	</script>
*/

