﻿/*
function Browser()
{
  var agent  = navigator.userAgent.toLowerCase();
  this.ns    = ((agent.indexOf('mozilla')   !=   -1) &&
                ((agent.indexOf('spoofer')   ==   -1) &&
                (agent.indexOf('compatible') ==   -1)));
  this.ie    = (agent.indexOf("msie")       !=   -1);
  this.opera = (agent.indexOf("opera")       !=   -1);
};
var browser = new Browser();
*/

function pinTab(container)
{
  this.version          = "8.0.0501";
	this.id               = container.id;
	this.container        = container;
  this.design           = "1";
  this.aItems           = new Array();
  this.__aAllTabComponents = new Array();
  this.counter          = 100;
  
  // 0 = top
  // 1 = bottom
  this.orientation      = "0";
  this.tabarea          = false;
	// IMAGE/COLOR
  this.designmode       = "IMAGE";
  // load all pages after startup
  this.loadOnStartup    = true;
  this.lastTabItem      = null;
  this.refreshAfterLoad = false;
  this.loadFinished     = false;
  this.isHooverEnabled  = true;
  this.tabItemWidth     = "";
  this.isRedraw         = true;
  this.loadedPages      = 0;
  this.supportSSL       = false;

	// styles
	this.standardstyle   = "";
	this.hooverstyle     = "";
	this.activestyle     = "";
	this.separatorstyle  = "";
	this.backgroundstyle = "";
	this.bodystyle       = "";
	this.textstyle       = "";
	this.activetextstyle = "";
	
	this.ImageUrl                   = "";
	this.StyleBack                  = "";
	this.StyleBody                  = "";
  this.StyleItemLeft              = "";
  this.StyleItemRight             = "";
  this.StyleItemLeftRight         = "";
  this.StyleItemMiddle            = "";
  this.StyleItemHoverMiddle       = "";
  this.StyleItemSelectedLeft      = "";
  this.StyleItemSelectedRight     = "";
  this.StyleItemSelectedMiddle    = "";
  this.StyleItemLeftSelectedRight = "";
  this.StyleItemRightSelectedLeft = "";
  this.StyleItemText              = "";
  this.StyleItemTextSelected      = "";
  this.StyleLine                  = "";
	
	// the event can be configured
	this.eventTabClick   = ""; 

	// 0 = Left
	// 1 = Center
	this.tabAlignment       = 0; 
	  
	// methods
  this.add                  = __tab_add;
  this.addDyn               = __tab_addDyn;
  this.create               = __tab_create;
  this.redraw               = __tab_redraw;
  this.createItem           = __tab_createitem;
  this.clear                = __tab_clear;
  this.getActiveTab         = __tab_getactive;
  this.getActiveTabItem     = __tab_getactiveitem;
  this.getActiveTabDocument = __tab_getactivedoc;
  this.setActiveTab         = __tab_setactive;
  this.getItems             = __tab_getitems;
  this.preparePost          = __tab_preparePost;
  this.setFocus             = __tab_setFocus; 
  this.getObjectWidth       = __tab_getObjectWidth;
  this.remove               = __tab_remove;
  this.getItemByIndex       = __tab_getitem_byindex;
  this.getTabItems          = __tab_get_tabitems;
  this.getTabItemByIndex    = __tab_get_tabitem_byindex;
  this.setRedraw            = __tab_set_redraw;
  this.addEventHandler      = __tab_add_event_handler;
  this.bind                 = __tab_bind;
  this.cancelEvent          = __tab_cancel_event;
  this.getEventSource       = __tab_get_source;

	// NEW in 2.0
	this.__intisev            = false;
	this.width                = 0;
	// 0=Standard
	// 1=Multiple Rows
	// 2=Scrolling
	this.tabMode              = 0;
	// shows the current item that is on the very left position
	// only valid in Scrolling mode
	this.scrollPosition       = -1;
	this.scrollButtonWidth    = "34";
	this.scrollLeftAllowed    = false;
	this.scrollRightAllowed   = true;
	
	this.maxTabItemsPerRow    = 100;
	// 0 = left
	// 1 = center
	// 2 = right
	this.textAlignment        = 0;
	// 0 = left
	// 2 = right
	this.imageAlignment       = 0;
	
	// if we have multiple rows
	this.aRowHtml = new Array();
	
  this.IE       = navigator.userAgent.toLowerCase().indexOf("msie") >=0;   
  
  // add event handler
  this.addEventHandler(this.container,"mouseover",__tab_direct,this,"OVER"); 
  this.addEventHandler(this.container,"mouseout",__tab_direct,this,"OUT"); 
  this.addEventHandler(this.container,"mousedown",__tab_direct,this,"DOWN"); 
  this.addEventHandler(this.container,"mouseup",__tab_direct,this,"UP"); 
  this.addEventHandler(this.container,"focus",__tab_direct,this,"FOCUS"); 
  this.addEventHandler(this.container,"keydown",__tab_direct,this,"KEY"); 
  
};

function __tab_get_source(e)
{
  var source = null;
  if(this.IE)
    source = window.event.srcElement;
  else
    source = e.target;
    
  return source;
}

function __tab_add_event_handler(handlerObject,eventName,callback)
{
  var aVariableArguments = new Array();
  // let the first entry for event object
  aVariableArguments[aVariableArguments.length] = "";
  for(var i=3;i<__tab_add_event_handler.arguments.length;i++) {
    aVariableArguments[aVariableArguments.length] = __tab_add_event_handler.arguments[i];
  }

  if(this.IE) {
    handlerObject.attachEvent("on" + eventName,this.bind(callback,aVariableArguments));
  } else {
    handlerObject.addEventListener(eventName, this.bind(callback,aVariableArguments), false);
  }
}

function __tab_bind(callback,args)
{
  return function(e) {
    var evt = null;
    if(this.IE)
      evt = window.event;
    else
      evt = e;
    args[0] = evt;
    callback.apply(this,args) 
  };
}

function __tab_cancel_event(evt) 
{
  try {
    evt.keyCode = 0; 
    if(this.IE) {
      evt.cancelBubble = true;
      evt.returnValue = false;
    } else {
      evt.preventDefault();
    }
  } catch(e) {}
};


function __tab_setFocus()
{
  var item = this.getActiveTabItem();
  document.getElementById(item.id + "_focus").focus();
  // raise event
  try {
		tabEventTabClick(item,this.id);
	} catch(Error) { }
  
}

function __tab_preparePost(form,doc)
{
  var parentDoc = doc ? doc : parent.document;
  var items = this.getTabItems();
  
  for(var i=0;i<items.length;i++) {
    var doc = items[i].getDocument();
    var elements = doc.getElementsByTagName("input");
    for(var j=0;j<elements.length;j++) {
      var newField = parentDoc.createElement("input");
      newField.name = this.id + ".Page" + (i + 1) + "." + (elements[j].id != "" ? elements[j].id : elements(j).name);
      newField.id = newField.name;
      newField.type = "hidden";
      if(elements[j].type == "checkbox" || elements[j].type == "radio")
        newField.value = elements[j].checked;
      else
        newField.value = elements[j].value;
      parentDoc.forms(form).appendChild(newField);
    }
    var elements = doc.getElementsByTagName("select");
    for(var j=0;j<elements.length;j++) {
      var newField = parentDoc.createElement("input");
      newField.name = this.id + ".Page" + (i + 1) + "." + (elements[j].id != "" ? elements[j].id : elements(j).name);
      newField.id = newField.name;
      newField.type = "hidden";
      newField.value = elements[j].value;
      parentDoc.forms(form).appendChild(newField);
    }
    var elements = doc.getElementsByTagName("textarea");
    for(var j=0;j<elements.length;j++) {
      var newField = parentDoc.createElement("input");
      newField.name = this.id + ".Page" + (i + 1) + "." + (elements[j].id != "" ? elements[j].id : elements(j).name);
      newField.id = newField.name;
      newField.type = "hidden";
      newField.value = elements[j].value;
      parentDoc.forms(form).appendChild(newField);
    }
  }
}

function __tab_set_redraw(value)
{
  this.isRedraw = value;
}

function __tab_remove(index)
{
  var removingItem = this.aItems[index];
  var IsResetActiveItem = false;
  var ResetIndex = this.lastTabItem.index;
  if (removingItem.active == true) {
      IsResetActiveItem = true;
  }
  
  var IsDeleted = false;
  for (var i= 0 ;i< this.aItems.length;i++) {
    if (IsDeleted) {
      this.aItems[i-1] = this.aItems[i];
      this.aItems[i-1].id = 'tabitem' + (this.aItems[i].id.substring(7) -1);
      this.aItems[i-1].index -=1;
      __aAllTabComponents[i-1] =  __aAllTabComponents[i];
    } else {
      if (removingItem.id == this.aItems[i].id) {
          IsDeleted = true;
      }
    }
  }
  this.aItems.length -=1;
  __aAllTabComponents.length -=1;
  
  this.redraw();
  
  if (IsResetActiveItem) {   
      this.setActiveTab(0);
  }
};

function __tab_getitems()
{
	return this.aItems;
};

function __tab_getitem_byindex(index)
{
	var item = null;
	try {
		item = this.aItems[index];
	} catch (Error) {};

	return item;
};

function __tab_get_tabitems()
{
	var aTabItems = new Array();

	try {	
		for(var i=0; i< this.aItems.length;i++) {
			var item = this.aItems[i];
			if(item.type == "ITEM") {
				aTabItems[aTabItems.length] = item;
			}
		}
	} catch (Error) {};

	return aTabItems;
};

function __tab_get_tabitem_byindex(index)
{
	var j=0;

	try {	
		for(var i=0; i< this.aItems.length;i++) {
			var item = this.aItems[i];
			if(item.type == "ITEM") {
				if(j == index)
					return item;
				j++;
			}
		}
	} catch (Error) {};
};

function __tab_getactive()
{
	var j=0;
	
	try {	
		for(var i=0; i< this.aItems.length;i++) {
			var item = this.aItems[i];
			if(item.type == "ITEM") {
				if(item.active)
					return j;
				j++;
			}
		}
	} catch (Error) {};

	return 0;
};

function __tab_getactiveitem()
{
	try {	
		for(var i=0; i< this.aItems.length;i++) {
			var item = this.aItems[i];
			if(item.active)
				return item;
		}
	} catch (Error) {};

	return null;
};

function __tab_getactivedoc()
{
	var item = this.getActiveTabItem();
	try {
		var doc = window.frames[item.name].document;
	} catch(Error) {
		doc = null;
	}
	return doc;
};

function __tab_setactive(tabNo)
{
	var j=0;
  for(var i=0; i< this.aItems.length;i++) {
    var item = this.aItems[i];
		if(item.type == "ITEM") {
			if(j == tabNo) 
				this.aItems[i].active = true;
			else
				this.aItems[i].active = false;
			j++;
		}
	}
	this.create(true);
};

function __tab_clear()
{
	//__tab_count = 100;
	this.__aAllTabComponents = new Array();
  this.aItems = new Array();
};

