/*

Font size functions, customized for the PICO site to put the class
on #content and set site_webroot in the script. --C.W.

*/

site_webroot = "http://bluegreenalliance.articulatedman.com/";

function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function CE_LoadPageFont() {
	if(Get_Cookie("font_size")) {
		fs = Get_Cookie("font_size");
		document.getElementById("left").className = "body_" + fs;
		document.getElementById("font_size_links").className = fs;
		
		// IE6 hack
		if (document.all && !window.XMLHttpRequest) {
			CE_FixIE6(fs);
		}
	}
}

function CE_FixIE6(which) {
	document.getElementById("font_select").style.cssText = "background-position:0px 0px";
	document.getElementById("font_select_med").style.cssText = "background-position:0px 0px";
	document.getElementById("font_select_large").style.cssText = "background-position:0px 0px";
	if (which == "") {
		document.getElementById("font_select").style.cssText = "background-position:0px -14px";
	} else {
		document.getElementById("font_select_" + which).style.cssText = "background-position:0px -14px";
	}
}

function CE_SetPageFont(which) {
	document.getElementById("left").className = "body_" + which;
	document.getElementById("font_size_links").className = which;
	document.getElementById("font_size_links").setAttribute("className", which);

	// IE6 hack
	if (document.all && !window.XMLHttpRequest) {
		CE_FixIE6(which);
	}
	
	var domain = site_webroot.substring(site_webroot.indexOf("http://") + 7, site_webroot.length - 1);
	Set_Cookie("font_size", which, 1, "index.html", domain, false);
}


