// Code pages
var codePages;

function buildCodePages(){
  codePages = new Array();
  codePages.push({name:"wscalc-js", on:false});
  codePages.push({name:"request-js", on:false});
  codePages.push({name:"transforn-js", on:false});
  codePages.push({name:"change-js", on:false});
  codePages.push({name:"complete-js", on:false});
  codePages.push({name:"polling-js", on:false});
}

/**
*  Activates code highlight for a page
*/	
function codeHighlight(key){
  for(page in codePages){
    if((codePages[page].name == key) && !(codePages[page].on)){
	  dp.SyntaxHighlighter.HighlightAll('code_' + key);  
	  codePages[page].on = true;
      break;
	}
  }
}

/**
*  Shift tab visibility
*/	
function shiftTab(tabGroup, panelGroup, index, codePage){
  var i = 0;
  var panel, tab;
  while (panel = document.getElementById(panelGroup + "-" + i)) {
    if(i != index)
      panel.className = 'hidden-panel';
    else
      panel.className = 'visible-panel';
    i++;
  }
  i = 0;  
  while (tab = document.getElementById(tabGroup + "-" + i)) {
    if(i != index)
      tab.className = '';
    else
      tab.className = 'selected';
    i++;
  } 
  if(codePage)
   codeHighlight(codePage);
}

/**
*  Control dropdown list
*/	
function dropDown(itemName){
  var title, list, button;
  title = document.getElementById(itemName + "-" + 'title')
  title.className = (title.className == 'dropdown-title-closed') ? 'dropdown-title-opened' : 'dropdown-title-closed';
  list = document.getElementById(itemName + "-" + 'list')
  list.className = (list.className == 'dropdown-hidden-list') ? 'dropdown-visible-list' : 'dropdown-hidden-list';
  button = document.getElementById(itemName + "-" + 'button')
  button.src = (list.className == 'dropdown-hidden-list') ? 'image/open.gif' : 'image/close.gif';
}