function __tab_createitem(type)
{
	if(type == "TabSeparator")
		return new TabSeparator();	
	else
		return new TabItem("","","","");	
};

function __tab_add(item)
{
  var id = this.aItems.length;
  this.aItems[id] = item;
  //item.id = "tabitem" + this.counter;
  item.id = "__" + this.id + this.counter;
  item.index = id;
  item.design = this.design;
  this.counter++;
  item.tab = this;

  // we ned this for access within events
  var id = this.__aAllTabComponents.length;
  this.__aAllTabComponents[id] = item;
};

function __tab_addDyn(item)
{
  var id = this.aItems.length;
  this.aItems[id] = item;
  item.id = "tabitem" + this.counter;
  item.index = id;
  item.design = this.design;
  this.counter++;
  item.tab = this;

  // we ned this for access within events
  var id = this.__aAllTabComponents.length;
  this.__aAllTabComponents[id] = item;

  item.name = "__tab_area" + id;  
  item.pageLoaded = true;

  try {
    // now add the IFRAME dynamicly
    var iframe = document.createElement("iframe");
    iframe.name = "__tab_area" + id;  
    iframe.id = "__tab_area" + id;  
    iframe.allowTransparency = true;
    if(item.url != "") {
      iframe.src = item.url;
    } else {
      if(this.supportSSL)
        iframe.src = "dummy.html";
    }
    iframe.frameBorder = 0;
    iframe.style.height = "100%";
    iframe.style.width = "100%";
    iframe.style.display = "none";
    
    document.getElementById("__container" + this.orientation).appendChild(iframe);
    if(objTab.tabMode == 1) {
      // if rows have been changed
      var count = this.visibleItems;
      if((count % this.maxTabItemsPerRow) == 0) {
	      objTab.create();
	    } else {
        this.redraw();
	    }
    } else {
      this.redraw();
    }
  } catch (Error) {}
};

function __tab_redraw()
{
  this.create(true);
}

