message_Popup = function(template_node_id) {
	this.template_node_id = template_node_id;
	this.template_node = document.getElementById(this.template_node_id);
	this.template_node_content = document.getElementById(this.template_node_id+"_content");
	this.template_node.parentNode.removeChild( this.template_node);
	var _this_ = this;
	this.register_event( this.template_node, "mouseover", function(){_this_.hide();return false;});
	this.register_event( this.template_node, "mouseout", function(){return false;});
}
message_Popup.prototype = {
	"Y":YAHOO,
	"YD":YAHOO.util.Dom,
	"show":function( obj, ev, content) {
		var top_div = this.top_div;
		if ( this.template_node.parentNode != obj ) {
			this.template_node.parentNode && this.template_node.parentNode.style && (this.template_node.parentNode.style.position = "static");
			obj.style.position = "relative";
			this.template_node_content.style.visibility = "hidden";
			this.template_node.parentNode && this.template_node.parentNode.removeChild( this.template_node);
			obj.insertBefore( this.template_node, obj.childNodes[0])
			this.template_node_content.innerHTML = content;
			this.template_node.className = "top";
			var view_area_reg = this.get_viewport_region();
			var template_node_reg = this.YD.getRegion( this.template_node.getElementsByTagName("DIV")[0]);
			if ( view_area_reg.top<template_node_reg.top ) {
				this.template_node.className = "top";
			} else {
				obj.appendChild( this.template_node);
				this.template_node.className = "bottom";
			}
			this.template_node_content.style.visibility = "visible";
		}
	},
	"hide":function() {
		var template_node = this.template_node;
		var f = function() {
			if ( template_node.parentNode ) {
				template_node.parentNode.style.position = "static";
				template_node.parentNode.removeChild( template_node);
			}
		}
		if ( template_node.parentNode ) {
			f();
		}
	},
	"get_viewport_region":function() {
		var height = window.innerHeight?window.innerHeight:(document.compatMode=='CSS1Compat'?document.documentElement.clientHeight:document.body.clientHeight);
		var width = window.innerWidth?window.innerWidth:(document.compatMode=='CSS1Compat'?document.documentElement.clientWidth:document.body.clientWidth);
		return new this.Y.util.Region( document.body.scrollTop, document.body.scrollLeft+width, document.body.scrollTop+height, document.body.scrollLeft);
	},
	"register_event":function( obj, event_, func) {
		if ( event_.pop ) {
			while( ev = event_.pop() ) {
				document.all?obj.attachEvent( "on".concat( ev), func):obj.addEventListener( ev, func, false);
			}
		} else {
			document.all?obj.attachEvent( "on".concat( event_), func):obj.addEventListener( event_, func, false);
		}
	}
}
