/////////////////////////////////////////////////////////////////////////////////////////
//
// dynamic text resizing
//

//
// variables and initialization
//
var textSize = 1;
var maxTextSize = 3;

// call at start of page to read text size from cookie and get style sheet
function init_textsize() {
  load_cookie_info();
  if (textSize == 2) {
    document.writeln("<link rel='stylesheet' href='/css/stylesMED.css' type='text/css'>");
  }
  else if (textSize == 3) {
    document.writeln("<link rel='stylesheet' href='/css/stylesLRG.css' type='text/css'>");
  }
}

//
// looks for text size in cookie
// if found, set textsize to 1, 2, or 3
//
function load_cookie_info() {
  var cookies = document.cookie.split(';');
  for (i = 0; i < cookies.length; i++) {
    if (cookies[i].indexOf('textSize') > -1) { // found the text size in cookie
      cookieparts = cookies[i].split('=')
      textSize = parseInt(cookieparts[1]);
      if (textSize < 1)
        textSize = 1;
      else if (textSize > 3)
        textSize = 3;
    }
  }
}
//
// save textsize to a cookie
//
function save_cookie_info() {
  var expire = new Date ();
  expire.setTime (expire.getTime() + (10*365*24*60*60*1000)); //expires in 10 years
  expire = expire.toGMTString();
  var str = 'textSize='+textSize+'; path=/; expires='+expire;
  document.cookie=str;
}

//
// called when small text size button clicked
//
function TextSmall() {
  text_resize_event(1);
}
//
// called when small text size button clicked
//
function TextMedium() {
  text_resize_event(2);
}
//
// called when small text size button clicked
//
function TextLarge() {
  text_resize_event(3);
}
//
// called by resize events
// sets the face sizes and saves info to cookie
//
function text_resize_event(size) {
  textSize = size;
  save_cookie_info();
  location.reload();
}

function textsize(action) {

//	textSize = size;
	//var box = document.getElementById(box_name);
//	var box_value = box.value * 1;

	if(action == '+') {

		textSize++;
	}
	else if(action == '-') {

		textSize--;
	}

	if (textSize <= 1 || !textSize) textSize = 1;
	if (textSize > 3) textSize = 3;

	save_cookie_info();
	location.reload();
}