function __tab_create(redraw)
{

	redraw = (redraw == null) ? false: true;

  if(!this.isRedraw)
    return;

  var emptySource = ""; 
	var temp = "";
	var tempItems = "";
	var oriPrefix = "";
	var isSeparator = false;
  var events = "";

  //if(this.supportSSL)
  //   emptySource = "dummy.html";

	// set tab id = control id
	this.id = this.container.id;

	// add "B" for all classes
	if(this.orientation == "1")
		oriPrefix = "B";
	// add "L" for all classes
	if(this.orientation == "2")
		oriPrefix = "L";
		
	// table
	if(this.designmode == "IMAGE") {
	  
	  if(this.design == "1") {
	    if(oriPrefix == "") {
	      this.StyleBack                  = "background-color: #ece9d8;";
	      this.StyleBody                  = "border-left: 1px solid #919B9C;border-right: 1px solid #919B9C;border-bottom: 1px solid #919B9C;";
	      this.StyleItemLeft              = "width: 3px; height: 22px; background-image: url(" + this.ImageUrl + "/left.png);";
	      this.StyleItemRight             = "width: 3px; height: 22px; background-image: url(" + this.ImageUrl + "/right.png);";
	      this.StyleItemLeftRight         = "width: 5px; height: 22px; background-image: url(" + this.ImageUrl + "/leftright.png);";
	      this.StyleItemMiddle            = "height: 22px;background-image: url(" + this.ImageUrl + "/middle.png);background-repeat: repeat-x;";
	      this.StyleItemHoverMiddle       = "cursor: hand;height: 22px;background-image: url(" + this.ImageUrl + "/hoover_middle.png);background-repeat: repeat-x;";
	      this.StyleItemSelectedLeft      = "width: 3px;height: 22px;background-image: url(" + this.ImageUrl + "/sel_left.png);";
	      this.StyleItemSelectedRight     = "width: 3px;height: 22px;background-image: url(" + this.ImageUrl + "/sel_right.png);";
	      this.StyleItemSelectedMiddle    = "height: 22px;background-image: url(" + this.ImageUrl + "/sel_middle.png);background-repeat: repeat-x;";
	      this.StyleItemLeftSelectedRight = "width: 5px;height: 22px;background-image: url(" + this.ImageUrl + "/left-sel_right.png);";
	      this.StyleItemRightSelectedLeft = "width: 5px;height: 22px;background-image: url(" + this.ImageUrl + "/sel_right-left.png);";
	      this.StyleItemText              = "margin-left: 4px;margin-right: 7px;font-family: arial;font-size: 10px;";
	      this.StyleItemTextSelected      = "margin-left: 4px;margin-right: 7px;font-family: arial;font-size: 10px;";
	      this.StyleLine                  = "background-image: url(" + this.ImageUrl + "/line.png);background-repeat: repeat-x;";
	    }
	  }

	  if(this.design == "3") {
	    if(oriPrefix == "") {
	      this.StyleBack                  = "";
	      this.StyleBody                  = "border-left: 1px solid #000080;border-right: 1px solid #000080;border-bottom: 1px solid #000080;";
	      this.StyleItemLeft              = "width: 5px; height: 24px; background-image: url(" + this.ImageUrl + "/left.png);";
	      this.StyleItemRight             = "width: 5px;height: 24px;background-image: url(" + this.ImageUrl + "/right.png);";
	      this.StyleItemLeftRight         = "width: 5px;height: 24px;background-image: url(" + this.ImageUrl + "/leftright.png);";
	      this.StyleItemMiddle            = "cursor: hand;height: 24px;background-image: url(" + this.ImageUrl + "/middle.png);background-repeat: repeat-x;";
	      this.StyleItemHoverMiddle       = " cursor: hand;height: 24px;background-image: url(" + this.ImageUrl + "/hoover_middle.png);background-repeat: repeat-x;";
	      this.StyleItemSelectedLeft      = "width: 5px;height: 24px;background-image: url(" + this.ImageUrl + "/sel_left.png);";
	      this.StyleItemSelectedRight     = "width: 5px;height: 24px;background-image: url(" + this.ImageUrl + "/sel_right.png);";
	      this.StyleItemSelectedMiddle    = "cursor: hand;height: 24px;background-image: url(" + this.ImageUrl + "/sel_middle.png);background-repeat: repeat-x;";
	      this.StyleItemLeftSelectedRight = "width: 5px;height: 24px;background-image: url(" + this.ImageUrl + "/left-sel_right.png);";
	      this.StyleItemRightSelectedLeft = "width: 5px;height: 24px;background-image: url(" + this.ImageUrl + "/sel_right-left.png);";
	      this.StyleItemText              = "width: 100%;height: 100%;margin-top: 4px;margin-left: 4px;margin-right: 4px;font-family: arial;font-size: 10px;";
	      this.StyleItemTextSelected      = "width: 100%;height: 100%;margin-top: 4px;margin-left: 4px;margin-right: 4px;font-family: arial;font-size: 11px;font-weight: bold;";
	      this.StyleLine                  = "background-image: url(" + this.ImageUrl + "/line.png); background-repeat: repeat-x;";
	    }
	  }

	  if(this.design == "10") {
	    if(oriPrefix == "") {
	      this.StyleBack                  = "background-color: #BFDBFF";
	      this.StyleBody                  = "border-left: 1px solid #000080;border-right: 1px solid #000080;border-bottom: 1px solid #000080;";
	      this.StyleItemLeft              = "width: 5px; height: 26px; background-image: url(" + this.ImageUrl + "/line.png);background-repeat: repeat-x;;";
	      this.StyleItemRight             = "width: 5px;height: 26px;background-image: url(" + this.ImageUrl + "/line.png);background-repeat: repeat-x;;";
	      this.StyleItemLeftRight         = "width: 5px;height: 26px;background-image: url(" + this.ImageUrl + "/line.png);background-repeat: repeat-x;;";
	      this.StyleItemMiddle            = "cursor: hand;height: 26px;background-image: url(" + this.ImageUrl + "/line.png);background-repeat: repeat-x;";
	      this.StyleItemHoverMiddle       = "cursor: hand;height: 26px;background-image: url(" + this.ImageUrl + "/line.png);background-repeat: repeat-x;";
	      this.StyleItemSelectedLeft      = "width: 5px;height: 26px;background-image: url(" + this.ImageUrl + "/sel_left.png);";
	      this.StyleItemSelectedRight     = "width: 5px;height: 26px;background-image: url(" + this.ImageUrl + "/sel_right.png);";
	      this.StyleItemSelectedMiddle    = "cursor: hand;height: 26px;background-image: url(" + this.ImageUrl + "/sel_middle.png);background-repeat: repeat-x;";
	      this.StyleItemLeftSelectedRight = "width: 5px;height: 26px;background-image: url(" + this.ImageUrl + "/sel_left.png);";
	      this.StyleItemRightSelectedLeft = "width: 5px;height: 26px;background-image: url(" + this.ImageUrl + "/sel_right.png);";
	      this.StyleItemText              = "padding-top:3px;padding-left:10px;padding-right:10px;font-family: arial;font-size: 11px;color: #15428B";
	      this.StyleItemTextSelected      = "padding-top:3px;padding-left:10px;padding-right:10px;font-family: arial;font-size: 11px;color: #15428B;";
	      this.StyleLine                  = "background-image: url(" + this.ImageUrl + "/line.png); background-repeat: repeat-x;";
	    }
	  }

	} else {
  }

	// determine width
	try {
		this.width = this.container.offsetWidth;  //this.getObjectWidth(parent.document.getElementById(controlID)); //parent.document.getElementById(controlID).style.width ? parseInt(parent.document.getElementById(controlID).style.width) : parseInt(parent.document.getElementById(controlID).width);
	} catch(Error) {}

	if(this.tabMode == 2) {
		// get control width
		// draw scroll buttons
		temp+= "<div unselectable='on' style='z-Index:1001;position:absolute;width:" + this.scrollButtonWidth + "px;height:17px;left:" + (this.width - this.scrollButtonWidth)  + "px;top:1px;'>";
		temp+= "<img id='__tab_scroll_left'   type=image src='design/image/arrow_left.gif' value='<' onclick='__tab_scroll(0)'>";
		temp+= "<img id='__tab_scroll_right'  type=image src='design/image/arrow_right.gif' value='>' onclick='__tab_scroll(1)'>";
		temp+= "</div>";
	}
  
	if(this.backgroundstyle != "")
	  temp+= "<table unselectable='on' style='" + this.backgroundstyle + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'>";
	else
	  //temp+= "<table unselectable='on' class='" + oriPrefix + backClass + this.design + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'>";
	  temp+= "<table unselectable='on' style='" + this.StyleBack + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'>";

	// if we redraw we draw only the tab items
	if(!redraw) {
		if(this.orientation == "1") {
			if(this.tabarea) {
				// the tab area
				temp+= "<tr unselectable='on'>";
				//temp+= "<td id='__container1' unselectable='on' style='height:100%' class='" + oriPrefix + bodyClass + this.design + "' colspan='" + (this.aItems.length*2 + 2) + "'>";
				temp+= "<td id='__container1' unselectable='on' style='height:100%;" + this.StyleBody + "' colspan='" + (this.aItems.length*2 + 2) + "'>";
				
				for(var i=0; i< this.aItems.length;i++) {
					var item = this.aItems[i];
					if(item.type == "ITEM") { 
						if(item.active)
							temp+= "<iframe allowtransparency=true onload=\"javascript:__tab_doc_loaded(" + i + ",'__tab_area" + i + "')\"  src='" + emptySource + "' style='height:100%;width:100%;' id='__tab_area" + i + "'  name='__tab_area" + i + "' frameborder=0></iframe>";
						else
							temp+= "<iframe allowtransparency=true onload=\"javascript:__tab_doc_loaded(" + i + ",'__tab_area" + i + "')\"  src='" + emptySource + "' style='display:none;height:100%;width:100%;' id='__tab_area" + i + "'  name='__tab_area" + i + "' frameborder=0></iframe>";
						item.name = "__tab_area" + i;
					}
				}
				temp+= "</td>";
				temp+= "</tr>";
			} else {
				temp+= "<tr>";
				temp+= "<td height='100%' colspan='" + (this.aItems.length*2 + 2) + "'>";
				temp+= "</td>";
				temp+= "</tr>";
			}
		}
	}

	// get only the visible ones
	var aVisibleItem = new Array();
  for(var i=0; i< this.aItems.length;i++) {
		if(this.aItems[i].visible)
			aVisibleItem[aVisibleItem.length] = this.aItems[i];  
		else
      // unvisible items can't be active
		  this.aItems[i].active = false;
	}	
	this.visibleItems = aVisibleItem.length;

	var j=0;  
	var isFirst  = false;
	var isMiddle = false;
	var	lastRowItemCount = aVisibleItem.length % this.maxTabItemsPerRow;
  var rowCount = -1;
  
  var aRowHtml = new Array();

  // top and bottom mode  
  if(this.orientation == "0" || this.orientation == "1") {
    while(j<aVisibleItem.length) {
		  rowCount++;
		  temp += "<tr unselectable='on'>"; 
		  temp += "<td unselectable='on' style='width:100%'>";
		  temp += "<div unselectable='on' id='row" + rowCount + "'>";
		  tempItems = "";
		  // tab mode
		  if(this.tabMode == 2) {
			  // we need a placeholder
			  tempItems+= "<div style='height:22px'></div>";
			  tempItems+= "<div id='scroll' style='position:absolute;left:0px;top:0px;'><table cellpadding='0' cellspacing='0' border='0'><tr>";
		  } else {
			  tempItems+= "<table cellpadding='0' cellspacing='0' border='0'><tr>";
      }

		  for(var i=0; i<this.maxTabItemsPerRow;i++) {

			  // we have last item
			  if(j==aVisibleItem.length) 
				  break;

			  var item = aVisibleItem[j];
			  var isLastItemSeparator = false; 

			  // we need to know if we have a next item
			  isFirst          = (i==0) ? true:false;
			  isMiddle         = (i>0 && j<aVisibleItem.length-1 && i<this.maxTabItemsPerRow-1) ? true:false;
			  isLastRow        = (j >= (aVisibleItem.length - lastRowItemCount)) ? true:false;
			  isSingleTab      = isFirst && (j==aVisibleItem.length -1) ? true:false;

			  // if we are left aligned
			  if(this.tabAlignment == 0){
				  alignwidth = "";
			  } else {
				  if(!isLastRow)
					  alignwidth = "width='" + 100/this.maxTabItemsPerRow + "%'"; 
				  else
					  alignwidth = "width='" + 100/lastRowItemCount + "%'"; 
			  }
        if(isSingleTab)
				  alignwidth = "width='" + 100/this.maxTabItemsPerRow + "%'"; 

			  if(i>0) {
				  isLastItemSeparator = aVisibleItem[j - 1].type == "SEPARATOR" ? true:false;
			  }
			  // set text alignment
			  var textAlignment = "";
			  if(this.textAlignment == 0)
				  textAlignment = "left";
			  else if(this.textAlignment == 1)
				  textAlignment = "center";
			  else 
				  textAlignment = "right";
  			
			  // creates the cell events
			  var events2 = "";
			  /*
			  var events2 = " onmouseover='__tab_direct(\"" + item.id + "\",\"OVER\")'";
			  events2+= " onmouseout='__tab_direct(\"" + item.id + "\",\"OUT\")'";
			  events2+= " onmousedown='__tab_direct(\"" + item.id + "\",\"DOWN\")'";
			  events2+= " onmouseup='__tab_direct(\"" + item.id + "\",\"UP\")' ";
			  events2+= " onfocus='__tab_direct(\"" + item.id + "\",\"FOCUS\")' ";
			  events2+= " onkeydown='__tab_direct(\"" + item.id + "\",\"KEY\")' ";
			  */
  			
			  events = "";
			  if(this.IE)
				  events+= "><table id='" + item.id + "_title' unselectable='on' title='" + item.title + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'><tr unselectable='on'>";
			  else
				  events+= "><a style='text-decoration: none' href='javascript: void(0);'><table id='" + item.id + "_title' unselectable='on' title='" + item.title + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'><tr unselectable='on'>";

        // get Shortcut info
        var UIShortcut = getUIShortcut(item.text);

        var itemText = UIShortcut.html;

			  // creates the image and text cells
			  var imageCell  = "<td style='padding-left: 3px;'><img unselectable='on'  src='" + item.image + "' onclick='javascript:__tabImageClick(" + item.index + ")' border=0></td>";
			  var textCell1  = "<td type='__pintab_item' item='" + item.id + "' id='" + item.id + "_focus' ";

        if(UIShortcut.accessKey != null) {
		      textCell1 += " accesskey='" + UIShortcut.accessKey + "' ";
        }
  		 
			  textCell1 += " unselectable='on' align='" + textAlignment + "' width='100%' nowrap " +  events2 + "><div id='" + item.id + "_text' " + (item.enabled ? "":"style='color:gray'") + " unselectable='on' ";
			  var textCell2  = itemText + "</div></td>";
			  if(this.IE)
				  var closeTags  = "</tr></table></td>";
			  else
				  var closeTags  = "</tr></table></a></td>";

			  // defines if class or style
			  var textClass = "";
        var textWidth = "";
        
        if(this.tabItemWidth != "" || item.width != "") {
          var w = (item.width != "") ? item.width : this.tabItemWidth; 
		      textWidth = ";width:" + w;
        }
        
			  if(item.active) {
				  textClass = " style='" + this.StyleItemTextSelected + textWidth + "'>";
			  } else {
				  //textClass = ((this.textstyle == "") ? (" class='" + oriPrefix + "TabItemText" + this.design + "' " + textWidth) : (" style='" + this.textstyle + textWidth + "' ")) + ">";
				  textClass = " style='" + this.StyleItemText + textWidth + "'>";
			  }

			  // defines images and text
			  var imagetext = "";
			  if(this.imageAlignment==0) {
				  if(item.image) imagetext = imageCell;
				  if(itemText)	 imagetext+= textCell1 + textClass + textCell2;
			  } else {
				  if(itemText)	 imagetext+= textCell1 + textClass + textCell2;
				  if(item.image) imagetext = imageCell;
			  }
  			
			  // We are in IMAGE mode
			  if(this.designmode == "IMAGE") {
				  // do we have item or separator
				  if(item.type == "ITEM") {
					  item.isFirst  = false;
					  item.isMiddle = false;
					  item.isLast   = false;

					  // if first item
					  if(isFirst) {	
						  item.isFirst = true;
						  // first item active
						  if(item.active) {
							  //var leftClass = oriPrefix + "TabItemSelectedLeft" + this.design;
							  //var middleClass = oriPrefix + "TabItemSelectedMiddle" + this.design;
							  //tempItems+= "<td unselectable='on'><div unselectable='on' id='" + item.id + "_1' class='" + leftClass + "'></div></td>";
							  tempItems+= "<td unselectable='on'><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedLeft + "'></div></td>";
							  // contains events
							  //tempItems+= "<td unselectable='on' " + alignwidth + " id='" + item.id + "' class='" + middleClass + "'";
							  tempItems+= "<td unselectable='on' " + alignwidth + " id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
							  tempItems+= events;
							  tempItems+= imagetext;
							  tempItems+= closeTags;
							  if(isSingleTab) {
  						    item.isSingleTab = true;
								  //tempItems+= "<td><div  unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td>";
								  tempItems+= "<td><div  unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemSelectedRight + "'></div></td>";
        				  //tempItems+= "<td class='" + oriPrefix + "TabLine" + this.design + "' width='100%'>&nbsp;</td>";
        				  tempItems+= "<td style='" + this.StyleLine + "' width='100%'>&nbsp;</td>";
							  }
						  } else {
							  // first item not active
							  //var leftClass = oriPrefix + "TabItemLeft" + this.design;
							  //var middleClass = oriPrefix + "TabItemMiddle" + this.design;
							  //tempItems+= "<td><div  unselectable='on' style='" + leftClass + "' id='" + item.id + "_1'></div></td>";
							  tempItems+= "<td><div  unselectable='on' style='" + this.StyleItemLeft + "' id='" + item.id + "_1'></div></td>";
							  //tempItems+= "<td " + alignwidth + " id='" + item.id + "' class='" + middleClass + "'"; 
							  tempItems+= "<td " + alignwidth + " id='" + item.id + "' style='" + this.StyleItemMiddle + "'"; 
							  tempItems+= events;
							  tempItems+= imagetext;
							  tempItems+= closeTags;
							  if(isSingleTab) {
  						    item.isSingleTab = true;
								  //tempItems+= "<td><div  unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td>";
								  tempItems+= "<td><div  unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td>";
        				  //tempItems+= "<td class='" + oriPrefix + "TabLine" + this.design + "' width='100%'>&nbsp;</td>";
        				  tempItems+= "<td style='" + this.StyleLine + "' width='100%'>&nbsp;</td>";
							  }
						  }
					  // items in middle
					  //} else if(i>0 && i<aVisibleItem.length-1) {
					  } else if(isMiddle) {
						  item.isMiddle = true;
						  if(aVisibleItem[j-1].type == "ITEM") {
							  // last item in middle active
							  if(aVisibleItem[j-1].active) {
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemRightSelectedLeft" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemRightSelectedLeft + "'></div></td>";
								  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems+= events;
								  tempItems+= imagetext;
								  tempItems+= closeTags;
							  // last items in middle not active
							  } else {
								  if(item.active) {
									  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftSelectedRight" + this.design + "'></div></td>";
									  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftSelectedRight + "'></div></td>";
									  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
									  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
									  tempItems+= events;
									  tempItems+= imagetext;
									  tempItems+= closeTags;
								  } else {
									  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftRight" + this.design + "'></div></td>";
									  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftRight + "'></div></td>";
									  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
									  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
									  tempItems+= events;
									  tempItems+= imagetext;
									  tempItems+= closeTags;
								  }
							  }
						  } else {
							  if(item.active) {
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemSelectedLeft" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedLeft + "'></div></td>";
								  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
								  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
								  tempItems+= events;
								  tempItems+= imagetext;
								  tempItems+= closeTags;
							  } else {
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeft" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeft + "'></div></td>";
								  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems+= events;
								  tempItems+= imagetext;
								  tempItems+= closeTags;
							  }
						  }
					  } else {
						  item.isLast = true;
						  // the last item active
						  if(aVisibleItem[j-1].type == "ITEM") {
							  if(aVisibleItem[j-1].active) {
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemRightSelectedLeft" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemRightSelectedLeft + "'></div></td>";
								  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems+= events;
								  tempItems+= imagetext;
								  tempItems+= closeTags;
								  //tempItems+= "<td><div id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td>";
								  tempItems+= "<td><div id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td>";
							  } else {
								  // the last item not active
								  if(item.active) {
									  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftSelectedRight" + this.design + "'></div></td>";
									  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftSelectedRight + "'></div></td>";
									  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
									  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
									  tempItems+= events;
									  tempItems+= imagetext;
									  tempItems+= closeTags;
									  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td>";
									  tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemSelectedRight + "'></div></td>";
								  } else {
									  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftRight" + this.design + "'></div></td>";
									  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftRight + "'></div></td>";
									  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
									  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
									  tempItems+= events;
									  tempItems+= imagetext;
									  tempItems+= closeTags;
									  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td>";
									  tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td>";
								  }
							  }
						  } else {
							  // the last item not active
							  if(item.active) {
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemSelectedLeft" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedLeft + "'></div></td>";
								  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
								  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
								  tempItems+= events;
								  tempItems+= imagetext;
								  tempItems+= closeTags;
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemSelectedRight + "'></div></td>";
							  } else {
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeft" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeft + "'></div></td>";
								  //tempItems+= "<td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems+= "<td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems+= events;
								  tempItems+= imagetext;
								  tempItems+= closeTags;
								  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td>";
								  tempItems+= "<td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td>";
							  }
						  }
					  } 
				  } else {
					  // we have a separator
					  isSeparator = true;
					  // if last item was  selected
					  if(i>0) {
						  if(aVisibleItem[j-1].active) {
							  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td>";
							  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedRight + "'></div></td>";
						  } else {
							  //tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td>";
							  tempItems+= "<td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemRight + "'></div></td>";
						  }
					  }
					  //tempItems+= "<td  style='width:" + item.width + "' nowrap class='" + oriPrefix + "TabLine" + this.design + "'><div style='width:" + item.width + "' id='" + item.id + "_text' unselectable='on' class='" + oriPrefix + "TabItemText" + this.design + "'>" + itemText + "</div></td>";
					  tempItems+= "<td  style='width:" + item.width + "' nowrap style='" + this.StyleLine + "'><div style='width:" + item.width + "' id='" + item.id + "_text' unselectable='on' style='" + this.StyleItemText + "'>" + itemText + "</div></td>";
				  }

			  // --------------------------------------------------------------------------------------------
			  // COLOR mode
			  // --------------------------------------------------------------------------------------------
			  } else {
				  if(item.type == "ITEM") {
					  var textClass = "";
					  var textStyle = "";

					  tempItems+= "<td  id='" + item.id + "_title' title='" + item.title + "' class='TabColorSeparator" + this.design + "'";
					  tempItems+= " onmouseover='__tab_direct(\"" + item.id + "\",\"OVER\")'";
					  tempItems+= " onmouseout='__tab_direct(\"" + item.id + "\",\"OUT\")'";
					  tempItems+= " onmousedown='__tab_direct(\"" + item.id + "\",\"DOWN\")'";
					  tempItems+= " onmouseup='__tab_direct(\"" + item.id + "\",\"UP\")'>";
  					
					  if(item.active) {
						  textClass = "TabColorTextSelected" + this.design;
						  textStyle = this.activetextstyle ;
						  if(this.activestyle != "")
							  tempItems+= "<a style='text-decoration: none' href='javascript: void(0);'><table unselectable='on'  id='" + item.id + "' style='" + this.activestyle + "' cellpadding='0' cellspacing='0'><tr>";
						  else
							  tempItems+= "<a style='text-decoration: none' href='javascript: void(0);'><table unselectable='on'  id='" + item.id + "' class='TabColorSelected" + this.design + "' cellpadding='0' cellspacing='0'><tr>";
					  } else {
						  textClass = "TabColorText" + this.design;
						  textStyle = this.textstyle ;
						  if(this.standardstyle != "")
							  tempItems+= "<a style='text-decoration: none' href='javascript: void(0);'><table unselectable='on'  id='" + item.id + "' style='" + this.standardstyle + "' cellpadding='0' cellspacing='0'><tr>";
						  else
							  tempItems+= "<a style='text-decoration: none' href='javascript: void(0);'><table unselectable='on'  id='" + item.id + "' class='TabColorStandard" + this.design + "' cellpadding='0' cellspacing='0'><tr>";
					  }
					  if(item.image)
						  tempItems+= "<td><div style='margin-left:2px;'><img unselectable='on'  src='" + item.image + "' border=0></div></td>";
					  if(itemText) {
						  if(this.textstyle != "")
							  tempItems+= "<td nowrap><div id='" + item.id + "_text' unselectable='on' style='" + textStyle + "'>" + itemText + "</div></td>";
						  else
							  tempItems+= "<td nowrap><div id='" + item.id + "_text' unselectable='on' class='" + textClass + "'>" + itemText + "</div></td>";
					  }
					  tempItems+= "</tr></table></a></td>";
				  } else {
					  // we have a separator
					  isSeparator = true;
					  // separator
					  if(this.separatorstyle != "")
						  tempItems+= "<td style='" + this.separatorstyle + "' width='100%'>&nbsp;</td>";
					  else
						  tempItems+= "<td class='" + oriPrefix + "TabColorSeparator" + this.design + "' width='100%'>&nbsp;</td>";
				  }
			  }
			  j++;
		  }
		  // if we have a separator we don't need the line
		  if(!isSeparator) {
			  if(this.tabAlignment == 0) {
				  // We are in IMAGE mode
				  if(this.designmode == "IMAGE")
					  //tempItems+= "<td class='" + oriPrefix + "TabLine" + this.design + "' width='100%'>&nbsp;</td>";
					  tempItems+= "<td style='" + this.StyleLine + "' width='100%'>&nbsp;</td>";
				  else
					  tempItems+= "<td class='" + oriPrefix + "TabColorSeparator" + this.design + "' width='100%'>&nbsp;</td>";
			  }
		  }
		  if(this.tabMode == 2)
			  tempItems+= "</tr></table></div>";
		  else
			  tempItems+= "</tr></table>";

		  //
		  temp+= tempItems;
		  //
		  temp+= "</div></td></tr>";
		  // save the row HTML code for refresh
		  //this.html = tempItems; 
		  aRowHtml[rowCount] = tempItems;
    }
  }
  
  //------------------------------------------------------------------------------------------------
  // left
  //------------------------------------------------------------------------------------------------
  if(this.orientation == "2") {
    // add all parts to an array
    var aParts = new Array();
    tempItems = "<tr><td height='100%' class='LTabLine1'></td></tr>"
    aParts[aParts.length] = tempItems;

		temp += "<tr unselectable='on'>"; 
		temp += "<td unselectable='on' style='width:22px;height:100%'>";
    temp += "<div unselectable='on' id='row0'>";
		temp += "<table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'>";

    while(j<aVisibleItem.length) {
		  tempItems = "";

		  for(var i=0; i<this.maxTabItemsPerRow;i++) {
			  // we have last item
			  if(j==aVisibleItem.length) 
				  break;

			  var item = aVisibleItem[j];
			  var isLastItemSeparator = false; 

			  // we need to know if we have a next item
			  isFirst          = (i==0) ? true:false;
			  isMiddle         = (i>0 && j<aVisibleItem.length-1 && i<this.maxTabItemsPerRow-1) ? true:false;
			  isLastRow        = (j >= (aVisibleItem.length - lastRowItemCount)) ? true:false;
			  isSingleTab      = isFirst && (j==aVisibleItem.length -1) ? true:false;

			  if(i>0) {
				  isLastItemSeparator = aVisibleItem[j - 1].type == "SEPARATOR" ? true:false;
			  }

			  // set text alignment
			  var textAlignment = "";
  			
			  // creates the cell events
			  var events2 = " onmouseover='__tab_direct(\"" + item.id + "\",\"OVER\")'";
			  events2+= " onmouseout='__tab_direct(\"" + item.id + "\",\"OUT\")'";
			  events2+= " onmousedown='__tab_direct(\"" + item.id + "\",\"DOWN\")'";
			  events2+= " onmouseup='__tab_direct(\"" + item.id + "\",\"UP\")' ";
			  events2+= " onfocus='__tab_direct(\"" + item.id + "\",\"FOCUS\")' ";
			  events2+= " onkeydown='__tab_direct(\"" + item.id + "\",\"KEY\")' ";
  			
			  events = "";
			  if(this.IE)
				  events+= "><table id='" + item.id + "_title' unselectable='on' title='" + item.title + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'><tr unselectable='on'>";
			  else
				  events+= "><a style='text-decoration: none' href='javascript: void(0);'><table id='" + item.id + "_title' unselectable='on' title='" + item.title + "' width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'><tr unselectable='on'>";

        // get Shortcut info
        var UIShortcut = getUIShortcut(item.text,true);

        var itemText = UIShortcut.html;

			  // creates the image and text cells
			  var imageCell  = ""; //"<tr><td style='padding-left: 3px;'><img unselectable='on'  src='" + item.image + "' onclick='javascript:__tabImageClick(" + item.index + ")' border=0></td></tr>";
			  var textCell1  = "<td valign='center' id='" + item.id + "_focus' ";

        if(UIShortcut.accessKey != null) {
		      textCell1 += " accesskey='" + UIShortcut.accessKey + "' ";
        }
  		 
			  textCell1 += " unselectable='on' align='center' width='100%' nowrap " +  events2 + "><div id='" + item.id + "_text' " + (item.enabled ? "":"style='color:gray'") + " unselectable='on' ";
			  var textCell2  = itemText + "</div></td>";

			  if(this.IE)
				  var closeTags  = "</tr></table></td></tr>";
			  else
				  var closeTags  = "</tr></table></a></td></tr>";


			  // defines if class or style
			  var textClass = "";
        var textWidth = "";
        var alignwidth = "";
  
  /*      
        if(this.tabItemWidth != "" || item.width != "") {
          var w = (item.width != "") ? item.width : this.tabItemWidth; 
		      textWidth = (this.activetextstyle == "" || this.textstyle == "") ? ("style='width:" + w + "'") : (";width:" + w);
        }
  */
        
			  if(item.active) {
				  //textClass = ((this.activetextstyle == "") ? (" class='" + oriPrefix + "TabItemTextSelected" + this.design + "' " + textWidth) : (" style='" + this.activetextstyle + textWidth + "' ")) + ">";
				  textClass = " style='" + this.StyleItemTextSelected + "'>";
			  } else {
				  //textClass = ((this.textstyle == "") ? (" class='" + oriPrefix + "TabItemText" + this.design + "' " + textWidth) : (" style='" + this.textstyle + textWidth + "' ")) + ">";
				  textClass = " style='" + this.StyleItemText + "'>";
			  }

			  // defines images and text
			  var imagetext = "";
			  if(this.imageAlignment==0) {
				  if(item.image) imagetext = imageCell;
				  if(itemText)	 imagetext+= textCell1 + textClass + textCell2;
			  } else {
				  if(itemText)	 imagetext+= textCell1 + textClass + textCell2;
				  if(item.image) imagetext = imageCell;
			  }

			  // We are in IMAGE mode
			  if(this.designmode == "IMAGE") {
				  // do we have item or separator
				  if(item.type == "ITEM") {
					  item.isFirst  = false;
					  item.isMiddle = false;
					  item.isLast   = false;

					  // if first item
					  if(isFirst) {	
						  item.isFirst = true;
						  // first item active
						  if(item.active) {
							  //var leftClass = oriPrefix + "TabItemSelectedLeft" + this.design;
							  //var middleClass = oriPrefix + "TabItemSelectedMiddle" + this.design;
							  //aParts[aParts.length] = "<tr><td unselectable='on'><div unselectable='on' id='" + item.id + "_1' class='" + leftClass + "'>&nbsp;</div></td></tr>";
							  aParts[aParts.length] = "<tr><td unselectable='on'><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedLeft + "'>&nbsp;</div></td></tr>";
							  // contains events
							  //tempItems = "<tr><td unselectable='on' " + alignwidth + " id='" + item.id + "' class='" + middleClass + "'";
							  tempItems = "<tr><td unselectable='on' " + alignwidth + " id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
							  tempItems += events;
							  tempItems += imagetext;
							  tempItems += closeTags;
							  aParts[aParts.length] = tempItems;
							  
							  if(isSingleTab) {
  						    item.isSingleTab = true;
								  //aParts[aParts.length] = "<tr><td><div  unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div  unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemSelectedRight + "'></div></td></tr>";
        				  //aParts[aParts.length] = "<tr><td class='" + oriPrefix + "TabLine" + this.design + "' width='100%'>&nbsp;</td></tr>";
        				  aParts[aParts.length] = "<tr><td style='" + this.StyleLine + "' width='100%'>&nbsp;</td></tr>";
							  }
						  } else {
							  // first item not active
							  //var leftClass = oriPrefix + "TabItemLeft" + this.design;
							  //var middleClass = oriPrefix + "TabItemMiddle" + this.design;
							  //aParts[aParts.length] = "<tr><td><div  unselectable='on' class='" + leftClass + "' id='" + item.id + "_1'>&nbsp;</div></td></tr>";
							  aParts[aParts.length] = "<tr><td><div  unselectable='on' style='" + this.StyleItemLeft + "' id='" + item.id + "_1'>&nbsp;</div></td></tr>";
							  //tempItems = "<tr><td " + alignwidth + " id='" + item.id + "' class='" + middleClass + "'"; 
							  tempItems = "<tr><td " + alignwidth + " id='" + item.id + "' style='" + this.StyleItemMiddle + "'"; 
							  tempItems += events;
							  tempItems += imagetext;
							  tempItems += closeTags;
							  aParts[aParts.length] = tempItems;
							  if(isSingleTab) {
  						    item.isSingleTab = true;
								  //aParts[aParts.length] = "<tr><td><div  unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div  unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td></tr>";
        				  //aParts[aParts.length] = "<tr><td class='" + oriPrefix + "TabLine" + this.design + "' width='100%'>&nbsp;</td></tr>";
        				  aParts[aParts.length] = "<tr><td style='" + this.StyleLine + "' width='100%'>&nbsp;</td></tr>";
							  }
						  }
					  // items in middle
					  //} else if(i>0 && i<aVisibleItem.length-1) {
					  } else if(isMiddle) {
						  item.isMiddle = true;
						  if(aVisibleItem[j-1].type == "ITEM") {
							  // last item in middle active
							  if(aVisibleItem[j-1].active) {
								  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemRightSelectedLeft" + this.design + "'>&nbsp;</div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemRightSelectedLeft + "'>&nbsp;</div></td></tr>";
								  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems += events;
								  tempItems += imagetext;
								  tempItems += closeTags;
								  aParts[aParts.length] = tempItems;
							  // last items in middle not active
							  } else {
								  if(item.active) {
									  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftSelectedRight" + this.design + "'></div></td></tr>";
									  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftSelectedRight + "'></div></td></tr>";
									  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
									  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
									  tempItems += events;
									  tempItems += imagetext;
									  tempItems += closeTags;
									  aParts[aParts.length] = tempItems;
								  } else {
									  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftRight" + this.design + "'>&nbsp;</div></td></tr>";
									  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftRight + "'>&nbsp;</div></td></tr>";
									  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
									  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
									  tempItems += events;
									  tempItems += imagetext;
									  tempItems += closeTags;
									  aParts[aParts.length] = tempItems;
								  }
							  }
						  } else {
							  if(item.active) {
								  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemSelectedLeft" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedLeft + "'></div></td></tr>";
								  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
								  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
								  tempItems += events;
								  tempItems += imagetext;
								  tempItems += closeTags;
								  aParts[aParts.length] = tempItems;
							  } else {
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeft" + this.design + "'></div></td></tr>";
								  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems += events;
								  tempItems += imagetext;
								  tempItems += closeTags;
								  aParts[aParts.length] = tempItems;
							  }
						  }
					  } else {
						  item.isLast = true;
						  // the last item active
						  if(aVisibleItem[j-1].type == "ITEM") {
							  if(aVisibleItem[j-1].active) {
								  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemRightSelectedLeft" + this.design + "'>&nbsp;</div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemRightSelectedLeft + "'>&nbsp;</div></td></tr>";
								  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems += events;
								  tempItems += imagetext;
								  tempItems += closeTags;
								  aParts[aParts.length] = tempItems;
								  //aParts[aParts.length] = "<tr><td><div id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td></tr>";
							  } else {
								  // the last item not active
								  if(item.active) {
									  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftSelectedRight" + this.design + "'></div></td></tr>";
									  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftSelectedRight + "'></div></td></tr>";
									  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
									  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
									  tempItems += events;
									  tempItems += imagetext;
									  tempItems += closeTags;
									  aParts[aParts.length] = tempItems;
									  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td></tr>";
									  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemSelectedRight + "'></div></td></tr>";
								  } else {
									  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeftRight" + this.design + "'></div></td></tr>";
									  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemLeftRight + "'></div></td></tr>";
									  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
									  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
									  tempItems += events;
									  tempItems += imagetext;
									  tempItems += closeTags;
									  aParts[aParts.length] = tempItems;
									  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td></tr>";
									  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td></tr>";
								  }
							  }
						  } else {
							  // the last item not active
							  if(item.active) {
								  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemSelectedLeft" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedLeft + "'></div></td></tr>";
								  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemSelectedMiddle" + this.design + "'";
								  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemSelectedMiddle + "'";
								  tempItems += events;
								  tempItems += imagetext;
								  tempItems += closeTags;
								  aParts[aParts.length] = tempItems;
								  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemSelectedRight + "'></div></td></tr>";
							  } else {
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemLeft" + this.design + "'></div></td></tr>";
								  //tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' class='" + oriPrefix + "TabItemMiddle" + this.design + "'";
								  tempItems = "<tr><td " + alignwidth + "  id='" + item.id + "' style='" + this.StyleItemMiddle + "'";
								  tempItems += events;
								  tempItems += imagetext;
								  tempItems += closeTags;
								  aParts[aParts.length] = tempItems;
								  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td></tr>";
								  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_2' style='" + this.StyleItemRight + "'></div></td></tr>";
							  }
						  }
					  } 
				  } else {
					  // we have a separator
					  isSeparator = true;
					  // if last item was  selected
					  if(i>0) {
						  if(aVisibleItem[j-1].active) {
							  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemSelectedRight" + this.design + "'></div></td></tr>";
							  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemSelectedRight + "'></div></td></tr>";
						  } else {
							  //aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' class='" + oriPrefix + "TabItemRight" + this.design + "'></div></td></tr>";
							  aParts[aParts.length] = "<tr><td><div unselectable='on' id='" + item.id + "_1' style='" + this.StyleItemRight + "'></div></td></tr>";
						  }
					  }
					  //aParts[aParts.length] = "<tr><td  style='width:" + item.width + "' nowrap class='" + oriPrefix + "TabLine" + this.design + "'><div style='width:" + item.width + "' id='" + item.id + "_text' unselectable='on' class='" + oriPrefix + "TabItemText" + this.design + "'>" + itemText + "</div></td></tr>";
					  aParts[aParts.length] = "<tr><td  style='width:" + item.width + "' nowrap class='" + oriPrefix + "TabLine" + this.design + "'><div style='width:" + item.width + "' id='" + item.id + "_text' unselectable='on' style='" + this.StyleItemText + "'>" + itemText + "</div></td></tr>";
				  }
				}
				j++;
			}

      tempItems = "<table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'>";
      for(var k=aParts.length-1;k>=0;k--) {
        tempItems += aParts[k];
      }

      // close table
		  tempItems +="</table>";

      temp += tempItems;
		  //
    	if(!redraw) {
			  if(this.tabarea) {
				  // the tab area
				  //temp+= "<td id='__container1' unselectable='on' style='height:100%' class='" + oriPrefix + bodyClass + this.design + "' colspan='" + (this.aItems.length*2 + 2) + "'>";
				  temp+= "<td id='__container1' unselectable='on' style='height:100%' style='" + this.StyleBody + "' colspan='" + (this.aItems.length*2 + 2) + "'>";
				  
				  
				  for(var i=0; i< this.aItems.length;i++) {
					  var item = this.aItems[i];
					  if(item.type == "ITEM") { 
						  if(item.active)
							  temp+= "<iframe allowtransparency=true onload=\"javascript:__tab_doc_loaded(" + i + ",'__tab_area" + i + "')\"  src='" + emptySource + "' style='height:100%;width:100%;' id='__tab_area" + i + "'  name='__tab_area" + i + "' frameborder=0></iframe>";
						  else
							  temp+= "<iframe allowtransparency=true onload=\"javascript:__tab_doc_loaded(" + i + ",'__tab_area" + i + "')\"  src='" + emptySource + "' style='display:none;height:100%;width:100%;' id='__tab_area" + i + "'  name='__tab_area" + i + "' frameborder=0></iframe>";
						  item.name = "__tab_area" + i;
					  }
				  }
				  temp+= "</td>";
			  }
      }
      		  
		  // close main table
		  temp +="</div></td></tr></table>";
		  
		  // save the row HTML code for refresh
		  aRowHtml[0] = tempItems;
		}
	}

	// if we redraw we draw only the tab items
	if(!redraw) {
		if(this.orientation == "0") {
			if(this.tabarea) {
				// the tab area
				temp+= "<tr>";
				//temp+= "<td id='__container0' style='height:100%;width:100%' class='" + oriPrefix + bodyClass + this.design + "'>";
				temp+= "<td id='__container0' style='height:100%;width:100%' style='" + this.StyleBody + "'>";
		
				for(var i=0; i< this.aItems.length;i++) {
					var item = this.aItems[i];
					if(item.type == "ITEM") { 
						if(item.active)
							temp+= "<iframe allowtransparency=true onload=\"javascript:__tab_doc_loaded(" + i + ",'__tab_area" + i + "')\" src='" + emptySource + "' style='height:100%;width:100%;' id='__tab_area" + i + "'  name='__tab_area" + i + "' frameborder=0></iframe>";
						else
							temp+= "<iframe allowtransparency=true onload=\"javascript:__tab_doc_loaded(" + i + ",'__tab_area" + i + "')\" src='" + emptySource + "' style='display:none;height:100%;width:100%;' id='__tab_area" + i + "'  name='__tab_area" + i + "' frameborder=0></iframe>";
						item.name = "__tab_area" + i;
					}
				}
				temp+= "</td>";
				temp+= "</tr>"
			} else {
				//temp+= "<tr>";
				//temp+= "<td height='100%' colspan='" + (aVisibleItem.length*2 + 2) + "'>";
				//temp+= "<td height='100%' colspan='" + (this.maxTabItemsPerRow*2 + 2) + "'>";
				//temp+= "</td>";
				//temp+= "</tr>"
			}
		}
	}

  temp+= "</table>";

	if(redraw) {
		// redraw
    for(var i=0;i<aRowHtml.length;i++) {
		  document.getElementById("row" + i).innerHTML = aRowHtml[i];
		}
    if(this.tabarea) {
		  // make visible
		  for(var l=0;l<objTab.aItems.length;l++) {
			  var item = objTab.aItems[l];
			  if(item.type == "ITEM" && item.visible) {
				  if(item.active) {
					  document.getElementById(item.name).style.display = "inline";
				  } else {
					  if(document.getElementById(item.name).style.display != "none")
						  document.getElementById(item.name).style.display = "none";
				  }
			  }
		  }
    }
  } else {
		// delay
		//code = temp;
		//window.setTimeout("__tab_delay()",50);
		//__tab_delay(temp);
		this.container.innerHTML = temp;
		this.loadFinished = true;
		this.lastTabItem = this.getActiveTabItem();
	}
}

