
/* - ++resource++prangerphilanthropic.theme.stylesheets/PrettyToolTip.js - */
var x,y,zInterval,radius,yoffset,xoffset,cursor,indent,backgroundColor,siteBackground,tipDelayTime,tipDisplayTime, isIE;
document.onmousemove = setMouseCoords;

function init() {
	var innerText = document.createElement('div');
	var toolTip = document.createElement('div');
	isIE = isIE();
	innerText.setAttribute('id', 'innerText');
	toolTip.setAttribute('id', 'toolTip');
	toolTip.style.position = 'absolute';
	toolTip.style.display = 'none';
	toolTip.style.zIndex = '100';

	// variable styles
	toolTipWidth = '250px';
	toolTipTextColor = '#4b721d';
	toolTipFontFamily = 'arial';
	toolTipFontSize = '11px';
	toolTipFontWeight = 'normal';
	toolTipFontStyle = 'normal';
	toolTipLineHeight = '1.25em';
	toolTipBackgroundColor = '#ffffff';
	toolTipBorderWidth = '4px'
	toolTipBorderColor = '#c1cd23';
	toolTipSiteBackground = '#ffffff'; // to determine what color the outside of the rounded corners should be
	toolTipIndent = 12;
	toolTipRadius = 7;
	toolTipXoffset = 0;
	toolTipYoffset = 60;
	toolTipCursor = 'pointer';
	toolTipDelayTime = .2;
	toolTipDisplayTime = 20;
	// end variable styles
	
	if (toolTipIndent > toolTipRadius)
		innerText.style.padding = (toolTipIndent - toolTipRadius) + 'px ' + toolTipIndent + 'px ' + (toolTipIndent - toolTipRadius) + 'px ' + toolTipIndent + 'px'; 
	else
		innerText.style.padding = '0 ' + toolTipIndent + 'px 0 ' + toolTipIndent + 'px';
	
	toolTip.style.width = toolTipWidth;
	toolTip.style.color = toolTipTextColor;
	innerText.style.fontFamily = toolTipFontFamily;
	innerText.style.fontSize = toolTipFontSize;
	innerText.style.fontWeight = toolTipFontWeight;
	innerText.style.fontStyle = toolTipFontStyle;
	innerText.style.lineHeight = toolTipLineHeight;
	toolTip.style.backgroundColor = toolTipBackgroundColor;
	toolTip.style.padding = '10px 7px';
	toolTip.style.border = '4px solid #c1cd23';

	toolTip.appendChild(innerText);
	document.body.appendChild(toolTip);
	
	var allElements = document.getElementsByTagName("*");
	var numElements = allElements.length;
	for(var i = 0; i < numElements; i++) {
		if(allElements[i].title != '') {
			allElements[i].alt = allElements[i].title;
			allElements[i].title = '';
			allElements[i].onmouseover = showToolTip;
			allElements[i].onmouseout = hideToolTip;
			allElements[i].style.cursor = toolTipCursor;
		}
	}

}

function setMouseCoords(e) {
	if(document.all) {
		x = window.event.clientX;
		y = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	} else {
		x = e.pageX;
		y = e.pageY;
	}
}

function showToolTip() {
	clearInterval(zInterval);
	zInterval = setTimeout("doShowToolTip('" + this.alt + "')",toolTipDelayTime * 1000);
}

function doShowToolTip(zText) {
	clearInterval(zInterval);
	document.getElementById("toolTip").style.top = (y + toolTipYoffset) + "px";
	document.getElementById("toolTip").style.left = (x + toolTipXoffset) + "px";
	document.getElementById("innerText").innerHTML = zText;
	document.getElementById("toolTip").style.display = "block";
	zInterval = setTimeout("hideToolTip()",toolTipDisplayTime * 1000);
}

function hideToolTip() {
	document.getElementById("toolTip").style.display = "none";
	clearInterval(zInterval);
}

function getElementsBySelector(selector) {
  var i;
  var s = [];
  var selid = "";
  var selclass = "";
  var tag = selector;
  var objlist = [];
  if (selector.indexOf(" ") > 0) {  //descendant selector like "tag#id tag"
    s = selector.split(" ");
    var fs = s[0].split("#");
    if (fs.length == 1) {
      return objlist;
    }
    return document.getElementById(fs[1]).getElementsByTagName(s[1]);
  }
  if (selector.indexOf("#") > 0) { //id selector like "tag#id"
    s = selector.split("#");
    tag = s[0];
    selid = s[1];
  }
  if (selid != "") {
    objlist.push(document.getElementById(selid));
    return objlist;
  }
  if (selector.indexOf(".") > 0) {  //class selector like "tag.class"
    s = selector.split(".");
    tag = s[0];
    selclass = s[1];
  }
  var v = document.getElementsByTagName(tag);  // tag selector like "tag"
  if (selclass == "") {
    return v;
  }
  for (i = 0; i < v.length; i++) {
    if (v[i].className == selclass) {
      objlist.push(v[i]);
    }
  }
  return objlist;
}

function isIE() {
	   return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

jq(init);

