﻿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(b){var a=new RegExp(b+"=[^;]+","i");if(document.cookie.match(a))return document.cookie.match(a)[0].split("=")[1];return ""};ddtabcontent.setCookie=function(b,a){document.cookie=b+"="+a+";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,c){if(a=="next")var b=this.currentTabIndex<this.hottabspositions.length-1?this.currentTabIndex+1:0;else if(a=="prev")var b=this.currentTabIndex>0?this.currentTabIndex-1:this.hottabspositions.length-1;if(typeof c=="undefined")this.cancelautorun();this.expandtab(this.tabs[this.hottabspositions[b]])},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 c=a.getAttribute("rel"),d=a.getAttribute("rev")?","+a.getAttribute("rev").replace(/\s+/,"")+",":"";this.expandsubcontent(c);this.expandrevcontent(d);for(var b=0;b<this.tabs.length;b++)this.getselectedClassTarget(this.tabs[b]).className=this.tabs[b].getAttribute("rel")==c?"selected":"";if(this.enabletabpersistence)ddtabcontent.setCookie(this.tabinterfaceid,a.tabposition);this.setcurrenttabindex(a.tabposition)},expandsubcontent:function(c){for(var a=0;a<this.subcontentids.length;a++){var b=document.getElementById(this.subcontentids[a]);b.style.display=b.id==c?"block":"none"}},expandrevcontent:function(c){var b=this.revcontentids;for(var a=0;a<b.length;a++)document.getElementById(b[a]).style.display=c.indexOf(","+b[a]+",")!=-1?"block":"none"},setcurrenttabindex:function(b){for(var a=0;a<this.hottabspositions.length;a++)if(b==this.hottabspositions[a]){this.currentTabIndex=a;break}},autorun:function(){this.cycleit("next",true)},cancelautorun:function(){if(typeof this.autoruntimer!="undefined")clearInterval(this.autoruntimer)},init:function(e){var f=ddtabcontent.getCookie(this.tabinterfaceid),b=-1,d=this.urlparamselect(this.tabinterfaceid);this.automodeperiod=e||0;for(var a=0;a<this.tabs.length;a++){this.tabs[a].tabposition=a;if(this.tabs[a].getAttribute("rel")){var c=this;this.hottabspositions[this.hottabspositions.length]=a;this.subcontentids[this.subcontentids.length]=this.tabs[a].getAttribute("rel");this.tabs[a].onclick=function(){c.expandtab(this);c.cancelautorun();return false};if(this.tabs[a].getAttribute("rev"))this.revcontentids=this.revcontentids.concat(this.tabs[a].getAttribute("rev").split(/\s*,\s*/));if(d==a||this.enabletabpersistence&&b==-1&&parseInt(f)==a||!this.enabletabpersistence&&b==-1&&this.getselectedClassTarget(this.tabs[a]).className=="selected")b=a}}if(b!=-1)this.expandtab(this.tabs[b]);else this.expandtab(this.tabs[this.hottabspositions[0]]);if(parseInt(this.automodeperiod)>500&&this.hottabspositions.length>1)this.autoruntimer=setInterval(function(){c.autorun()},this.automodeperiod)}}
