/**

 * Sets a Cookie with the given name and value.

 */

function setCookie(name, value, expires, path, domain, secure) {

	document.cookie = name + "=" + escape(value) +

		((expires) ? "; expires=" + expires.toGMTString() : "") +

		((path) ? "; path=" + path : "") +

		((domain) ? "; domain=" + domain : "") +

		((secure) ? "; secure" : "");

}



/**

 * Gets the value of the specified cookie.

 */

function getCookie(name) {

	var dc = document.cookie;

	var prefix = name + "=";

	var begin = dc.indexOf("; " + prefix);

	if (begin == -1) {

		begin = dc.indexOf(prefix);

		if (begin != 0) return null;

	} else {

		begin += 2;

	}

	var end = document.cookie.indexOf(";", begin);

	if (end == -1) {

		end = dc.length;

	}

	return unescape(dc.substring(begin + prefix.length, end));

}



/**

 * Deletes a Cookie with the given name.

 */

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";

	}

}



/*

 * This is needed for the cookie functions.

 *

 * @see http://www.webreference.com/js/column8/functions.html

 */

function fixDate(date) {

	var base = new Date(0);

	var skew = base.getTime();

	if (skew > 0)

		date.setTime(date.getTime() - skew);

}



/**

 * Displays the font size options.

 */

function chgFontSize_display(display_text, display_image) {

	if (display_text == 'on' || display_image == 'on') {

		document.write('<form id="chgfontsizeoptions">');

		if (display_text == 'on') {

			document.write('<label for="t">Text Size: </label>');

			document.write('<select id="chgfontsizeselection" onChange="chgFontSize_change(this.options[selectedIndex].value);">');

			for (var size = 8; size <= 24; size++) {

				if (Number(size) == Number(chgfontsize_font_size)) {

					document.write('<option value="' + size + '" selected="selected">' + size + '<\/option>');

				} else {

					document.write('<option value="' + size + '">' + size + '<\/option>');

				}

			}

			document.write('<\/select>');

		}

		if (display_image == 'on') {

			if (chgfontsize_font_size > 8) {

				document.write('&nbsp;<a href="javascript:void(0);" onclick="chgFontSize_decrease();"><img src="' + chgfontsize_imgdecact.src + '" title="Decrease Font" alt="a-" id="chgfontsizeimgdec" /></a>&nbsp;');

			} else {

				document.write('&nbsp;<a href="javascript:void(0);" onclick="chgFontSize_decrease();"><img src="' + chgfontsize_imgdecdea.src + '" title="Decrease Font" alt="a-" id="chgfontsizeimgdec" /></a>&nbsp;');

			}

			if (chgfontsize_font_size < 24) {

				document.write('&nbsp;<a href="javascript:void(0);" onclick="chgFontSize_increase();"><img src="' + chgfontsize_imgincact.src + '" title="Increase Font" alt="A+" id="chgfontsizeimginc" /></a>&nbsp;');

			} else {

				document.write('&nbsp;<a href="javascript:void(0);" onclick="chgFontSize_increase();"><img src="' + chgfontsize_imgincdea.src + '" title="Increase Font" alt="A+" id="chgfontsizeimginc" /></a>&nbsp;');

			}

		}

		document.write('<\/form>');

	}

}





/**

 * Change the font size with the given  value.

 */

function chgFontSize_change(fontsize) {

	chgfontsize_font_size = fontsize;

	chgFontSize();

}



/**

 * Decrease the font size.

 */

function chgFontSize_decrease() {

	if (chgfontsize_font_size > 8) {

		chgfontsize_font_size--;

		chgFontSize();

	}

}



/**

 * Increase the font size.

 */

function chgFontSize_increase() {

	if (chgfontsize_font_size < 24) {

		chgfontsize_font_size++;

		chgFontSize();

	}

}



/**

 * Changes the font size and sets the cookie.

 */

function chgFontSize() {

	var now = new Date();

	fixDate(now);

	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); //expire in a year

	setCookie('fontsize', chgfontsize_font_size, now, '/', '', '');

	var content = document.getElementById(chgfontsize_element);

	if (!content) return;

	content.style.fontSize = chgfontsize_font_size + 'px';

	var fsselection = document.getElementById('chgfontsizeselection');

	if (fsselection != null) {

		fsselection.selectedIndex = chgfontsize_font_size - 8;

	}

	var imgdec = document.getElementById('chgfontsizeimgdec');

	if (imgdec != null) {

		if (chgfontsize_font_size > 8) {

			imgdec.src = chgfontsize_imgdecact.src;

		} else {

			imgdec.src = chgfontsize_imgdecdea.src;

		}

	}

	var imginc = document.getElementById('chgfontsizeimginc');

	if (imginc != null) {

		if (chgfontsize_font_size < 24) {

			imginc.src = chgfontsize_imgincact.src;

		} else {

			imginc.src = chgfontsize_imgincdea.src;

		}

	}

}



var chgfontsize_element = null;

var chgfontsize_font_size = null;