/*
function __tab_delay()
{
	document.body.innerHTML = code;
	
  // if no tab area
	if(!objTab.tabarea) {
		objTab.loadFinished = true;
		objTab.lastTabItem = objTab.getActiveTabItem();
  	if(objTab.tabMode == 2) 
 	    __tab_check_loaded();
		return;
	}

	// load url
  for(var i=0; i< objTab.aItems.length;i++) {
    var item = objTab.aItems[i];
    // load all pages except active
		if(objTab.loadOnStartup && item.type == "ITEM" && item.url != "" && !item.active) {
			document.getElementById(item.name).src = item.url;
		}
		// active item
		if(item.type == "ITEM" && item.active) {
			if(item.url != "") {
				document.getElementById(item.name).src = item.url;
  		} else {
				if(!this.IE)
					window.frames[item.name].document.body.style.backgroundColor = "white";
			}
			objTab.lastTabItem = item;
		}				
   }
	// check if loaded
	setTimeout("__tab_check_loaded()",10);
};

// executed when a file has been loaded
function __tab_doc_loaded(index,name)
{
	// if there is no URL and this tab is clicked loading is finished, too
	var item = objTab.getItemByIndex(index);

	if(item.url == "")
		objTab.loadFinished = true;


	// if ssl
  if(this.supportSSL) {
	  if(document.getElementById(name).src.indexOf("dummy.html") >= 0 )
  		return;
  } else {
	  if(document.getElementById(name).src == "" || document.getElementById(name).src.indexOf("pinTab.html") >0)
		  return;
  }

	for(var i=0; i< objTab.aItems.length;i++) {
		if(i==index) {
			var item = objTab.aItems[i];
			item.pageLoaded = true;
      objTab.loadedPages++;
 			try {
				parent.tabEventPageLoaded(item,controlID);
			} catch(Error) {}
			// refresh
			if(item.active && item.refreshAfterLoad) {
				item.refresh();
			}
		}
	}

	var allLoaded = true;
	if(objTab.loadOnStartup) {
	  // #############################################
		if(!browser.opera) {
			for(var i=0; i< objTab.aItems.length;i++) {
				var item = objTab.aItems[i];
				if(item.type == "ITEM" && item.url != "" && !item.pageLoaded) {
					allLoaded = false;
				}
			}
		}

		if( allLoaded) {
			// all pages have been loaded
			objTab.loadFinished = true;
			// call event
			try {
				parent.tabEventLoaded(controlID);
			} catch (Error) {};
		}
	} else {
		objTab.loadFinished = true;
		allLoaded = true;
		for(var i=0; i< objTab.aItems.length;i++) {
			var item = objTab.aItems[i];
			if(item.type == "ITEM" && item.url != "" && !item.pageLoaded) {
				allLoaded = false;
			}
		}
		// call loaded event when all pages have been loaded
		if( allLoaded) {
			// call event
			try {
				parent.tabEventLoaded(controlID);
			} catch (Error) {};
		}
	}
}

// called from tab_delay
// needed for tabMode = 2
function __tab_check_loaded()
{
	// get all tab item positions
	if(objTab.tabMode == 2) {
		var allWidth = 0;
		var lastRight = 0;
		for(var i=0; i< objTab.aItems.length;i++) {
			var item = objTab.aItems[i];
			if(item.visible) {
				var width = 0;
				try {
					width = width + parseInt(document.getElementById(objTab.aItems[i].id + "_1").offsetWidth);
				} catch(Error) {
				}
				width = width + parseInt(document.getElementById(objTab.aItems[i].id).offsetWidth);
				try {
					width = width + parseInt(document.getElementById(objTab.aItems[i].id + "_2").offsetWidth / 2);
				} catch(Error) {
					width = width + 2;
				}
				item.width = width;
				allWidth = allWidth + width;
				// 
				if(i>0)
					item.right = lastRight + width;
				else
					item.right = width;
				lastRight = item.right;
			}
		}

		objTab.allTabItemsWidth = allWidth;
	}

  // ##############################################
	if(browser.opera) {
		// all pages have been loaded
		objTab.loadFinished = true;

		// call event
		try {
			parent.tabEventLoaded(controlID);
		} catch (Error) {};
	}
}
*/

