/* MID_GLOBAL.JS for MID menus of BACHWARE.COM, 
©2007 Central Utah Data, Orem, UT  84057-4466 */
scr_w = 800; scr_h = 600;
w=window; wd=w.document; not_found = -1; 
nol = new Object;
inf = new Object; 
ear = new Object; 
ear_w = 780; ear_h = 240; ear_x = (scr_w - ear_w)/2; ear_y = (scr_h - ear_h)/2;
graphic =  txt = true; 
nongraphic =  no_tx = false;
this_htm=	location.protocol + "////" +
			location.hostname + location.pathname; // name of current .htm file
path = location.href.substring(0,location.href.lastIndexOf(this_htm));
(navigator.appName.indexOf("Microsoft Internet Explorer")>=0) ?
	msie = true 	: msie = false;
(navigator.appName.indexOf("Netscape")>=0) ?
	ns = true		: ns = false;

if (msie)	brv = navigator.appVersion.substring(
	navigator.appVersion.indexOf('MSIE') + 5,
	navigator.appVersion.indexOf('MSIE') + 9);
if (ns)		brv = navigator.appVersion.substring(
	0,
	4);

bar_dir = lv2r(lv2g, nongraphic) +  'services/barometer/';
setTimeout("", 300);
inf_i = new Array(20);
//generate array for caching barometer images
for(var i = 1; i < 21; i++){
	inf_i[i] = new Image();
	inf_i[i].src =	bar_dir + 5*i + ".GIF";
	}
//alert("First image is " +inf_i[1].src)

// This function spawns a child window that displays a temporary message
// during load/parse of the JavaScript.
function spawn_msg(bkcolor, WinName){
	var mw = w.open("", WinName, "width=250,height=60,left=312,top=354");
	if(!msie)mw.focus();
	mw.document.open();
	var md = mw.document;
	md.writeln('<html><head>');
	md.writeln('	<title>page-load message</title>');
	md.writeln('	<meta name="Author" ' + 
						'content="text/html; charset=iso-8859-1">');
	md.writeln('	<meta name="generator" ' +
						'content="Mozilla/4.71 (win98; u) [Netscape]">');
	md.writeln('	</head>');
	md.writeln('<body text="black" bgcolor=' + bkcolor + '>');
	md.writeln('	<div style="text-align: center; font-size: larger; font-weight: bold;">Loading page.');
	md.writeln('	<br>please wait...');
	md.writeln('	<br><img src="' + bar_dir + '0.gif"');
	md.writeln('	name="bar" style="margin: 8px; border: 2px solid;"></img>');
	md.writeln('	</div></body></html>');
	md.close();
//	alert("window (" + msgwin + ") created, name: '" + msgwin.name + "'");
	return mw;
	}

//These two functions merely type HTML comment tags to block HTML-only/non-JS HTML
function com(){document.write("<!-- ");}
function unc(){document.write(" -->");}

// This function concatenates ../'s to make a string that's supposed to point to the correct graphics directory.
function lv2r(lvs, gr){
	lvstr="";
	while(lvs > 0){lvstr += "../"; lvs--;}
	if (gr) lvstr += "Graphics/"
	return lvstr;
	}

// This function makes a dead-link box
function no_link(lng){
	nol=open("","NOL","width=300,height=200,top=282,left=412");
	nd=nol.document;
	nd.write('<html><head>',
			'<title>no link</title>',
			'<meta name="Author" content="' + this_htm + '.htm">',
			'<meta name="Generator" content="Mozilla/4.06 (Win98; u) [Netscape]">',
		'</head>',
		'<body text="#ffffff" bgcolor="#ffcc33">',
		'<center>',
		'<a name="Top"></a><span style="font-size: xx-large; font-weight: bold;">',
		'This link is<br>not currently active.</span>',
		'<p><a href="#Top"',
		'onmouseover="window.status=' + "'Click to close window'; return true;" + '"',
		'onmouseout="window.status=' + "''" + ';"',
		'onclick="self.close(); return false;">',
		'<img src="' + path + lv2r(lv2g,graphic) + 'GREEN_CLOSE.GIF" ',
		'alt="[Close], 1k .gif" style="border: none; vertical-align: middle;">',
		'</p></body></html>');
	nd.close();
	return false;
   }

// This function makes an info box
function mi(htmf, subj, wn_nm, w, h, linktx){
	document.write('<a href="#' + subj + '" ');
	mk_ieh_str(htmf + ".htm", subj, wn_nm, w, h);
	document.write(
		'title="Display info for ' + subj + '"><img \nsrc="',
		lv2r(lv2g,graphic) + 'Q.GIF" alt="[?] -- 1K .GIF"\n',
		'style="border: none; vertical-align: middle;">');
	if(linktx)	document.write('<span style="font-weight: bold;">&nbsp;' + subj);
	document.write('</span></a>');
	}

