
var moment1 = new Date();
var moment2 = new Date(moment1.getUTCFullYear() + 1, moment1.getUTCMonth(), moment1.getUTCDate() );
var moment0 = new Date(moment1.getUTCFullYear() - 1, moment1.getUTCMonth(), moment1.getUTCDate() );

function setCookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + value +
   ((expires)	? ";expires=" + expires.toUTCString() : "") +
   ((path)		? ";path=" + path : "") +
   ((domain)	? ";domain=" + domain : "") +
   ((secure)	? ";secure" : "");
}


function readCookie(cookieName) {

	if (document.cookie) {

		var whichChip = new RegExp("\\b" + cookieName + "=", "i");
		var index = document.cookie.search(whichChip);

		if (index != -1) {

			// Find the start 
			cookieStart = index + cookieName.length + 1;

			// Find the end 
			cookieStop = document.cookie.indexOf(";", index);
			if (cookieStop == -1) { cookieStop = document.cookie.length }

			// with the start and the end... now you've got the whole thing 
			return document.cookie.substring(cookieStart, cookieStop)
		}
		
		else return false;
		
	}
	return false;
}

//if (readCookie('tempAdmin') == false) { location.href = "/updating.html"; }


function FuckSpam(name,domain,text) {

	if (name == "") 	{name = "Botch";}
	if (domain == "") 	{domain = "BotchTheCrab.com";}
	if (text == "")		{text = name + "@" + domain; }

	var mailto = "<a href=\"mailto:" + name + "@" + domain + "\">" + text + "</a>";
	document.write(mailto);
}

function spaceTrim(text) {

	while (text.charAt(text.length-1) == " ") {
		text = text.substring(0,text.length-1);
	}

	return text;
}


function changeScene() {

	//try {
	//	document.getElementById('transition_music').Play();
	//} catch (x) {}
	
	var T = document.images['scene'];
	var newFace = "con";
	
	if (document.images['scene'].src.indexOf("con") != -1) {
		newFace = "bot";
		T.src = "/images/transition_bot.gif";
	} else {
		T.src = "/images/transition_con.gif";
	}
	
	setCookie("FACE", newFace, moment2, "/");
	//setTimeout("location.reload()", 2750)
	location.reload();
}


function empty() {
	alert("Sorry, this page no longer exists.");
}



function tf(tfName, tfCoat, tfSub)
{
	var tfpop = window.open("/archive/focus2.asp?CharName=" + tfName + "&CharCoat=" + tfCoat + "&CharSub=" + tfSub, "Focus2", "resizable,scrollbars,status,top=0,left=0");
	tfpop.focus();
	return false;
}

function decode(tfName, tsURL)
{
	var ts = window.open("/archive/decoder.asp?CharName=" + escape(tfName) + "&ImgURL=" + escape(tsURL), "Decode", "resizable,scrollbars,status,top=0,left=0,width=250,height=250");
	ts.focus();
	return false;
}

onerror = function() { 
	if (navigator.userAgent.indexOf('MSIE') != -1)
		return true; 
	else
		return false;
}



// Nav mouseover function

function navItemMouse(ref,over) {

	if (over) 
	{
		// change item rollover appearance
		ref.style.backgroundColor='#333333';
		
		// test for sub-items and reveal if they exist
		if (ref.getElementsByTagName('ul').length > 0) ref.getElementsByTagName('ul')[0].style.visibility = 'visible';
	} 
	else 
	{
		// change item rollover appearance
		ref.style.backgroundColor='#000000';
		
		// test for sub-items and reveal if they exist
		if (ref.getElementsByTagName('ul').length > 0) ref.getElementsByTagName('ul')[0].style.visibility = 'hidden';
	}
}

// nav click function

function navUrl(evt) {
	
	// determine event model, get URL attribute and cancel event bubble
	if (window.event) {
	
		var destination = event.srcElement.getAttribute('url');
		event.cancelBubble = true;
		
		event.srcElement.blur();
	
	} else {
	
		var destination = evt.target.getAttribute('url');
		//evt.cancelBubble = true;
	}
	
	// if not URL property, return
	if (destination == null) return;
	
	// follow link, either in same or new window
	if (destination.indexOf("http") != -1) {
		window.open(destination,'link');
	}
	else
		location.href = destination;

}


function activateNav()
{
	var arrow	= '<img src="/images/nav_arrow.gif" width="5" height="9" border="0" align="right" vspace="3" hspace="3">';
	var ulArray = document.getElementById('btcNav').getElementsByTagName('ul');
	
	for (u = 0; u < ulArray.length; u++) {
	
		if (ulArray[u].className == "navList") {
		
			var liArray = ulArray[u].getElementsByTagName('li');
			
			for (s = 0; s < liArray.length; s++) {
			
				if (liArray[s].innerHTML.indexOf('transition') != -1) continue;
				if (liArray[s].innerHTML.toLowerCase().indexOf('iframe') != -1 && liArray[s].innerHTML.toLowerCase().indexOf('home') == -1) continue;

				
				liArray[s].onmouseover	= function() { navItemMouse(this,true) };
				liArray[s].onmouseout	= function() { navItemMouse(this,false) };
				
				if (liArray[s].getAttribute('url') != null)
					liArray[s].style.cursor = "pointer";
				
				if (liArray[s].getElementsByTagName('ul').length > 0 && liArray[s].innerHTML.indexOf('arrow') == -1)
					liArray[s].innerHTML = arrow + liArray[s].innerHTML;
				
			}
		}
	}
}









function validateReply() {

	var R = document.createReply;
	
	for (u=0; u < R.elements.length; u++) {
		R.elements[u].value = trim(R.elements[u].value);
	}
	
	// add protocol to Website if necessary
	if (R.website.value != "" && R.website.value.indexOf('http') == -1) R.website.value = "http://" + R.website.value;
	
	if (R.replybody.value == "") {
		alert("You cannot enter an empty reply.");
		R.replybody.focus();
		return false;
	} else if (R.poster.value == "") {
		alert("To post a reply, you must enter a name.");
		R.poster.focus();
		return false;
	} else if (R.captchacode.value == "") {
		alert("Please prove that you are not a robot.");
		R.captchacode.focus();
		return false;
	} else {
		return true;
	}

}

/*
	} else if (R.sum.value == "" || isNaN(R.sum.value)) {
	
		alert("I know it's silly, but I need you to prove you're not a robot.\nPlease solve that addition problem.");
		R.sum.focus()
		return false;

	} else if (parseInt(R.sum.value) != (parseInt(R.addendA.value) + parseInt(R.addendB.value))) {
	
		alert("You need to check your math.");
		R.sum.focus()
		return false;


*/




function trim(txt) {

	while (txt.charAt(0) == " ")
		txt = txt.substring(1);
		
	while (txt.charAt(txt.length - 1) == " ")
		txt = txt.substring(0, txt.length - 1);
	
	return txt;
}







function toggleItem(e, which)
{
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	
	if (which.className == "open")
		which.className = "closed";
	else
		which.className = "open";
}
	

