/всплывающие окна подсказок/


var HintBgColor="#FFFFE6";
var HintTextColor="black";
var HintTextSize="11px";
var HintBorderWidth="1";
var HintBorderColor="black";
var MaxHintWidth=250;
var withiFrame=false;

function trim(s) { return s != null ? s.replace(/(^\s*)|(\s*$)/,"") : s;	} 

function InitAllHints(useIframe, maxWidth, bgColor, txtColor, txtSize, borderWidth, borderColor) {
  var node;
   if (useIframe != null) withiFrame=useIframe;
   if (maxWidth != null) MaxHintWidth=maxWidth;
   if (bgColor != null) HintBgColor=bgColor;
   if (txtColor != null) HintTextColor=txtColor;
   if (txtSize != null) HintTextSize=txtSize+"px";
   if (borderWidth != null) HintBorderWidth=borderWidth;
   if (borderColor != null) HintBorderColor=borderColor;
   for (var j = 0; (node = document.getElementsByTagName("*")[j]); j++) {
       if (node.getAttribute("hint") == null ) continue;
	   addHint(node);
   }
}

function addHint(obj) {
   if (obj==null) return;
   if (obj.addEventListener) {obj.addEventListener("mouseover", showHint, false);
                                             obj.addEventListener("mouseout", hideHint, false);  
                                              }
   else if (obj.attachEvent) {obj.attachEvent("onmouseover", showHint);
                                           obj.attachEvent("onmouseout", hideHint);   
                                            }
}

function HintBody() {
   var str="";
   var b="border:"+HintBorderColor+" solid "+HintBorderWidth+"px;";
   str+='<table cellspacing=0 cellpadding=4 style="width:100%"><tr><td style="'+b+'cursor:default;background:'+HintBgColor+';" id="hintHolder" align=center>';
   if (withiFrame) str+='<iframe style="margin:0px;width:100%" name="hintFrame" id="hintFrame" frameborder=0 scrolling=no ></iframe>';
   str+='</td></tr></table>';
   return str;
}






function createHint(obj,x,y) {
  if (obj==null) return false;
  var DivTag=document.createElement("DIV");
  DivTag.setAttribute("id","HintLayer");
  DivTag.style.position="absolute";
  DivTag.style.display="";
  DivTag.style.zIndex="1000";
  DivTag.style.left=(!x)?0:x;
  DivTag.style.top=(!y)?0:y;
  DivTag.style.width=MaxHintWidth+"px";
  var bodies = document.getElementsByTagName('BODY');
    if (bodies.length > 0) bodies[0].appendChild( DivTag );
  dtag = document.getElementById("HintLayer");
  dtag.position="absolute";
  if (x+MaxHintWidth+15> bodies[0].offsetWidth)
    x-=(x+MaxHintWidth-bodies[0].offsetWidth-document.documentElement.scrollLeft);
  dtag.style.left=((!x)?0:x)+"px";
  dtag.style.top=((!y)?0:y)+"px";
  dtag.innerHTML=HintBody();
  return DivTag;   
}

function showHint(e) {
   var e = window.event ? window.event : e;
   var src = window.event ? e.srcElement : e.target;
   if(!src) return;
   var hintTxt=src.getAttribute("hint");
   if (hintTxt==null || trim(hintTxt)=="") return;
   hintTxt="<table cellspacing=0 id='mt'><tr><td "+((withiFrame)?"class='hint'":"style='font-size:"+HintTextSize+";padding:5px;text-align:justify;color:"+HintTextColor+"'")+">"+hintTxt+"</td></tr></table>";
   var x=((e.pageX) ? e.pageX : e.x+document.documentElement.scrollLeft)+15;
   var y=((e.pageY) ? e.pageY : e.y+document.documentElement.scrollTop)+10;
   stopEvent(e);
   var hintDiv=document.getElementById("HintLayer");
   if (hintDiv== null)
	  { hintDiv=createHint(src,x,y);
	     if (!hintDiv)  return; }

   if (withiFrame) {
        var hint=hintHeader()+hintTxt+"</body></html>";
        hintDiv.style.display="";
        var hintObj=document.getElementById('hintFrame');
        if (hintObj!=null)
        {
	        var ifrDoc=  (hintObj.contentDocument) ? hintObj.contentDocument : (window.frames) ? window.frames["hintFrame"].document:document.frames["hintFrame"].document; 
            if (ifrDoc !=null)
            {
                with(ifrDoc) 
                {
                    open();
		            write(hint);
		            close();
			    }   
	            resizeHint(hintDiv,hintObj,0)
	        }
            else hintDiv.style.display="none";
        }
    }
	else 
	{
        var hintObj=document.getElementById("hintHolder");
	    hintObj.innerHTML=hintTxt;
        hintDiv.style.display="";
    }

}



function hideHint(e) {
  var e = window.event ? window.event : e;
  stopEvent(e);
  var obj=document.getElementById("HintLayer");
  if (obj) {
	  obj.style.display="none";
	  self.document.body.removeChild(obj);
   }
}


function stopEvent(e) {
  if (e) 
    {e.cancelBubble=true;
      if (e.stopPropagation) e.stopPropagation();}
}
				function onLoad()
				{
				    InitAllHints(null,300,"#FFFCEA","#36638E",11,1,"#45688E");
				}
window.onload = onLoad;
