// IS IE
is_ie = false;
if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)){
	is_ie = true;
}
isIE = is_ie;
// COOKIES
function getExpire(year){
	var expire = new Date ();
	expire.setTime (expire.getTime() + ((year *365) *24 * 60 * 60 * 1000));
	expire = expire.toGMTString();
	return expire;
}
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
	  ((expires) ? "; expires=" + getExpire(expires) : "") +
	  ((path) ? "; path=" + path : "") +
	  ((domain) ? "; domain=" + domain : "") +
	  ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
  } else
	begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
	end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
// REFRESH PARENT
function refreshParent(){
	window.opener.location.href = window.opener.location.href;
}
// VISIT & GO
function visit(url){
	document.location.href = url;
}
function go(url,msg){
	msg = msg || "You have requested a page that will leave the Partners Trust site. Are you sure?";
	if(confirm(msg)){
		window.open(url);
	}
}
// WINDOW STATUS
function setStatus(value) {
	window.status = value;
}
// IMAGE POSITION
var tempEl;
function getRealLeft(imgElem){
	if(ns4){
		xPos=imgElem.x;
	}else if(!exclude){
		xPos=eval(imgElem).offsetLeft;
		tempEl=eval(imgElem).offsetParent;
		while(tempEl!=null){
			xPos+=tempEl.offsetLeft;
			tempEl=tempEl.offsetParent;
		}
	}
	if(is_ie && is_mac){
		xPos+=parseInt(document.body.leftMargin);
	}
	return xPos;
}
function getRealTop(imgElem){
	if(ns4){
		yPos=imgElem.y;
	}else if(!exclude){
		yPos=eval(imgElem).offsetTop;
		tempEl=eval(imgElem).offsetParent;
		while(tempEl!=null){
			yPos+=tempEl.offsetTop;
			tempEl=tempEl.offsetParent;
		}
	}
	if(is_ie && is_mac){
		yPos+=parseInt(document.body.topMargin);
	}
	return yPos;
}
function getURL(url){
    if(url.indexOf('?') >= 0){
        url = url.split("?");
        url = url[0];
    }
    return(url);
}
// CMC
function preparePrint(){
	var url = document.location.href;
	if(url.indexOf('?') >= 0){
		if(url.indexOf('&print=') >= 0){
			document.location.href = document.location.href;
		}else{
			document.location.href = document.location.href + "&print=1";
		}		
	}else{
		document.location.href = document.location.href + "?print=1";
	}
}
function embedObject(obHTML){
	document.write(obHTML);
}
// DIV SHOW/HIDE
function hideDiv(id){
	document.getElementById(id).style.visibility = 'hidden';
}
function showDiv(id){
	document.getElementById(id).style.visibility = 'visible';
}

// DIV ROLLOVERS
function divOver(el){
	var className = el.className+"Over";
	el.className = className;
}
function divOut(el){
	var className = el.className.replace(/Over/,"");
	el.className = className;
}

// BUTTON ROLLOVERS
var buttonState = "off";
function buttonOver(id){
	var left = document.getElementById(id+"_left");
	var right = document.getElementById(id+"_right");
	var bkg = document.getElementById(id+"_bkg");
	var prefix = id.split("_");
	prefix = prefix[0];
	var className = "theme_"+prefix;
	
	if(left.src.indexOf("/on/") >= 0){
		buttonState = "on";
	}else{
		buttonState = "off";
	}
	
	if(buttonState == "off"){
		left.src = left.src.replace(/\/off\//,"/over/");
		right.src = right.src.replace(/\/off\//,"/over/");
		bkg.style.backgroundImage = bkg.style.backgroundImage.replace(/\/off\//,"/over/");
		bkg.className = className+"_over";
	}else if(buttonState == "on"){
		//left.src = left.src.replace(/\/on\//,"/over/");
		//right.src = right.src.replace(/\/on\//,"/over/");
		//bkg.style.backgroundImage = bkg.style.backgroundImage.replace(/\/on\//,"/over/");
		//bkg.className = className+"_on";
	}
	//setStatus(buttonState);
}
function buttonOut(id){
	var left = document.getElementById(id+"_left");
	var right = document.getElementById(id+"_right");
	var bkg = document.getElementById(id+"_bkg");
	var prefix = id.split("_");
	prefix = prefix[0];
	var className = "theme_"+prefix;	
	
	if(buttonState != "on"){
		left.src = left.src.replace(/\/over\//,"/"+buttonState+"/");
		right.src = right.src.replace(/\/over\//,"/"+buttonState+"/");
		bkg.style.backgroundImage = bkg.style.backgroundImage.replace(/\/over\//,"/"+buttonState+"/");
		bkg.className = className+"_"+buttonState;
	}
	//setStatus("");
}
