function fspEmail()
{
	var text, a, email, epat, atpat, dotpat;
	epat = /^\s*(\S+(\s+dot\s+\S+)*\s+at\s+\S+(\s+dot\s+\S+)+)\s*$/;
	atpat = /\s+at\s+/g;
	dotpat = /\s+dot\s+/g;
	if(this.tagName && this.attributes && this.parentNode && this.parentNode.insertBefore && document.createElement && this.parentNode.removeChild)
	{
		if(this.tagName.toUpperCase()=='A' && this.childNodes && this.childNodes[0])
		{
			text = this.href;
			if(text.search('mailto:')==0)
			{
				text = text.substr(7);
				text = text.replace(/\%20/g,' ');
				if(epat.test(text))
				{
					text = text.replace(atpat,'@');
					text = text.replace(dotpat,'.');
					this.href = 'mailto:'+text;
				}
			}
		}
		else if(this.tagName.toUpperCase()=='B' && this.childNodes && this.childNodes[0] && this.childNodes[0].nodeValue)
		{
			text = this.childNodes[0].nodeValue;
			if(epat.test(text))
			{
				text = text.replace(atpat,'@');
				text = text.replace(dotpat,'.');
				a = document.createElement('a');
				a.href = 'mailto:'+text;
				text = document.createTextNode(text);
				a.appendChild(text);
				this.parentNode.insertBefore(a,this);
				this.style.display = 'none';
			}
		}
		else if(this.tagName.toUpperCase()=='INPUT')
		{
			text = this.value;
			if(epat.test(text))
			{
				text = text.replace(atpat,'@');
				text = text.replace(dotpat,'.');
				this.value = text;
			}
		}
	}
}

document.register('b,a',null,fspEmail,'load',false);
document.register('input','NoSpam',fspEmail,'load',false);

function setupZebra(e)
{
	if(!e || !e.currentTarget) n = window.event.srcElement;
	else n = e.currentTarget;
	var r, t, mode;
	if(n.tagName.toLowerCase()=='table') mode='table';
	else mode='generic';
	if(mode=='table') r = n.getElementsByTagName('tr');
	else r = n.childNodes;
	t=1;
	for(var x=0; x<r.length; x++)
	{
		if((mode=='table' && r[x].getElementsByTagName('td').length) || (mode=='generic' && r[x].nodeType==ELEMENT_NODE))
		{
			addClassName(r[x],((t)?'fspZebraOdd':'fspZebraEven'));
			removeClassName(r[x],((t)?'fspZebraEven':'fspZebraOdd'));
			t = (t+1) % 2;
		}
	}
}

document.register('table,div,p,td,ul','zebra',setupZebra,'load',false);
document.register('table,div,p,td,ul','zebra',setupZebra,'recalc',false);

function setCookie(name, value, expireDays){
	if(expireDays){
		var today = new Date();
		var expire = new Date();
		expire.setTime(today.getTime() + 1000*60*60*24*expireDays);
	}
	else expires = null;
	document.cookie = name + "=" + escape(value) + ((!expire) ? "" : ("; expires=" + expire.toGMTString()))
	if(value){
		tcook = getCookie(name);
		if(tcook == value) return true;
		return false;
	}
}

function getCookie(Name){
	var search = Name + "=";
	if(document.cookie.length > 0){
		var offset = document.cookie.indexOf(search);
		if(offset != -1){
			offset += search.length;
			var end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(offset,end));
		}
		else return false;
	}
	else return false;
}

var gPersistValues = null;
var gSplitVal = '^%*#';

function mmPersistLoad(e)
{
	var c = getCookie('mmPersist');
	gPersistValues = new Object();
	if(c && (c = c.split(gSplitVal)) && !(c.length%2))
	{
		var x=0;
		while(x<c.length)
		{
			gPersistValues[c[x]] = c[x+1];
			x+=2;
		}
	}
}

function mmPersistFill(e)
{
	var f;
	if(f = this.mmPersistFields)
	{
		for(x=0;x<f.length;x++)
		{
			if(gPersistValues[f[x]]) this.elements[f[x]].value = gPersistValues[f[x]];
			// This only works on text and textarea. All others will fail
			// This only works in HTML. Served as XML, this will probably fail.
		}
	}
}

function mmPersistSetup(e)
{
	var f = this.form;
	if(!f.mmPersistFields)
	{
		f.mmPersistFields = new Array();
		addEventHandler(f,'submit',mmPersistSave,false);
	}
	f.mmPersistFields[f.mmPersistFields.length] = this.name;
}

function mmPersistSave(e)
{
	var f,i,t,c,x;
	if(f = this.mmPersistFields)
	{
		for(x=0;x<f.length;x++)
		{
			gPersistValues[f[x]] = this.elements[f[x]].value;
			// This only works in HTML. Served as XML, this will probably fail.
			// This only works on text and textarea. All others will fail
		}
		c = new Array();
		for(prop in gPersistValues)
		{
			c[c.length] = prop;
			c[c.length] = gPersistValues[prop];
		}
		setCookie('mmPersist',c.join(gSplitVal),365);
	}
}

document.register('body',null,mmPersistLoad,'load',false);
document.register('input','Persist',mmPersistSetup,'load',false);
document.register('form',null,mmPersistFill,'load',false);