function __tabImageClick(index)
{
  var item = objTab.getTabItemByIndex(index);
  
  // call event
  try {
	  parent.tabEventImageClick(item);
  } catch(Error) {}
}

function __tab_direct(evt,objTab,action)
{
	var oriPrefix = "";
	var hasTabArea = true;
	var id = "";

  var source = objTab.getEventSource(evt);
  while(source.id != objTab.container.id) {
    if(source.getAttribute("type") == "__pintab_item") {
      id = source.getAttribute("item");
      break;
    }
    source = source.parentNode;
  }
  
  if(id == "")
    return;

  if(action == "OVER" && !objTab.isHooverEnabled) {
    if(objTab.IE)
      document.getElementById(id).style.cursor = "hand";
    return;
  }
    
	try {	
		// get orientation
		if(objTab.__aAllTabComponents.length >0) {
			var component = objTab.__aAllTabComponents[0];
			hasTabArea = component.tab.tabarea;
			// add "B" for all classes
			if(component.tab.orientation == "1")
				oriPrefix = "B";
	    // add "L" for all classes
	    if(component.tab.orientation == "2")
		    oriPrefix = "L";
		}

		// if not loaded do nothing
		if(!objTab.loadFinished)
			return;
			
		// get only the visible ones
		var aVisibleItem = new Array();
		for (var i=0;i<objTab.__aAllTabComponents.length;i++) {
			if(objTab.__aAllTabComponents[i].visible)
				aVisibleItem[aVisibleItem.length] = objTab.__aAllTabComponents[i];  
		}	

		for (var j=0;j<aVisibleItem.length;j++) {
			if(aVisibleItem[j].id == id){
				var component = aVisibleItem[j];

  			if(action == "KEY") {
  			  var keyCode = window.event.keyCode;
  			  // cursor right
  			  if((keyCode == 39 && component.tab.orientation != "2") || ((keyCode == 38 || keyCode == 39) && component.tab.orientation == "2")) {
  			    // get id of 
		        var isCurrent = false;
		        var nextSibling = null;
		        for (var n=0;n<__aAllTabComponents.length;n++) {
			        if(objTab.__aAllTabComponents[n].visible && objTab.__aAllTabComponents[n].enabled && objTab.__aAllTabComponents[n].type == "ITEM") {
			          //
			          if(isCurrent) {
			            nextSibling = objTab.__aAllTabComponents[n];
			            break;
			          }
			          if(objTab.__aAllTabComponents[n].id == component.id) {
			            isCurrent = true;
			          }
			        }
		        }
		        if(nextSibling != null) {
		          //component.active = false;
              //component = nextSibling;
              //component.active = true;
              //action = "DOWN";
              objTab.setActiveTab(nextSibling.index);
              document.getElementById(nextSibling.id + "_focus").focus();
              return;
		        }
  			    
  			  }
  			  // cursor left
  			  if((keyCode == 37 && component.tab.orientation != "2") || ((keyCode == 40 || keyCode == 37) && component.tab.orientation == "2")) {
  			    // get id of 
		        var isCurrent = false;
		        var previousSibling = null;
		        for (var n=0;n<__aAllTabComponents.length;n++) {
			        if(objTab.__aAllTabComponents[n].visible && objTab.__aAllTabComponents[n].enabled && objTab.__aAllTabComponents[n].type == "ITEM") {
			          if(objTab.__aAllTabComponents[n].id == component.id) {
			            break;
			          }
		            previousSibling = objTab.__aAllTabComponents[n];
			        }
		        }
		        if(previousSibling != null) {
		          //component.active = false;
              //component = previousSibling;
              //component.active = true;
              //action = "DOWN";
              objTab.setActiveTab(previousSibling.index);
              document.getElementById(previousSibling.id + "_focus").focus();
              return;
		        }
  			  }
  			}
  			
        // if we have focus then activate
  			if(action == "FOCUS") {
  			  action = "DOWN";
  			}

  			if(action == "OVER") {
					// call event
					try {
						tabEventItemOver(component);
					} catch(Error) {}
				}

				// before tab event
  			if(action == "DOWN" && component.type =="ITEM") {
					
					// call event
					try {
						var result = false;
						result = tabEventBeforeTabClick(component.tab.lastTabItem);
						if(result)
							return;
					} catch(Error) {}
				}


				if(component.enabled) {
				
					if(component.tab.designmode == "IMAGE") {
						if(action == "OVER" && component.type =="ITEM" && component.design == "1") {
							if(component.active) {
								//if(document.getElementById(id).className != oriPrefix + "TabItemSelectedMiddle" + component.design) {
								//	document.getElementById(id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
								//}
								document.getElementById(id).style.cssText = objTab.StyleItemSelectedMiddle;
							} else {
								//if(document.getElementById(id).className != oriPrefix + "TabItemHoverMiddle" + component.design) {
								//	document.getElementById(id).className = oriPrefix + "TabItemHoverMiddle" + component.design;
								//}
								document.getElementById(id).style.cssText = objTab.StyleItemHoverMiddle;
							}
						}
						if(action == "OUT" && component.type =="ITEM" && component.design == "1") {
							if(component.active) {
								//if(document.getElementById(id).className != oriPrefix + "TabItemSelectedMiddle" + component.design)
								//	document.getElementById(id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
								document.getElementById(id).style.cssText = objTab.StyleItemSelectedMiddle;
							} else {
								//if(document.getElementById(id).className != oriPrefix + "TabItemMiddle" + component.design)
								//	document.getElementById(id).className = oriPrefix + "TabItemMiddle" + component.design;
  							document.getElementById(id).style.cssText = objTab.StyleItemMiddle;
							}
						}
						if(action == "DOWN" && component.type =="ITEM") {
							// get the active item
							if(aVisibleItem.length > 1) {
								for(var k=0;k<aVisibleItem.length;k++) {
									var item = aVisibleItem[k];
									if(item.active) {
										if(k==0) {
											//document.getElementById(item.id + "_1").className = oriPrefix + "TabItemLeft" + component.design;
											document.getElementById(item.id + "_1").style.cssText = objTab.StyleItemLeft;
											//document.getElementById(item.id).className = oriPrefix + "TabItemMiddle" + component.design;
											document.getElementById(item.id).style.cssText = objTab.StyleItemMiddle;

											if(aVisibleItem[1].type == "ITEM")
												document.getElementById(aVisibleItem[k + 1].id + "_1").style.cssText = objTab.StyleItemLeftRight;
											else
												//document.getElementById(aVisibleItem[k + 1].id + "_1").className = oriPrefix + "TabItemRight" + component.design;
												document.getElementById(aVisibleItem[k + 1].id + "_1").style.cssText = objTab.StyleItemRight;
										} else {
  										if(item.isSingleTab) {
											  //document.getElementById(item.id + "_1").className = oriPrefix + "TabItemLeft" + component.design;
											  document.getElementById(item.id + "_1").style.cssText = objTab.StyleItemLeft;
  										} else {
											  if(aVisibleItem[k-1].type == "ITEM")
												  //document.getElementById(item.id + "_1").className = oriPrefix + "TabItemLeftRight" + component.design;
												  document.getElementById(item.id + "_1").style.cssText = objTab.StyleItemLeftRight;
											  else
												  //document.getElementById(item.id + "_1").className = oriPrefix + "TabItemLeft" + component.design;
												  document.getElementById(item.id + "_1").style.cssText = objTab.StyleItemLeft;
                      }
											//document.getElementById(item.id).className = oriPrefix + "TabItemMiddle" + component.design;
											document.getElementById(item.id).style.cssText = objTab.StyleItemMiddle;
											// do we have the last item
											if(k == aVisibleItem.length-1) {
												//document.getElementById(item.id + "_2").className = oriPrefix + "TabItemRight" + component.design;
												document.getElementById(item.id + "_2").style.cssText = objTab.StyleItemRight;
											} else {
												// in multiple mode
												if(item.isFirst) {
													//document.getElementById(item.id + "_1").className = oriPrefix + "TabItemLeft" + component.design;
													document.getElementById(item.id + "_1").style.cssText = objTab.StyleItemLeft;
													//document.getElementById(item.id).className = oriPrefix + "TabItemMiddle" + component.design;
													document.getElementById(item.id).style.cssText = objTab.StyleItemMiddle;

													if(aVisibleItem[1].type == "ITEM")
														//document.getElementById(aVisibleItem[k + 1].id + "_1").className = oriPrefix + "TabItemLeftRight" + component.design;
														document.getElementById(aVisibleItem[k + 1].id + "_1").style.cssText = objTab.StyleItemLeftRight;
													else
														//document.getElementById(aVisibleItem[k + 1].id + "_1").className = oriPrefix + "TabItemRight" + component.design;
														document.getElementById(aVisibleItem[k + 1].id + "_1").style.cssText = objTab.StyleItemRight;
												} else if(item.isLast) {
													//document.getElementById(item.id + "_2").className = oriPrefix + "TabItemRight" + component.design;
													document.getElementById(item.id + "_2").style.cssText = objTab.StyleItemRight;
												} else {
													// we are in the middle
													var id = aVisibleItem[k + 1].id;
													if(aVisibleItem[k+1].type == "ITEM")
														//document.getElementById(id + "_1").className = oriPrefix + "TabItemLeftRight" + component.design;
														document.getElementById(id + "_1").style.cssText = objTab.StyleItemLeftRight;
													else
														//document.getElementById(id + "_1").className = oriPrefix + "TabItemRight" + component.design;
														document.getElementById(id + "_1").style.cssText = objTab.StyleItemRight;
												}
											}
										} 
										if(item.text) {
											//document.getElementById(item.id + "_text").className = oriPrefix + "TabItemText" + component.design;
											document.getElementById(item.id + "_text").style.cssText = objTab.StyleItemText;
										}
										
										item.active = false;
										break;
									} 
								}
							}
												
							if(aVisibleItem.length > 1) {
								if(component.type == "ITEM") {
									// set active item
									component.active = true;
									// find out the new location
									if(j==0) {        
										//document.getElementById(component.id + "_1").className = oriPrefix + "TabItemSelectedLeft" + component.design;
										document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemSelectedLeft;
										//document.getElementById(component.id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
										document.getElementById(component.id).style.cssText = objTab.StyleItemSelectedMiddle;

										if(aVisibleItem[j+1].type == "ITEM")
											//document.getElementById(aVisibleItem[j + 1].id + "_1").className = oriPrefix + "TabItemRightSelectedLeft" + component.design;
											document.getElementById(aVisibleItem[j + 1].id + "_1").style.cssText = objTab.StyleItemRightSelectedLeft;
										else
											//document.getElementById(aVisibleItem[j + 1].id + "_1").className = oriPrefix + "TabItemSelectedRight" + component.design;
											document.getElementById(aVisibleItem[j + 1].id + "_1").style.cssText = objTab.StyleItemSelectedRight;
									} else if(j>0 && j<aVisibleItem.length-1){
										// in multiple mode
										if(component.isFirst) {
											//document.getElementById(component.id + "_1").className = oriPrefix + "TabItemSelectedLeft" + component.design;
											document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemSelectedLeft;
											//document.getElementById(component.id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
											document.getElementById(component.id).style.cssText = objTab.StyleItemSelectedMiddle;

											if(aVisibleItem[j+1].type == "ITEM")
												//document.getElementById(aVisibleItem[j + 1].id + "_1").className = oriPrefix + "TabItemRightSelectedLeft" + component.design;
												document.getElementById(aVisibleItem[j + 1].id + "_1").style.cssText = objTab.StyleItemRightSelectedLeft;
											else
												//document.getElementById(aVisibleItem[j + 1].id + "_1").className = oriPrefix + "TabItemSelectedRight" + component.design;
												document.getElementById(aVisibleItem[j + 1].id + "_1").style.cssText = objTab.StyleItemSelectedRight;
										} else if(component.isLast) {
											if(aVisibleItem[j-1].type == "ITEM")
												//document.getElementById(component.id + "_1").className = oriPrefix + "TabItemLeftSelectedRight" + component.design;
												document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemLeftSelectedRight;
											else
												//document.getElementById(component.id + "_1").className = oriPrefix + "TabItemSelectedLeft" + component.design;
												document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemSelectedLeft;
											//document.getElementById(component.id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
											document.getElementById(component.id).style.cssText = objTab.StyleItemSelectedMiddle;
											//document.getElementById(component.id + "_2").className = oriPrefix + "TabItemSelectedRight" + component.design;
											document.getElementById(component.id + "_2").style.cssText = objTab.StyleItemSelectedRight;
										} else {
											if(aVisibleItem[j-1].type == "ITEM")
												//document.getElementById(component.id + "_1").className = oriPrefix + "TabItemLeftSelectedRight" + component.design;
												document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemLeftSelectedRight;
											else
												//document.getElementById(component.id + "_1").className = oriPrefix + "TabItemSelectedLeft" + component.design;
												document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemSelectedLeft;
											
											//document.getElementById(component.id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
											document.getElementById(component.id).style.cssText = objTab.StyleItemSelectedMiddle;

											if(aVisibleItem[j+1].type == "ITEM")
												//document.getElementById(aVisibleItem[j + 1].id + "_1").className = oriPrefix + "TabItemRightSelectedLeft" + component.design;
												document.getElementById(aVisibleItem[j + 1].id + "_1").style.cssText = objTab.StyleItemRightSelectedLeft;
											else
												//document.getElementById(aVisibleItem[j + 1].id + "_1").className = oriPrefix + "TabItemSelectedRight" + component.design;
												document.getElementById(aVisibleItem[j + 1].id + "_1").style.cssText = objTab.StyleItemSelectedRight;
										}										
									} else {
										if(component.isSingleTab) {
										  //document.getElementById(component.id + "_1").className = oriPrefix + "TabItemSelectedLeft" + component.design;
										  document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemSelectedLeft;
										  //document.getElementById(component.id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
										  document.getElementById(component.id).style.cssText = objTab.StyleItemSelectedMiddle;
										  //document.getElementById(component.id + "_2").className = oriPrefix + "TabItemSelectedRight" + component.design;
										  document.getElementById(component.id + "_2").style.cssText = objTab.StyleItemSelectedRight;
										} else {
										  if(aVisibleItem[j-1].type == "ITEM")
											  //document.getElementById(component.id + "_1").className = oriPrefix + "TabItemLeftSelectedRight" + component.design;
											  document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemLeftSelectedRight;
										  else
											  //document.getElementById(component.id + "_1").className = oriPrefix + "TabItemSelectedLeft" + component.design;
											  document.getElementById(component.id + "_1").style.cssText = objTab.StyleItemSelectedLeft;
										  //document.getElementById(component.id).className = oriPrefix + "TabItemSelectedMiddle" + component.design;
										  document.getElementById(component.id).style.cssText = objTab.StyleItemSelectedMiddle;
										  //document.getElementById(component.id + "_2").className = oriPrefix + "TabItemSelectedRight" + component.design;
										  document.getElementById(component.id + "_2").style.cssText = objTab.StyleItemSelectedRight;
                    }
									}
									if(component.text) {
									  //document.getElementById(component.id + "_text").className = oriPrefix + "TabItemTextSelected" + component.design;
									  document.getElementById(component.id + "_text").style.cssText = objTab.StyleItemTextSelected;
									}				
								}
							}
						}
					} else {
						//----------------------------------------------------------------------------------------------------
						// COLOR mode
						//----------------------------------------------------------------------------------------------------
						if(action == "OVER" && component.type =="ITEM") {
							if(!component.active) {
								if(component.tab.hooverstyle != "") {
									document.getElementById(id).style.cssText = component.tab.hooverstyle;
								} else {
									document.getElementById(id).className = oriPrefix + "TabColorHover" + component.design;
								}
							} 
						}
						if(action == "OUT" && component.type =="ITEM") {
							if(component.active) {
								if(component.tab.activestyle != "")
									document.getElementById(id).style.cssText = component.tab.activestyle;
								else
									document.getElementById(id).className = oriPrefix + "TabColorSelected" + component.design;
							} else {
								if(component.tab.standardstyle != "")
									document.getElementById(id).style.cssText = component.tab.standardstyle;
								else
									document.getElementById(id).className = oriPrefix + "TabColorStandard" + component.design;
							}
						}

						if(action == "DOWN" && component.type =="ITEM") {
							// get the active item
							for(var k=0;k<aVisibleItem.length;k++) {
								var item = aVisibleItem[k];
								if(item.active) {
									if(component.tab.standardstyle != "")
										document.getElementById(item.id).style.cssText = component.tab.standardstyle;
									else
										document.getElementById(item.id).className = oriPrefix + "TabColorStandard" + component.design;

									if(component.tab.textstyle != "")
										document.getElementById(item.id + "_text").style.cssText = component.tab.textstyle;
									else
										document.getElementById(item.id + "_text").className = oriPrefix + "TabColorText" + component.design;
									item.active = false;
								}
							}
							component.active = true;
							if(component.tab.activestyle != "")
								document.getElementById(id).style.cssText = component.tab.activestyle;
							else
								document.getElementById(id).className = oriPrefix + "TabColorSelected" + component.design;
  						if(component.tab.activetextstyle != "")
								document.getElementById(id + "_text").style.cssText = component.tab.activetextstyle;
							else
								document.getElementById(id + "_text").className = oriPrefix + "TabColorTextSelected" + component.design;
						}
					}
				}
				
  			if(action == "DOWN" && component.type =="ITEM" && component.enabled) {

					// call event
					try {
						if(component.tab.eventTabClick != "") {
							eval(component.tab.eventTabClick + "()");
							return;
						}
            document.getElementById(component.id + "_focus").focus();
						
					} catch(Error) {
					}

					// set new tab
					component.tab.lastTabItem = component;

					if(hasTabArea) {			  
						if(component.url != "") {
							if(!component.cached) {
//								document.getElementById(component.name).src = component.url;
									__tab_temp_item = component; 
                  // these avoids IE status bar problem
                  setTimeout("__tab_delay_load_click()",50);
							} else {
								if(!component.pageLoaded) {
									document.getElementById(component.name).src = component.url;
									__tab_temp_item = component; 
								}
							}
						} else {
							if(!this.IE) 
								window.frames[component.name].document.body.style.backgroundColor = "white";
						}
						// make visible
						for(var l=0;l<objTab.aItems.length;l++) {
							var curItem = objTab.aItems[l];
							if(curItem.type == "ITEM" && curItem.visible) {
								if(document.getElementById(curItem.name).style.display != "none")
									document.getElementById(curItem.name).style.display = "none";
							}
						}
						document.getElementById(component.name).style.display = "inline";
					}
					// postback
          try {
						tabEventTabClick(component,component.tab.id);
					} catch(Error) { }
				}
				
  			if(action == "OUT") {
					// call event
					try {
						tabEventItemOut(component);
					} catch(Error) {}
				}
				return;
			}
		}
	} catch(Error) {}
}

