var Spry;if(!Spry){Spry={}}if(!Spry.Widget){Spry.Widget={}}Spry.Widget.whtnew=function(A,C){this.element=this.getElement(A);this.defaultTab=0;this.bindings=[];this.tabSelectedClass="whtnewTabSelected";this.tabHoverClass="whtnewTabHover";this.tabFocusedClass="whtnewTabFocused";this.panelVisibleClass="whtnewContentVisible";this.focusElement=null;this.hasFocus=false;this.currentTabIndex=0;this.enableKeyboardNavigation=true;Spry.Widget.whtnew.setOptions(this,C);if(typeof (this.defaultTab)=="number"){if(this.defaultTab<0){this.defaultTab=0}else{var B=this.getnewTabbedPanelCount();if(this.defaultTab>=B){this.defaultTab=(B>1)?(B-1):0}}this.defaultTab=this.getTabs()[this.defaultTab]}if(this.defaultTab){this.defaultTab=this.getElement(this.defaultTab)}this.attachBehaviors()};Spry.Widget.whtnew.prototype.getElement=function(A){if(A&&typeof A=="string"){return document.getElementById(A)}return A};Spry.Widget.whtnew.prototype.getElementChildren=function(B){var A=[];var C=B.firstChild;while(C){if(C.nodeType==1){A.push(C)}C=C.nextSibling}return A};Spry.Widget.whtnew.prototype.addClassName=function(B,A){if(!B||!A||(B.className&&B.className.search(new RegExp("\\b"+A+"\\b"))!=-1)){return }B.className+=(B.className?" ":"")+A};Spry.Widget.whtnew.prototype.removeClassName=function(B,A){if(!B||!A||(B.className&&B.className.search(new RegExp("\\b"+A+"\\b"))==-1)){return }B.className=B.className.replace(new RegExp("\\s*\\b"+A+"\\b","g"),"")};Spry.Widget.whtnew.setOptions=function(D,C,A){if(!C){return }for(var B in C){if(A&&C[B]==undefined){continue}D[B]=C[B]}};Spry.Widget.whtnew.prototype.getTabGroup=function(){if(this.element){var A=this.getElementChildren(this.element);if(A.length){return A[0]}}return null};Spry.Widget.whtnew.prototype.getTabs=function(){var A=[];var B=this.getTabGroup();if(B){A=this.getElementChildren(B)}return A};Spry.Widget.whtnew.prototype.getContentPanelGroup=function(){if(this.element){var A=this.getElementChildren(this.element);if(A.length>1){return A[1]}}return null};Spry.Widget.whtnew.prototype.getContentPanels=function(){var A=[];var B=this.getContentPanelGroup();if(B){A=this.getElementChildren(B)}return A};Spry.Widget.whtnew.prototype.getIndex=function(C,A){C=this.getElement(C);if(C&&A&&A.length){for(var B=0;B<A.length;B++){if(C==A[B]){return B}}}return -1};Spry.Widget.whtnew.prototype.getTabIndex=function(B){var A=this.getIndex(B,this.getTabs());if(A<0){A=this.getIndex(B,this.getContentPanels())}return A};Spry.Widget.whtnew.prototype.getCurrentTabIndex=function(){return this.currentTabIndex};Spry.Widget.whtnew.prototype.getnewTabbedPanelCount=function(A){return Math.min(this.getTabs().length,this.getContentPanels().length)};Spry.Widget.whtnew.addEventListener=function(C,B,D,A){try{if(C.addEventListener){C.addEventListener(B,D,A)}else{if(C.attachEvent){C.attachEvent("on"+B,D)}}}catch(E){}};Spry.Widget.whtnew.prototype.onTabClick=function(B,A){this.showPanel(A)};Spry.Widget.whtnew.prototype.onTabMouseOver=function(B,A){this.addClassName(A,this.tabHoverClass)};Spry.Widget.whtnew.prototype.onTabMouseOut=function(B,A){this.removeClassName(A,this.tabHoverClass)};Spry.Widget.whtnew.prototype.onTabFocus=function(B,A){this.hasFocus=true;this.addClassName(this.element,this.tabFocusedClass)};Spry.Widget.whtnew.prototype.onTabBlur=function(B,A){this.hasFocus=false;this.removeClassName(this.element,this.tabFocusedClass)};Spry.Widget.whtnew.ENTER_KEY=13;Spry.Widget.whtnew.SPACE_KEY=32;Spry.Widget.whtnew.prototype.onTabKeyDown=function(C,B){var A=C.keyCode;if(!this.hasFocus||(A!=Spry.Widget.whtnew.ENTER_KEY&&A!=Spry.Widget.whtnew.SPACE_KEY)){return true}this.showPanel(B);if(C.stopPropagation){C.stopPropagation()}if(C.preventDefault){C.preventDefault()}return false};Spry.Widget.whtnew.prototype.preorderTraversal=function(A,B){var D=false;if(A){D=B(A);if(A.hasChildNodes()){var E=A.firstChild;while(!D&&E){D=this.preorderTraversal(E,B);try{E=E.nextSibling}catch(C){E=null}}}}return D};Spry.Widget.whtnew.prototype.addPanelEventListeners=function(D,B){var C=this;Spry.Widget.whtnew.addEventListener(D,"click",function(F){return C.onTabClick(F,D)},false);Spry.Widget.whtnew.addEventListener(D,"mouseover",function(F){return C.onTabMouseOver(F,D)},false);Spry.Widget.whtnew.addEventListener(D,"mouseout",function(F){return C.onTabMouseOut(F,D)},false);if(this.enableKeyboardNavigation){var E=null;var A=null;this.preorderTraversal(D,function(F){if(F.nodeType==1){var G=D.attributes.getNamedItem("tabindex");if(G){E=F;return true}if(!A&&F.nodeName.toLowerCase()=="a"){A=F}}return false});if(E){this.focusElement=E}else{if(A){this.focusElement=A}}if(this.focusElement){Spry.Widget.whtnew.addEventListener(this.focusElement,"focus",function(F){return C.onTabFocus(F,D)},false);Spry.Widget.whtnew.addEventListener(this.focusElement,"blur",function(F){return C.onTabBlur(F,D)},false);Spry.Widget.whtnew.addEventListener(this.focusElement,"keydown",function(F){return C.onTabKeyDown(F,D)},false)}}};Spry.Widget.whtnew.prototype.showPanel=function(A){var F=-1;if(typeof A=="number"){F=A}else{F=this.getTabIndex(A)}if(!F<0||F>=this.getnewTabbedPanelCount()){return }var E=this.getTabs();var C=this.getContentPanels();var B=Math.max(E.length,C.length);for(var D=0;D<B;D++){if(D!=F){if(E[D]){this.removeClassName(E[D],this.tabSelectedClass)}if(C[D]){this.removeClassName(C[D],this.panelVisibleClass);C[D].style.display="none"}}}this.addClassName(E[F],this.tabSelectedClass);this.addClassName(C[F],this.panelVisibleClass);C[F].style.display="block";this.currentTabIndex=F};Spry.Widget.whtnew.prototype.attachBehaviors=function(D){var C=this.getTabs();var A=this.getContentPanels();var E=this.getnewTabbedPanelCount();for(var B=0;B<E;B++){this.addPanelEventListeners(C[B],A[B])}this.showPanel(this.defaultTab)};