/*
 * menuExpandable2.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // I'm too tired

    actuator.onclick = function() {
        var display = menu.style.display;
        this.parentNode.style.backgroundImage =
            (display == "block") ? "url(/chris/i/menuclosed.gif)" : "url(/chris/i/menuopen.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}

/*  Menu Initialization  */

window.onload = function() {
            initializeMenu("archivesmenu", "archivesact");
            initializeMenu("feedsmenu", "feedsact");
            initializeMenu("foliomenu", "folioact");
            initializeMenu("aboutmenu", "aboutact");
            initializeMenu("contactmenu", "contactact");
            initializeMenu("searchmenu", "searchact");
            initializeMenu("artistsmenu", "artistsact");
            initializeMenu("readingmenu", "readingact");
            initializeMenu("artmenu", "artact");
            initializeMenu("deliciousmenu", "deliciousact");
}




/* Movable Type Scripts */

function image_popup(url,windowid,width,height)
{
	var left = Math.round((screen.availWidth - width - 10) * .5);
	var top = Math.round((screen.availHeight - height - 10) * .3);
	window.open(url,windowid,'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}
  
// clear text in the search news box. From HicksDesign | hicksdesign.co.uk
	function ClearSearchBy()
{
	if (document.getElementById('search').value == 'search site')
	{
			document.getElementById('search').value = '';
	}
}

var HOST = 'www.tinypineapple.com/chris';

// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.

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, '/chris', HOST, ''); 
		setCookie('mtcmtmail', f.email.value, now, 'chris', HOST, ''); 
		setCookie('mtcmthome', f.url.value, now, '/chris', HOST, ''); 
}

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