// -- Generic functions --------------------------------------------------
function $(id) {
	return document.getElementById(id);
}


// text resize functions -------------------------------------------------
var currentTextSize = null;
var currentLineHeight = null;
// check for cookie
if (get_text_cookie("ihtfontsize")) {
    currentTextSize = parseInt(get_text_cookie("ihtfontsize"));
} else {
    currentTextSize = 13;
    createCookie("ihtfontsize",currentTextSize,1000);
}
currentLineHeight = currentTextSize + 5;

// 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=/";
}

function textSize(dir) {
    if (dir == 'up') {
        if (currentTextSize <= 17) {
            currentTextSize += 2;
        }
    } else if (dir == 'down') {
        if (currentTextSize >= 11) {
            currentTextSize -= 2;
        }
    }
    currentLineHeight = currentTextSize + 5;
    document.getElementById('bodyText').style.fontSize = currentTextSize + 'px';
    document.getElementById('bodyText').style.lineHeight = currentLineHeight + 'px';
    // write/rewrite cookie
    createCookie("ihtfontsize",currentTextSize,1000);
}

function get_text_cookie ( cookie_name )
{
  var results = document.cookie.match ( cookie_name + '=(.*?)(;|$)' );

  if ( results ) {
    return ( unescape ( results[1] ) );
  }
  else { return null; }
}

// -- Window onload functions --------------------------------------------
/*************************************************************
 * The woms array holds all of the functions you wish to run
 * when the page loads.
 *************************************************************/
var woms = new Array();

/*************************************************************
 * The womOn() function will set the window.onload function to
 * be womGo() which will run all of your window.onload
 * functions.
 *************************************************************/
function womOn(){
	window.onload = womGo;
}

/*************************************************************
 * The womGo() function loops through the woms array and
 * runs each function in the array.
 *************************************************************/
function womGo(){
	if ((woms.length != 0 ) && (woms.length != null)) {
		for(var i = 0;i < woms.length;i++)
			eval(woms[i]);
	}
}

/*************************************************************
 * The womAdd() function will add another function to the woms
 * array to be run when the page loads.
 *************************************************************/
function womAdd(func){
	woms[woms.length] = func;
}


