// rcdatetime 0.2

// please keep this text when you copy the source code
// made by Ragecreations version 0.2

// call with
/*
	<script language="javascript">
		document.write(	lday + ", "  +lmonth + " " + 
						date + ", " + year + " " + timeValue);
	</script>
*/
//Get Date
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000) 
year = year + 1900; 

//Get Time
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += (hours >= 12) ? " pm" : " am"

//Get Day
var days=new Array(7);
days[0]="Sunday";
days[1]="Monday";
days[2]="Tuesday";
days[3]="Wednesday";
days[4]="Thursday";
days[5]="Friday";
days[6]="Saturday";
var lday=days[time.getDay()];

// -- end rcdatetime 0.2


// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

// end central randomizer

/* COOKIE STUFF */
function getCookie(cookieName)	{
	if (document.cookie.length > 0) {
		begin = document.cookie.indexOf(cookieName+"=");
		if (begin != -1) {
			begin += cookieName.length+1;
			end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		}
	}
	return null;
}

function setCookie(cookieName, value, expiredays)	{
	var expireDate = new Date ();
	expireDate.setTime(expireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = cookieName + "=" + escape(value) + (
		(expiredays == null)
		? ""
		: "; expires=" + expireDate.toGMTString()
	);
}

function deleteCookie(cookieName)	{
	if (getCookie(cookieName))	{
		document.cookie = cookieName + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
/* end COOKIES */


/*	
	FLAG ROTATION 

	We need to rotate flags in some page headers. We want to start with
	a specific flag; on subsequent visits to that page, we want to 
	display the next flag in the list. So, in the page HTML we'll call 
	this code with 
	
		document.write(writeFlags(n)); 
	
	where 'n' is the index number of the preferred flag for that page.

	writeFlags() will write an iframe and ilayer, and source an HTML file 
	that renders the flag. writeFlags() will also attempt to set a
	cookie with the index of the last flag seen. Next time thru, we will
	look for that cookie, and seed writeFlags() with the flag following
	the last one seen. 
	
	If there's no cookie, we use the preferred flag 'n'. This is the starting
	condition, since the cookie expire at the end of the session. If we can't
	set a cookie, we'll always use the preferred flag -- cookies disabled
	means no rotation.
		
	The page-level code incldes a <NOSCRIPT> tag that contains the preferred
	flag. No JavaScript, no rotation.

*/

// root-relative path to the flag HTML files
flagBase = "/nav/flags/";

// all the available flag filenames go into the 'flags' array, 
// in the order they will be rotated
// if we add a new flag, add it to this array
// remember, count starts at ZERO! 
// so to call the first element, use 'writeFlags(0)'
flags = [
		"flag_monkey.html"
	,	"flag_over.html"
	,	"flag_school.html"
	,	"flag_baby_er.html"
	,	"flag_no_matter.html"
	,	"flag_mississippi.html"
	,	"flag_mean.html"
];	// *NO COMMA* after the last element! or we'll get an empty element 
	// after the last filename listed

numFlags = flags.length;
lastFlag = '';
whichFlag = '';

function writeFlag(n)	{ // 'n' is the preferred flag
	lastFlag = getCookie("lastFlag"); // see if there's a cookie

	if (lastFlag) {		// use the flag following the index in the cookie
		whichFlag = ((parseInt(lastFlag)+1) % numFlags); // wrap using numFlags as modulus
	} else {			// no cookie; use the seed value passed from the page
		whichFlag = n;	
	}

	var s = '';
	s+='<iframe src="' + flagBase;  
	s+=flags[whichFlag];
	s+='" id="flagiframe" scrolling="no" frameborder="0" width="630" height="136">\n';
	s+='<ilayer src="' + flagBase;
	s+=flags[whichFlag];
	s+='" id="flagilayer"><\/ilayer>\n';
	s+='<\/iframe>';

	// remember the last flag; cookie expires after current session
	setCookie("lastFlag", whichFlag);	

	return s;
}	

function debug()	{
	var d = '';
	d += '<div id="debug">\n';
	d += '<p>lastFlag: ' + lastFlag;
	d += '<br>whichFlag: ' + whichFlag;
	d += '</div>\n';
	return d;
}


function goback()	{
	var s = '';					
	s += '<div class="nav">\n';
	s += '<a href="javascript:history.back()">back</a> \n';
	s += '</div>\n';
	return s;
}

/* end FLAG stuff */


/*
	LINK TRACKING
	
	This function uses AXS to log *offsite* links. Use it in anchors that 
	refer to a page outside the site. So, the only target value we 
	care about is "_blank" -- _self, _parent, _top refer inside 
	the site. Internal pages track themselves when loaded; no reason 
	to track them from the caller. This currently won't support tracking 
	links to offsite pages that target a frame we own.

	Usage:
	<a href="http://some.other.site/page.html" 
		onclick="return log(this)" [target="_blank"]>
*/
function log(anchor)	{			// take an <a> object
	var axsurl = "/cgi-bin/axs/ax.pl";	// modify this if AXS is elsewhere

	var fullurl = axsurl + "?" + anchor.href;
	if ( anchor.target == "_blank" ) {
		window.open(fullurl); 		// open in new win
	} else {
		location.href = fullurl;	// open in this win
	}
	return false; 				// suppress browser's link behavior
}


function foo () {
	window.alert ("bar!");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Netscape 4 resize bug fix
// from http://javascriptworld.com/scripts/chap09/script02.html

if (document.layers) {
	origWidth = window.innerWidth;
	origHeight = window.innerHeight;
}

function resizeFix() {
	if (document.layers) {
		if ((window.innerWidth != origWidth) ||
			(window.innerHeight != origHeight)) {
				window.location.reload()
		}
	}
}

window.onresize = resizeFix;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




function init()	{
	MM_preloadImages(	'/nav/flags/img/baby_er_flag_quote_on.gif',
						'/nav/flags/img/mean_flag_quote_on.gif',
						'/nav/flags/img/mississippi_flag_quote_on.gif',
						'/nav/flags/img/no_matter_flag_quote_on.gif'
	)
}
