

// 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>'
	var html_content = '<html><head><title>EquusLoco Image Gallery</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();
}


