// this is a consolidation of all scripting needed by the microfab site,
// done for no other reason than to expedite download time.

/////////////////////////////////////////////////////////////////////////////////////WRITE THE FLOATER STYLE
	//var NS = (document.layers) ? 1 : 0;
	//var IE = (document.all) ? 1: 0;

	var NS;
	var IE;

	var browserName = navigator.appName;
	
	if (browserName == "Netscape") { NS = 1; } else { NS = 0; }
	if (browserName == "Microsoft Internet Explorer") { IE = 1; } else { IE = 0; }
	
	nsfloatstyle = '<STYLE TYPE="text/css">#floater { position: relative;}</STYLE>';
	iefloatstyle = '<STYLE TYPE="text/css">#floater { position: relative;}</STYLE>';

	if (NS)
	{ document.write(nsfloatstyle); }
	else if (IE)
	{ document.write(iefloatstyle); }

/////////////////////////////////////////////////////////////////////////////////////WRITE THE FLOATER STYLE

/////////////////////////////////////////////////////////////////////////////////////Floater SCRIPT

	//This page uses the 'Stalker' floating menu JavaScript module by Spotted Antelope, Inc. (http://www.spottedantelope.com).
	//This script is protected by US Copyright law. No portion of it may be re-used, modified or altered without the express written permission
	//of Spotted Antelope, Inc., its agents or assigns. 
	//This script may not be used without this header under any circumstances.
	//For more information, contact Bill Womack (bw@spottedantelope.com)
	
	topOfPagePadding = 128;
	bottomOfPagePadding = 34;
	
	self.onError=null;
	
	currentY = 0;  
	whichIt = null;           
	lastScrollY = 0;
	
	MIN_Y = 0;

	function heartBeat()
	{
	
		if(IE)
		{
			if (document.body) {
				if (document.getElementById("floater").offsetHeight + bottomOfPagePadding > document.body.clientHeight) {
					tmpTop = (topOfPagePadding + document.getElementById("floater").offsetHeight + bottomOfPagePadding - document.body.clientHeight);
					diffY = Math.max(document.body.scrollTop, tmpTop) - tmpTop;
				} else
					diffY = Math.max(document.body.scrollTop, topOfPagePadding) - topOfPagePadding;
			} else
				{ return; }
		}
	    if(NS) {
			if (document.getElementById("floater").offsetHeight + bottomOfPagePadding > document.body.clientHeight) {
				tmpTop = (topOfPagePadding + document.getElementById("floater").offsetHeight + bottomOfPagePadding - document.body.clientHeight);
				diffY = Math.max(self.pageYOffset, tmpTop) - tmpTop;
			} else
				diffY = Math.max(self.pageYOffset, topOfPagePadding) - topOfPagePadding;
		}
		
		if(diffY != lastScrollY)
		{
	        percent = .1 * (diffY - lastScrollY);
			
			if(percent > 0)
			{ percent = Math.ceil(percent); }
	        else
			{ percent = Math.floor(percent); }

			if (IE) {
				var newval = document.getElementById("floater").style.posTop + percent;
	
				if (newval > MIN_Y)
				{ document.getElementById("floater").style.posTop += percent; }
				else
				{ document.getElementById("floater").style.posTop = MIN_Y; }
			}
			
			if (NS) {
				if (document.getElementById("floater").style.top.indexOf("p") != -1) {
					var strPosition = document.getElementById("floater").style.top.indexOf("p");
					var newval = parseInt(document.getElementById("floater").style.top.substring(0, strPosition)) + percent;
				} else {
					var newval = document.getElementById("floater").style.top + percent;
				}
				
				if (newval > MIN_Y) { 
					if (document.getElementById("floater").style.top.indexOf("p") != -1) {
						document.getElementById("floater").style.top = parseInt(document.getElementById("floater").style.top.substring(0, strPosition)) + percent;
					} else {
						document.getElementById("floater").style.top = document.getElementById("floater").style.top + percent;
					}
				}
				else
				{ document.getElementById("floater").style.top = MIN_Y; }
			}
			
	        lastScrollY = lastScrollY + percent;
	    }
	}

	function checkFocus(y)
	{ 
	    stalkery = document.getElementById("floater").pageY;
	    stalkerwidth = document.getElementById("floater").style.width;
	    stalkerheight = document.getElementById("floater").style.height;
	    if((y > stalkery) && (y < stalkery + stalkerheight))
		{ return true; }
	    else
		{ return false; }
	}
	
	function grabIt(e)
	{
		if(IE)
		{
			whichIt = event.srcElement;
			while (whichIt.id.indexOf("floater") == -1)
			{
				whichIt = whichIt.parentElement;
				if (whichIt == null) { return true; }
		    }
			
		    whichIt.style.pixelTop = whichIt.offsetTop + MIN_Y;
	   		currentY = (event.clientY + document.body.scrollTop); 	
		}
		else
		{ 
	        window.captureEvents(Event.MOUSEMOVE);
	        if(checkFocus (e.pageY))
			{ 
	            whichIt = document.getElementById("floater");
	            StalkerTouchedY = e.pageY-document.floater.pageY;
	        } 
		}
	    return true;
	}
	
	function moveIt(e)
	{
		if (whichIt == null) { return false; }
		if(IE)
		{
		    newY = (event.clientY + document.body.scrollTop);
		    distanceY = (newY - currentY);
		    currentY = newY;
		    whichIt.style.pixelTop += distanceY;
			if(whichIt.style.pixelTop < document.body.scrollTop)
				{ whichIt.style.pixelTop = document.body.scrollTop; }
			if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5)
				{ whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5; }
			//if(whichIt.offsetTop < topOfPagePadding)
			//	{ whichIt.offsetTop = topOfPagePadding; }
			//if(whichIt.offsetTop > document.body.scrollTop + document.body.offsetHeight - bottomOfPagePadding - whichIt.offsetHeight)
			//	{ whichIt.offsetTop = document.body.scrollTop + document.body.offsetHeight - bottomOfPagePadding - whichIt.offsetHeight; }
			event.returnValue = false;
		}
		else
		{
			//alert("test");
			whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
	        if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
	        if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
	        return false;
		}
	    return false;
	}
	
	function dropIt()
	{
		whichIt = null;
	    if(NS) window.releaseEvents (Event.MOUSEMOVE);
	    return true;
	}

	
	if(NS)
	{
		//window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
		//window.onmousedown = grabIt;
	 	window.onmousemove = moveIt;
		window.onmouseup = dropIt;
	}
	if(IE)
	{
		//document.onmousedown = grabIt;
	 	document.onmousemove = moveIt;
		document.onmouseup = dropIt;
	}
	
	if(NS || IE)
	{ action = window.setInterval("heartBeat()",10); }
/////////////////////////////////////////////////////////////////////////////////////Floater SCRIPT
