/*
<div class="roundcont">
   <div class="roundtop">
	 <img src="tl.gif" alt="" 
	 width="15" height="15" class="corner" 
	 style="display: none" />
   </div>

   <p>Lorem ipsum dolor</p>
   <div class="roundbottom">
	 <img src="bl.gif" alt="" 
	 width="15" height="15" class="corner" 
	 style="display: none" />
   </div>
</div>	

*/


NITRO.ctrl.Hint = function () {
//normal
  this.hintbox = this.createBox();
  this.hintcontent = this.hintbox;
//rounded
//  this.hintbox = this.createBoxRound();

}

NITRO.ctrl.Hint.prototype.Bind = function(containerId,hint,hwidth) {
  var container = document.getElementById(containerId);  
  container.control = this;
  container.onmouseover = this.Show;
  container.onmouseout = this.Hide;
  container.hint = hint;
  if (hwidth)
    container.hintwidth = hwidth;
  else
    container.hintwidth = '150px';
}

NITRO.ctrl.Hint.prototype.createBox = function() {
  var divblock=document.createElement("div");
  divblock.className = 'hintbox';
  document.body.appendChild(divblock);
  return divblock;
}

NITRO.ctrl.Hint.prototype.createBoxRound = function() {
  var divElem = document.createElement("div");
  divElem.className = 'hintround';
//top
  var subdivElem = document.createElement("div");
  subdivElem.className = 'hinttop';
  var imgElem = document.createElement("img");
  imgElem.src = 'nimg/tl.gif';
  imgElem.alt = '';
  imgElem.style.width = '15px';
  imgElem.style.height = '15px';
  imgElem.className = 'hintcorner';
  subdivElem.appendChild(imgElem);
  divElem.appendChild(subdivElem);
//content
  var pElem = document.createElement("p");
  this.hintcontent = pElem;
  divElem.appendChild(pElem);
//bottom
  var subdivElem = document.createElement("div");
  subdivElem.className = 'hintbottom';
  var imgElem = document.createElement("img");
  imgElem.src = 'nimg/bl.gif';
  imgElem.alt = '';
  imgElem.style.width = '15px';
  imgElem.style.height = '15px';
  imgElem.className = 'hintcorner';
  subdivElem.appendChild(imgElem);
  divElem.appendChild(subdivElem);
  document.body.appendChild(divElem); 
  return divElem;
}

NITRO.ctrl.Hint.prototype.Show = function(e) {
  var elem;
  if (!e) e = window.event;
  if (e.srcElement)
    elem = e.srcElement;
  else 
    elem = e.target;
 
  var ctrl = elem.control;
  if (ctrl.hintbox){
    var obj = ctrl.hintbox;
    ctrl.hintcontent.innerHTML=elem.hint;
    obj.style.width = elem.hintwidth;
    obj.style.top =  NITRO.util.Coords.offset(elem).y + elem.offsetHeight + "px"; 
    obj.style.left = NITRO.util.Coords.offset(elem).x + elem.offsetWidth - parseInt( elem.hintwidth ,10 ) + "px";      
    obj.style.visibility="visible";
    obj.style.display = 'block';
  }
}

NITRO.ctrl.Hint.prototype.Hide = function(e) {
  var elem;
  if (!e) e = window.event;
  if (e.srcElement) 
    elem = e.srcElement;
  else 
    elem = e.target;
  elem.control.hintbox.style.visibility="hidden";
  elem.control.hintbox.style.display="none";
}
