
Panel = function(panel_src, panel_divid, config){

	this.panel_src = panel_src;
	this.config = (config!=undefined) ? config : { modal:true, visible:false, width:"500px", fixedcenter:true, constraintoviewport:true, draggable:true };
	this.div_id = panel_divid;	

}
YAHOO.extend(Panel, YAHOO.widget.Panel);

Panel.prototype.init_panel = function(){		
	if (document.getElementById(this.div_id)==null) {
		this.div  = document.createElement('div');
		this.div.id = this.div_id;
		document.body.appendChild(this.div);
	} else {
		this.div = document.getElementById(this.div_id);	
	}
	this.init(this.div_id, this.config); // init the panel
	this.load_panel(this.panel_src); // ajax - get the panel html
}

// use ajax to load in the panel script
Panel.prototype.load_panel = function(panel_src){
	var callback = 
	{ 
	  success:this.accept_panel, 
	  failure: this.failed_panel,
	  argument: { my_panel:this }
	};
	var load_panel_transaction = YAHOO.util.Connect.asyncRequest('GET', panel_src, callback, null); 
}

Panel.prototype.accept_panel = function(o){	
	if(o.responseText !== undefined){		
		o.argument.my_panel.setBody(o.responseText);	
		if (typeof(o.argument.my_panel.config.header)!="undefined"){
			o.argument.my_panel.setHeader(o.argument.my_panel.config.header);			
		}
		o.argument.my_panel.render();
	}
}
Panel.prototype.failed_panel = function(o){
	alert('loading panel failed: ' + o.status);
}
