
// * note about ROLLOVERS 
//		Because of Netscape 4...the image arrays must be included within each HTML file.  
//		The image arrays cannot be used in a SRC file because NS4 errors out, even if root is correct.


// MOUSEOVER functions -----------------------------
	function imageLoader(a) {
		if (document.images) {
			if (!document.p) document.p=new Array();
			var i, j=document.p.length;
			for (i=0; i<a.length; i++)
				if (a[i].indexOf("#")!=0) { document.p[j] = new Image; document.p[j++].src = a[i]; }
		}
	}
	function preloadImages() {
		imageLoader(preloadArray);
	}

	// PRELOAD ARRAY - located in template

	// start preloading images after page load
	if (window.addEventListener) {
		window.addEventListener("load", preloadImages, true);
	} else if (window.attachEvent) {
		window.attachEvent("onload", preloadImages);
	} else {
		window.onload = preloadImages;
	}

	HOVER_X = "_on"; // mouse-over extension
	// USAGE: swap(this, ['newimage.gif'])
	function swap(i) {
		if (document.images && i.childNodes) {
			var a = swap.arguments[1], s = i.childNodes[0];
			if (a) s.src = a;
			else {
				var x = s.src.lastIndexOf('.'), xl = HOVER_X.length;
				if (s.src.substring(x-xl, x) == HOVER_X)
					s.src = s.src.substring(0,x-xl)+s.src.substring(x,s.src.length);
				else s.src = s.src.substring(0,x)+HOVER_X+s.src.substring(x,s.src.length);
			}
		}
	}
// end mouseover -----------------------------




// ** Use by Flight to Mars
	// popup window, variable size
	function popWindow(url, name, intWidth, intHeight)
	{
		winParameters = "width=" + intWidth + ",height=" + intHeight + ",scrollbars=yes";
		popupWin = window.open(url, name, winParameters);
		popupWin.focus();
	}





function stripCharString (InString, CharString)  {
	OutString="";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar=InString.substring (Count, Count+1);
		Strip = false;
		for (Countx = 0; Countx < CharString.length; Countx++) {
			StripThis = CharString.substring(Countx, Countx+1)
			if (TempChar == StripThis) {
				Strip = true;
				break;
			}
		}
		if (!Strip)
			OutString=OutString+TempChar;
	}
	return (OutString);
}



// Designs of Alien Life quiz functions
function answerize(x) {
	var answer = "x";
	if (x) { var answer = x.substr(5,1); }
	if (answer != "a" && answer != "b") { answer = "x"; } 
	return answer;
}

function anscheck(z,n) {
	var msg = " "; var url = "index.html";
	if (n) { 
		var quiz = "i"; var url = "index.html"; var Q = n.substr(0,1); var P = n.substr(1,1);
		switch (Q) {
			case "e":
				quiz = "europa"; break;
			case "m":
				quiz = "mars"; break;
			default:
				quiz = "i";
		}
		if (quiz != "i") { url = quiz+P+".html"; }
	}
	if (z == "y") { msg = "<div class=\"error\"><b class=\"red\">The answer submitted is not a valid option.  <a href=\""+url+"\">Try again.</a></b></div>"; }
	if (z == "x") { msg = "<div class=\"error\"><b class=\"red\">You must submit an answer.  Please <a href=\""+url+"\">go back and try again.</a></b></div>"; }
	return msg;
}
// end quiz functions




// New and Better popup

// 	usage: popuplink(['js-only url',] this[, w[, h[, scroll[, extras]]]])
// 	basic usage: <a href="popup.html" target="_blank" onclick="return(popuplink(this));">new pop</a>
// 	advanced usage: <a href="popup_nojs.html" target="_blank" onclick="return(popuplink('popup_yesjs.html', this, 200, 100, false));">new pop</a>
// 	site-wide defaults:
popup_w = 600;
popup_h = 450;
popup_scroll = true;
popup_extras = 'location=0,status=0,menubar=0,resizable=0';
//	POPUP_FANCY = 'location=yes,toolbar=yes,menubar=yes,directories=yes,status=yes,resizable=yes';
// 	NS4 placement:   	screenX and screenY
//	IE placement:		left and top
function popuplink() {
	var undef, i=0, args=popuplink.arguments;
	var url = (typeof(args[i])=='string') ? args[i++] : args[i].getAttribute('href');
	var target = args[i++].getAttribute('target') || '_blank';
	var w = args[i++];
	var h = args[i++];
	var s = (args[i]===undef) ? popup_scroll : args[i++];

	//	centering: determine screen center
	var scrw=(screen.width/2)-((w || popup_w)/2);
	var scrh=(screen.height/2)-((h || popup_w)/2);
	 	if (scrh > 100) { scrh = scrh - 40; } // bump vertical pos. just above center, but only if it fits

	var features = 'width=' + (w || popup_w)
		 + ',height=' + (h || popup_h)
		 + ',scrollbars=' + (s ? 'yes,' : 'no,')
		 + (args[i] || popup_extras)
		 + ',left='+scrw+',top='+scrh+',screenX='+scrw+',screenY='+scrh; // positioning for IE and NS
	var win = window.open(url, target, features);
	win.focus();
	return false;
}
// END POP UP