function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function menuOn(option) {
  option.style.color = '#ffff00';
  option.style.cursor = 'hand';
}

function menuOff(option) {
  option.style.color = '#ffffff';
}

function randomString(string_length) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function showPic(picture_url, dflt_width, dflt_height, use_random) {
	var attr = 'scrollbars=no,resizable,width='+ dflt_width +',height='+ dflt_height +',left=200,top=100';
	var popupWin = window.open('', randomString(8), attr);

	var str =
		'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
		'<html lang="en" xmlns="http://www.w3.org/1999/xhtml">' +
		'<head>' +
		'<title>Miro Tool & Mfg., Inc.</title>' +
			'<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">' +
		'</head>' +
		'<script language="javascript" src="miro.js"></script>' +
		'<script language="javascript" type="text/javascript">' +
		'function resizeMe() {' +
			'if (parseInt(navigator.appVersion) > 3) {' +
				'if (navigator.appName == "Netscape") {' +
					'window.innerWidth  = document.images["pic"].width + 2;' +
					'window.innerHeight = document.images["pic"].height + 41;' +
				'}' +
				'else {' +
					'window.resizeTo(document.images[0].width, document.images[0].height);' +
					'var w = document.images[0].width - (f_clientWidth() - document.images[0].width) + 2;' +
					'var h = document.images[0].height - (f_clientHeight() - document.images[0].height) + 41;' +
					'window.resizeTo(w, h);' +
				'}' +
			'}' +
		'}' +
		'</script>' +
		'<style type="text/css">' +
		'body {' +
			'visibility: hidden;' +
			'margin: 0 0 5px 0;' +
			'padding: 0;' +
			'background-color: #ffffff;' +
		'}' +
		'</style>' +
		'<body onload="resizeMe(); document.body.style.visibility=\'visible\'; self.focus();" onblur="self.close();">' +
		'<table cellspacing="0" cellpadding="0" width="100%" height="100%" align="center" border="0">' +
			'<tbody>' +
			'<tr>' +
				'<td align="center" valign="top"><img name="pic" src="'+ picture_url + (use_random ? '&rs='+randomString(6) : '') +'" border="1"></td>' +
			'</tr>' +
			'<tr>' +
				'<td><img src="images/spacer.gif" width="5" height="6" border="0"></td>' +
			'</tr>' +
			'<tr>' +
				'<td align="center" valign="top"><button onclick="javascript:window.close();">Close</button></td>' +
			'</tr>' +
			'</tbody>' +
		'</table>' +
		'</body>' +
		'</html>';

	popupWin.document.write(str);
	popupWin.document.close();
}	// showPic()


function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

