// provided by Matthew Woodruff
// revised Dec. 2007
// version 3.1

// Adds a red corner to subnav element previous to the selected element.
function modifySubNav() {
	var navX;
	var parentX;
	
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		navX =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)('currentSubNav');
		
		// While the previous node is a text node
		while (navX.previousSibling.nodeType == '3') {
			navX = navX.previousSibling;
		}
		if (navX.previousSibling != null) {
			 _proxy_jslib_assign('', navX.previousSibling.firstChild.style, 'backgroundImage', '=', ( "url(/images/subnav_prev_cap.gif)"));
		}
	}
}


sfHover = function() {
			
	//var sfEls = document.getElementById("tools").getElementsByTagName("LI");
	var listenEls = getElementsByClassName(document, "ul", "listen");
	for (var j=0; j<listenEls.length; j++) {
		
		 _proxy_jslib_handle(listenEls, (j), 0, 0).onmouseover=function() {
			this.className+=" sfhover";
		}
		 _proxy_jslib_handle(listenEls, (j), 0, 0).onmouseout=function() {
			this.className= _proxy_jslib_handle(this.className, 'replace', '', 1, 0)(new (RegExp)(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


//Displays the year's archive of posts
function openArchiveYear(archive_id) {
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		var link_id = archive_id + "_link";
		
		if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(archive_id).className != "archive_year_open") {
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(archive_id).className = "archive_year_open";
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(link_id).className = "accordion_open";
		}
		else {
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(archive_id).className = "hidden";
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(link_id).className = "accordion";
		}
	}
	
}


//Displays the month's archive of posts
function openArchiveMonth(archive_id) {
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		var link_id = archive_id + "_link";
		
		if ( _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(archive_id).className != "archive_month_open") {
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(archive_id).className = "archive_month_open";
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(link_id).className = "accordion_open";
		}
		else {
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(archive_id).className = "hidden";
			 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(link_id).className = "accordion";
		}
	}
	
}



function showRssEmailForm(formId, posId) {
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		var obj =  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(posId);
		var pos = findPos(obj);
		
		pos[1] += 20;
		
		 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(formId).style.left = pos[0] + 'px';
		 _proxy_jslib_assign('',  _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(formId).style, 'top', '=', ( pos[1] + 'px'));
		 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(formId).style.display = 'block';
		document.rss_email_form.email_input.focus();
	}
}



/*  Utility Funcions -------------------------------------------------------------  */

/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName) {
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all :  _proxy_jslib_handle(oElm, 'getElementsByTagName', '', 1, 0)(strTagName);
    var arrReturnElements = new (Array)();
    strClassName =  _proxy_jslib_handle(strClassName, 'replace', '', 1, 0)(/\-/g, "\\-");
    var oRegExp = new (RegExp)("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement =  _proxy_jslib_handle(arrElements, (i), 0, 0);      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}





function changeClass(id, newClass) {
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(id).className = newClass;
	}
	
}


function hideBlock(id) {
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(id).style.display = "none";
	}
}

function showBlock(id) {
	if ( _proxy_jslib_handle(document, 'getElementById', '', 0, 0)) {
		 _proxy_jslib_handle(document, 'getElementById', '', 1, 0)(id).style.display = "block";
	}
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
 curtop = obj.offsetTop
 while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
 curtop += obj.offsetTop
 }
	}
	return [curleft,curtop];
}
 ;
_proxy_jslib_flush_write_buffers() ;