/**
* Copyright (c) 2006 Andriy Bidochko. All Rights Reserved.
* http://www.mapbuilder.net
*
* This code (including but not limited to the actual source code, documentation and database schemes) 
* is not freeware and is intended for the use of the original license purchaser according to the license agreement.
* The code all or in part may not be sold, redistributed, or included as part of another application.
* 
* THIS SOFTWARE PRODUCT IS PROVIDED "AS IS" AND LICENSOR MAKE NO WARRANTY AS TO ITS USE, PERFORMANCE, 
* OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
MAPBUILDER.namespace("MAPBUILDER.widget");MAPBUILDER.widget.TabbedPane=function(container){if(MAPBUILDER.widget.TabbedPane.counter==undefined)
MAPBUILDER.widget.TabbedPane.counter=0;else
MAPBUILDER.widget.TabbedPane.counter++;this.container=container;this.containerID=container.id;this.imgSrcPixel='http://mapobject.net.dev1.abidcom.com/images/tab/pixel.gif';this.imgSrcTab='http://mapobject.net.dev1.abidcom.com/images/tab/tab.110.gif';this.imgSrcTabActive='http://mapobject.net.dev1.abidcom.com/images/tab/tabActive.110.gif';this.currentTab='';this.imageWidth=110;this.imageHeight=25;this.leftMargin=5;this.topMargin=6;this.overlap=19;this.incr=this.imageWidth-this.overlap;this.tabID='tab_'+MAPBUILDER.widget.TabbedPane.counter+'_';this.tabNum=0;this.init=function(){this.currentTab=arguments[0];var edge=document.createElement('img');this.container.appendChild(edge);edge.src=this.imgSrcPixel;edge.width=this.container.offsetWidth;edge.height=1;edge.style.position="absolute";edge.style.left="0px";edge.style.top=(parseInt(this.topMargin)+this.imageHeight-1)+"px";edge.style.zIndex=1;}
this.add=function(id,title,panel,callback){var tabDiv=document.createElement('div');tabDiv.setAttribute('id',this.tabID+id);tabDiv.setAttribute('panel',panel);tabDiv.setAttribute('callback',callback);this.container.appendChild(tabDiv);tabDiv.style.position="absolute";tabDiv.style.left=(parseInt(this.leftMargin)+(this.incr*this.tabNum++))+"px";tabDiv.style.top=this.topMargin+"px";tabDiv.style.width=this.imageWidth+"px";tabDiv.style.height=this.imageHeight+"px";tabDiv.style.backgroundImage="URL("+this.imgSrcTab+")";tabDiv.style.backgroundRepeat='no-repeat';tabDiv.style.textAlign='center';tabDiv.style.zIndex=0;tabDiv.setAttribute('class','tabDiv');var p=document.createElement('div');p.appendChild(document.createTextNode(title));p.style.position='absolute';p.style.left='0px';p.style.top='3px';p.style.width=this.imageWidth+"px";p.style.height=this.imageHeight+"px";p.style.textAlign='center';p.style.fontWeight='bold';p.style.display='block';tabDiv.appendChild(p);var d=document.createElement('div');var a=document.createElement('a');a.setAttribute('href',"javascript:"+this.containerID+".set('"+id+"')");a.appendChild(document.createTextNode(title));d.style.position='absolute';d.style.left='0px';d.style.top='2px';d.style.width=this.imageWidth+"px";d.style.height=this.imageHeight+"px";d.style.textAlign='center';d.style.display='block';d.appendChild(a);tabDiv.appendChild(d);}
this.set=function(tab,skipCallback){var d,s,e;if(this.currentTab){d=document.getElementById(this.tabID+this.currentTab);s=d.getAttribute('panel');e=document.getElementById(s);e.style.display='none';}
this.currentTab=tab;this.drawTabs();if(skipCallback==undefined)skipCallback=false;if(!skipCallback){d=document.getElementById(this.tabID+tab);eval(d.getAttribute('callback'));}
d=document.getElementById(this.tabID+tab);s=d.getAttribute('panel');e=document.getElementById(s);e.style.display='block';}
this.drawTabs=function(){var activeTab;for(var i=0;i<this.container.childNodes.length;i++){tabDiv=this.container.childNodes[i];var s=tabDiv.getAttribute('id');if(s){s=s.substring(6);if(s==this.currentTab){activeTab=i;tabDiv.style.backgroundImage="URL("+this.imgSrcTabActive+")";tabDiv.style.zIndex=2;tabDiv.firstChild.style.display='block';tabDiv.lastChild.style.display='none';}
else{tabDiv.style.backgroundImage="URL("+this.imgSrcTab+")";tabDiv.style.zIndex=0;tabDiv.firstChild.style.display='none';tabDiv.lastChild.style.display='block';}}}}}