
var Tooltip=new Class.create();Tooltip.prototype={timer_delay: 400,left_offset: -2,top_offset: 18,popup_max_width: 500,popup_obj: null,tag_new_attribute: null,timer_id: null,initialize: function(tag_attribute){this.tag_new_attribute=tag_attribute;this.popup_obj=document.createElement("DIV");this.popup_obj.className=this.tag_new_attribute;document.body.appendChild(this.popup_obj);},process: function(source, tags){var tags=tags || ['A', 'IMG', 'INPUT'];for (var i=0; i<tags.length; i++)this.parse_tag(source, tags[i]);},parse_tag: function(source, name){var tag_obj=source.getElementsByTagName(name);var total_elm=tag_obj.length;var elm_title=null;var elm_alt=null;var new_title='';for (var i=0; i<total_elm; i++){elm_title=tag_obj[i].getAttribute("title");elm_alt=tag_obj[i].getAttribute("alt");if ((elm_title!=null && elm_title!='') || (elm_alt!=null && elm_alt!='')){(elm_title!=null && elm_title.length>0)? new_title=elm_title : new_title=elm_alt;tag_obj[i].setAttribute(this.tag_new_attribute, new_title);if (tag_obj[i].getAttribute(this.tag_new_attribute)){tag_obj[i].removeAttribute("title");tag_obj[i].removeAttribute("alt");main.attach_event(tag_obj[i], "mouseover", this.show_popup);main.attach_event(tag_obj[i], "mouseout", this.hidden_popup);}}}},show_popup: function(oME){if (typeof(x_tooltip)!='object')return false;var elm=window.event ? window.event.srcElement : oME.currentTarget;if (elm!=null && elm.getAttribute(x_tooltip.tag_new_attribute)){main.attach_event(elm, "mousemove", x_tooltip.set_coordinate);x_tooltip.timer_id=setTimeout(function() {x_tooltip.popup_obj.innerHTML=main.trim(elm.getAttribute(x_tooltip.tag_new_attribute));x_tooltip.popup_obj.style.visibility="visible";}, x_tooltip.timer_delay);}},set_coordinate: function(oME){var new_x_pos=0;var new_y_pos=0;var ev_obj=window.event ? window.event : oME;var db_obj=document.body;var x=ev_obj.clientX+db_obj.scrollLeft;var y=ev_obj.clientY+db_obj.scrollTop;var popup_width=(window.event)? x_tooltip.popup_obj.clientWidth : x_tooltip.popup_obj.offsetWidth;var popup_height=(window.event)? x_tooltip.popup_obj.clientHeight : x_tooltip.popup_obj.offsetHeight;var window_width=db_obj.clientWidth+db_obj.scrollLeft;var window_height=db_obj.clientHeight+db_obj.scrollTop;( (window_width-x)<(popup_width))? new_x_pos=(x-popup_width)+6 :  new_x_pos=x+x_tooltip.left_offset;( (window_height-y)<(popup_height+x_tooltip.top_offset))? new_y_pos=(y-popup_height)-5 :  new_y_pos=y+x_tooltip.top_offset;if (popup_width>x_tooltip.popup_max_width){x_tooltip.popup_obj.style.width=x_tooltip.popup_max_width+"px";popup_width=x_tooltip.popup_obj.clientWidth;}x_tooltip.popup_obj.style.left=new_x_pos+"px";x_tooltip.popup_obj.style.top=new_y_pos+"px";},__destruct: function(){ this.hidden_popup();},hidden_popup: function(){if (typeof(x_tooltip)!='object')return false;x_tooltip.popup_obj.style.left="-99px";x_tooltip.popup_obj.style.top="-99px";x_tooltip.popup_obj.style.visibility="hidden";x_tooltip.popup_obj.innerHTML='';clearTimeout(x_tooltip.timer_id);}}
