//<![CDATA[
function findFormObject(caller) {
	for (var obj = caller; obj; obj = obj.parentNode) {
		if (obj.nodeName == "FORM")
			return obj;
	}
	return null;
}

function trim(str) {
	var start = 0;
	var end = str.length;
	for (var i = 0; i < str.length; i ++) {
		if (str.charAt(i) != " ") {
			start = i;
			break;
		}
	}
	for (var i = str.length - 1; i >= 0; i --) {
		if (str.charAt(i) != " ") {
			end = i + 1;
			break;
		}
	}
	return str.substring(start, end);
}

function open_img(img_src) {
	img_view = window.open("", "ImagePopup", "width=0, height=0, left=0, top=0, scrollbars=yes, resizable=yes");
	img_view.document.write(
		'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' + 
		'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n' + 
		'	<head>\n' + 
		'		<title> :: View :: <\/title>\n' + 
		'		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>\n' + 
		'		<script type="text/javascript">\n' + 
		'			function resize(img) {\n' + 
		'				var imageWidth = img.width;\n' + 
		'				var imageHeight = img.height;\n' + 
		'				var screenWidth = screen.availWidth;\n' + 
		'				var screenHeight = screen.availHeight;\n' + 
		'				var windowWidth = imageWidth + 50;\n' + 
		'				var windowHeight = imageHeight + 70;\n' + 
		'				var positionX = (screenWidth - imageWidth) / 2;\n' + 
		'				var positionY = (screenHeight - imageHeight) / 2;\n' + 
		'				if(imageWidth > screenWidth) {\n' + 
		'					windowWidth = screenWidth;\n' + 
		'					document.body.scroll ="yes";\n' + 
		'					positionX = 0;\n' +
		'				}\n' + 
		'				if(imageHeight > screenHeight) {\n' + 
		'					windowHeight = screenHeight;\n' + 
		'					document.body.scroll ="yes";\n' + 
		'					positionY = 0;\n' +
		'				}\n' + 
		'				window.resizeTo(windowWidth, windowHeight);\n' + 
		'				window.moveTo(positionX, positionY);\n' + 
		'			}\n' + 
		'		<\/script>\n' + 
		'	<\/head>\n' + 
		'	<body style="margin: 0px">\n' + 
		'		<table style="width: 100%; height: 100%">\n' + 
		'			<tr>\n' + 
		'				<td style="text-align: center" valign="middle">\n' + 
		'					<a href="javascript:window.close()"><img src="' + img_src + '" style="border: 0px" onload="resize(this)"/><\/a>\n' + 
		'				<\/td>\n' + 
		'			<\/tr>\n' + 
		'		<\/table>\n' + 
		'	<\/body>\n' + 
		'<\/html>');

	img_view.document.close();
	try { img_view.document.focus(); }
	catch(e) { }
}
