window.addEvent('domready', function(){     
    var myTips = new Class({
        Extends: Tips,
        elementEnter: function(event, element)
        {
            $A(this.container.childNodes).each(Element.dispose);
 
            var old_title = element.retrieve('tip:title');
            var dual =  old_title.split('::');
            var title = dual[0].trim();
            var text = dual[1].trim();
 
            if (title){
                this.titleElement = new Element('div', {'class': 'tip-title'}).inject(this.container);
                this.fill(this.titleElement, title);
            }
 
            if (text){
                this.textElement = new Element('div', {'class': 'tip-text'}).inject(this.container);
                this.fill(this.textElement, text);
            }
 
            this.timer = $clear(this.timer);
            this.timer = this.show.delay(this.options.showDelay, this);
 
            this.position((!this.options.fixed) ? event : {page: element.getPosition()});
        }
    });
     
    /* Tips 3 */
    var Tips3 = new myTips($$('.Tips3'), {
        timeOut          : 700,
        maxTitleChars    : 50,
        hideDelay        : 200,
        className        : 'tips', //for you yo use in the css classes being then .tip .tip-title and .tip-text
        onShow: function(tip) {
            tip.fade('in');
            
        },
        onHide: function(tip) {
            tip.fade('out');
        }


    });
     
    /* Tips 4 */
    var Tips4 = new Tips($$('.Tips4'), {
        className: 'custom'
    });
}); 

function enableTooltips(id){ 
                                   
    var links,i,h;
    if(!$ || !$$) return;
    //AddCss();
    h=document.createElement("span");
    h.id="btc";
    h.setAttribute("id","btc");
    h.style.position="absolute";
    $(id).appendChild(h);
    if(id==null) links=getElementsByTagName("input");
    else links=$(id).getElementsByTagName("input");
    for(i=0;i<links.length;i++){
        Prepare(links[i]);
    }
    
}

function Prepare(el){
    var tooltip,t,b,s,l;
    t=el.getAttribute("title");
    if(t==null || t.length==0) t="link:";
    el.removeAttribute("title");
    tooltip=CreateEl("span","tooltip");
    s=CreateEl("span","top");
    s.appendChild(document.createTextNode(t));
    tooltip.appendChild(s);
    b=CreateEl("b","bottom");
    //l=el.getAttribute("title");
    //if(l.length>30) l=l.substr(0,27)+"...";
   // b.appendChild(document.createTextNode(l));
    tooltip.appendChild(b);
    setOpacity(tooltip);
    el.tooltip=tooltip;
    el.onmouseover=showTooltip;
    el.onmouseout=hideTooltip;
    el.onmousemove=Locate;
}

function showTooltip(e){
    //alert('ok'); 
    $("btc").appendChild(this.tooltip);
    Locate(e);
        
}

function hideTooltip(e){
    var d=$("btc");
    if(d.childNodes.length>0) d.removeChild(d.firstChild);
}

function setOpacity(el){
    el.style.filter="alpha(opacity:95)";
    el.style.KHTMLOpacity="0.95";
    el.style.MozOpacity="0.95";
    el.style.opacity="0.95";
}

function CreateEl(t,c){
    var x=document.createElement(t);
    x.className=c;
    x.style.display="block";
    return(x);
}

function AddCss(){
    var l=CreateEl("link");
    l.setAttribute("type","text/css");
    l.setAttribute("rel","stylesheet");
    l.setAttribute("href","/css/layout.css");
    l.setAttribute("media","screen");
    $$("head")[0].appendChild(l);
        
}

function Locate(e){
    var posx=0,posy=0;
    if(e==null) e=window.event;
    if(e.pageX || e.pageY){
        posx=e.pageX; posy=e.pageY;
        }
    else if(e.clientX || e.clientY){
        if(document.documentElement.scrollTop){
            posx=e.clientX+document.documentElement.scrollLeft;
            posy=e.clientY+document.documentElement.scrollTop;
        }  else{
            posx=e.clientX+document.body.scrollLeft;
            posy=e.clientY+document.body.scrollTop;
        }
    }
    //alert('ok');
    $("btc").style.top=(posy)+"px";
    $("btc").style.left=(posx-(screen.width/4))+"px";
} 
       