function ShowSticky(obj,field) {
	if (document.all)
		helpObj = document.all[field+"_help"];
	else if (document.getElementById)
		helpObj = document.getElementById(field+"_help");
	if (helpObj && helpObj.style.display == "none")
		ShowHelp(obj,field);
}

function ShowHelp(obj,field) {
	if (!obj.id)
		obj = document.getElementById(field+"_source");
	//Get help object
	var helpObj = document.getElementById(field+"_help");
	
	if (helpObj) {
		//if help object is shown, hide it ; if object hidden, show it
		
		if (helpObj.style.display == "") {
		  helpObj.style.display = "none";
		  var dobj = helpObj.getElementsByTagName("DIV")[0];
		  dobj.style.padding='0px';
		} else{
		  helpObj.style.display = "";
		  var dobj = helpObj.getElementsByTagName("DIV")[0];
		  dobj.style.padding='10px';  
		
			var divWidth = 340;
			if(helpObj.style.width) divWidth= parseInt(helpObj.style.width.replace('px',''))			
			var offsetLeft = helpGetOffsetLeft(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 = helpGetOffsetTop(obj) + obj.offsetHeight;
			var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
			screenHeight = (screenHeight < 500) ? 500 : screenHeight;
			if ((offsetTop + divHeight) > screenHeight + helpGetScrollY()) offsetTop = helpGetOffsetTop(obj) - divHeight;
			newY = offsetTop;

			helpObj.style.top = newY + 'px';
			helpObj.style.left = newX  + 'px';
		}
	}
}

function helpGetOffsetTop (elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetTop;
}

function helpGetOffsetLeft (elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetLeft;
}

function helpGetScrollY() {
  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 = '';
    }
  }
}
