var tipPanel;

// TipPanel panel subclass
TipPanel = function(el, userConfig) {
	if (arguments.length > 0) {
		TipPanel.superclass.constructor.call(this, el, userConfig);
	}
}

// Inherit from YAHOO.widget.Panel
YAHOO.extend(TipPanel, YAHOO.widget.Panel);

// Initialize the TipPanel
TipPanel.prototype.init = function(el, userConfig) {
	TipPanel.superclass.init.call(this, el);
	
	this.beforeInitEvent.fire(TipPanel);
	
	this.beforeRenderEvent.subscribe(function() {
			if (! this.footer) {
				this.setFooter("");
			}
		},
		this, true
	);

	this.renderEvent.subscribe(function() {
		var me = this;
		var headerHeight = me.header.offsetHeight;
		me.bodyContentDiv = YAHOO.util.Dom.getElementsByClassName("yui-content", "div", me.body)[0];
		var contentDivId = YAHOO.util.Dom.generateId(me.bodyContentDiv, "tippanel");
		me.bodyContentDiv.setAttribute("id", contentDivId);
		
		YAHOO.util.Event.addListener(me.element, "click", me.hide, me, true);
		
	}, this, true);
	
	
	if (userConfig) {
		this.cfg.applyConfig(userConfig, true);
	}
	
	this.initEvent.fire(TipPanel);
}

// Set up the default values for the properties
TipPanel.prototype.initDefaultConfig = function() {
	TipPanel.superclass.initDefaultConfig.call(this);
}

TipPanel.prototype.setContent = function(newContent) {
	this.bodyContentDiv.innerHTML = newContent;
}

TipPanel.prototype.showPanel = function(refObj) {
	YAHOO.util.Dom.setStyle(this.element, "opacity", "0.9");
//	var refXY = YAHOO.util.Dom.getXY(refObj);
//	refXY[0] += refObj.scrollWidth + 15;
	var refXY = [724, 166]
	YAHOO.util.Dom.setXY(this.element, refXY);
	this.show();
}

YAHOO.util.Event.addListener(window, "load", function() {
	// create div structures
	var tipPanelDiv = document.createElement("DIV");
	tipPanelDiv.setAttribute("id", "tipPanel");
	document.body.appendChild(tipPanelDiv);
	tipPanelDiv.innerHTML = 
		'<div class="bd">'
		+ '		<div class="yui-content">'
		+ 		'</div>'
		+ '</div>';
	
	tipPanel = new TipPanel("tipPanel", { width:'230px', constraintoviewport:false, underlay: 'none', close: false, visible: false});
	tipPanel.render();
});

