function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function pad2(number) { 
     return (number < 10 ? '0' : '') + number
}

function getRealSize(fnm){
	$('pp').setStyle('display','block');
	$('pp').setStyle('top','0');
	$('iw').set('html', '<img src="'+fnm+'" id="iw_img2" />');
	myImageWidth = $('iw_img2').getStyle('width').toInt();
	myImageHeight = $('iw_img2').getStyle('height').toInt();
	if(myImageWidth>size.x || myImageHeight>size.y){
		fotoclass='priveszoom';
		$('iw').set('html', '');
		$('pp').setStyle('display','none');
	}else{
		fotoclass='showfoto';
		$('iw').set('html', '');
		$('pp').setStyle('display','none');
	}
	return fotoclass;
}

function showfoto(fotoname){
		size = window.getSize();
		var once=false;
		$('lightbox').setStyle('display','none');
		$('pp').setStyle('display','block');
		$('pp').setStyle('top','0');
		$('iw').set('html', '<img src="'+fotoname+'" id="iw_img">');
		var myImage = new Asset.image(fotoname, {id: 'image', 
			onload:	function(){
				if(once){
					return;
				}else{
					once = true;
					myImageWidth = $('iw_img').getStyle('width').toInt();
					myImageHeight = $('iw_img').getStyle('height').toInt();
					if(myImageWidth>size.x || myImageHeight>size.y){
						$('iw').setStyle('top','0px');						
						$('pp').addEvents({
							'mouseup':function(e){sp(e);},'mousemove':function(e){sp(e);},
							'click':function(e){
								$('pp').removeEvents();
								$('pp').setStyle('display','none');
								$('iw').setStyle('top','-10000px');
								$('iw').set('html', '');
							}
						});
					}else{
						///
						$('lightbox').setStyles({
							'display': 'block',
							'position': 'fixed',
							'top': '0',
							'left': '0',
							'bottom':'0',
							'right':'0',
							'text-align': 'center',
							'background':'black',
							'z-index': '60000'
						});
						$('lightbox').setStyle('display', 'block');
						$('lightboximage').set('html','<table align="center" width="100%" height="100%"><tr><td height="100%"><img id="lb_img" src="' + fotoname + '"></td></tr></table><div id=\"lb\">&nbsp;</div>');
						image = $('lightboximage').getElement('img');
						imageheight=image.getStyle('height').toInt();
						imagewidth=image.getStyle('width').toInt();
						if(imageheight>size.y){
							image.setStyles({
								'max-height':size.y,
								'position': 'relative',
								'z-index': '5'
							});//einde setStyles 
						}else{
							image.setStyles({
								'top':'50%',
								'margin-top':(-1*(imageheight/2)),
								'position': 'absolute',
								'left':'50%',
								'margin-left':(-1*(imagewidth/2)),
								'z-index': '5'
							});//einde setStyles 
						}
						$('lightbox').addEvent('click', function () {
							$('universetext').set('html', '');
							$('lightboximage').set('html', '');
							$('lightbox').setStyle('display', 'none');
						})						
						///
						$('pp').removeEvents();
						$('pp').setStyle('display','none');
						$('iw').setStyle('top','-10000px');
						$('iw').set('html', '');
					}
				}
			}
		});		
}

getsize2=function(fnm){
		var once=false;
		$('lightbox').setStyle('display','none');
		$('pp').setStyle('display','block');
		$('pp').setStyle('top','0');
		$('iw').set('html', '<img src="'+fnm+'" id="iw_img">');
		var myImage = new Asset.image(fnm, {id: 'image', 
			onload:	function(){
				if(once){
					return;
				}else{
					once = true;
					myImageWidth = $('iw_img').getStyle('width').toInt();
					myImageHeight = $('iw_img').getStyle('height').toInt();
					if(myImageWidth>size.x || myImageHeight>size.y){
						$('iw').setStyle('top','0px');						
						$('pp').addEvents({
							'mouseup':function(e){sp(e);},'mousemove':function(e){sp(e);},
							'click':function(e){$('pp').removeEvents();$('pp').setStyle('display','none');$('iw').setStyle('top','-10000px');}
						});
					}else{
						$('pp').removeEvents();$('pp').setStyle('display','none');
					}
				}
			}
		});		
}

function si2(fnm){
	getsize2(fnm);
}

function sp(e){
    w=$('pp').getStyle('width').toInt();h=$('pp').getStyle('height').toInt();if(w==100){gs();}
    var iw=myImageWidth;var ih=myImageHeight;
	
    if(iw){
        $('iw').setStyle('left',((iw>w)?((e.client.x/w)*(w-iw)):((w-iw)/2)));
        $('iw').setStyle('top',((ih>h)?((e.client.y/h)*(h-ih)):((h-ih)/2)));
    }
}
function gs() {
    // IE patch
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    w = window.innerWidth;
    h = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    w = document.body.clientWidth;
    h = document.body.clientHeight;
  }
 return Array(w, h);
}	
