<!--
var g_sRoot = "http://countdown.org/";	// Root for the site
var g_oldResize;						// Holders for events we replace
var g_oldScroll;
var g_oldLoad;
var g_sSection = get_section(0);		// Current section of site

// alert(g_sSection);

// Figure out which graphic to use
if(g_sSection == "end")
	var g_sImage = 'common/floater_brn.gif';	
else if(g_sSection == "y2k")
	var g_sImage = 'common/floater_ppl.gif';
else
	var g_sImage = 'common/floater_blk.gif';
	
var sizeImage = new size(76, 26);
 
// Main HTML
var g_Html = '<MAP NAME="FloaterMap">' + 
		   	 '<AREA SHAPE="RECT" COORDS="54, 4, 72, 21" TITLE="Email" ALT="Email" HREF="' + get_email(g_sSection) + '">' +
		     '<AREA SHAPE="RECT" COORDS="32, 4, 51, 21" TITLE="Search this site" ALT="Search this site" HREF="' + g_sRoot + 'search/">' +
		     '<AREA SHAPE="RECT" COORDS="11, 4, 28, 21" TITLE="Countdown to Armageddon Home Page" ALT="Countdown to Armageddon Home Page" HREF="' + g_sRoot + '"></MAP>' +
			 '<a href="#none" onmouseover="fade_floater(100);" onmouseout="fade_floater(60);">' +
		     '<img alt="" name="imgFloater" ismap usemap="#FloaterMap" border="0" height="' + sizeImage.y + '" src="' + g_sRoot + g_sImage + '" width="' + sizeImage.x + '">' +
			 '</a>';

function size(_x, _y)
	{ this.x = _x;  this.y = _y; }

var idFloater = "idFloater";	// Holds the name of the floater
var nVisibleState = false;		// Are we visible right now?
var intervalFade;				// Fade ID Holder

write_floater();

function write_floater()
{
	// alert("write_floater()");
	
	// We don't do jazz on IE4 for the MAC
	if(window.document.all && (navigator.appVersion.indexOf("Mac") > -1))
		return;

	// Start the IE setup here...
	if(window.document.all)
		document.write('<span id="idFloater" style="filter:alpha(opacity=0);position:absolute;top:100;width:' + sizeImage.x + ';height:' + sizeImage.y + '">' + g_Html + '</span>');

	// Chain our event in	
	g_oldLoad = window.onload;
	window.onload = setup_floater;
}

function setup_floater()
{
	// Should only be called in onload function
	// Netscape bug: onload doesn't have an event object, so we can't test for it
	// Assume we are in the onload event and call previous onload
	if(g_oldLoad)
		g_oldLoad();
		
	// Main Netscape setup
	if(document.layers)
	{
		navFloater = new Layer(100);
		navFloater.left =- 300;
		navFloater.top = 120;
		navFloater.document.write(g_Html);
		navFloater.document.close()
		idFloater = navFloater.id; // Some wierd ID NS gives it
	}
	
	// Make sure DHTML Lib is loaded
	if(window.document.dhtmllib_inc && !window.document.dhtmllib_loaded)
		setup();
	
	// Version 3.0 browsers exit here (and NS4 without DHTML Lib)...
	if(!window.document.dhtmllib_loaded && !document.all)
		return;
	
	// If DHTML Lib hasn't recognized our floater then one more chance
	if(!window.document.all[idFloater])
		setup();
		
	// No go
	if(!window.document.all[idFloater])
	{
		window.status = "Can't display floater";
		return;
	}
	
	// Chain Events in
	// Save old events
	g_oldScroll = window.onscroll;
	g_oldResize = window.onresize;
	
	// Position event
	window.onresize = window.onscroll = position_floater;
	
	// Twice fixes some bugs
	position_floater();
	position_floater();
}
		


function position_floater() 
{
	// If we got this far either IE 4.0 or DHTMTL Lib

	// Call old events
	if(window.event && window.event.type)
	{
		if(window.event.type == "resize" && g_oldResize)
			g_oldResize();
		
		if(window.event.type == "scroll" && g_oldScroll)
			g_oldScroll();
	}

	// Position
	var clientHeight = window.document.body.clientHeight;
	var clientWidth = window.document.body.clientWidth;
	var docTop = window.document.body.scrollTop;
	var docLeft = window.document.body.scrollLeft;
	var floater = window.document.all[idFloater];
	
	//	alert(floater.innerHTML);

	// If we're at the top then..	
	if(docTop <= 0)
	{
		// ..hide it
		if(nVisibleState == true)
		{
			fade_floater(0);
			nVisibleState = false;			
		}

	}
	else
	{
		// ... otherwise show it
		if(nVisibleState == false)
		{
			fade_floater(60);	
			nVisibleState = true;
		}
	}
		
	// a little move over for Netscape
	if(document.layers)
	{
		docLeft += 4;
		docTop -= 2;		
	}

	// Set those values	
	floater.style.pixelTop = docTop;
	floater.style.pixelLeft = clientWidth - floater.offsetWidth + docLeft;	
}

function fade_floater(nTo)
{
	// Clear any current fading
	if(intervalFade)
		clearInterval(intervalFade);
		
	// Fade it 
	intervalFade = setInterval("fader(" + nTo + ",15);", 70);
}

function fader(nTotal, nAmount)
{
	var floater = window.document.all[idFloater];
	
	// For all those supporting fades...
	if(floater.filters)
	{
		var nCurrent = floater.filters.alpha.opacity;
	
		// Fading Out
		if(nCurrent > nTotal)
		{
			nCurrent -= nAmount;
			if(nCurrent < nTotal)
				nCurrent = nTotal;
		}
		// Fading In
		else if (nCurrent < nTotal)
		{
			nCurrent += nAmount;
			if(nCurrent > nTotal)
				nCurrent = nTotal;
		}

		// Set it
		floater.filters.alpha.opacity = nCurrent;
		
		// If we're done then stop
		if(nCurrent == nTotal)
			clearInterval(intervalFade);	
	}
	// Don't support fading go here
	else
	{
		// Clear and set to final
		clearInterval(intervalFade);
		nCurrent = nTotal;
	}
	
	// If we're not visible then hide ourselves so we don't get
	// in the way and also for non-filter browsers
	if(nCurrent == 0)
		floater.style.visibility = "hidden";
	else
		floater.style.visibility = "visible";	
}

function get_email(sSection)
{
	if(sSection == "")
		sSection = "questions";
	
	return "mailto:" + sSection + "@countdown.org";
}

function get_section()
{
	var sTemp = window.location.href;

	// Should find at least the last four characters of root
	var nStart = sTemp.indexOf(g_sRoot.substring(g_sRoot.length - 4, g_sRoot.length)) + 4;

	var nEnd = sTemp.indexOf('/', nStart);	
	if(nEnd == -1)
		nEnd = sTemp.length;
	
	return sTemp.substring(nStart, nEnd);
}

//: -->
