/*---------------------------------------------------------------------------\
|                               Tab Pane 1.02                                 |
|-----------------------------------------------------------------------------|
|                         Created by Erik Arvidsson                           |
|                  (http://webfx.eae.net/contact.html#erik)                   |
|                      For WebFX (http://webfx.eae.net/)                      |
|-----------------------------------------------------------------------------|
|                Copyright (c) 2002, 2003, 2006 Erik Arvidsson                |
|-----------------------------------------------------------------------------|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License.  You may obtain a copy |
| of the License at http://www.apache.org/licenses/LICENSE-2.0                |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Unless  required  by  applicable law or  agreed  to  in  writing,  software |
| distributed under the License is distributed on an  "AS IS" BASIS,  WITHOUT |
| WARRANTIES OR  CONDITIONS OF ANY KIND,  either express or implied.  See the |
| License  for the  specific language  governing permissions  and limitations |
| under the License.                                                          |
|-----------------------------------------------------------------------------|
| 2002-01-?? | First working version                                          |
| 2002-02-17 | Cleaned up for 1.0 public version                              |
| 2003-02-18 | Changed from javascript uri for anchors to return false        |
| 2003-03-03 | Added dispose methods to release IE memory                     |
| 2006-05-28 | Changed license to Apache Software License 2.0.                |
|-----------------------------------------------------------------------------|
| Dependencies: *.css           a css file to define the layout               |
|-----------------------------------------------------------------------------|
| Created 2002-01-?? | All changes are in the log above. | Updated 2006-05-28 |
\----------------------------------------------------------------------------*/
function hasSupport(){if(typeof hasSupport.support!="undefined"){return hasSupport.support}var A=/msie 5\.[56789]/i.test(navigator.userAgent);hasSupport.support=(typeof document.implementation!="undefined"&&document.implementation.hasFeature("html","1.0")||A);if(A){document._getElementsByTagName=document.getElementsByTagName;document.getElementsByTagName=function(B){if(B=="*"){return document.all}else{return document._getElementsByTagName(B)}}}return hasSupport.support}function WebFXTabPane(E,B){if(!hasSupport()||E==null){return }this.element=E;this.element.tabPane=this;this.pages=[];this.selectedIndex=null;this.useCookie=B!=null?B:true;this.element.style.visibility="visible";this.element.className=this.classNameTag+" "+this.element.className;this.tabRow=document.createElement("div");this.tabRow.className="tab-row";E.insertBefore(this.tabRow,E.firstChild);var A=0;if(this.useCookie){A=Number(WebFXTabPane.getCookie("webfxtab_"+this.element.id));if(isNaN(A)){A=0}}this.selectedIndex=A;var D=E.childNodes;var F;for(var C=0;C<D.length;C++){if(D[C].nodeType==1&&D[C].className=="tab-page"){this.addTabPage(D[C])}}}WebFXTabPane.prototype.classNameTag="dynamic-tab-pane-control";WebFXTabPane.prototype.setSelectedIndex=function(A){if(this.selectedIndex!=A){if(this.selectedIndex!=null&&this.pages[this.selectedIndex]!=null){this.pages[this.selectedIndex].hide()}this.selectedIndex=A;this.pages[this.selectedIndex].show();if(this.useCookie){WebFXTabPane.setCookie("webfxtab_"+this.element.id,A)}}};WebFXTabPane.prototype.getSelectedIndex=function(){return this.selectedIndex};WebFXTabPane.prototype.addTabPage=function(A){if(!hasSupport()){return }if(A.tabPage==this){return A.tabPage}var C=this.pages.length;var B=this.pages[C]=new WebFXTabPage(A,this,C);B.tabPane=this;this.tabRow.appendChild(B.tab);if(C==this.selectedIndex){B.show()}else{B.hide()}return B};WebFXTabPane.prototype.dispose=function(){this.element.tabPane=null;this.element=null;this.tabRow=null;for(var A=0;A<this.pages.length;A++){this.pages[A].dispose();this.pages[A]=null}this.pages=null};WebFXTabPane.setCookie=function(C,E,B){var A="";if(B){var D=new Date();D.setTime(D.getTime()+B*24*60*60*1000);A="; expires="+D.toGMTString()}document.cookie=C+"="+E+A+"; path=/"};WebFXTabPane.getCookie=function(C){var B=new RegExp("(;|^)[^;]*("+C+")=([^;]*)(;|$)");var A=B.exec(document.cookie);return A!=null?A[3]:null};WebFXTabPane.removeCookie=function(A){setCookie(A,"",-1)};function WebFXTabPage(G,C,A){if(!hasSupport()||G==null){return }this.element=G;this.element.tabPage=this;this.index=A;var F=G.childNodes;for(var E=0;E<F.length;E++){if(F[E].nodeType==1&&F[E].className=="tab"){this.tab=F[E];break}}var B=document.createElement("A");this.aElement=B;B.href="#";B.onclick=function(){return false};while(this.tab.hasChildNodes()){B.appendChild(this.tab.firstChild)}this.tab.appendChild(B);var D=this;this.tab.onclick=function(){D.select()};this.tab.onmouseover=function(){WebFXTabPage.tabOver(D)};this.tab.onmouseout=function(){WebFXTabPage.tabOut(D)}}WebFXTabPage.prototype.show=function(){var B=this.tab;var A=B.className+" selected";A=A.replace(/ +/g," ");B.className=A;this.element.style.display="block"};WebFXTabPage.prototype.hide=function(){var B=this.tab;var A=B.className;A=A.replace(/ selected/g,"");B.className=A;this.element.style.display="none"};WebFXTabPage.prototype.select=function(){this.tabPane.setSelectedIndex(this.index)};WebFXTabPage.prototype.dispose=function(){this.aElement.onclick=null;this.aElement=null;this.element.tabPage=null;this.tab.onclick=null;this.tab.onmouseover=null;this.tab.onmouseout=null;this.tab=null;this.tabPane=null;this.element=null};WebFXTabPage.tabOver=function(A){var C=A.tab;var B=C.className+" hover";B=B.replace(/ +/g," ");C.className=B};WebFXTabPage.tabOut=function(A){var C=A.tab;var B=C.className;B=B.replace(/ hover/g,"");C.className=B};function setupAllTabs(){if(!hasSupport()){return }var G=document.getElementsByTagName("*");var B=G.length;var D=/tab\-pane/;var C=/tab\-page/;var H,F;var A;for(var E=0;E<B;E++){F=G[E];H=F.className;if(H==""){continue}if(D.test(H)&&!F.tabPane){new WebFXTabPane(F)}else{if(C.test(H)&&!F.tabPage&&D.test(F.parentNode.className)){F.parentNode.tabPane.addTabPage(F)}}}}function disposeAllTabs(){if(!hasSupport()){return }var F=document.getElementsByTagName("*");var A=F.length;var C=/tab\-pane/;var G,E;var B=[];for(var D=0;D<A;D++){E=F[D];G=E.className;if(G==""){continue}if(C.test(G)&&E.tabPane){B[B.length]=E.tabPane}}for(var D=B.length-1;D>=0;D--){B[D].dispose();B[D]=null}};
