

//basic browser detection
var isIE=(document.all && navigator.userAgent.toLowerCase().indexOf('msie')!=-1? true : false);
var isOpera=(document.all && navigator.userAgent.toLowerCase().indexOf('opera')!=-1? true : false);
var isSafari=(document.getElementById && !isIE && !isOpera && navigator.userAgent.toLowerCase().indexOf('safari')!=-1? true :false)
var isFF=(document.getElementById && !isIE && !isOpera && !isSafari && navigator.userAgent.toLowerCase().indexOf('firefox')!=-1? true :false)
var isNS=isFF;
function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}
var isIE6 = (isIE && vIE()==6? true : false)

var isWin=(navigator.platform.toLowerCase().indexOf('win')!=-1? true: false);
var isMac=(navigator.platform.toLowerCase().indexOf('mac')!=-1? true: false);

/*
	allows for multiple actions to be added to the window.onload event
	without overwriting the existing event contents

	called as
	addOnLoadAct(functionName);
	NOTE: do not include () in the function name 
*/
function addOnLoadAct(fNewOnLoad){	
	// save the existing onload event(s)
	var fCurrentOnLoad = window.onload;
	// if the existing onload does not have a function ...
	if (typeof window.onload != 'function'){
		// give it this function
		window.onload = fNewOnLoad;
	}else{
		// else add the new function to the existing function
		window.onload = function(){
			fCurrentOnLoad();
			fNewOnLoad();
		}
	}
}

// used primarily for image rotation on mouseover actions
var sTemp;

//used to detect the top position of an html object
function getTop(obj){
	yPos = eval(obj).offsetTop;
	tempEl = eval(obj).offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
return yPos;
}
//used to detect the left position of an html object
function getLeft(obj){
	xPos = eval(obj).offsetLeft;
	tempEl = eval(obj).offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
return xPos;
}

//AR2008 new code - opensd an email with subject and email body defined
//uses window open to keep the user on the page
// %0D - new line
// %09 - tab
function setmail(){
	var sBody='Hello,%0D%0DI thought you might be interested in this page from OPTrust\'s 2008 Annual Report:%0D '+ document.location.href +' %0D%0DCourtesy of OPTrust';
	mywin = window.open('mailto:?from=&to=&subject='+document.title+'&body='+  sBody)
	if(mywin && !mywin.closed){
		mywin.close();
	}
}

var maxFont=14;
var defaultFont=9;
var minFont=7;
var arrFontArray= new Array();

function fontResize(objName, iResize){
	if(!arrFontArray[objName]){
		arrFontArray[objName]=defaultFont;
	}
	arrFontArray[objName]+=(iResize*1);
	if (arrFontArray[objName]<minFont){
		arrFontArray[objName]=minFont;
	}

	if (arrFontArray[objName]>maxFont){
		arrFontArray[objName]=maxFont;
	}
	setFontSize(objName,arrFontArray[objName])
}


function setFontSize(objName,iFontSize){
	arrFontArray[objName]=(iFontSize*1);
	if(iFontSize>maxFont){
		iFontSize=maxFont;
	}
	if(document.getElementById(objName)){
		document.getElementById(objName).style.fontSize=iFontSize+'pt';
		setCookie(objName, iFontSize, 30, '/','' ,'' ) 
	}
}


var myWin;
function openWindow(sUrl){
	if(!myWin || myWin.closed){
		window.open(sUrl);
	}else{
		myWin.close();
		openWindow(sUrl)
	}
}


function setCookie(name, value, expires, path, domain, secure ){
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ){
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}
		
		
function getCookie(checkName) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var arrAllCookies = document.cookie.split( ';' );
	var arrTempCookie = '';
	var cookieName = '';
	var cookieValue = '';
	var bCookieFound = false; // set boolean t/f default f

	for ( i = 0; i < arrAllCookies.length; i++ ){
		// now we'll split apart each name=value pair
		arrTempCookie = arrAllCookies[i].split( '=' );
		// and trim left/right whitespace while we're at it
		cookieName = arrTempCookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed checkName
		if ( cookieName == checkName ){
			bCookieFound = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( arrTempCookie.length > 1 ){
				cookieValue = unescape( arrTempCookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookieValue;
			break;
		}
		arrTempCookie = null;
		cookieName = '';
	}
	if (!bCookieFound){
		return null;
	}
}

var arrFontControl = new Array('pagecontent');

function setDefaultUserFont(){
	for (x=0;x<arrFontControl.length;x++){
		if(getCookie(arrFontControl[x])){
			setFontSize(arrFontControl[x], getCookie(arrFontControl[x]))	
		}
	}
}

var screenW = 1024, screenH = 768;


function showContainer(objName){
	document.getElementById(objName).style.display='block';

}

function hideContainer(objName){
	document.getElementById(objName).style.display='none'
}
var objFlash;

addOnLoadAct(setDefaultUserFont);




