function writeDate() {
var today, month, day, year;
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

today = new Date();
month = months[today.getMonth()];
day = today.getDate();
year = today.getFullYear();

document.write(month, " ", day, ", ", year);
}

function preLoadImages() {
if (document.images){

        abouton = new Image; aboutoff = new Image;
        abouton.src = "tales2001/ab_on.gif";
        aboutoff.src = "tales2001/ab_off.gif";

        adviceon = new Image; adviceoff = new Image;
        adviceon.src = "tales2001/ad_on.gif";
        adviceoff.src = "tales2001/ad_off.gif";
  	  
	fortuneon = new Image; fortuneoff = new Image;
        fortuneon.src = "tales2001/for_on.gif";
        fortuneoff.src = "tales2001/for_off.gif";

        archiveson = new Image; archivesoff = new Image;
        archiveson.src = "tales2001/ar_on.gif";
        archivesoff.src = "tales2001/ar_off.gif";

        taleson = new Image; talesoff = new Image;
        taleson.src = "tales2001/ta_on.gif";
        talesoff.src = "tales2001/ta_off.gif";

        contacton = new Image; contactoff = new Image;
        contacton.src = "tales2001/co_on.gif";
        contactoff.src = "tales2001/co_off.gif";

        linkson = new Image; linksoff = new Image;
        linkson.src = "tales2001/li_on.gif";
        linksoff.src = "tales2001/li_off.gif";

        homeon = new Image; homeoff = new Image;
        homeon.src = "tales2001/ho_on.gif";
        homeoff.src = "tales2001/ho_off.gif";
        
        moreon = new Image; moreoff = new Image;
        moreon.src = "tales2001/more_on.gif";
        moreoff.src = "tales2001/more_off.gif";
}
}
   
function swapem(iname, gname) 
{
        if(document.images)
	{
                iname.src = gname.src;
        }
}

function Trim (string) {
	if (string.length > 0) {
		string = RemoveLeadingSpaces (string);
	}
	if (string.length > 0) {
		string = RemoveTrailingSpaces(string);
	}
	return string;
}

function RemoveLeadingSpaces(string) {
	var space = /\s/;
	string.multiline = true;
	while(space.test(string.substring(0, 1))) {
		string = string.substring(1, string.length);
	}
	return string;
}

function RemoveTrailingSpaces(string) {
	var space = /\s/;
	string.multiline = true;
	while(space.test(string.substring((string.length - 1), string.length))) {
		string = string.substring(0, (string.length - 1));
	}
	return string;
} 

function isSpam(string) {
	var link = /href/gi;
	return link.test(string);
}

function checkFields() {  
	// checks for blank content field
	var description = Trim(document.form.content.value);
	if (description.length > 2) {
		if(isSpam(description)) {
			alert("Sorry, links are not accepted.");
			document.form.content.value = "";		 	
			document.form.content.focus();
			return false;	
		}
		else {
		    return !(isSpam(description));
		}
	}
	else { 	
		alert("Nothing on your mind, honeybunch?"); 		
			document.form.content.value = "";		 	
			document.form.content.focus(); 	
		return false; 
	} 		
} 