function __tab_delay_load_click()
{
  var component = __tab_temp_item;
  document.getElementById(component.name).src = component.url;
}

var __tab_temp_item = null;
function __tab_load_item()
{
	try {
		var test = window.frames[__tab_temp_item.name].document.body.innerHTML;
		if(test == "") {
			setTimeout("__tab_load_item()",50);
			return;
		}
		__tab_temp_item.pageLoaded = true;
		// call event
		try {
			parent.tabEventPageLoaded(__tab_temp_item,controlID);
		} catch(Error) {}

		// refresh
		if(__tab_temp_item.refreshAfterLoad) {
			__tab_temp_item.refresh();
		}

	} catch (Error) {
		setTimeout("__tab_load_item()",50);
		return;
	};

}


function TabItem(text,image,active,url)
{
	// holds parent
  this.id         = "";
	this.tab        = null;
  this.text       = text;
  this.image      = image;
  this.active     = active;
  this.index      = 0;
	if(url != "")
		this.url        = url;
	else
		this.url        = "";
  this.width      = "";
  this.iframe     = null;
  this.design     = "1";
  this.type       = "ITEM"; 
  this.title      = "";
  this.cached     = true;
  this.tag        = "";
  //this.call       = __tabitem_call;

	// new in 2.0
	this.html        = "";
	this.pageLoaded  = false;
	// this.html     = "";
	this.visible     = true;
	this.enabled     = true;
	this.setVisible  = __tabitem_setvisible;
	this.setEnabled  = __tabitem_setenabled;
	//this.netPostback = __tabitem_postback;
	//this.netValidate = __tabitem_validate;
  //this.refresh     = __tabitem_refresh;

  //this.getDocument = __tabitem_getdoc;
  //this.getWindow   = __tabitem_getwindow;
  //this.setUrl      = __tabitem_seturl;
  this.setText     = __tabitem_settext;
  this.setTitle    = __tabitem_settitle;
}

