// setcontent
function MMYUI_setContent(id, str, onLoad) {
	var idobj = (typeof id == "string" || id instanceof String) ? YAHOO.util.Dom.get(id) : id;
	idobj.innerHTML=str;
	if (typeof(onLoad)!='undefined') { onLoad(str); }
}

// seturl
function MMYUI_setUrl(id, url, onLoad, errmsg) {
	var idobj = (typeof id == "string" || id instanceof String) ? YAHOO.util.Dom.get(id) : id;
	var	param = {
			timeout:3000,
			argument:[idobj, url, onLoad, errmsg],
			success:function(httpObj){
				httpObj.argument[0].innerHTML = httpObj.responseText;
				if (typeof(httpObj.argument[2])!='undefined') { httpObj.argument[2](httpObj.argument[1]); }
			},
			failure:function(httpObj){ httpObj.argument[0].innerHTML = httpObj.argument[3]; }
		};
	YAHOO.util.Connect.asyncRequest("GET", url, param);
}

// titlepane
function MMYUI_clickTitlePane(event, id) {
	var titleobj = (typeof id == "string" || id instanceof String) ? YAHOO.util.Dom.get(id) : id;
	var contentobj = YAHOO.util.Dom.get(titleobj.m_contentid);
	var newstyle = titleobj.m_bshow ? 'none' : titleobj.m_oldstyle;
	titleobj.m_bshow = titleobj.m_bshow ? false : true;
	YAHOO.util.Dom.setStyle(contentobj, 'display', newstyle);
	return false;
}
function MMYUI_initTitlePane(title, content, bshow) {
	var titleobj = (typeof title == "string" || title instanceof String) ? YAHOO.util.Dom.get(title) : title;
	var contentobj = (typeof content == "string" || content instanceof String) ? YAHOO.util.Dom.get(content) : content;
	titleobj.m_bshow = (typeof(bshow)!='undefined') ? bshow : true;
	titleobj.m_contentid = contentobj.id;
	titleobj.m_oldstyle = YAHOO.util.Dom.getStyle(contentobj, 'display');
	var newstyle = titleobj.m_bshow ? titleobj.m_oldstyle : 'none';
	YAHOO.util.Dom.setStyle(contentobj, 'display', newstyle);
	YAHOO.util.Event.addListener(titleobj, 'click', MMYUI_clickTitlePane, title);
}

//
function MM_setStyle(id, style) {
	var idobj = (typeof id == "string" || id instanceof String) ? YAHOO.util.Dom.get(id) : id;
	idobj.setAttribute("style", style);
	idobj.style.cssText = style;
}
function MM_getStyle(id) {
	var idobj = (typeof title == "string" || title instanceof String) ? YAHOO.util.Dom.get(id) : title;
	var style = idobj.getAttribute("style");
	if (style==null || typeof style == "undefined") { return idobj.style.cssText; }
	return style;
}

// Resize Dialog
YAHOO.widget.ResizePanel = function(el, userConfig) {
	if (arguments.length > 0) { YAHOO.widget.ResizePanel.superclass.constructor.call(this, el, userConfig); }
}
YAHOO.extend(YAHOO.widget.ResizePanel, YAHOO.widget.Panel);
YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE = "resizepanel";
YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE = "resizehandle";
YAHOO.widget.ResizePanel.prototype.init = function(el, userConfig) {
	YAHOO.widget.ResizePanel.superclass.init.call(this, el);
	this.beforeInitEvent.fire(YAHOO.widget.ResizePanel);
	YAHOO.util.Dom.addClass(this.innerElement, YAHOO.widget.ResizePanel.CSS_PANEL_RESIZE);
	this.resizeHandle = document.createElement("DIV");
	this.resizeHandle.id = this.id + "_r";
	this.resizeHandle.className = YAHOO.widget.ResizePanel.CSS_RESIZE_HANDLE;
    this.beforeShowEvent.subscribe(function() { this.body.style.overflow = "auto"; }, this, true);
    this.beforeHideEvent.subscribe(function() { this.body.style.overflow = "hidden"; }, this, true);
	this.beforeRenderEvent.subscribe(function() { this.body.style.overflow = "hidden"; if (! this.footer) { this.setFooter(""); }}, this, true);
	this.renderEvent.subscribe(function() {
		var me = this;
		me.innerElement.appendChild(me.resizeHandle);
		this.ddResize = new YAHOO.util.DragDrop(this.resizeHandle.id, this.id);
		this.ddResize.setHandleElId(this.resizeHandle.id);
		var headerHeight = me.header.offsetHeight;
		this.ddResize.onMouseDown = function(e) {
			this.startWidth = me.innerElement.offsetWidth;
			this.startHeight = me.innerElement.offsetHeight;
			me.cfg.setProperty("width", this.startWidth + "px");
			me.cfg.setProperty("height", this.startHeight + "px");
			this.startPos = [YAHOO.util.Event.getPageX(e), YAHOO.util.Event.getPageY(e)];
			me.innerElement.style.overflow = "hidden";
			me.body.style.overflow = "auto";
		}
		this.ddResize.onDrag = function(e) {
			var newPos = [YAHOO.util.Event.getPageX(e), YAHOO.util.Event.getPageY(e)];
			var offsetX = newPos[0] - this.startPos[0];
			var offsetY = newPos[1] - this.startPos[1];
			var newWidth = Math.max(this.startWidth + offsetX, 10);
			var newHeight = Math.max(this.startHeight + offsetY, 10);
			me.cfg.setProperty("width", newWidth + "px");
			me.cfg.setProperty("height", newHeight + "px");
			var bodyHeight = (newHeight - 5 - me.footer.offsetHeight - me.header.offsetHeight - 3);
			if (bodyHeight < 0) { bodyHeight = 0; }
			me.body.style.height =  bodyHeight + "px";
			var innerHeight = me.innerElement.offsetHeight;
			var innerWidth = me.innerElement.offsetWidth;
			if (innerHeight < headerHeight) { me.innerElement.style.height = headerHeight + "px"; }
			if (innerWidth < 20) { me.innerElement.style.width = "20px"; }
		}
	}, this, true);
	if (userConfig) { this.cfg.applyConfig(userConfig, true); }
	this.initEvent.fire(YAHOO.widget.ResizePanel);
};
YAHOO.widget.ResizePanel.prototype.toString = function() { return "ResizePanel " + this.id; };