//
// This is the old version of the HelpText code, using standard HelpText sizes...
//

var ButtonWidth = 110;
var ButtonHeight = 23;
var HelpWidth = 162;
var HelpHeight = 112;
var AllowHelpScroll = true;
var MainPageWidth, PageHeight, PageWidth;
var BubbleURL = '/images/generic/HelpBubble.GIF';
var ActiveHelpFrame;                 //The frame used to display help text in...

var DebugFlag = false;

function AddButton(ID,Title,x,y,JSCode,HelpText) {
  //
  // Add in a button in the standard button bar (in the left frame of the window)
  //
  if(PageHeight==0 && PageWidth==0) {
    PageHeight = DynAPI.document.getHeight() * 0.99 - 30;
    PageWidth = 130;
  }
  
  // This is required to enable proper mouse functionality over the button
  var NewButton = new Button('<TABLE WIDTH="'+ButtonWidth.toString()+'" HEIGHT="' + ButtonHeight.toString() + '" Class="Button" CELLPADDING="0" BORDER="0" CELLSPACING="0"><TR><TD Class="Button" WIDTH="100%" HEIGHT="100%">' + Title + '</TD></TR></TABLE>');
  NewButton.moveTo(x,y);
  // Need to setHTML to overcome bug in Firefox 1 with grey buttons.
  if(!is.ns4) NewButton.setHTML('<TABLE WIDTH="'+ButtonWidth.toString()+'" HEIGHT="' + ButtonHeight.toString() + '" Class="Button" CELLPADDING="0" BORDER="0" CELLSPACING="0"><TR><TD Class="Button" WIDTH="100%" HEIGHT="100%">' + Title + '</TD></TR></TABLE>');
  NewButton.setZIndex(10);  // Raise the level of the button so that other levels can go below it if needed...
  if(ID!='') NewButton.setID(ID);
  DynAPI.document.addChild(NewButton);
//  var NewButtonWidth = ((NewButton.getWidth()<ButtonWidth) ? ButtonWidth : NewButton.getWidth());
//  var NewButtonHeight = ((NewButton.getHeight()<ButtonHeight) ? ButtonHeight : NewButton.getHeight());
//  NewButton.setSize(NewButtonWidth,NewButtonHeight);

  var NewButtonListnr = new EventListener(NewButton);

  if(HelpText!='') {
    NewButtonListnr.onmouseover=function(e) {
      if(ActiveHelpFrame) {
        var FrameObj = eval(ActiveHelpFrame);
        if(FrameObj) if(FrameObj.DisplayHelpText) FrameObj.DisplayHelpText(HelpText,0,((y>PageHeight-150)?PageHeight-150:y));
      }
    }

    NewButtonListnr.onmouseout=function(e) {
      if(ActiveHelpFrame) {
        var FrameObj = eval(ActiveHelpFrame);
        if(FrameObj) if(FrameObj.NoDisplayHelpText) FrameObj.NoDisplayHelpText();
      }
    }
  }

  NewButtonListnr.onclick=function(e) {
    if(JSCode != '') eval(JSCode);
  }
  NewButton.addEventListener(NewButtonListnr);
}

function AddSubButton(ID,Title,x,y,JSCode,HelpText) {
  //
  // Add in a button in the sub-button bar (at the top of the Main frameset)
  //
  if(PageHeight==0 && PageWidth==0) {
    PageHeight = DynAPI.document.getHeight() * 0.99 - 30;
    PageWidth = DynAPI.document.getWidth();
  }
  var NewButton = new Button('<TABLE WIDTH="'+ButtonWidth.toString()+'" HEIGHT="' + ButtonHeight.toString() + '" Class="Button" CELLPADDING="0" BORDER="0" CELLSPACING="0"><TR><TD Class="Button" WIDTH="100%" HEIGHT="100%">' + Title + '</TD></TR></TABLE>');
  NewButton.moveTo(x,y);
  NewButton.setZIndex(10);  // Raise the level of the button so that other levels can go below it if needed...
  if(ID!='') NewButton.setID(ID);
  DynAPI.document.addChild(NewButton);
  var NewButtonWidth = ((NewButton.getWidth()<ButtonWidth) ? ButtonWidth : NewButton.getWidth());
  var NewButtonHeight = ((NewButton.getHeight()<ButtonHeight) ? ButtonHeight : NewButton.getHeight());
  NewButton.setSize(NewButtonWidth,NewButtonHeight);

  var NewButtonListnr = new EventListener(NewButton);

  if(HelpText!='') {
    NewButtonListnr.onmouseover=function(e) {
      DisplayHelpText(HelpText,x,y+ButtonHeight+15);
    }

    NewButtonListnr.onmouseout=function(e) {
      NoDisplayHelpText();
    }
  }

  NewButtonListnr.onclick=function(e) {
    if(JSCode != '') {
      NoDisplayHelpText();               	
      eval(JSCode);
    }
  }
  NewButton.addEventListener(NewButtonListnr);
}

function IsDynLayer(Layer) {
  if(Layer) return true;
  return false;
}

function ShowHelpText(Text,x,y,w,h) {

  // Display helptext at a particular position on the specified page
  var IntWidth = w||128;
  var IntHeight = h||71;
//  var HelpWidth = IntWidth+34;
//  var HelpHeight = IntHeight+41;

  var Continue = false;
  if(DynAPI) if(DynAPI.document) if(DynAPI.document.all) Continue = true;
  if(!Continue) return true;
  //
  // Compensate for scrolling within the frame
  //
  if(AllowHelpScroll) {
    if(is.ns) y += self.pageYOffset;     // Netscape support
    else if(is.ie) y += self.document.body.scrollTop;  //IE support
  }
  var NewText = '<table cellpadding="0" cellspacing="0" border="0"><tr><td width="' + IntWidth.toString() + '" height="' + IntHeight.toString() + '" class="TinyHelp" valign="top" align="left">' + Text + '</td></tr></table>';
  if(DynAPI.document.all['Help']) DynAPI.document.all['Help'].del();
  HelpLayer=new DynLayer('Help',x,y,HelpWidth,HelpHeight) ;
  HelpLayer.setHTML('<img src="' + BubbleURL + '" width="' + HelpWidth.toString() + '" height="' + HelpHeight.toString() + '">');
  if(is.ns4 && window.name!= 'main') HelpLayer.setBgColor('#ffffcc');
  InlineLayer=new DynLayer(null,16,23,IntWidth,IntHeight);
  InlineLayer.setVisible(true);
  InlineLayer.setHTML(NewText);
  HelpLayer.addChild(InlineLayer);
  HelpLayer.setVisible(true);
  HelpLayer.setZIndex(15);
  DynAPI.document.addChild(HelpLayer);
  return true;
}

function HideHelpText() {

  if(DynAPI) if(DynAPI.document) if(DynAPI.document.all) if(DynAPI.document.all['Help']) DynAPI.document.all['Help'].del();
  return true;
}

