//increases/decreases document font size at runtime
//delta is -1 to smaller text, +1 for larger text or 0 to return to normal
function defineFontSize(delta){
	var new_font_size, new_width;
	//if the font size should be either increased or decreased
	if (delta!=0) {
		//if font size change has already taken place, fetch the current value
		if (document.body.style.fontSize) {
			var current_font_size = document.body.style.fontSize;
			current_font_size = Number(current_font_size.match(/[0-9]{1,4}/));
			//make the font-size 10% larger in increments (clicking many times will gradually increase the size)
			var new_font_size = parseInt(current_font_size + 10*delta);

			//limit size to 60-200%
			if (new_font_size>200) new_font_size=200;
			if (new_font_size<60) new_font_size=60;
		}
		//if the font size has not been previosuly changed, use *100* +/- 15
		else {
			new_font_size = parseInt(100 + 20*delta);
		}

		//make the width of the main content div (with id="wrapper") incrementally narrower/wider (to house new font size and make good use of screen real estate)
		//note: make sure the value below is the same as the "width:" specified in styles.css for #wrapper
		//calculate new widths based on the original size +/- offset
		new_width = parseInt(880 + (new_font_size - 100)*3 );
	}
	//if the font size should return to default
	else {
		new_font_size = 100;
		new_width = 880;
	}

	//apply new widths
	document.getElementById('main-wrapper').style.width = new_width + 'px';


	//update the global font size in the document
	document.body.style.fontSize = new_font_size + '%';


	//alert(document.getElementsByTagName('body')[0].style.fontSize);

	//store user preferences in cookie
	var new_date = new Date();
	//set expiration date to one year from now
	var expires = new_date.getFullYear()+1;
	new_date.setFullYear(expires);
	expires = '; expires=' + new_date.toGMTString();
	//alert(expires);

	document.cookie = 'PREF-font-size=' + new_font_size + expires;
	document.cookie = 'PREF-col-width=' + new_width + expires;

}


//displays text explanation about what the icons -A A A+ means
function fontInfo(mode){
	var obj = document.getElementById('font-size-info');
	switch (mode) {
		case 0: obj.value='Click to RESET text size.'; break;
		case 1: obj.value='Click repeatedly for LARGER text size.'; break;
		case -1: obj.value='Click repeatedly for SMALLER text size.'; break;
		default: obj.value='';
	}
}


//translate dropdown
function toggleTrans(elem_id, state){
	if (document.getElementById(elem_id)) {
		obj = document.getElementById(elem_id);
		if (state=='on') obj.style.visibility='visible'; else obj.style.visibility='hidden';
	}
}
