function load()
{
document.getElementById('content').style.fontSize = currentTextSize + 'px';
document.getElementById('content').style.lineHeight = currentLineHeight + 'px';
}

window.onload = load;


function emailit(whoto,domainto,title,subject,displayname)
{
	if (domainto == null || domainto == '') {domainto = 'brooklynpubliclibrary.org';}
	var writeit = whoto + '@' + domainto;
	if (displayname == null || displayname == '') {displayname = writeit;}
	
	if (subject == null || subject == '') {
		document.write("<a href='mailto:"+writeit+"' title='"+title+"'>"+displayname+"</a>");
	}
	else {
		document.write("<a href='mailto:"+writeit+"?subject="+subject+"' title='"+title+"'>"+displayname+"</a>");
	}
}




/* (C) www.dhtmlgoodies.com, September 2005 */	
function showHideAnswer()
{
	var numericID = this.id.replace(/[^\d]/g,'');
	var obj = document.getElementById('a' + numericID);
	if(obj.style.display=='block'){
		obj.style.display='none';
	}else{
		obj.style.display='block';
	}		
}


function initShowHideContent()
{
	var divs = document.getElementsByTagName('a');
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='question'){
			divs[no].onclick = showHideAnswer;
		}	
		
	}	
}



// text resizing
var currentTextSize = null;
var currentLineHeight = null;
// check for cookie
if (get_text_cookie("seniorsfontsize")) {
    currentTextSize = parseInt(get_text_cookie("seniorsfontsize"));
} else {
    currentTextSize = 13;
    createCookie("seniorsfontsize",currentTextSize,1000);
}
currentLineHeight = currentTextSize + 5;

function textSize(dir) {
    if (dir == 'up') {
        if (currentTextSize <= 20) {
            currentTextSize += 2;
        }
    } else if (dir == 'down') {
        if (currentTextSize >= 11) {
            currentTextSize -= 2;
        }
    }
    currentLineHeight = currentTextSize + 5;
    document.getElementById('content').style.fontSize = currentTextSize + 'px';
    document.getElementById('content').style.lineHeight = currentLineHeight + 'px';
    // write/rewrite cookie
    createCookie("seniorsfontsize",currentTextSize,1000);
}

function get_text_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results ) {
    return ( unescape ( results[1] ) );
  }
  else { return null; }
}



// cookie code

// creates a cookie with the given parameters
function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

// locates and reads the value of a cookie with a specified name
function readCookie(name){
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

// deletes a cookie with a specified name
function eraseCookie(name){
	createCookie(name,"",-1);
}

// parses the value of the cookie
// returns an array of the different values
function parseCookie(cookievalues){
	if (cookieValues.length > 0){
		var cookieValuesArray = new Array(3);
		var CookiesArray = cookievalues.split("&");
		for (var i = 0; i < CookiesArray.length; i++){
			var v = CookiesArray[i].split(":");
			cookieValuesArray[i] = v[1];
		}
		return cookieValuesArray;
	} else {
		return null;
	}
}