var panes = new Array();

function setupPanes(containerId, defaultTabId) {
  // go through the DOM, find each tab-container
  // set up the panes array with named panes
  // find the max height, set tab-panes to that height
  panes[containerId] = new Array();
  var maxHeight = 0; var maxWidth = 0;
  var container = document.getElementById(containerId);
  var paneContainer = container.getElementsByTagName("div")[0];
  var paneList = paneContainer.childNodes;
  for (var i=0; i < paneList.length; i++ ) {
    var pane = paneList[i];
    if (pane.nodeType != 1) continue;
    if (pane.offsetHeight > maxHeight) maxHeight = pane.offsetHeight;
    if (pane.offsetWidth  > maxWidth ) maxWidth  = pane.offsetWidth;
    panes[containerId][pane.id] = pane;
    pane.style.display = "none";
  }
    paneContainer.style.height = maxHeight + "px";
    paneContainer.style.width  = maxWidth + "px";
    document.getElementById(defaultTabId).onclick();
}

function showPane(paneId, activeTab) {
  // make tab active class
  // hide other panes (siblings)
  // make pane visible
  
    for (var con in panes) {
    activeTab.blur();
    activeTab.className = "tab-active";
    if (panes[con][paneId] != null) { // tab and pane are members of this container
      var pane = document.getElementById(paneId);
      pane.style.display = "block";
      var container = document.getElementById(con);
      var tabs = container.getElementsByTagName("ul")[0];
      var tabList = tabs.getElementsByTagName("a")
      for (var i=0; i<tabList.length; i++ ) {
        var tab = tabList[i];
        if (tab != activeTab) tab.className = "tab-disabled";
      }
      for (var i in panes[con]) {
        var pane = panes[con][i];
        if (pane == undefined) continue;
        if (pane.id == paneId) continue;
        pane.style.display = "none"
      }
    }
  }
  return false;    
}

var desc_jump = true;

	function Show_Sub(i,I){
		for(var l=0;l<=9;l++){
			if(GetObj("tab"+i+l)){
				GetObj("tab"+i+l).className='tab-disabled';
			}
			if(GetObj("pane"+i+l)){
				GetObj("pane"+i+l).style.display='none';
			}
			if(GetObj("imgL_"+l)){
				GetObj("imgL_"+l).src='images/tab-gary1.gif';
			}
			if(GetObj("imgR_"+l)){
				GetObj("imgR_"+l).src='images/tab-gary2.gif';
			}
		}
		if(GetObj("tab"+i+I)){
			GetObj("tab"+i+I).className='tab-active';
		}
		if(GetObj("pane"+i+I)){
			GetObj("pane"+i+I).style.display='block';
		}
		if(GetObj("imgL_"+I)){
			GetObj("imgL_"+I).src='images/tab-red1.gif';
		}
		if(GetObj("imgR_"+I)){
			GetObj("imgR_"+I).src='images/tab-red2.gif';
		}
		if(GetObj("lineImg")){
			GetObj("lineImg").src='images/tab-arrow'+I+'.gif';
		}

		if (GetObj("tab-panes") && desc_jump){
			GetObj("tab-panes").style.height = GetObj("pane"+i+I).offsetHeight + 'px';
		}
		return false;
	}

function setwidth(a,b,c){
	alert('ok');
	if(GetObj('tabs')){
		var ob = GetObj('tabs');
		var tds = ob.getElementsByTagName('td');
		var total =0;
		for(var i=0;i< tds.length; i++){
			if (tds[i].className.indexOf('t-td') != -1)	{
				var tables = tds[i].getElementsByTagName('table');
				alert(tds[i].width + "," + tds[i].offsetWidth +","+ tds[i].clientWidth+ "," + tables[0].clientWidth );
				if (tds[i].offsetWidth == 0) return;
				total += tds[i].offsetWidth + b + c;
			}
		}
		if (a > total)
		{
			total = a - total;
			if (GetObj('lastone')){
				GetObj('lastone').style.width = total + 'px';
				alert(total);
			}
		}
	}
}

function writeHeight(i){

	var height =0;
	for(var l=0;l<=9;l++){
		if(GetObj("pane"+i+l)){
			var obj = GetObj("pane"+i+l);
			var h = obj.offsetHeight;
			//alert(l+","+h+","+obj.clientHeight+","+obj.id);
			if (h > height)	{
				height = h;
			}
			obj.style.display='none';
		}
	}
	GetObj("pane"+i+"1").style.display='block';
	if (height == 0 ){
		height = 175;
	}
	if (GetObj("tab-panes")){
		if (!desc_jump){
			GetObj("tab-panes").style.height = height + 'px';
		}else{
			height = GetObj("pane"+i+"1").offsetHeight;
			if (height == 0){
				height = 175;
			}
			GetObj("tab-panes").style.height = height + 'px';
		}
		//alert('now,' + GetObj("tab-panes").style.height);
	}
}