//This function makes the info box hyperlink's event-handler strings
function mk_ieh_str(htm, subj, nm, w, h){
	document.write(
		'\nonMouseOver="window.status=\n\t'+
		"'Display info for " + subj + "'", '; \n\treturn true;"'+
		"\nonMouseOut=\n\t", '"window.status=', "''", ';"' +
		"\nonClick=\n\t" +
		"\042if(inf.closed == undefined || inf.closed)\n" +
			'inf = si(\n\t'+ 
				"'" + htm	+ "',\n\t"	+ 
				"'" + nm	+ "',\n\t"	+ 
				"'" + w		+ "',\n\t"	+ 
				"'"	+ h		+ "');\n\t"	+
		"else if(!(msie&&brv=='3.0')) inf.focus();\042"
		);
   }

//This function generates the info box's content
function si(htmf, wn_nm, w, h){
	if(inf.closed == undefined || inf.closed)
	var	win = open(
		path + htmf,
		wn_nm, 
		"width="	+ w 			+ "," +
		"height="	+ h 			+ "," +
		"top=" 		+ (300 - h/2) 	+ "," +
		"left="		+ (400 - w/2) 	+ "," +
		"scrollbars,status");
	win.document.close();
	if(!(msie&&brv=="3.0")) win.focus();
	return win;
   }

// This function makes the hyperlink HTML for an earlobe
function mb(pc, fnm, alttx, altsz, txt){
	document.write('<span style="white-space: nowrap;"><a href="#' + pc + '"');
	mk_ehs("onMouseOver",	pc,	"/*not used*/", alttx,	altsz);
	mk_ehs("onClick", 		pc,	fnm,						alttx,	altsz);
	document.write(
		' title="Display earlobe score for ' + alttx + '" ' +
		'><img \n' + 
		'src="'+ lv2r(lv2g, graphic) + 'TCLEF_ICO.GIF" alt="[SCORE -- 1K .GIF]"\n'+
		'style="border: none; vertical-align: middle;">&nbsp;');
	if(txt)	document.write('<span class="tiny b">' + pc + '</span>');
	document.write('</a>&nbsp;<span class="tiny b">('+
	altsz + 'K&nbsp;.GIF)</span></span> ');
	}

// This function makes the event-handler strings for the respective hyperlinks
function mk_ehs(h, pc, fnm, alttx, altsz){
	document.write(
		"\n" + h + '="');			//start each handler w/ its name & leading dquo
		if(h=="onMouseOver"){	//status line message setup
			document.write(
				"window.status='Display earlobe score for " + alttx, 
					" (", altsz, "K&nbsp;.GIF)'; return true;", '"');
				//explicitly clear the status line for Netscape 3.0...
			document.write(
				'\nonMouseOut="window.status=' + "'';");}
		if(h=="onClick")//generate the earlobe window, its handle is ear
			document.write(
			'if((ear.closed == undefined) || ear.closed)',
			"ear = sp('"+	fnm 	+ "',\n\t'",
							alttx	+ "',\n\t'",
							altsz	+ "','",
							pc		+ "');\n\t",
			"else if(!(msie && brv == '3.0')) ear.focus();\t",
			"return false;");
	document.write('"');
	}

// This function spawns a child window that displays the earlobe .GIF, 
// allowing the user to play it.
function sp(fnm, alttx, altsz, pc){
	if(ear.closed == undefined || ear.closed)
		var win = open(
			"", 
			"EARLOBE", 
			"width="	+ ear_w 	+ ",height="	+ ear_h		+ "," +
			"top="		+ ear_y 	+ ",left="		+ ear_x 	+ ",status");
	if(!(msie&&brv=="3.0")) win.focus();
	var wind = win.document;
	wind.bgcolor="white";
	wind.write(
	'<html><head>',
		'<title>'+pc+' earlobe</title>',
		'<meta name="Author" Content="'+this_htm+'.htm">',
		'<meta name="generator" content="Mozilla/4.71 (Win98; U) [Netscape]">',
		'</head>',
	'<body text="#000000" bgcolor="#ffffff" link="#0000ee" vlink="#ff00ff" alink="#ff0000">',
	'<span style="color :#805020;"><div style="text-align: center; font-weight: bold;">Click notation to play earlobe. ',
	'<a href="" ', 'OnClick="self.close(); return opener.ear_o = false;" ',
	'onMouseOver="window.status='+"'Click to close window.'; "+'return true;" ',
	'onMouseOut="window.status=', "'';", '"> ',
	'<img src="', path+lv2r(lv2g,graphic)+"GREEN_CLOSE.GIF"+'" ',
	'style="border: none; vertical-align: middle;"></a>',
	'<a href="' + path + fnm + '_ear.MID" ',
	'onMouseOver="window.status='+"'Click to play "+ pc +" earlobe...'; "+'return true;" ',
	'onMouseOut="window.status=', "'';", '">',
	'<img src="' + path + fnm + '_ear.GIF" ',
	'alt="[' + alttx  + '], ' + altsz + 'K .GIF" '+
	'style="border: none; vertical-align: middle;"></a>',
	'</body></html>');
	wind.close();
	return win;
	}

