var last_tab = 0;
var active;
var no_tabs;
var totalMaxWidth=720;
var totalWidth=0; 
var word_cut=0;
var longest_word;
var longest_id;


function createTabs(){
	

		
	document.write('<div id="tab_row_1" style="position: relative; height:20px; margin-left:15px">\n\r');
	
	 
	 var arguments = createTabs.arguments;	
	 no_tabs = arguments.length-1
	 active = createTabs.arguments[arguments.length-1];
	 
		for(var i=0; i < no_tabs; i++){
			
			namelink = arguments[i].split("->");
		
			
			eval("tab_"+i+" = new tab('tab_"+i+"','"+namelink[0]+"','"+namelink[1]+"',"+i+",'"+active+"');");
			
				tabwidth =	document.getElementById('left_tab_'+i).offsetWidth + 	document.getElementById('mid_tab_'+i).offsetWidth +	document.getElementById('right_tab_'+i).offsetWidth ;
				thisdiv = document.getElementById('all_tab_'+i);	
				//thisdiv.style.width = tabwidth+"px";
				//alert(tabwidth); tabwidth messed up in Firefox Windows 7, removed by katarina 2011-06-01
				
				thistab = eval('tab_'+i);
				
				thisdiv.style.left= totalWidth+"px";
				thistab.shiftleft=tabwidth;
				totalWidth = totalWidth + tabwidth;
		}
		
	
	document.write('</div>\n\r');
	document.write('<div style="clear:both;"></div>\n\r');

				
				if(totalWidth > totalMaxWidth){
				
					setWidth();				
				}else{
					document.getElementById('tab_row_1').style.width = totalMaxWidth+"px";
				}


			
			
	
	
	
	}

	
//--------------------------------------------------------------------------------------------------
	

	
	
	function setWidth(){
	
	
	do{	
			
			
			for(var i=0; i < no_tabs; i++){
					
					
					
				thisdiv = document.getElementById('all_tab_'+i);
				thistab = eval('tab_'+i);
				
				thistab.shiftleft = thisdiv.style.left.substring(0,thisdiv.style.left.length-2)-i;
				//alert(thistab.shiftleft);
			  thisdiv.style.left = thistab.shiftleft+"px";
			 
			
		}	
		totalWidth = totalWidth - (no_tabs-1)
	
	
	}while(totalWidth > totalMaxWidth)
	document.getElementById('tab_row_1').style.width = totalMaxWidth+"px";
	
	}
	
//--------------------------------------------------------------------------------------------------
	
	function tab(tab_id,tab_name,tab_link,crumb,active,last){
		
		
		this.crumb=crumb+1;
		this.tab_id = tab_id; 
		this.tab_name = tab_name
		this.tab_link = tab_link
		this.active = active
		this.lastzindex=0;
		this.shiftleft=0;

		
		var active_tabL = "axisRTabSmallActiveL";
		var active_tabM = "axisRTabSmallActiveM";
		var active_tabR = "axisRTabSmallActiveR";

		var inactive_tabL = "axisRTabSmallInActiveL";
		var inactive_tabM = "axisRTabSmallInActiveM";
		var inactive_tabR = "axisRTabSmallInActiveR";
		
		if(this.active==this.tab_name){
			
		var tabL = active_tabL
		var tabM = active_tabM
		var tabR = active_tabR
		var mouseEvents ='';
		var tabContent ='<b>'+this.tab_name+'</b>';
		var activezindex = no_tabs+1;
		
		}else{
			
		var tabL = inactive_tabL
		var tabM = inactive_tabM
		var tabR = inactive_tabR
		var tabContent = '<a id="link_'+this.tab_id+'" href="'+this.tab_link+'">'+this.tab_name+'</a>';
		var activezindex = 0 ;
		}
		
		var mouseEvents = 'onMouseOver="'+this.tab_id+'.bringToFront();" onMouseOut="'+this.tab_id+'.sendToBack();" ';
	
		this.setWidth = setWidth;
		this.bringToFront = bringToFront;
		this.sendToBack = sendToBack;
	
		theZindex = this.crumb + activezindex;
		
		document.write('<div id="all_'+this.tab_id+'" style="z-index:'+theZindex+'; position: absolute; float:left" '+mouseEvents+'>');
		document.write('<div id="left_'+this.tab_id+'"  class="'+tabL+'" ><img width="17" height="25" alt="" src="/core/graphics/blank.gif"/></div>\n\r');
		document.write('<div id="mid_'+this.tab_id+'"  class="'+tabM+'" ><b id="b_'+this.tab_id+'"><font size="1.5">'+this.crumb+' - </font></b>');
		document.write(tabContent);
		document.write('</div>\n\r');
		document.write('<div id="right_'+this.tab_id+'" class="'+tabR+'" "><img width="17" height="25" alt="" src="/core/graphics/blank.gif"/></div>\n\r');
		document.write('</div>\n\r');
	
	
	}
	
	function bringToFront(){
		theDiv = document.getElementById('all_'+this.tab_id)
		this.lastzindex = parseInt(theDiv.style.zIndex)
		newzindex = this.lastzindex+no_tabs+5;
		theDiv.style.zIndex = newzindex;
	
	}
	
	function sendToBack(){
		theDiv = document.getElementById('all_'+this.tab_id)
		theDiv.style.zIndex = this.lastzindex
		
	
	}	

