
// Browser detection code, visit 'http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html' for more info.
var agent = navigator.userAgent.toLowerCase();
var is_gecko = (agent.indexOf('gecko') != -1);

var scr_wide = screen.width;
var scr_high = screen.height;

function preview (text) {
	if (is_gecko) {
		document.getElementById('caption_preview').innerHTML = text;
	} else {
		document.all.caption_preview.innerHTML = text;
	}
}

/* void zoom() function
	img_src = relative path to image file to display
	img_wide = actual width of image
	img_high = actual height of image
	use_caption = true (1) or false (0), if true will use captions.
	caption = caption to output if use_caption is true
*/
function zoom (img_src, img_wide, img_high, use_caption, caption) {
	// default settings
	var scrollbar = 'no';
	var win_properties = 'toolbar=0,status=0,menubar=0,resizable=0,directories=0,dependent=yes,';
	var html_content = '<html><head><title>(' + img_src + ')</title><style>'
					 + 'div.content{position:absolute;top:0;left:0;}'
					 + 'table{padding:0;border:0;width:100%;height:100%;background-color:' + cap_backcolor +';color:' + cap_forecolor + '}'
					 + 'tr{border:0;padding:0;}'
					 + 'td.image{border:0;padding:2px;width:' + img_wide + 'px;height:' + img_high + 'pxl}'
					 + 'td.caption{border:0;padding:2px;overflow:auto;font-family:arial,verdana,helvetica;font-size:8pt;text-align:' + cap_align + ';';
	var td_image = '<td class="image" onClick="self.close();"><img border="0" src="' + img_src + '" /></td>';
	var td_caption = '<td class="caption">' + caption + '</td>';

	// determine window properties & html styling
	if (img_wide > scr_wide) { var win_wide = scr_wide; win_high += 16; scrollbar = 'yes'; }
	else { var win_wide = img_wide; }
	if (img_high > scr_high) { var win_high = scr_high; win_wide += 16; scrollbar = 'yes'; }
	else { var win_high = img_high; }
	win_wide += 4;
	win_high += 4;
	if (use_caption) {
		switch (cap_float) {
			case 0: case 1:
				var cap_dims = 'width:100px;height:' + img_high;
				var cap_midpt = '</td>';
				win_wide += 100;
				break;
			case 2: case 3:
				var cap_dims = 'height:100px;width:' + img_wide;
				var cap_midpt = '</td></tr><tr>';
				win_high += 100;
		}
	} else {
		td_caption = '';
		var cap_midpt = '';
	}

	// generate html
	html_content += cap_dims + '}</style></head>'
					 + '<body leftmargin="0" topmargin="0"><div class="content"><table cellpadding="0" cellspacing="0"><tr>';
	switch (cap_float) {
		case 0: case 2:
			html_content += td_caption + cap_midpt + td_image;
			break;
		case 1: case 3:
			html_content += td_image + cap_midpt + td_caption;
	}

	html_content += '</tr></table></div></body></html>';

	// display
	if (win_wide >= scr_wide) { var x = 0; }
	else { var x = (scr_wide - win_wide) / 2; }
	if (win_high >= scr_high) { var y = 0; }
	else { var y = (scr_high - win_high) / 2; }
	win_properties += 'scrollbars=' + scrollbar + ',width=' + win_wide + ',height=' + win_high + ',top=' + y + ',left=' + x;
	var win_handle = window.open('', '_blank', win_properties);
	win_handle.document.open();
	win_handle.document.write(html_content);
	win_handle.document.close();
	win_handle.focus();
}

function aboutmubla () {
	var win_wide = 320;
	var win_high = 240;
	var left = (screen.width - win_wide) / 2;
	var top = (screen.height - win_high) / 2;
	var winAttribs =
		'toolbar=0,status=0,menubar=0,resizable=0,scrollbars=yes,directories=0,dependent=yes'
		+ ',width=' + win_wide + ',height=' + win_high + ',top=' + top + ',left=' + left;
	var winHandler = window.open('', 'about', winAttribs);
	var htmlContent = '<html><head><title>About MUBLA!</title>'
		+ '<style>body{background-color:#000000;font-family:tahoma,arial,verdana,helvetica;font-size:8pt;}'
		+ 'div.text{position:absolute;left:10px;top:10px;width:300px;height:200px;background-color:#404040;'
		+ 'color:#d0d0d0;border:1px #202020 solid;padding:4px;text-align:justify;overflow:auto;}'
		+ 'div.bottom{position:absolute;left:10px;top:211px;width:300px;height:10pt;background-color:transparent;'
		+ 'color:#c0c0c0;padding:2px;text-align:center;}a{text-decoration:underline;color:#f0d000;}</style></head><body>'
		+ '<div class="text"><b>MUBLA! 2004</b> uses PHP, JavaScript, and CSS to create an easy to manage, '
		+ 'user-friendly, and aesthetically-pleasing image gallery. MUBLA! is free to use and can be installed on any '
		+ 'server running PHP4 with GD installed. It features multiple albums, support for a variety of image formats, '
		+ 'five different thumbnailing modes, generated-image caching, built-in album browsing, CSS-based layout, '
		+ 'and much more! To learn more about MUBLA! or to get your own copy of it, please visit '
		+ '<a target="_blank" href="http://sketch.cmatter.com/">Sketchworx Studios</a>.<br /><br />Thanks for using MUBLA!'
		+ '</div><div class="bottom"><a href="#" onClick="javascript:self.close();">Close Window</a></div></body></html>';
	winHandler.document.open();
	winHandler.document.write(htmlContent);
	winHandler.document.close();
	winHandler.focus();
}