function popup_bonus_image(file,title,cstext)
{
	var htmlSourceOrCredit = '';
	// *DESCRIPTION*
	
	if(cstext) 
	{
		var html;
	
		//html = (cs == 'c' ? cstext : '<b>Source(s):</b> '+cstext);
		html = cstext;

		htmlSourceOrCredit = 
			'<div style=\"width: 100%; height: 52; background-color: #FFFFFF; overflow: auto; '+
			'overflow-x: hidden; border-top: 1px solid #000000; padding: 2px; font-size: '+
			'smaller; word-wrap: break-word;\">'+html+'</div>';
			// *DEFAULT* 52, white background color to match the book's, just a little padding (ic #10)
			// *INFO* "word-wrap: break-word" only works on internet explorer (05/23/2009)
	}
	var widthPopup  = 640;
	// *DEFAULT*
        var heightPopup = 480;
        // *DEFAULT*
        var fPopup = function() 
        {
		f1 = window.open(
			'',0,
			'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,'+
			'width='+widthPopup+',height='+(heightPopup+(cstext ? 52 : 0)) 
			// *DEFAULT* 52: div for image credits
		);

		if(document.domain) {
			file = 'http://'+document.domain+'/final_truth/'+file;
		}
		f1.document.open();
		f1.document.writeln(
			'<html><head><title>'+title+'</title></head><body topmargin=0 leftmargin=0 rightmargin=0>'+
			'<img src=\"'+file+'\" />'+htmlSourceOrCredit+'</body></html>' 
		);
		f1.document.close();
	}
	if(document.images)
	// *INFO* document.images is supported by firefox 3, and internet explorer 6 or higher (hopefully)
	{
        	var imgBonus = new Image();
        	var idTimeoutForPopup = 0;
        	
        	imgBonus.src = file;
        	
        	widthPopup  = imgBonus.width;
            	heightPopup = imgBonus.height;
         
		imgBonus.onload = function() {
			if(widthPopup == 0) 
			// *DESCRIPTION* makes sure that we get a non-zero width and height because in some
			// browsers these properties remain zero until the image has not been loaded.
			{
				widthPopup  = imgBonus.width;
            			heightPopup = imgBonus.height;

            			window.clearTimeout(idTimeoutForPopup);
            			// *DESCRIPTION* no need to wait anymore. we can launch the popup right now
            			window.setTimeout(fPopup,0);
			}
		}
	}
	// *DESCRIPTION* else the popup opens using standard values for width and height
	
	if(widthPopup == 0) {
        	idTimeoutForPopup = setTimeout(fPopup,1000);
		// *DESCRIPTION* gives some time for the image to load and hopefully fill imgBonus.width
		// and imgBonus.height with non-zero values.
        }
        else {
        	window.setTimeout(fPopup,0);
        }
}
