<!--
if (window != top) top.location.href = location.href;

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			if (src.search("_off") != -1) {
				var hsrc = src;
			} else {
				var hsrc = src.replace(ftype, '_off'+ftype);
			}

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_off'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
	
	var aDivs = document.getElementsByTagName('div');
	
	for (var i = 0; i < aDivs.length; i++) {		
		if (aDivs[i].className == 'imgover') {
			var src = aDivs[i].getAttribute('style');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			if (src.search("_off") != -1) {
				var hsrc = src;
			} else {
				var hsrc = src.replace(ftype, '_off'+ftype);
			}

			aDivs[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aDivs[i].onmouseover = function() {
				sTempSrc = this.getAttribute('style');
				this.setAttribute('style', this.getAttribute('hsrc'));
			}	
			
			aDivs[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('style').replace('_off'+ftype, ftype);
				this.setAttribute('style', sTempSrc);
			}
		}
	}


}

function openDW(url, width, height) {
	var winDW;
	var winName;
	var specs;
	winName  = "daughter";
	specs = "toolbar=no,";
	specs += "location=no,";
	specs += "directories=no,";
	specs += "status=no,";
	specs += "menubar=no,";
	specs += "scrollbars=yes,";
	specs += "resizable=yes,";
	specs += "top=50,";
	specs += "left=50,";
	specs += "screenX=0,";
	specs += "screenY=0,";
	specs += "width="+width+",";
	specs += "height="+height;
	winDW = window.open(url, winName, specs);
}

function gen_addy() {
	if (!document.getElementById) return
		
	var aMail = document.getElementsByTagName('a');
	for (var i = 0; i < aMail.length; i++) {		
		if (aMail[i].className == 'obscure') {
			var username = aMail[i].getAttribute('name');
			var hostname = aMail[i].getAttribute('id');
			var atsign = "&#64;";
			var addr = 'mail' + 'to:' + username + '@' + hostname;
			aMail[i].setAttribute('href', addr);
		}
		

		var linkName = aMail[i].getAttribute('href');
		if (linkName != null) {
			linkName = linkName.toLowerCase();
			var theCode = aMail[i].innerHTML;

			if (linkName.substring(linkName.length,linkName.length - 3) == 'pdf' && theCode.substring(0 , 4).toLowerCase() != '<img') {
				//aMail[i].setAttribute('class','pdf');
				//aMail[i].setAttribute('className','pdf');
				aMail[i].innerHTML = theCode + '<img src="https://www.fpmt.org/images/icons/pdf.gif" border="0" style="margin:0 3px 0 5px;">';
			}else{
				if ((theCode.substring(0 , 4).toLowerCase() != '<img' && linkName.substring(0 , 19) != 'http://www.fpmt.org' && linkName.substring(0 , 30) != 'http://onlinelearning.fpmt.org' && linkName.substring(0 , 26) != 'http://moodletest.fpmt.org' && linkName.substring(0 , 14) != 'https://secure' && linkName.substring(0 , 16) != 'https://www.fpmt' && linkName.substring(0 , 16) != 'http://localhost' && linkName.substring(0 , 17) != 'http://www.lamrim' && linkName.substring(0 , 4) == 'http') || ((linkName.substring(0 , 24) == 'http://www.fpmt.org/shop' || linkName.substring(0 , 5) == '/shop') && theCode.substring(0 , 4).toLowerCase() != '<img' && aMail[i].getAttribute('id') != 'shop')) {
					//aMail[i].setAttribute('class','outgoing');
					//aMail[i].setAttribute('className','outgoing');
					aMail[i].innerHTML = theCode + '<img src="https://www.fpmt.org/images/icons/external.gif" border="0" style="margin:0 3px 0 5px;">';
				}
			}
		}
	}
}

function start() {
  initRollovers();
  gen_addy();
}

window.onload = start;

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
	var fontSize = GetCookie('fonttextsize');
	if(fontSize != null) {
		setActiveStyleSheet(fontSize, 1);
	}	
	//-->