//
// Javascript Image links and popup window
// Copyright Maxint (c) 2006
//
// Made by M. Molenaar, info@maxint.nl 
// Inspired by Nando, nandOOnline - http://www.nandoonline.com
// 
function newScreenshot(uerel,titel,positie) {
	var strLok = uerel.indexOf(".jpg");
	if (strLok==-1) strLok = uerel.indexOf(".gif");
	var tmbnl = uerel.substring(0, strLok);
	var pos='', width='';
	var img = new Image();
	//img.src = uerel;
	img.src=tmbnl+"_tn"+uerel.substring(strLok);
	if (positie == 'left') {pos = 'floatLeft';}
	else if (positie == 'right') {pos = 'floatRight';}
	else if (positie == 'center') {pos = 'floatCenter';}
	if (positie == '80%') {pos = 'floatLine'; width=img.width*0.8;}
	if (positie == '60%') {pos = 'floatLine'; width=img.width*0.6;}
	if (positie == 'b80') {pos = ''; width=img.width*0.8;}
	
	var htmCode = "<a href=\"#\" onclick=\"popImageMm('"+uerel+"','"+titel+"');return false;\"";
	//var htmCode = "<a href=\"#\" onclick=\"popUp('', 'perceel','50','50','no','"+titel+"','"+uerel+"');return false;\"";
	htmCode += " onMouseOver=\"window.status='Schermafbeelding "+titel+" (klik voor grote versie)'; return true;\"";
	htmCode += " onMouseout=\"window.status=' '; return true;\">";
	htmCode += "<img class=\""+pos+"\" style=\"float:"+positie+"\" src=\""+img.src+"\" alt=\"Schermafbeelding "+titel+"\n(klik voor grote versie)\"";
	if(width=='' && img.width>560) htmCode += " width=\"560\"";
	else if (width!='') htmCode += " width=\""+width+"\"";
	htmCode += " /></a>";
	
	document.writeln(htmCode);
}

function newImgLink(uerel,titel, tekst)
{  // maak tekstlink naar image
	
	var sStatus = tekst+" ";
	if(tekst=="hier") sStatus="";
	sStatus+="(klik om in nieuw venster te openen)";
	var htmCode = "<a href=\"#\" onclick=\"popImageMm('"+uerel+"','"+titel+"');return false;\"";
	htmCode += " onMouseOver=\"window.status='"+sStatus+"'; return true;\"";
	htmCode += " onMouseout=\"window.status=' '; return true;\">";
	htmCode += tekst;
	htmCode += "</a>";
	
	document.writeln(htmCode);
}

function newPdfLink(uerel,titel, tekst)
{  // maak tekstlink naar pdf
	
	var htmCode = "<a href=\"#\" onclick=\"newWin=window.open('"+uerel+"','mmPDF','toolbar=no,resizable=yes'); if( window.focus){newWin.focus()} return false;\"";
	htmCode += " onMouseOver=\"window.status='"+tekst+" (klik om PDF in nieuw venster te openen)'; return true;\"";
	htmCode += " onMouseout=\"window.status=' '; return true;\">";
	htmCode += tekst;
	htmCode += "</a>";
	
	document.writeln(htmCode);
}



// Auto-Sizing Image Popup Window
// http://www.codelifter.com/main/javascript/autosizeimagepopup.html
// Adjusted for MMinternet.nl by MMOLE

// Set the horizontal and vertical position for the popup
PositionX = 20;
PositionY = 20;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = true;

// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='resizable=yes, scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='resizable=yes, scrollbars=yes,width=250,height=100,left='+PositionX+',top='+PositionY;

function popImageMm(imageURL,imageTitle)
{
//alert("imageURL: " +imageURL+ ", imageTitle:" + imageTitle);
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
		var htmCode='';
		htmCode += '<html><head><title>Geduld a.u.b. ...</title>';
		htmCode += '<meta name="Copyright" content="Copyright © Maxint.nl" />';
		htmCode += '<style type="text/css" media="screen">body{overflow:none; margin:0px; padding:0px;} img{margin:0px; padding:0px; border:none;}</style>';
		htmCode += '<sc'+'ript language="JavaScript">';
		htmCode += 'var isNN,isIE;';
		htmCode += 'if (parseInt(navigator.appVersion.charAt(0))>=4){';
		htmCode += 'isNN=(navigator.appName=="Netscape")?1:0;';
		htmCode += 'isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}';
		htmCode += 'function reSizeToImage(){';
		htmCode += 'if (isIE){';
		htmCode += 'window.resizeTo(100,100);';
		htmCode += 'width=100-(document.body.clientWidth-document.images[0].width);';
		htmCode += 'height=100-(document.body.clientHeight-document.images[0].height);';
		htmCode += 'window.resizeTo(width,height);}';
		htmCode += 'if (isNN){';       
		htmCode += 'window.innerWidth=document.images["mmImage"].width;';
		htmCode += 'window.innerHeight=document.images["mmImage"].height;}}';
   	htmCode += 'function autofit() { w=(isNN)?window.innerWidth:document.body.clientWidth; h=(isNN)?window.innerHeight:document.body.clientHeight; w=Math.min(screen.availWidth-80, document.getElementById(\'mmImage\').width) - w; h=Math.min(screen.availHeight-80, document.getElementById(\'mmImage\').height) - h; window.resizeBy(w, h); /*self.focus();*/	} ';
		htmCode += ' function hide_scroll() {if(document.getElementById(\'mmImage\').width< (screen.availWidth-20)&&document.getElementById(\'mmImage\').height<(screen.availHeight-20)){document.body.style.overflow=\'hidden\';}}';
		htmCode += 'function doTitle(){document.title="'+imageTitle+'";}';
		htmCode += '</sc'+'ript>';
		htmCode += '</head><body bgcolor=000000 scroll="yes" onload="hide_scroll();autofit();doTitle();self.focus()"';
		if (AutoClose)
			htmCode += ' onblur="self.close()"';
		htmCode += '>';
		htmCode += '<a href="javascript:window.close()">';
		htmCode += '<img id="mmImage" src="'+imageURL+'" style="display:block" alt="' +imageTitle+ '\n(Klik om venster te sluiten)' +'"/>';
		htmCode += '</a>';
		htmCode += '</body></html>';
		writeln(htmCode);
		close();		
	}
}
