var Tabs=new Class({options:{sInitUrl:'tennis.php',sPagesDir:'',oTransition:Fx.Transitions.linear},initialize:function(options)
{this.setOptions(options);this.sUpdateContent='tabsContent';this.sUpdateIndex='tabsIndex';this.sUpdateInIndex='inTabsIndex';this.sLoading='tabsLoading';this.sClassContent='TabsContent';this.sClassInContent='TabsInContent';this.sClassIndex='TabsIndex';this.sClassInIndex='InTabsIndex';this.sClassTitle='TabsTitle';this.sClassLoading='TabsLoading';window.addEvent('domready',function(){new Element('div',{'id':this.sUpdateContent,'class':this.sClassContent}).inject(document.body);new Element('div',{'id':this.sUpdateIndex,'class':this.sClassIndex}).inject(document.body);this.bDisplayEffect=true;this.oFxSlide=new Fx.Slide(this.sUpdateContent,{transition:this.options.oTransition,duration:500,wait:false});if(this.options.sInitUrl)
this.load(this.options.sInitUrl);}.bind(this));},load:function(sIdcurrentPage,mParams,sMethod,bReload)
{this.showLoading();var sTestMethod='get';if($defined(sMethod)&&sMethod=='post')
sTestMethod='post';var sTypeParam=$type(mParams);if(sTypeParam!='element'&&sTypeParam!='object'&&sTypeParam!='string')
mParams='';this.sIdcurrentPage=sIdcurrentPage;this.hide();this.unFocusIndex();if(!$(this.sIdcurrentPage)){new Ajax(this.options.sPagesDir+this.sIdcurrentPage,{method:sTestMethod,data:mParams,evalScripts:true,onclick:this.clear_running(this.sIdcurrentPage),onComplete:this.loadComplete.bind(this)}).request();}else{if($defined(bReload)){this.reload(sIdcurrentPage,mParams,sMethod,true);}else{$(this.sIdcurrentPage).style.display='block';this.hideLoading();this.focusIndex(this.sIdcurrentPage);}}},clear_running:function(nopage)
{if(nopage=='tennis_feed.php?status=all')
{if(typeof(show_live)=="number")
{clearInterval(show_live);CTabs.remove2('tennis_feed.php?status=live')}
if(typeof(show_fin)=="number")
{clearInterval(show_fin);CTabs.remove2('tennis_feed.php?status=fin')}
if(typeof(show_sched)=="number")
{clearInterval(show_sched);CTabs.remove2('tennis_feed.php?status=sched')}}
if(nopage=='tennis_feed.php?status=live')
{if(typeof(show_all)=="number")
{clearInterval(show_all);CTabs.remove2('tennis_feed.php?status=all')}
if(typeof(show_fin)=="number")
{clearInterval(show_fin);CTabs.remove2('tennis_feed.php?status=fin')}
if(typeof(show_sched)=="number")
{clearInterval(show_sched);CTabs.remove2('tennis_feed.php?status=sched')}}
if(nopage=='tennis_feed.php?status=fin')
{if(typeof(show_all)=="number")
{clearInterval(show_all);CTabs.remove2('tennis_feed.php?status=all')}
if(typeof(show_live)=="number")
{clearInterval(show_live);CTabs.remove2('tennis_feed.php?status=live')}
if(typeof(show_sched)=="number")
{clearInterval(show_sched);CTabs.remove2('tennis_feed.php?status=sched')}}
if(nopage=='tennis_feed.php?status=sched')
{if(typeof(show_all)=="number")
{clearInterval(show_all);CTabs.remove2('tennis_feed.php?status=all')}
if(typeof(show_fin)=="number")
{clearInterval(show_fin);CTabs.remove2('tennis_feed.php?status=fin')}
if(typeof(show_live)=="number")
{clearInterval(show_live);CTabs.remove2('tennis_feed.php?status=live')}}},loadComplete:function(sRequest)
{var oDiv=new Element('DIV',{'id':this.sIdcurrentPage,'class':this.sClassInContent}).inject($(this.sUpdateContent));oDiv.innerHTML=sRequest;this.addIndex(this.sIdcurrentPage);this.focusIndex(this.sIdcurrentPage);this.hideLoading();},reload:function(sIdPage,mParams,sMethod,bShow)
{this.showLoading();var sTestMethod='get';if($defined(sMethod)&&sMethod=='post')
sTestMethod='post';var sTypeParam=$type(mParams);if(sTypeParam!='element'&&sTypeParam!='object'&&sTypeParam!='string')
mParams='';this.sIdPageReloaded=sIdPage;this.bShow=bShow;if($(sIdPage)){new Ajax(this.options.sPagesDir+this.sIdPageReloaded,{method:sTestMethod,data:mParams,evalScripts:true,onComplete:this.reloadComplete.bind(this)}).request();}else{this.load(sIdPage);}},reloadComplete:function(sRequest)
{$(this.sIdPageReloaded).innerHTML=sRequest;if(this.sIdPageReloaded==this.sIdcurrentPage){}
if($defined(this.bShow)){this.focusIndex(this.sIdcurrentPage);this.hide();this.show(this.sIdPageReloaded);}
this.hideLoading();},hide:function(){var aContent=$ES('div.'+this.sClassInContent,this.sUpdateContent);aContent.each(function(oDiv){oDiv.style.display='none';});},show:function(sIdPage){$(sIdPage).style.display='block';},remove:function(sIdPage)
{if($(sIdPage)){$(sIdPage).remove();this.removeIndex(sIdPage);}
if($(this.sUpdateIndex).getChildren()!=''){var sIdPrevious=$(this.sUpdateIndex).getLast().getProperty('id');if(sIdPrevious==this.sUpdateIndex+'_'+this.sIdcurrentPage)
this.bDisplayEffect=false;this.load(sIdPrevious.substring(this.sUpdateIndex.length+1,sIdPrevious.length));}else if(this.options.sInitUrl){this.load(this.options.sInitUrl);}},remove2:function(sIdPage)
{if($(sIdPage)){$(sIdPage).remove();this.removeIndex(sIdPage);}},reset:function()
{$(this.sUpdateContent).empty();this.resetIndex();if(this.options.sInitUrl)
this.load(this.options.sInitUrl);},addIndex:function(sIdPage)
{var oDiv=new Element('DIV',{'id':this.sUpdateIndex+'_'+sIdPage,'class':this.sClassInIndex}).inject($(this.sUpdateIndex));new Element('IMG',{'src':'images/close.png','events':{'click':this.remove.bind(this,sIdPage,true)}}).inject(oDiv);new Element('IMG',{'src':'images/reload.png','events':{'click':this.reload.bind(this,sIdPage,true)}}).inject(oDiv);var sTitle='';var sTmpTitle=$E('.'+this.sClassTitle,sIdPage);if(sTmpTitle)
sTitle=sTmpTitle.getText();new Element('A',{'events':{'click':this.load.bind(this,sIdPage,true)}}).setText(sTitle).inject(oDiv);},removeIndex:function(sIdPage)
{$(this.sUpdateIndex+'_'+sIdPage).remove();},resetIndex:function()
{if($(this.sUpdateIndex))
$(this.sUpdateIndex).empty();},focusIndex:function(sIdPage)
{$(this.sUpdateIndex+'_'+sIdPage).addClass('SelectedTab');},unFocusIndex:function()
{var aIndex=$ES('div',this.sUpdateIndex);aIndex.each(function(oDiv){oDiv.removeClass('SelectedTab');});},showLoading:function()
{if($(this.sLoading)){$(this.sLoading).setStyle('display','none');}else{}},hideLoading:function()
{if($(this.sLoading))
$(this.sLoading).setStyle('display','none');}});Tabs.implement(new Options);var CTabs=new Tabs({sInitUrl:'tennis_feed.php?status=all',sPagesDir:'',oTransition:Fx.Transition(Fx.Transitions.Back,3).easeOut});