/*
function __tabitem_refresh()
{
	try {
		window.frames[this.name].document.body.innerHTML = window.frames[this.name].document.body.innerHTML;
	} catch(Error) {}
}
*/

function __tabitem_setvisible(value)
{
  if(this.visible == value)
    return;

  // check if we have multiple rows
	this.visible = value;

  if(this.tab.tabMode == 1) {
    // if rows have been changed
    var count = this.tab.visibleItems;
    if((count % this.tab.maxTabItemsPerRow) == 1) {
	    this.tab.create();
	  } else {
	    this.tab.create(true);
	  }
  } else {
	  this.tab.create(true);
	}
}

function __tabitem_setenabled(value)
{
  if(this.enabled == value)
    return;
    
	this.enabled = value;
	this.tab.create(true);
}

/*
function __tabitem_getwindow()
{
	var win = null;
	try {
		win = window.frames[this.name];
	} catch (Error) {}

	return win;
}
*/

/*
function __tabitem_getdoc()
{
	var doc = null;
	try {
		doc = window.frames[this.name].document;
	} catch (Error) {}

	return doc;
}

function __tabitem_call(name)
{
	try {
		// call
		if(this.IE) {
		  return eval("window.frames[this.name]." + name);
		} else {
      if(this.active) {
  		  return eval("window.frames[this.name]." + name);
  		} else {
        // Mozilla doesn not work when not active
			  var iframe = document.getElementById(this.name);
			  var save = iframe.style.height;
        iframe.style.height = 0;
			  iframe.style.display = "inline";
  		  eval("window.frames[this.name]." + name);
  		  iframe.style.height = save;
			  iframe.style.display = "none";
  		}
		}
	} catch(Error) {
		return false;
	}
}

function __tabitem_postback(param1)
{
  if(param1 != null)
	  return this.call("__doPostBack('" + param1 + "','')");
  else
  	return this.call("__doPostBack('','')");
}

function __tabitem_validate()
{
	if(this.tab.IE)
		return this.call("Page_ClientValidate()");
	else
		return true;
}

function __tabitem_seturl(url)
{
	try {
		// call
		document.getElementById(this.name).src = url;
		return true;
	} catch(Error) {
		return false;
	}
}
*/

