/***********************************************
* Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
		
var tipwidth='150px' //default tooltip width
var tipbgcolor='lightyellow'  //tooltip bgcolor
var disappeardelay=300  //tooltip disappear speed onMouseout (in miliseconds)
var vertical_offset="1px" //horizontal offset of tooltip from anchor link
var horizontal_offset="0px" //horizontal offset of tooltip from anchor link
/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

//if (ie4||ns6)
//document.write('<div id="fixedtipdiv" style="visibility:hidden;width:'+tipwidth+';background-color:'+tipbgcolor+'" ></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

var show_timeout_id;
var hide_timeout_id;

function fixedtooltip(cfg, delay) {
   var cfg = cfg;
   
   hidetip(); // kadangi uzhvedeme ant kazhko naujo tai galime drasiai paslepti popup'a is ten kur jis buvo anksciau
   
   if(show_timeout_id) { // rodysime nauja, todel tai kas buvo uzhvesta priesh tai ir turi timeout'a turi buti sustabdyta
       clearTimeout(show_timeout_id);
   }   
   if(hide_timeout_id) { 
       clearTimeout(hide_timeout_id); // kazhkur norima ishjungti popup'a bet kadangi mes norime rodyti nauja tai reikia ji sustabdyti
   }

   show_timeout_id = setTimeout(function() {
       
	   // jeigu jau rodome popup'a tai galime perrashyti zhemiau esanti onmouseout
	   cfg.obj.onmouseout = function() {
	       delayhidetip(); // reikia delay'jaus tam , kad vartotojas spetu uzhvesti ant popopo
       }

       fixedtooltip_delay(cfg);
   }, delay);
   
   
   // jei nuo objekto nuvedem pele iki to laiko kai pasirode popupas... tai jo rodyti jau ir nereikia
   cfg.obj.onmouseout = function() {
	   clearTimeout(show_timeout_id);
   }

}

function delayhidetip(){
   if (ie4||ns6) {
       hide_timeout_id=setTimeout("hidetip()",disappeardelay);
   }
}



var border_obj = null;
//function fixedtooltip(html, scroll_div_id, obj, e, offset){
function fixedtooltip_delay(cfg){
   // side - 0 left frame, 1 - right frame

   if(border_obj) {
	   border_obj.style.borderColor = "";
	   border_obj.style.borderStyle = "";
	   border_obj.style.borderWidth = "";
       border_obj.style.margin = "1px";
	   border_obj.style.backgroundColor = "";
	   border_obj = null; 
   }
   if (cfg.show_border) {
	   border_obj = cfg.obj;
       border_obj.style.margin = "0px";
	   border_obj.style.borderColor = "#aaaaaa";
	   border_obj.style.borderStyle = "solid";
	   border_obj.style.borderWidth = "1px";
	   border_obj.style.backgroundColor = "white";
   }
   
   if(!cfg.offset) { hoffset=0; voffset=0;}
   else {
       hoffset=cfg.offset[0]; voffset=cfg.offset[1];
   }

   if (window.event) event.cancelBubble=true
   else if (cfg.event.stopPropagation) cfg.event.stopPropagation();
   
   //clearhidetip(); // jei jau rodau, tai galiu neslepti priesht tai rodomo popupo, todel atjungiu ishjungima
   //hidetip();
   
   dropmenuobj=document.getElementById? document.getElementById("fixedtipdiv") : fixedtipdiv;
   
   dropmenuobj.innerHTML=cfg.html;
   //dropmenuobj.innerHTML="";
   //$(dropmenuobj).append(cfg.html);

   if (ie4||ns6){
      dropmenuobj.style.left=dropmenuobj.style.top=-500; // paslepiame 
      dropmenuobj.style.visibility="visible"; // ir atverchiame
   
      //showhide(dropmenuobj.style, cfg.event, "visible", "hidden", tipwidth);
      dropmenuobj.x=getposOffset(cfg.obj, "left");
      dropmenuobj.y=getposOffset(cfg.obj, "top");
      dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(cfg.obj, "rightedge")+ hoffset + "px";

	  var scroll = (cfg.scroll_div_id) ? (document.getElementById(cfg.scroll_div_id).scrollTop) : 0;
      dropmenuobj.style.top=dropmenuobj.y + voffset + cfg.obj.offsetHeight - scroll + "px";
  }
  //is_hidden = false;
  
}

function hidetip(e){
	//return;
    if (typeof dropmenuobj!="undefined"){
        if (ie4||ns6) {
            dropmenuobj.style.visibility="hidden"
		}
    }
	if(border_obj) {
	   border_obj.style.borderColor = "";
	   border_obj.style.borderStyle = "";
	   border_obj.style.borderWidth = "";
       border_obj.style.margin = "1px";
	   border_obj.style.backgroundColor = "";
	   border_obj = null;
	}
}

//function suspendhide() {
//clearTimeout(delayhide)
//}


function clearhidetip(){
if (typeof hide_timeout_id!="undefined")
clearTimeout(hide_timeout_id)
}

