/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var buttonDataHolder = new Array();
/**
 * name is a name for the button group;
 * currentButtonId is the id of the button that starts pressed or null;
 * ontainerId is the id of the data to contain the page when loaded
 * alignment is HOR or VER for horizontal tabls or vertical tabs
 */
function declarePageset(name, currentButtonId, containerId, alignment){
    buttonDataHolder[name]= new Array();
    buttonDataHolder[name].buttonList = new Array();
    buttonDataHolder[name].buttonList[currentButtonId]=1;
    buttonDataHolder[name].containerId=containerId;
    buttonDataHolder[name].alignment=alignment;
}
function loadSubPage(name, page, buttonId){
    var obj = buttonDataHolder[name];
    if (obj){
        obj.buttonList[buttonId]=1;
        for (var clrBtn in obj.buttonList){
            var oldButton = document.getElementById(clrBtn);
            if (oldButton){
                oldButton.className = obj.alignment=="HOR"?
                                    "button hor-button":
                                    "button ver-button";
            }
        }
        var newButton = document.getElementById(buttonId);
        if (newButton){
            newButton.className = obj.alignment=="HOR"?
                                "button hor-button pressed hor-pressed":
                                "button ver-button pressed ver-pressed";
        }
        loadSubPageToContainer(page, obj.containerId);
    }
}
function initialisePageset(name, initialSubpage, container, direction, buttonset, defaultButton){
      var initialButton=defaultButton;
      for (var idVal in buttonset){
          if (!initialButton) initialButton = idVal;
          var e = document.getElementById(idVal);
          if (e){
              var ee = e.getElementsByTagName("A")[0];
              if (ee){
                  var php=buttonset[idVal];
                  if (php == initialSubpage) initialButton = idVal;
                  ee.href="#"+name;
                  ee.onclick=(function(phpFile, btnId){
                      return (function (){
                          loadSubPage(name, phpFile, btnId);
                      })
                  })(php, idVal);
              }
          }
      }

    declarePageset(name, initialButton, container, direction);
      for (var idValAfter in buttonset){
          var phpAfter=buttonset[idValAfter];
          if (phpAfter == initialSubpage) initialButton = idVal;
      }
}
function buttonsVersion(){
    return "$Revision: 1.2 $"+
          "$Date: 2011-09-14 07:30:09 $";
}

