Section = function(id,url, webroot)
{
	this.id=id;
	this.webroot = webroot;
	//this.url=url;
	this.update=Section_update;	
	this.urlparams='';
	this.show=Section_show;
	this.hide=Section_hide;
	this.elem=document.getElementById(id);
	this.setURL=Section_setURL;
	this.setURLParams=Section_setURLParams;
	this.setContent=Section_setContent;
	this.appendContent=Section_appendContent;
	this.isVisible=Section_isVisible;
	this.getElement=Section_getElement;
	this.getTemplate=Section_getTemplate;
	this.setTemplate=Section_setTemplate;	
	this.request = new Request(url,this.urlparams,'',Section_defaultSuccessHandler,null, 'POST');	
	this.request.callback.section=this;
	this.dispatchResponse=Section_DispatchResponse;	
};

Section_getTemplate=function()
{
    return this.url;
};

Section_setTemplate=function(template)
{
    this.setURL(template);
};

Section_getElement=function()
{
	return this.elem;
};

Section_setContent=function(str)
{
	YAHOO.util.Dispatcher.process(this.id,str);
};

Section_appendContent=function(str)
{
	var current_content = this.getElement().innerHTML;
	YAHOO.util.Dispatcher.process(this.id,current_content+str);
};

Section_setURLParams=function(urlparams)
{	
	this.request.setStaticParams(urlparams)
};

Section_defaultSuccessHandler=function(o)
{
	var response={};
	eval('response='+o.responseText+';');
	if(response===null)
	{
		response={'exception':o.responseText};
	}
	this.section.dispatchResponse(response,this.section.id);
};

Section_DispatchResponse=function(response,secid)
{	
	if(typeof(response['exception'])!=='undefined')
	{
		var rpart=response.exception;
		
	}
	else
	{
		var rpart=response[secid]
	}	
	getCustomTag(secid).setContent(rpart);
};

Section_update=function(callback)
{
	this.request.send();
};

Section_show=function()
{
	this.elem.style.display='block';
};

Section_hide=function()
{
	this.elem.style.display='none';
};

Section_setURL=function(url)
{
	if (this.webroot && this.webroot.length !== 0) 
	{
		url = this.webroot+url;
	}
	this.request.url=url;
};

Section_isVisible=function()
{
	return this.elem.style.display!='none';
};
