var oldMenu;
var popTimer;
var isNav, isIE;


if( parseInt( navigator.appVersion ) >= 4 ) {
	if( navigator.appName == "Netscape" ) {
		isNav = true;
	} else {
		isIE = true;
	}
}


function WindowWidth() {
	if( isNav ) {
		return( window.innerWidth );
	} else {
		return( document.body.clientWidth );
	}
}


function WindowHeight() {
	if( isNav ) {
		return( window.innerHeight );
	} else {
		return ( document.body.clientHeight );
	}
}


function menu_action(src, showMenu) {
	if (showMenu == true) {
		window.clearTimeout(popTimer);
		if( oldMenu != null ) {
			close_menu();
		}
		src.origColor=src.style.backgroundColor;
		src.style.backgroundColor="003344";
		var menu = src.firstChild.nextSibling;
		menu.style.visibility = "visible";
		if( WindowWidth() > 700 + src.offsetLeft ) {
			menu.style.left = ( ( WindowWidth() - 700 ) / 2 + 112 + src.offsetLeft );
		} else {
			menu.style.left = ( 122 + src.offsetLeft );
		}
		menu.style.top = (src.offsetTop + src.offsetHeight + 18 );
	} else {
		// Set up our timer for closing this menu
		oldMenu = src;
		popTimer = window.setTimeout('close_menu()', 400);
	}
}


function highlight_menu(e, highlight) {
	var src = get_src(e);
	e.cancelBubble = true;
	if ((src.tagName == "TD") || (src.nodeName == "#text")) {
		if (highlight == true) {
			window.clearTimeout(popTimer);
			src.origColor=src.style.backgroundColor;
			src.style.backgroundColor="#333366";
	 } else {
			popTimer = window.setTimeout('close_menu()', 400);
			src.style.backgroundColor=src.origColor;
		}
	}
}


function close_menu() {
	oldMenu.style.backgroundColor= oldMenu.origColor;
	oldMenu.firstChild.nextSibling.style.visibility = "hidden";
	oldMenu = null;
}


