Colloquio.Controls.Tabs={};Colloquio.Controls.Tabs.Tab=Class.create(Colloquio.Views.CoreView,{TAB_LABEL_CLASS:'tab_label',SELECTED_CLASS:'selected',initialize:function(tabElement,pageElement,url,index,cssPrefix)
{this.tabElement=$(tabElement);this.labelElement=this.tabElement.selectFirstByClassName(cssPrefix+'_'+this.TABS_TAB_LABEL_CLASS);this.pageElement=$(pageElement);this.url=url;this.index=index;this.tabElement.observe('click',this._onClick.bind(this));},_onClick:function()
{this._notifyObservers();},select:function()
{new Ajax.Updater(this.pageElement,this.url,{method:'get',evalScripts:true});this.pageElement.show();this.tabElement.addClassName(this.SELECTED_CLASS);},unselect:function()
{this.pageElement.hide();this.tabElement.removeClassName(this.SELECTED_CLASS);},getIndex:function()
{return this.index;}});Colloquio.Controls.Tabs.Tab.addMethods(Colloquio.Observable);Colloquio.Controls.Tabs.Tabs=Class.create(Colloquio.Views.CoreView,{TAB_CLASS:'tab',PAGE_CLASS:'page',TAB_PARAM:'tab',initialize:function($super,element,cssPrefix,urls)
{$super(element);this.tabs=new Array();var tabRows=this.element.selectByClassName(cssPrefix+'_'+this.TAB_CLASS);var tabPages=this.element.selectByClassName(cssPrefix+'_'+this.PAGE_CLASS);for(var i=0;i<tabRows.length;i++)
{var t=new Colloquio.Controls.Tabs.Tab(tabRows[i],tabPages[i],urls[i],i,cssPrefix);t.pageElement.hide();t.addObserver(this);this.tabs.push(t);}
this.tabs[0].select();this.selected=this.tabs[0];Colloquio.LocationManager.getInstance().addObserver(this);this.update(Colloquio.LocationManager.getInstance());},selectByIndex:function(index)
{this.select(this.tabs[index]);},select:function(tab,skipHash)
{if(!tab||(tab==this.selected))return;if(!skipHash)
{var params={};params[this.TAB_PARAM]=tab.getIndex();Colloquio.LocationManager.getInstance().setHash($H(params).toQueryString());}
this.selected.unselect();tab.select();this.selected=tab;},update:function(model)
{var tab=model;if(model==Colloquio.LocationManager.getInstance())
this.select(this._getTabFromHash(),true);else
this.select(tab);},_getTabFromHash:function()
{var tabIndex=Colloquio.LocationManager.getInstance().getHashParams(this.TAB_PARAM);tabIndex=tabIndex?tabIndex.toInteger():0;return this.tabs[tabIndex];}});