function __tabitem_settext(text)
{
	try {
		// call
		document.getElementById(this.id + "_text").innerHTML = text;
	} catch(Error) {
	}
}

function __tabitem_settitle(text)
{
	try {
		// call
		document.getElementById(this.id + "_title").title = text;
	} catch(Error) {
	}
}


function TabSeparator()
{
  this.type       = "SEPARATOR"; 
  this.text       = "";
  this.width      = "100%";
 	this.visible     = true;
	this.enabled     = true;
}


function __tab_scroll(direction)
{
	// set scroll position
	if(direction == 0) {
		if(objTab.scrollPosition >=0 ) {
			if(objTab.scrollLeftAllowed)
				objTab.scrollPosition = objTab.scrollPosition - 1;
		}
	} else {
		//if( (objTab.width - objTab.scrollButtonWidth) < (objTab.allTabItemsWidth - position))
		if(objTab.scrollRightAllowed)
			objTab.scrollPosition = objTab.scrollPosition + 1;
	}

	var position = 0;
	if(objTab.scrollPosition == -1) {
		position = 0;
	} else {
		// get the item that is visible with this position
		var j=0;
		for(var i=0;i<objTab.aItems.length;i++) {
			var item = objTab.aItems[i];
			if(item.visible) {
				if(j == objTab.scrollPosition) {
					position = objTab.aItems[i].right;
					break;
				}
				j++;
			}
		}
	}

	// set left position
	document.getElementById("scroll").style.left = -position;	

	// control left button
	if( (objTab.width - objTab.scrollButtonWidth) < (objTab.allTabItemsWidth - position))
		objTab.scrollRightAllowed = true;
	else
		objTab.scrollRightAllowed = false;
	
	// control right button
	if(objTab.scrollPosition > -1)
		objTab.scrollLeftAllowed = true;
	else
		objTab.scrollLeftAllowed = false;
	
}

function __tab_getObjectWidth(obj)
{
	if(this.IE) {
		return parseInt(obj.style.pixelWidth);
	} else {
		var width = obj.width ? obj.width: obj.style.width;
		if(width.indexOf("%") >0)
			width = obj.offsetWidth;
		return parseInt(width);
	}
}

//---------------------------------------------------------------------------------------------
// KEYBOARD SHORTUCT FUNCTIONS
//---------------------------------------------------------------------------------------------

// Create a new UIShortcut object
function UIShortcut(sText, sAccessKey, sHtml)
{
		
	this.text = sText;
	this.accessKey = sAccessKey;
	this.html = sHtml;
	
	return this;
	
}

// Return a UIShortcut specific to text parameter (value in en.js)
function getUIShortcut(sText,orientation)
{
	var temp = "";

  sText = sText.replace("&&","|");
  
	if(orientation == true) {
	  for(var i=0;i<sText.length - 1;i++) {
	    if(sText.substring(i,i+1) != "&") {
  	    temp = temp  + sText.substring(i,i+1) + "<br>";
  	  } else {
  	    temp = temp + "&";
  	  }
	  }
  	sText = temp + sText.substring(sText.length-1,sText.length);
	}

	// init
	var text = sText;
	var accessKey = null;
	var html = sText;
	
	// set attributes for UI Shortcut object & return
	if(sText.match("&") != null) {
		text = text.replace("&", "");
		accessKey = sText.charAt(sText.indexOf("&") + 1);
		html = html.substring(0, html.indexOf("&")) + "<u>" + accessKey + "</u>" + html.substring(html.indexOf("&") + 2);
	}
  text = text.replace("|","&");
  html = html.replace("|","&");

	return UIShortcut(text, accessKey, html);
}



