/*Copyright Scand LLC http://www.scbr.com
To use this component please contact info@scbr.com to obtain license
*/
 

 


 
function dhtmlXTabBar(parentObject,mode,height)
{this._isIE7s=((_isIE)&&window.XMLHttpRequest&&(document.compatMode != "BackCompat"));mode=mode||"top";this._mode=mode+"/";this._eczF=true;if (_isIE)this.preventIECashing(true);if (typeof(parentObject)!="object")
 this.entBox=document.getElementById(parentObject);else
 this.entBox=parentObject;this.width = this.entBox.getAttribute("width") || this.entBox.style.width || (window.getComputedStyle?window.getComputedStyle(this.entBox,null)["width"]:(this.entBox.currentStyle?this.entBox.currentStyle["width"]:0));this.height = this.entBox.getAttribute("height") || this.entBox.style.height || (window.getComputedStyle?window.getComputedStyle(this.entBox,null)["height"]:(this.entBox.currentStyle?this.entBox.currentStyle["height"]:0));if (((this.width||"").indexOf("%")!=-1)||((this.width||"").indexOf("%")!=-1))
 this.enableAutoReSize(true,true);if ((!this.width)||(this.width=="auto")||(this.width.indexOf("%")!=-1)||(parseInt(this.width)==0))
 this.width=this.entBox.offsetWidth+"px";if ((!this.height)||(this.height.indexOf("%")!=-1)||(this.height=="auto"))
 this.height=this.entBox.offsetHeight+"px";this.activeTab = null;this.tabsId = new Object();this._align="left";this._offset=5;this._margin=1;this._height=parseInt(height||20);this._bMode=(mode=="right"||mode=="bottom");this._tabSize='150';this._content=new Array();this._tbst="win_text";this._styles={winScarf:["with_bg/p_left.gif","with_bg/p_middle.gif","with_bg/p_right_skos.gif","with_bg/a_left.gif","with_bg/a_middle.gif","with_bg/a_right_skos.gif","with_bg/p_middle_over.gif",3,18,6,false,false,false]
 };this._createSelf(mode=="right"||mode=="left");this.setStyle("winScarf");this._TabCloseButton = false;this._TabCloseButtonSrc = 'close.png';this._enableAutoRowAdd = false;return this;};dhtmlXTabBar.prototype.setOffset = function(offset){this._offset=offset;};dhtmlXTabBar.prototype.setAlign = function(align){if (align=="top")align="left";if (align=="bottom")align="right";this._align=align;};dhtmlXTabBar.prototype.setMargin = function(margin){this._margin=margin;};dhtmlXTabBar.prototype._createSelf = function(vMode)
{this._tabAll=document.createElement("DIV");this._tabZone=document.createElement("DIV");this._conZone=document.createElement("DIV");this.entBox.appendChild(this._tabAll);{
 this._tabAll.appendChild(this._tabZone);this._tabAll.appendChild(this._conZone);};this._vMode=vMode;this._tabAll.className='dhx_tabbar_zone';this._tabZone.className='dhx_tablist_zone';this._conZone.className='dhx_tabcontent_zone';this._tabZone.onselectstart = function(){return false;};this._tabAll.onclick = this._onClickHandler;this._tabAll.onmouseover = this._onMouseOverHandler;if (_isFF)this._tabZone.onmouseout = this._onMouseOutHandler;else
 this._tabZone.onmouseleave = this._onMouseOutHandler;this._tabAll.tabbar=this;this._lineA=document.createElement("div");this._lineA.className="dhx_tablist_line";this._lineA.style[vMode?"left":"top"]=(this._bMode?0:(this._height+2))+"px";this._lineA.style[vMode?"height":"width"]=parseInt(this[vMode?"height":"width"])+((_isIE && document.compatMode!="BackCompat")?2:0)+"px";this._conZone.style.width=parseInt(this.width)-(_isFF?2:0)+"px";this.rows=new Array();this.rowscount=1;this._createRow();this._setSizes();};dhtmlXTabBar.prototype._createRow = function(){var z=document.createElement("DIV");z.className='dhx_tabbar_row';this._tabZone.appendChild(z);z._rowScroller=document.createElement('DIV');z._rowScroller.style.display="none";z.appendChild(z._rowScroller);this.rows[this.rows.length]=z;{
 z.style.height=parseInt(this._height)+3+"px";z.style.width=parseInt(this.width)+((_isIE && document.compatMode!="BackCompat")?2:0)+"px";};z.appendChild(this._lineA);};dhtmlXTabBar.prototype._removeRow=function(row){row.parentNode.removeChild(row);var z=new Array();for (var i=0;i<this.rows.length;i++)if (this.rows[i]!=row)z[z.length]=this.rows[i];this.rows=z;};dhtmlXTabBar.prototype._checkSizes = function(row){var count=parseInt(this._offset);for (var i=0;i<row.tabCount;i++){if (row.childNodes[i].style.display=="none")continue;count+=row.childNodes[i]._offsetSize+this._margin*1;};};dhtmlXTabBar.prototype._setSizes = function(){this._tabAll.height=this.height;this._tabAll.width=this.width;if (this._tabZone.childNodes.length)var z=this._tabZone.lastChild.offsetTop-this._tabZone.firstChild.offsetTop+this._height;else
 var z=this._height+(_isIE?5:0);var a=z-2;this._tabZone.style.height=(a>0?a:0)+"px";a=parseInt(this.height)-z-4;this._conZone.style.height=(a>0?a:0)+"px";};dhtmlXTabBar.prototype._onMouseOverHandler=function(e)
{if (_isIE)var target = event.srcElement;else
 var target = e.target;target=this.tabbar._getTabTarget(target);if (!target){this.tabbar._hideHover(target);return;};this.tabbar._showHover(target);(e||event).cancelBubble=true;};dhtmlXTabBar.prototype._onMouseOutHandler=function(e)
{this.parentNode.tabbar._hideHover(null);return;};dhtmlXTabBar.prototype._onClickHandler=function(e)
{if (_isIE)var target = event.srcElement;else
 var target = e.target;if (document.body.onclick)document.body.onclick(e);(e||event).cancelBubble=true;target=this.tabbar._getTabTarget(target);if (!target)return;this.tabbar._setTabActive(target);return false;};dhtmlXTabBar.prototype._getTabTarget=function(t){while ((!t.className)||(t.className.indexOf("dhx_tab_element")==-1)){if ((t.className)&&(t.className.indexOf("dhx_tabbar_zone")!=-1)) return null;t=t.parentNode;if (!t)return null;};return t;};dhtmlXTabBar.prototype._redrawRow=function(row){var count=parseInt(this._offset);for (var i=0;i<row.tabCount;i++){if (row.childNodes[i].style.display=="none")continue;row.childNodes[i]._cInd=i;row.childNodes[i].style[this._align]=count+"px";count+=row.childNodes[i]._offsetSize+parseInt(this._margin);};};dhtmlXTabBar.prototype.addTab = function(id, text, size, position, row){row=row||0;var z=this.rows[row].tabCount||0;if ((!position)&&(position!==0))
 position=z;var nss=this._getTabStyle(id);var tab=this._createTab(text, size, this._TabCloseButton, nss);tab.idd=id;this.tabsId[id] = tab;var close = tab.childNodes[2].getElementsByTagName('img')[0];if (this._TabCloseButton && close){var self = this;close.onclick = function() {if ((!self.dhx_tab_close)||(self.dhx_tab_close(id))) self.removeTab(id, true)};};this.rows[row].insertBefore(tab,this.rows[row].childNodes[position]);var prevCount = this.rows[row].tabCount;this.rows[row].tabCount=z+1;if (size=="*")this.adjustTabSize(tab);this._redrawRow(this.rows[row]);this._setSizes();};dhtmlXTabBar.prototype._showHover=function(tab){if (tab._disabled)return;this._hideHover(tab);if (tab==this._lastActive)return;var nss=this._getTabStyle(tab.idd);switch (this._tbst){case "win_text":
 tab._lChild.style.backgroundImage='url('+this._imgPath+this._mode+nss[6]+')';break;};this._lastHower=tab;};dhtmlXTabBar.prototype._getTabStyle=function(id){var nss=this._styles[this._cstyle];if (nss["id_"+id])nss=nss["id_"+id];return nss;};dhtmlXTabBar.prototype._hideHover=function(tab){if ((!this._lastHower)||(this._lastHower==tab)||(this._lastHower==this._lastActive))
 return;var nss=this._getTabStyle(this._lastHower.idd);switch (this._tbst){case "win_text":
 this._lastHower._lChild.style.backgroundImage='url('+this._imgPath+this._mode+nss[1]+')';break;};this._lastHower=null;};dhtmlXTabBar.prototype._getTabById=function(tabId){return this.tabsId[tabId];};dhtmlXTabBar.prototype.setTabActive=function(tabId){var tab=this._getTabById(tabId);if (tab)this._setTabActive(tab);};dhtmlXTabBar.prototype._setTabActive=function(tab){var oss=this._styles[this._cstyle]
 var nss=oss;if (this._lastActive && oss["id_"+this._lastActive.idd])oss=oss["id_"+this._lastActive.idd];if (nss["id_"+tab.idd])nss=nss["id_"+tab.idd];if ((tab._disabled)||(tab.style.display=="none")) return false;if ((this._onsel)&&(!this._onsel(tab.idd,this._lastActive?this._lastActive.idd:null))) return false;if (this._lastActive)this._lastActive.className=this._lastActive.className.replace(/dhx_tab_element_active/g,"dhx_tab_element_inactive");tab.className=tab.className.replace(/dhx_tab_element_inactive/g,"dhx_tab_element_active");if ((this._lastActive)&&(oss[10]))
 this._lastActive.style.backgroundColor=oss[10];if (nss[11])tab.style.backgroundColor=nss[11];{
 switch (this._tbst){case "win_text":
 if (this._lastActive){this._lastActive._scrollState=this._conZone.scrollTop;this._lastActive._lChild.style.backgroundImage='url('+this._imgPath+this._mode+oss[1]+')';this._lastActive.childNodes[0].childNodes[0].src=this._imgPath+this._mode+oss[0];this._lastActive.childNodes[1].childNodes[0].src=this._imgPath+this._mode+oss[2];this._lastActive.style.width=parseInt(this._lastActive.style.width)-oss[9]+"px";this._lastActive._lChild.style.width=parseInt(this._lastActive._lChild.style.width)-oss[9]+"px";this._lastActive.style[this._align=="left"?"marginLeft":"marginRight"]="0px"
 this._lastActive.style.height=this._height+1+"px";};tab._lChild.style.backgroundImage='url('+this._imgPath+this._mode+nss[4]+')';tab.childNodes[0].childNodes[0].src=this._imgPath+this._mode+nss[3];tab.childNodes[1].childNodes[0].src=this._imgPath+this._mode+nss[5];tab.style.width=parseInt(tab.style.width)+nss[9]+"px";tab._lChild.style.width=parseInt(tab._lChild.style.width)+nss[9]+"px";tab.style[this._align=="left"?"marginLeft":"marginRight"]="-3px"
 tab.style.height=this._height+3+"px";this._conZone.scrollTop=tab._scrollState||0;break;};};this._setContent(tab);this._lastActive=tab;return true;};dhtmlXTabBar.prototype._createTab = function(text,size,IsCloseButton,nss){var tab=document.createElement("DIV");tab.className='dhx_tab_element dhx_tab_element_inactive';var thml="";if (size=="*"){size="10";tab.style.whiteSpace="nowrap";};switch (this._tbst){case 'text':
 thml=text;break;case 'win_text':

 {thml='<div style="position:absolute;'+(this._bMode?"bottom":"top")+':0px;left:0px;width:'+nss[7]+'px;height:'+(this._height+3)+'px;"><img src="'+this._imgPath+this._mode+nss[0]+((this._bMode&&(_isOpera||_isFF||this._isIE7s))?'" style="position:absolute;bottom:0px;"':'"')+'></div>';thml+='<div style="position:absolute;'+(this._bMode?"bottom":"top")+':0px;right:0px;width:'+nss[8]+'px;height:'+(this._height+3)+'px;"><img src="'+this._imgPath+this._mode+nss[2]+((this._bMode&&(_isOpera||_isFF||this._isIE7s))?'" style="position:absolute;bottom:0px;left:0px;"':'"')+'></div>';thml+='<div style="position:absolute;background-repeat: repeat-x;background-image:url('+this._imgPath+this._mode+nss[1]+');height:'+(this._height+(this._bMode?1:3))+'px;top:0px;left:'+nss[7]+'px;width:'+(parseInt(size||this._tabSize)-nss[8]-nss[7]+"px")+';">';if (IsCloseButton){thml+='<img src="'+(this._imgPath+this._TabCloseButtonSrc)+'" style="cursor:pointer;position:absolute;right:0px;top:4px;" onclick="" />';};thml+='<div style="padding-top:3px;" '+(nss[13]?('" class="'+nss[13]+'"'):'')+'>'+text+'</div>';thml+='</div>';};if (!nss[10])tab.style.backgroundColor='transparent';else tab.style.backgroundColor=nss[10];break;};tab.innerHTML=thml;tab.style.padding="0px";tab._lChild=tab.childNodes[tab.childNodes.length-1];{

 tab.style.width=parseInt(size||this._tabSize)+"px";tab.style.height=this._height+1+"px";};tab._offsetSize=parseInt(size||this._tabSize);return tab;};dhtmlXTabBar.prototype.adjustTabSize=function(tab,size){var nss=this._getTabStyle(tab.idd);size=size||tab.scrollWidth+(this._TabCloseButton?50:20);tab.style[this._vMode?"height":"width"]=size+"px";tab.childNodes[2].style[this._vMode?"height":"width"]=size-nss[8]-nss[7]+"px";tab._offsetSize=size;};dhtmlXTabBar.prototype.setImagePath = function(path){this._imgPath=path;};dhtmlXTabBar.prototype.setOnSelectHandler=function(func){if (typeof(func)=="function")
 this._onsel=func;else
 this._onsel=eval(func);};dhtmlXTabBar.prototype.setContent=function(id,nodeId){if (typeof(nodeId)=="string")
 nodeId=document.getElementById(nodeId);if (this._content[id])this._content[id].parentNode.removeChild(this._content[id]);this._content[id]=nodeId;this._content[id]._loaded=true;if (nodeId.parentNode)nodeId.parentNode.removeChild(nodeId);nodeId.style.position="absolute";if (this._dspN){nodeId.style.display="none";nodeId.style.visibility="visible";}else{nodeId.style.visibility="hidden";nodeId.style.display="block";};nodeId.style.top="0px";nodeId.style.top="0px";this._conZone.appendChild(nodeId);if ((this._lastActive)&&(this._lastActive.idd==id)) this._setContent(this._lastActive);};dhtmlXTabBar.prototype._setContent=function(tab,stelth){if (!stelth){if ((this._lastActive)&&(this._content[this._lastActive.idd]))
 if (this._dspN)this._content[this._lastActive.idd].style.display='none';else
 this._content[this._lastActive.idd].style.visibility='hidden';if (this._content[tab.idd])if (this._dspN)this._content[tab.idd].style.display='block';else
 this._content[tab.idd].style.visibility='';};};dhtmlXTabBar.prototype.setContentHTML=function(id,html){var z=document.createElement("DIV");z.className="dhx_tabcontent_sub_zone";z.innerHTML=html;this.setContent(id,z);};dhtmlXTabBar.prototype.setStyle=function(name){if (this._styles[name]){this._cstyle=name;if(this._styles[this._cstyle][12])this._conZone.style.backgroundColor=this._styles[this._cstyle][12];};};dhtmlXTabBar.prototype.enableContentZone=function(mode){this._eczF=convertStringToBoolean(mode);this._conZone.style.display=this._eczF?"":'none';};dhtmlXTabBar.prototype.enableForceHiding=function(mode){this._dspN=convertStringToBoolean(mode);};dhtmlXTabBar.prototype.setSkinColors=function(a_tab,p_tab,c_zone){this._styles[this._cstyle][10]=p_tab;this._styles[this._cstyle][11]=a_tab;this._conZone.style.backgroundColor=c_zone||a_tab;};dhtmlXTabBar.prototype.preventIECashing=function(mode){this.no_cashe = convertStringToBoolean(mode);if (this.XMLLoader)this.XMLLoader.rSeed=this.no_cashe;};
