function ddtabcontent(a){this.tabinterfaceid=a;this.tabs=document.getElementById(a).getElementsByTagName("a");this.enabletabpersistence=true;this.hottabspositions=[];this.currentTabIndex=0;this.subcontentids=[];this.revcontentids=[];this.selectedClassTarget="link"}ddtabcontent.getCookie=function(a){var b=new RegExp(a+"=[^;]+","i");if(document.cookie.match(b))return document.cookie.match(b)[0].split("=")[1];return""};ddtabcontent.setCookie=function(a,b){document.cookie=a+"="+b+";path=/"};ddtabcontent.prototype={expandit:function(a){this.cancelautorun();var b="";try{if(typeof a=="string"&&document.getElementById(a).getAttribute("rel"))b=document.getElementById(a);else if(parseInt(a)!=NaN&&this.tabs[a].getAttribute("rel"))b=this.tabs[a]}catch(c){alert("Invalid Tab ID or position entered!")}if(b!="")this.expandtab(b)},cycleit:function(a,b){if(a=="next"){var c=this.currentTabIndex<this.hottabspositions.length-1?this.currentTabIndex+1:0}else if(a=="prev"){var c=this.currentTabIndex>0?this.currentTabIndex-1:this.hottabspositions.length-1}if(typeof b=="undefined")this.cancelautorun();this.expandtab(this.tabs[this.hottabspositions[c]])},setpersist:function(a){this.enabletabpersistence=a},setselectedClassTarget:function(a){this.selectedClassTarget=a||"link"},getselectedClassTarget:function(a){return this.selectedClassTarget=="linkparent".toLowerCase()?a.parentNode:a},urlparamselect:function(a){var b=window.location.search.match(new RegExp(a+"=(\\d+)","i"));return b==null?null:parseInt(RegExp.$1)},expandtab:function(a){var b=a.getAttribute("rel");var c=a.getAttribute("rev")?","+a.getAttribute("rev").replace(/\s+/,"")+",":"";this.expandsubcontent(b);this.expandrevcontent(c);for(var d=0;d<this.tabs.length;d++){this.getselectedClassTarget(this.tabs[d]).className=this.tabs[d].getAttribute("rel")==b?"selected":""}if(this.enabletabpersistence)ddtabcontent.setCookie(this.tabinterfaceid,a.tabposition);this.setcurrenttabindex(a.tabposition)},expandsubcontent:function(a){for(var b=0;b<this.subcontentids.length;b++){var c=document.getElementById(this.subcontentids[b]);c.style.display=c.id==a?"block":"none"}},expandrevcontent:function(a){var b=this.revcontentids;for(var c=0;c<b.length;c++){document.getElementById(b[c]).style.display=a.indexOf(","+b[c]+",")!=-1?"block":"none"}},setcurrenttabindex:function(a){for(var b=0;b<this.hottabspositions.length;b++){if(a==this.hottabspositions[b]){this.currentTabIndex=b;break}}},autorun:function(){this.cycleit("next",true)},cancelautorun:function(){if(typeof this.autoruntimer!="undefined")clearInterval(this.autoruntimer)},init:function(a){var b=ddtabcontent.getCookie(this.tabinterfaceid);var c=-1;var d=this.urlparamselect(this.tabinterfaceid);this.automodeperiod=a||0;for(var e=0;e<this.tabs.length;e++){this.tabs[e].tabposition=e;if(this.tabs[e].getAttribute("rel")){var f=this;this.hottabspositions[this.hottabspositions.length]=e;this.subcontentids[this.subcontentids.length]=this.tabs[e].getAttribute("rel");this.tabs[e].onclick=function(){f.expandtab(this);f.cancelautorun();return false};if(this.tabs[e].getAttribute("rev")){this.revcontentids=this.revcontentids.concat(this.tabs[e].getAttribute("rev").split(/\s*,\s*/))}if(d==e||this.enabletabpersistence&&c==-1&&parseInt(b)==e||!this.enabletabpersistence&&c==-1&&this.getselectedClassTarget(this.tabs[e]).className=="selected"){c=e}}}if(c!=-1)this.expandtab(this.tabs[c]);else this.expandtab(this.tabs[this.hottabspositions[0]]);if(parseInt(this.automodeperiod)>500&&this.hottabspositions.length>1){this.autoruntimer=setInterval(function(){f.autorun()},this.automodeperiod)}}}