function get_src(event_obj) {
	var src;
	// Fork for Netscape event handling
	if (navigator.appName == "Netscape")
		src = event_obj.target;
	else
		src = event_obj.srcElement;
	return src;
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function Coming() {
	alert( "I ain't yet done." );
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function clearstat() {
	window.status = '';
	return true;
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PrimeDates() {

	var FutureYearRange = 3;
	var YearRangeStart = 2001;
	var YearRangeEnd = 2010;
	var MonthNames = new Array( "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" );
	var OrderedMonthNames = new Array();
	var Today = new Date();
	var CurMonth = Today.getMonth();
	var CurYear = Today.getFullYear();
	var FromStart = 0;

	// Prime the month choices, starting with the current month.

	for( var i = 0 ; i < 12 ; i++ ) {
		if( MonthNames[i + CurMonth] ) {
			document.admin.sdtextmonth.options[i]  = new Option( MonthNames[ i + CurMonth ] , ( i + CurMonth ) , false , false );
			document.admin.sdpicmonth.options[i]   = new Option( MonthNames[ i + CurMonth ] , ( i + CurMonth ) , false , false );
		} else {
			document.admin.sdtextmonth.options[i]  = new Option( MonthNames[ FromStart ] , ( FromStart ) , false , false );
			document.admin.sdpicmonth.options[i]    = new Option( MonthNames[ FromStart ] , ( FromStart ) , false , false );
			FromStart++;
		}
	}


	// Prime the day. Will be overridden if the date is specified in the function call.

	document.admin.sdtextday.selectedIndex = ( Today.getDate() - 1 );
	document.admin.sdpicday.selectedIndex = ( Today.getDate() - 1 );

	// Prime the year, starting with current and stretching into the future based on "EventFutureYearRange" value.

	for( var i = YearRangeStart ; i <= YearRangeEnd ; i++ ) {
		document.admin.sdtextyear.options[ i - YearRangeStart ] = new Option( ( YearRangeStart + ( i - YearRangeStart ) ) , ( YearRangeStart + ( i - YearRangeStart ) ) , false , false );
		document.admin.sdpicyear.options[ i - YearRangeStart ] = new Option( ( YearRangeStart + ( i - YearRangeStart ) ) , ( YearRangeStart + ( i - YearRangeStart ) ) , false , false );
		if( YearRangeStart + ( i - YearRangeStart ) == CurYear ) {
			document.admin.sdtextyear.options[ i - YearRangeStart ].selected = true;
			document.admin.sdpicyear.options[ i - YearRangeStart ].selected = true;
		}
	}


	UpdateDOW();
}

function UpdateDOW() {
	if( navigator.appName == "Microsoft Internet Explorer" && parseInt( navigator.appVersion ) >= 4 ) {
		var DayNames = new Array( "sunday" , "monday" , "tuesday" , "wednesday" , "thursday" , "friday" , "saturday" );

		var SdTextDate = new Date();
		var SdPicDate = new Date();

		SdTextDate.setFullYear( document.admin.sdtextyear.value  );
		SdTextDate.setMonth   ( document.admin.sdtextmonth.value );
		SdTextDate.setDate    ( document.admin.sdtextday.value   );

		SdPicDate.setFullYear( document.admin.sdpicyear.value  );
		SdPicDate.setMonth   ( document.admin.sdpicmonth.value );
		SdPicDate.setDate    ( document.admin.sdpicday.value   );

		document.all.sdtextdow.innerText = DayNames[ SdTextDate.getDay() ];
		document.all.sdpicdow.innerText = DayNames[ SdPicDate.getDay() ];

	} else {
		// Netscape is behind the times, sadly enough.
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function SemiDailyText() {
	var Year  = document.admin.sdtextyear.value;
	var Month = ZeroPad( ( parseInt( document.admin.sdtextmonth.value ) + 1 ).toString() , 2 );
	var Day   = document.admin.sdtextday.value;
	window.location = ( "/cgi-bin/a/fdca-semidaily.cgi?d=" + Year + Month + Day );
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function SemiDailyPic() {
	var Year = document.admin.sdpicyear.value;
	var Month = ZeroPad( ( parseInt( document.admin.sdpicmonth.value ) + 1 ).toString() , 2 );
	var Day   = document.admin.sdpicday.value;
	window.location = ( "/cgi-bin/a/fdca-semidaily-pic.cgi?d=" + Year + Month + Day );
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ZeroPad( thisString , Length ) {
	if( Length > thisString.length ) {
		var RetStr = thisString;
		for( var i = thisString.length ; i < Length ; i++ ) {
			RetStr = "0" + RetStr;
		}
		return RetStr;
	} else {
		return thisString;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFSD() {
	if( ! document.sd.entry.value ) {
		alert( "You have to put an entry in there moron!      " );
		return false;
	} else {
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFHS() {
	var Mesg = "";
	if( ! document.hs.whosaid.value ) {
		Mesg += "      + Who Said is empty          \n";
	}
	if( ! document.hs.quote.value ) {
		Mesg += "      + Quote is empty          \n";
	}
	if( Mesg ) {
		alert( "\n    The form cannot be submitted:          \n\n" + Mesg + "\n\n" );
		return false;
	} else {
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFHW() {
	var Mesg = "";
	if( ! document.hw.number.value ) {
		Mesg += "      + Number is empty          \n";
	}
	if( ! document.hw.name.value ) {
		Mesg += "      + Name is empty          \n";
	}
	if( ! document.hw.count.value ) {
		Mesg += "      + Count is empty          \n";
	}
	if( Mesg ) {
		alert( "\n    The form cannot be submitted:          \n\n" + Mesg + "\n\n" );
		return false;
	} else {
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFGB() {
	var Mesg = "";
	if( ! document.gb.name.value ) {
		Mesg += "      + Name is empty          \n";
	}
	if( ! document.gb.comment.value ) {
		Mesg += "      + Comment is empty          \n";
	}
	if( Mesg ) {
		alert( "\n    The form cannot be submitted:          \n\n" + Mesg + "\n\n" );
		return false;
	} else {
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function ValidateGB() {
	var Mesg = "";
	if( ! document.gb.name.value ) {
		Mesg += "    + You didn't tell me your name          \n";
	}
	if( ! document.gb.comment.value ) {
		Mesg += "    + You didn't tell me anything          \n";
	}
	if( document.gb.color.selectedIndex < 1 ) {
		Mesg += "    + WHAT! Is your favorite color?          \n";
	}
	if( Mesg ) {
		alert( "  Aw, come on... you flubbed the following things:          \n\n" + Mesg + "\n" );
		return false;
	} else {
		document.gb.site.value = "true";
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteSD( myDate ) {
	if( confirm( "You sure?" ) ) {
		window.location = "/cgi-bin/a/fdca-semidaily-delete.cgi?d=" + myDate;
	} else {
		return false;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteHS( myId ) {
	if( confirm( "You sure?" ) ) {
		window.location = "/cgi-bin/a/fdca-hearsay-delete.cgi?id=" + myId;
	} else {
		return false;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteGB( myId ) {
	if( confirm( "You sure?" ) ) {
		window.location = "/cgi-bin/a/fdca-guestbook-delete.cgi?id=" + myId;
	} else {
		return false;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteHotwheels( myId ) {
	if( confirm( "You sure?" ) ) {
		window.location = "/cgi-bin/a/fdca-hotwheels-delete.cgi?id=" + myId;
	} else {
		return false;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function DeleteSDpic( myDate ) {
	if( confirm( "You sure?" ) ) {
		window.location = "/cgi-bin/a/fdca-semidaily-delete-pic.cgi?d=" + myDate;
	} else {
		return false;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PopFullSizeImage( myDate ) {
	var URL = "/cgi-bin/a/fdca-semidaily-pic-view.cgi?d=" + myDate;
	var newWindow = window.open( URL , "fullview", "screenX=25,left=25,screenY=25,top=25,width=700,height=700,scrollbars=yes,resizable=yes" , false );
	newWindow.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFSDpic() {
	var Mesg = "";
	var Img = new Array();
	var Bad = new Array();
	var fi = document.sdpic.elements;

	for( i = 0 ; i < ( fi.length - 1 ) ; i++ ) {
		if( fi[i].name.match( /^thumbnail/ ) || fi[i].name.match( /^fullsize/ ) ) {
			if( fi[i].value != "" ) {
				if( fi[i].value.match( /\.jpe?g$/i ) ) {
					Img[Img.length] = fi[i].value;
				} else {
					Bad[Bad.length] = ( i + 1 );
				}
			}
		}
	}

	if( Img.length == 0 ) {
		Mesg += "    No (valid) images were chosen    \n    to upload.    \n\n";
	}
	if( Bad.length > 0 ) {
		Mesg += "    Make sure all the files above    \n";
		Mesg += "    are image files.    \n\n";
		Mesg += "\n";
	}
	if( Mesg != "" ) {
		Mesg = ( "    ---------------------------------------------    \n\n    The form cannot be submitted.    \n\n" ) + Mesg;
		Mesg += ( "    Only images can be uploaded, and    \n    only files with an extension of    \n    .jpg or .jpeg.         \n\n" );
		Mesg += ( "    ---------------------------------------------    \n\n" );
		alert( Mesg );
		return false;
	} else {
		return true;
	}
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PopHS() {
	var subWindow = window.open( "/hearsay-new-form.html" , "hearsayform" , "screenX=50,left=50,screenY=50,top=50,width=450,height=350,scrollbars=yes,resizable=yes" , false );
	subWindow.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function VFnewHS() {
	var Mesg = "";
	if( ! document.hearsay.quote.value ) {
		Mesg += "      + What Was Said? is EMPTY          \n";
	}
	if( ! document.hearsay.whosaid.value ) {
		Mesg += "      + Who Said It? is EMPTY          \n";
	}
	if( ! document.hearsay.whotold.value ) {
		Mesg += "      + Your Name is EMPTY          \n";
	}
	if( Mesg ) {
		alert( "\n    The form can't be submitted yet:          \n\n" + Mesg + "\n" );
		return false;
	} else {
		return true;
	}
}


// # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #


function PopUp( URL , Name , X , Y , Xoff , Yoff ) {
	if( ! Xoff ) { Xoff = 25; }
	if( ! Yoff ) { Yoff = 25; }
	var newWindow = window.open( URL , Name , "screenX=" + Xoff + ",left=" + Xoff + ",screenY=" + Yoff + ",top=" + Yoff + ",width=" + X + ",height=" + Y + ",scrollbars=yes,resizable=yes" , false );
	newWindow.focus();
}


//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
//# - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - # - #
