/////////////////////////////////////////////////
//
// Snoop browser versions
// Taken from DHTML Tutoral www.htlmguru.com
//
function Is() {
    var agent  = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns    = ((agent.indexOf('mozilla')!=-1) && 
                  ((agent.indexOf('spoofer')==-1) && 
                   (agent.indexOf('compatible') == -1)));
    this.ns2   = (this.ns && (this.major == 2));
    this.ns3   = (this.ns && (this.major == 3));
    this.ns4b  = (this.ns && (this.minor < 4.04));
    this.ns4   = (this.ns && (this.major >= 4));
    this.ie    = (agent.indexOf("msie") != -1);
    this.ie3   = (this.ie && (this.major == 2));
    this.ie4   = (this.ie && (this.major >= 4));
    this.op3   = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
}

var is = new Is();

var SelectedButton;
var SelectedPage;
var ResizeAllowed;

// This array stores the number of pages in the array so that
// the previous and next buttons can figure out when to turn
// on and off.  There is probably a better way to do this
// and I need to get a book to figure out if there is some
// form of "objectExists" property
var SectionPagesArray = new Array()
   SectionPagesArray[0] = 0;
   SectionPagesArray[1] = 2;
   SectionPagesArray[2] = 9;
   SectionPagesArray[3] = 3;

/////////////////////////////////////////////////
//
//  My Stuff
//
//
function Init() {

   if(is.ns4) {
      doc = "document";
      sty = "";
      htm = ".document"
   } 
   else if(is.ie4) {
      doc = "document.all";
       sty = ".style";
       htm = ""
   }

  ResizeAllowed    = 1;
  SelectedButton   = 1;
  SelectedPage     = 1;

}


function MouseClickButton(ButtonNumber) {

   if (ButtonNumber != SelectedButton) {

      // There was a button already selected, turn all that stuff off
      if (SelectedButton != 0) {

         ObjOldPage             = eval(doc + "['Section" + SelectedButton + "Page" + SelectedPage + "']" + sty);
         ObjOldPage.visibility  = "hidden";

         ObjPrev                = eval(doc + "['ButtonPrevious']" + sty);
         ObjPrev.visibility     = "hidden";

         ObjNext                = eval(doc + "['ButtonNext']" + sty);
         ObjNext.visibility     = "hidden";

         ObjButton              = eval(doc + "['ButtonOn" + SelectedButton + "']" + sty);
         ObjButton.visibility   = "hidden";

      }

      SelectedButton            = ButtonNumber;
      SelectedPage              = 1;

      ObjSectionPage            = eval(doc + "['Section" + ButtonNumber + "Page" + SelectedPage + "']" + sty);
      ObjSectionPage.visibility = "visible";

      ObjButton                 = eval(doc + "['ButtonOn" + SelectedButton + "']" + sty);
      ObjButton.visibility      = "visible";

      ObjPrev                   = eval(doc + "['ButtonPrevious']" + sty);
      ObjPrev.visibility        = "hidden";

      ObjNext                   = eval(doc + "['ButtonNext']" + sty);


      // Show the next button if there is a next page
      if (parseInt(SelectedPage) < parseInt(SectionPagesArray[parseInt(SelectedButton)])) {
         ObjNext.visibility = "visible";
      }
      else {
         ObjNext.visibility = "hidden";
      }

   }

}

function SwitchPage(Direction) {

   ObjOldPage            = eval(doc + "['Section" + parseInt(SelectedButton) + "Page" + parseInt(SelectedPage) + "']" + sty);
   ObjOldPage.visibility = "hidden";

   NewPageNumber         = parseInt(SelectedPage) + parseInt(Direction);
   ObjNewPage              = eval(doc + "['Section" + SelectedButton + "Page" + NewPageNumber + "']" + sty);
   ObjNewPage.visibility = "visible";
   SelectedPage          = NewPageNumber;

   ObjPrevious           = eval(doc + "['ButtonPrevious']" + sty);

   // Show the previous button if there is a previous page
   if (parseInt(SelectedPage) > 1) {
      ObjPrevious.visibility = "visible";
   }
   else {
      ObjPrevious.visibility = "hidden";
   }

   ObjNext               = eval(doc + "['ButtonNext']" + sty);

   // Show the next button if there is a next page
   if (parseInt(SelectedPage) < parseInt(SectionPagesArray[parseInt(SelectedButton)])) {
      ObjNext.visibility = "visible";
   }
   else {
      ObjNext.visibility = "hidden";
   }
   
}

function DialogOpen() {

   ObjDialog                = eval(doc + "['DialogBox']" + sty);
   ObjDialog.visibility     = "visible";

   ObjDialogText            = eval(doc + "['DialogBoxText1']" + sty);
   ObjDialogText.visibility = "visible";

   ObjDialogClose            = eval(doc + "['DialogBoxClose']" + sty);
   ObjDialogClose.visibility = "visible";

}

function DialogClose() {

   ObjDialog                = eval(doc + "['DialogBox']" + sty);
   ObjDialog.visibility     = "hidden";

   ObjDialogText            = eval(doc + "['DialogBoxText1']" + sty);
   ObjDialogText.visibility = "hidden";

   ObjDialogText            = eval(doc + "['DialogBoxText2']" + sty);
   ObjDialogText.visibility = "hidden";

   ObjDialogClose            = eval(doc + "['DialogBoxClose']" + sty);
   ObjDialogClose.visibility = "hidden";

}

function DialogMore() {

   ObjDialogText            = eval(doc + "['DialogBoxText1']" + sty);
   ObjDialogText.visibility = "hidden";

   ObjDialogText            = eval(doc + "['DialogBoxText2']" + sty);
   ObjDialogText.visibility = "visible";

}
