// JavaScript Document

// ----- START Text Resizer -----
// set the font size according to the user's preference, called by setFontSize() or user click
function chgFontSz(i) {
	var bodyID = document.getElementsByTagName("body")[0];
	setCookie(i);
	switch(i) {
		case "1":
			bodyID.style.fontSize="100%";
			break;
		case "2":
			bodyID.style.fontSize="115%";
			break;
		case "3":
			bodyID.style.fontSize="130%";
			break;
	}
	return false
}

// saves the font size preference to a cookie, expires in one year
function setCookie(i) {
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	document.cookie = "diageofontsize=" + i + "; expires=" + nextyear.toGMTString() + "; path=/";
}

// sets the font size according to the cookie value, called by onload
function setFontSize() {
	var allCookies = document.cookie;
	var pos = allCookies.indexOf("diageofontsize=");
	if (pos != -1) {
		var start = pos + 9;
		var end = allCookies.indexOf(";", start);
		if (end == -1) end = allCookies.length;
		var value = allCookies.substring(start, end);
		chgFontSz(value);
	}
}
// ----- END Text Resizer -----

// ----- START Toggle Show Hide function -----
function showhide(hideableObj,textObj,textType) {
	
	if (document.getElementById(hideableObj).style.display == 'none') {
		document.getElementById(hideableObj).style.display = 'block';
		switch(textType) {
			case "null":
				break;
			case "more-close":
				document.getElementById(textObj).innerHTML = 'Close';
				break;
		}
		return;
		
	} else {
		document.getElementById(hideableObj).style.display = 'none';
		switch(textType) {
			case "null":
				break;
			case "more-close":
				document.getElementById(textObj).innerHTML = 'More';
				break;
		}
		return;
	}
}
// ----- END Toggle Show Hide function -----

// ----- START Loop function to Toggle Show Hide multiple objects -----
function initShowHide(objName,objTotal,textName,textType) {
	for (var i = 1; i <= objTotal; i++) {
		var hideableObj = objName + i;
		if (textName != "null") {
			var textObj = textName + i;
		} else {
			var textObj = "null";
		}
		showhide(hideableObj,textObj,textType);
	}
}
// ----- END Loop function to Toggle Show Hide multiple objects -----


// ---- START Lightwindow launch functions ---

function lw_caseStudy() {
	myLightWindow = new lightwindow();
	myLightWindow.activateWindow({
	href: '../../flash/Pages/ofr_elsevier.aspx',
	title: '',
	type: 'external',
	width: 750,
	height: 390
	});
}
