var Page = {
	viewHeight: 0,
	viewWidth: 0,
	pageHeight: 0,
	pageWidth: 0,
	scrollLeft: 0,
	scrollTop: 0,
	refresh: function()
	{
		if (window.innerHeight != null)
		{
			this.viewHeight = window.innerHeight;
			this.viewWidth = window.innerWidth;
			this.scrollLeft = window.pageXOffset;
			this.scrollTop = window.pageYOffset;
			this.pageHeight = document.documentElement.offsetHeight;
			this.pageWidth = document.documentElement.offsetWidth;
		}
		else
		{
			var docElement = null;
			if (document.compatMode != null && document.compatMode != "BackCompat")
				docElement = document.documentElement;
			else
				docElement = document.body;
		
			this.viewHeight = docElement.clientHeight;
			this.viewWidth = docElement.clientWidth;
			this.scrollLeft = docElement.scrollLeft;
			this.scrollTop = docElement.scrollTop;
			//this.pageHeight = docElement.offsetHeight > docElement.scrollHeight ? docElement.offsetHeight : docElement.scrollHeight;
			//this.pageWidth = docElement.offsetWidth > docElement.scrollWidth ? docElement.offsetWidth : docElement.scrollWidth;
			this.pageHeight = docElement.scrollHeight;
			this.pageWidth = docElement.scrollWidth;
		}
		
		if (this.viewHeight > this.pageHeight) this.pageHeight = this.viewHeight;
		if (this.viewWidth > this.pageWidth) this.pageWidth = this.viewWidth;
	}
};

function viewImage(link, w, h)
{
	var html = '<html><head><title>' + link.title + '</title></head>';
	html += '<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">';
	html += '<img src="' + link.href + '" height="' + h + '" width="' + w + '" alt="' + link.title + '">';
	html += '</body></html>';
	
	if (window.opera == null)
	{
		l = Math.round((screen.availWidth - w) / 2);
		t = Math.round((screen.availHeight - h) / 2);
	}
	else
	{
		Page.refresh();
		l = Math.round((Page.viewWidth - w) / 2);
		t = Math.round((Page.viewHeight - h) / 2);
	}
	
	var win = window.open("", "winImage", "copyhistory=no,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbar=no,left=" + l + ",top=" + t + ",height=" + h + ",width=" + w);
	win.document.open();
	win.document.write(html);
	win.document.close();
	win.focus();
	return false;
}

function openImage(link, w, h)
{
	var html = '<html>\n' + 
	           '<head>\n' + 
						 '<title>' + link.title + '</title>\n' + 
	           '<script type="text/javascript" src="/includes/js/si_images.js"></script>\n' + 
						 '<script type="text/javascript">\n' + 
						 '<!--\n' + 
						 'si_preload("/page-images/", ["closewindow-on.jpg", "order-on.jpg"]);\n' + 
						 '//-->\n' + 
						 '</script>\n' + 
	           '<script type="text/javascript" src="/includes/js/viewer.js"></script>\n' + 
						 '</head>\n' + 
	           '<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onload="doResize()">\n' + 
	           '<table border="0" cellpadding="0" cellspacing="0" width="' + (w + 20) + '">\n' + 
						 '  <tr>\n' + 
						 '    <td rowspan="8"><img src="/page-images/blank.gif" height="1" width="10" alt=""></td>\n' + 
						 '    <td colspan="2"><img src="/page-images/blank.gif" height="10" width="1" alt=""></td>\n' + 					 
						 '    <td rowspan="8"><img src="/page-images/blank.gif" height="1" width="10" alt=""></td>\n' + 
             '  </tr>\n' + 
	           '  <tr>\n' + 
						 '    <td style="font:18pt Arial,sans-serif; color:#67cbfd;">' + link.title + '</td>\n' + 
             '    <td align="right" valign="bottom"><a href="javascript:window.close()" title="Close Window" onmouseover="si_over(\'closeWindow\', \'closewindow-on.jpg\')" onmouseout="si_out(\'closeWindow\')"><img src="/page-images/closewindow-off.jpg" name="closeWindow" id="closeWindow" height="16" width="86" alt="Close Window" border="0"></a></td>\n' + 
						 '  </tr>\n' + 
						 '  <tr>\n' + 
						 '    <td bgcolor="#67cbfd" colspan="2"><img src="/page-images/blank.gif" height="9" width="1" alt=""></td>\n' + 
						 '  </tr>\n' + 
						 '  <tr><td colspan="2"><img src="/page-images/blank.gif" height="10" width="1" alt=""></td></tr>\n' + 
	           '  <tr>\n' + 
						 '    <td colspan="2"><img src="' + link.href + '" height="' + h + '" width="' + w + '" alt="' + link.title + '"></td>\n' + 
						 '  </tr>\n' + 
						 '  <tr><td colspan="2"><img src="/page-images/blank.gif" height="10" width="1" alt=""></td></tr>\n' + 
	           '  <tr>\n' + 
						 '    <td align="right" colspan="2"><a href="/documents/order-form.doc" target="_blank" title="Order" onmouseover="si_over(\'order\', \'order-on.jpg\')" onmouseout="si_out(\'order\')"><img src="/page-images/order-off.jpg" name="order" id="order" height="23" width="85" alt="Order" border="0"></a></td>\n' + 
						 '  </tr>\n' + 
						 '  <tr><td colspan="2"><img src="/page-images/blank.gif" height="10" width="1" alt=""></td></tr>\n' + 
						 '</table>\n' + 
						 '</body>\n' + 
						 '</html>';
	
	var win = window.open("", "winImage", "copyhistory=no,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbar=no,height=100,width=100");
	win.document.open();
	win.document.write(html);
	win.document.close();
	win.focus();
	return false;
}

function doResize()
{
	Page.refresh();
	var table = document.getElementsByTagName("table")[0];
	
	var w = table.offsetWidth;
	var h = table.offsetHeight;
	var hDiff = w - Page.viewWidth;
	var vDiff = h - Page.viewHeight;
	resizeBy(hDiff, vDiff);
	
	if (window.opera == null)
	{
		l = Math.round((screen.availWidth - Page.pageWidth) / 2);
		t = Math.round((screen.availHeight - Page.pageHeight) / 2);
	}
	else
	{
		l = Math.round((opener.Page.viewWidth - Page.pageWidth) / 2);
		t = Math.round((opener.Page.viewHeight - Page.pageHeight) / 2);
	}
	
	moveTo(l, t);
	focus();
}

/*function doResize()
{
	Page.refresh();
	window.resizeTo(250, 100);
	
	var div = document.getElementsByTagName("div")[0];
	var table = document.getElementsByTagName("table")[0];
	var h = div.offsetHeight - table.offsetHeight;
	var w = div.offsetWidth - table.offsetWidth;
	window.resizeTo(-w, -h);
	
	if (window.opera == null)
	{
		l = Math.round((screen.availWidth - Page.pageWidth) / 2);
		t = Math.round((screen.availHeight - Page.pageHeight) / 2);
	}
	else
	{
		l = Math.round((opener.Page.viewWidth - Page.pageWidth) / 2);
		t = Math.round((opener.Page.viewHeight - Page.pageHeight) / 2);
	}
	window.moveTo(l, t);
}*/
