
// THIS CODE was mutated, modified, and re-done by the K10k semi-bald posse
// and then further mutated, modified, and re-done by Ryan Singer
// THIS CODE was done in 1997-2002
// ----------------------------------------------------------------------------



// CHECK CLIENT BROWSER & PLATFORM
// original code from http://developer.apple.com/internet/_javascript/
//
// USAGE:	browserNaming();
// NOTES:	call it from within an external JS document
// RESULT:	browserNew = true/false
//			browserName = IE/NS/Opera
//			browserNameLong = IE5/etc
//			Macintosh = true/false
// WORKS:	everything

	var its;
	var browserName;
	var browserNameLong;
	var browserNew;
	var preloadFlag = false;
	var Macintosh = navigator.userAgent.indexOf('Mac')>0;

	function its() {
		var n = navigator;
		var ua = ' ' + n.userAgent.toLowerCase();
		var pl = n.platform.toLowerCase();
		var an = n.appName.toLowerCase();

		// browser version
		this.version = n.appVersion;
		this.nn = ua.indexOf('mozilla') > 0;

		// 'compatible' versions of mozilla aren't navigator
		if(ua.indexOf('compatible') > 0) {
			this.nn = false;
		}
		
		this.opera = ua.indexOf('opera') > 0;
		this.ie = ua.indexOf('msie') > 0;
		this.major = parseInt( this.version );
		this.minor = parseFloat( this.version );

		// platform
		this.mac = ua.indexOf('mac') > 0;
		this.win = ua.indexOf('win') > 0;

		// workaround for IE5 which reports itself as version 4.0
		if(this.ie) {
			if(ua.indexOf("msie 5") > 1) {
			var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
			this.major = parseFloat(navigator.appVersion.substr(msieIndex,3));
			}
		}

		return this;
	}

	function browserNaming() {
		its = new its();
		
		// is it a DOM-enabled browser?
		if (!document.getElementById) {
			browserNew = false;
		}
		else {
			browserNew = true;
		}

		// need the name, too
		if (its.opera) {
			browserName = "Opera";
		}
		else if (its.ie) {
			browserName = "IE";
		}
		else {
			browserName = "NS";
		}

		// and the number
		browserNameLong = browserName + its.major;
	
	}
	

// PRELOAD FUNCTION
// USAGE:	window.onload = preloadMe();
// NOTES:	call it from within the html page
// WORKS:	ie4+, ns4+, opera5

	function preloadMe() {
		createObject('b10','img/b1-0.gif');
		createObject('b11','img/b1-1.gif');
		createObject('b20','img/b2-0.gif');
		createObject('b21','img/b2-1.gif');
		createObject('b30','img/b3-0.gif');
		createObject('b31','img/b3-1.gif');
		createObject('b40','img/b4-0.gif');
		createObject('b41','img/b4-1.gif');
		createObject('b50','img/b5-0.gif');
		createObject('b51','img/b5-1.gif');
		createObject('b60','img/b6-0.gif');
		createObject('b61','img/b6-1.gif');
		createObject('b70','img/b7-0.gif');
		createObject('b71','img/b7-1.gif');
		createObject('b80','img/b8-0.gif');
		createObject('b81','img/b8-1.gif');
		createObject('b90','img/b9-0.gif');
		createObject('b91','img/b9-1.gif');
		createObject('ba0','img/b10-0.gif');
		createObject('ba1','img/b10-1.gif');
		createObject('bb0','img/b11-0.gif');
		createObject('bb1','img/b11-1.gif');
		preloadFlag = true;
	}


// CREATING THE MOUSEOVER IMAGES
// USAGE:	createObject('buttonoff','images/specfeature_celluar_off.gif');
// NOTES:	call it from within the preload function
// WORKS:	ie4+, ns4+, opera5

	function createObject(imgName,imgSrc) {
		if (browserNew && (browserName == "NS")) {
		// a DOM-compatible browser
		// which is probably NS6/mozilla (the other code works better in IE/Opera)
			var tempImg = document.createElement("img");
			tempImg.src = imgSrc;
			tempImg.id = imgName;
			tempImg.style.visibility = 'hidden';
			tempImg.style.position = 'absolute';
			tempImg.style.top = 0;
			document.body.appendChild(tempImg);
		}
		else {
		// a non-DOM-compatible browser
		// and IE/Opera
			eval(imgName+' = new Image()');
			eval(imgName+'.src = "'+imgSrc+'"');
		}
	}


// MOUSEOVER SWITCHING
// USAGE:	<a href="#" onmouseover="changeImage(null,'buttonname','buttonnameon');" onmouseout="changeImage(null,'buttonname','buttonnameoff');">
// NOTES:	if the image is in a DIV, substitute 'null' with the DIV name.
// WORKS:	ie4+, ns4+, opera5

	function changeImage(layer,imgName,imgObj) {
		if (preloadFlag) {
			if (browserNew && (browserName == "NS")) {
			// a DOM-compatible browser
			// which is probably NS6/mozilla (the other code works better in IE/Opera)
				thisImage = document.getElementById(imgName);
				newImage = document.getElementById(imgObj);
				newSrc = newImage.getAttribute("src");
				thisImage.setAttribute("src",newSrc);
			}
			else {
			// a non-DOM-compatible browser
			// and IE/Opera
				if ((browserName == "NS") && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
				else document.images[imgName].src = eval(imgObj+".src")
			}
		}
	}


// POPUP WINDOW (FIXES THE IE4/MAC PROBLEM WHICH MAKES WINDOWS TOO SMALL)
// USAGE:	<a href="#" onclick="spawnWindow('newpage.html','windowname',400,384,'no');">
// NOTES:	substitute 400 with the width, 384 with the height, windowname with the name of the new window, scroll with either 'yes', 'no' or 'auto'
// WORKS:	ie4+, ns4+, opera5

	function spawnWindow(desktopURL,windowName,width,height,scroll,x,y) {
		if (x && y) {
			var leftspace = x;
			var topspace = y;
		}
		else {
			if (Macintosh) {
				if (browserNameLong == "IE4") {
					newheight = parseInt(height + 17);
				}
				else if (browserNameLong == "IE4.5") {
					newheight = parseInt(height + 17);
				}
				else {
					newheight = height;
				}
			}
			else { newheight = height; }	
			var leftspace = (screen.width - width) / 2;
			var topspace = (screen.height - newheight) / 3;
		}
  		remote = window.open("", windowName, "toolbar=no,location=no,status=no,menubar=no,scrollbars="+scroll+",width="+width+",height="+newheight+",left="+leftspace+",top="+topspace+",resizable=no" );
		remote.location.href = desktopURL;
		if (remote.opener == null) remote.opener = window;
		remote.opener.name = "opener";
		remote.focus();
	}

	function systemnav()
	{
		box = document.nav.systems;
		destination = box.options[box.selectedIndex].value;
		for(var i = 0; i < box.length; i++)
			if (box.options[i].value == "") box.options[i].selected = true;
		if (destination) location.href = destination;
	}
