﻿var isOpera  = (navigator.userAgent.toLowerCase().indexOf('opera') > -1);
var isIE     = (!isOpera && navigator.userAgent.toLowerCase().indexOf('msie') > -1);


function showBubble(targetId,link)
{
   if(isIE) 
   {
      //get rid of the alt because IE displays it over the bubble which becomes un readable
	   var image = link.childNodes[0];
	   currentImgAlt = image.getAttribute('alt');
	   image.setAttribute('alt','');
   }
   showInfo(targetId);
}

function hideBubble(targetId,link)
{
   if(isIE) 
   {
	   var image = link.childNodes[0];
	   image.setAttribute('alt',currentImgAlt);
	   currentImgAlt = '';
   }
   hideInfo(targetId);
}


function showInfo(targetId)
{
   document.getElementById(targetId).style.display = 'block';
}

function hideInfo(targetId)
{
   document.getElementById(targetId).style.display = 'none';
}

//------------------------------------------------

var agt=navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);

function ShowHelp(obj,field,hide)
{
	//Get help object
	var helpObj;
	if (document.all){
	helpObj = document.all[field+"_help"];}
	else if (document.getElementById){
		helpObj = document.getElementById(field+"_help");}
	if (helpObj) {
		//if help object is shown, hide it ; if object hidden, show it
		if (hide){
		  helpObj.style.display = "none";}
		else{
		  helpObj.style.display = "";}

		//Get location of mouseover object, move help object to the left if will display off-screen
		var divWidth = 340;
		var offsetLeft = getOffsetLeft(obj);
		var screenWidth = (window.innerWidth) ? window.innerWidth - 25 : document.body.clientWidth;
		if ((offsetLeft + divWidth) > screenWidth) offsetLeft = screenWidth - divWidth;
		newX = offsetLeft;
	
		//Get location of mouseover object, move help object on top if will display off-screen
		var divHeight = helpObj.offsetHeight;
		var offsetTop = getOffsetTop(obj) + obj.offsetHeight;
		var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
		if ((offsetTop + divHeight) > screenHeight + getScrollY()) offsetTop = getOffsetTop(obj) - divHeight;
		newY = offsetTop;	
	
		helpObj.style.top = newY;
		helpObj.style.left = newX;

		if (!hide){
		  qh_hideElement("select",helpObj);  
		  qh_hideElement("object",helpObj);  
		  qh_hideElement("embed",helpObj);  }
		else{
		  qh_showElement("select");  
		  qh_showElement("object");  
		  qh_showElement("embed");}
	}
}

function getOffsetTop (elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetTop;
}

function getOffsetLeft (elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetLeft;
}

function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape
    scrOfY = window.pageYOffset;}
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM
    scrOfY = document.body.scrollTop;}
  else if( document.documentElement &&
      ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6
    scrOfY = document.documentElement.scrollTop;}
  return scrOfY;
}

function qh_hideElement( elmID, overDiv ) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags( elmID )[i];
      if(!obj || !obj.offsetParent) continue;

      // Find the element's offsetTop and offsetLeft relative to the BODY tag.
      objLeft   = obj.offsetLeft;
      objTop    = obj.offsetTop;
      objParent = obj.offsetParent;

      while(objParent.tagName.toUpperCase() != 'BODY') {
        objLeft  += objParent.offsetLeft;
        objTop   += objParent.offsetTop;
        objParent = objParent.offsetParent;
      }

      objHeight = obj.offsetHeight;
      objWidth  = obj.offsetWidth;

      if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
      else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop);
      else if(overDiv.offsetTop >= (objTop + objHeight));
      else if(overDiv.offsetLeft >= (objLeft + objWidth));
      else {
        obj.style.visibility = 'hidden';
      }
    }
  }
}
function qh_showElement(elmID) {
  if(document.all) {
    for(i = 0; i < document.all.tags( elmID ).length; i++) {
      obj = document.all.tags(elmID)[i];
      if(!obj || !obj.offsetParent) continue;
      obj.style.visibility = '';
    }
  }
}