function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
    setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
    setCookie('mtcmthome', f.url.value, now, '', HOST, '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '', HOST);
    deleteCookie('mtcmthome', '', HOST);
    deleteCookie('mtcmtauth', '', HOST);
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}


/* No Frames Please! */
if(top.location != self.location){top.location=self.location;}

/* *********************************************************** */

/* ABBR support */
function styleAbbr() {
    var oldBodyText, newBodyText, reg;
    if (isIE) {
	oldBodyText = document.body.innerHTML;
	reg = /<ABBR([^>]*)>([^<]*)<\/ABBR>/g;
	newBodyText = oldBodyText.replace(reg, '<ABBR $1><SPAN class=\"abbr\" $1>$2</SPAN></ABBR>');
	document.body.innerHTML = newBodyText;
    }
}

//*** This JavaScript library is copyright 2002 by Gavin Kistner and Refinery; www.refinery.com
//*** Re-use or modification permitted provided the previous line is included

//Adds a new class to an object, preserving existing classes
function AddClass(obj,cName){ KillClass(obj,cName); return obj.className+=(obj.className.length>0?' ':'')+cName; }

//Removes a particular class from an object, preserving other existing classes.
function KillClass(obj,cName){ return obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); }

/*********** End of JavaScript Library ***********/

/* Fragment Highlight */

/* Indicates area that has been linked to if fragment identifiers have
 * been used. Especially useful in situations where a short fragment
 * is near the end of a page. */

var fragHLed = '';
var fragExclude = ('header');

Array.prototype.search = function(myVariable) { for(x in this) if(x == myVariable) return true; return false; }

function fragHL(frag) {
    if (fragHLed.length > 0 && document.getElementById(fragHLed)) {
	KillClass(document.getElementById(fragHLed),'fragment');
    }
    if (frag.length > 0 && document.getElementById(frag)) {
	fragHLed = frag;
	AddClass (document.getElementById(frag),'fragment');
    }
}

function fragHLload() {
    fragHL(location.hash.substring(1));
}

function fragHLlink() {
    if (document.getElementsByTagName) {
	var an = document.getElementsByTagName('a');
	for (i=0; i<an.length; i++) {
	    if (an.item(i).getAttribute('href').indexOf('#') >= 0) {
		var fragment = an.item(i).getAttribute('href').substring(an.item(i).getAttribute('href').indexOf('#') + 1);
		if (fragExclude.search(fragment)) {
		    var evn = "fragHL('" + fragment + "')";
		    var fun = new Function('e',evn);
		    an.item(i).onclick = fun;
		}
	    } 
	}
    }
} 



/* function printFriendly() {
    if (document.getElementById) {
	document.getElementById('printerFriendly').attachEvent('onclick',function() { confirm('This document is already Print Friendly. Just use your normal print option. Read more?'); });
    }
} */



/* Onload */

window.onload = function(){


if (document.getElementById('email')) {
	document.getElementById('email').value = getCookie("mtcmtmail");
	document.getElementById('author').value = getCookie("mtcmtauth");
	document.getElementByID('url').value = getCookie("mtcmthome");
	if (getCookie("mtcmtauth")) {
	    document.getelementById('bakecookie').checked = true;
	} else {
	    document.getelementById('forget').checked = true;
	}
}


    styleAbbr();
/*    printFriendly(); */
    fragHLload();
    fragHLlink();
};

isIE = (document.all) ? true:false;