﻿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=/";
}

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;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function fontSize(theSize)
{
	
	switch(theSize)
	{
		case 'l':
			createCookie('fontsize',theSize,365);
			document.getElementById('masterLayout').style.fontSize = '1.4em';
			document.getElementById('fontSmall').className = 'inactive';
			document.getElementById('fontMed').className = 'inactive';
			document.getElementById('fontLarge').className = 'active';
			break;
		case 's':
			createCookie('fontsize','s',365);
			document.getElementById('masterLayout').style.fontSize = '0.85em';
			document.getElementById('fontSmall').className = 'active';
			document.getElementById('fontMed').className = 'inactive';
			document.getElementById('fontLarge').className = 'inactive';
			break;
		default:
			createCookie('fontsize',theSize,365);
			document.getElementById('masterLayout').style.fontSize = '1em';
			document.getElementById('fontSmall').className = 'inactive';
			document.getElementById('fontMed').className = 'active';
			document.getElementById('fontLarge').className = 'inactive';
	}
}

function loadFontSizeFromCookie()
{
	var url = document.location;
	var hostExp = new RegExp('(^http://admin\.actgov\.org)|(^http://www\.actgov\.org)');
	if(hostExp.test(url))
	{
		var theSize = readCookie('fontsize');
		if(theSize != null)
		{
			fontSize(theSize);
		}
		else
		{
			fontSize('s');
		}
	}
}

function emailFriend()
{
mail_str = "mailto:?subject=ACT:  " + document.title;
mail_str += "&body=I thought you might be interested in this page that I found on the ACT|IAC web site.";
mail_str += ".  You can view it by clicking on the following link:  " + location.href; 
location.href = mail_str;
}

