// Copyright © 2003 Cognos Incorporated. All Rights Reserved.
// Cognos and the Cognos logo are trademarks of Cognos Incorporated.

// var navigation_pages
// The HTML page using this JavaScript will define the variable as an array
// and populate it with page id's.


/// Functions used by the navigation buttons frame.


// Button state has not been set yet.
var loaded = false; 


/// Return the window that contains the reports contents.
function get_contents()
{
  if (parent) {
    if (parent.frames) {
      var contents = parent.frames["body"];
      return contents;
    }
  }
  return null;
}

/// Return the window that contains the table of contents contents.
function get_toc()
{
  if (parent) {
    if (parent.frames) {
      var toc = parent.frames["toc"];
      return toc;
    }
  }
  return null;
}


////////// Functions called by other JavaScripts



function enable_up_button(enable)
{
  if (enable) {
    window.document.images.up_button.src = "cg47up.gif";
    window.document.images.up_button.alt = "Previous";
  } else {
    window.document.images.up_button.src = "cg47upd.gif";
    window.document.images.up_button.alt = "Previous Disabled";
  }
  
  return null;
}


function enable_down_button(enable)
{
  if (enable) {
    window.document.images.down_button.src = "cg47dn.gif";
    window.document.images.down_button.alt = "Next";
  } else {
    window.document.images.down_button.src = "cg47dnd.gif";
    window.document.images.down_button.alt = "Next Disabled";
  }
}


function enable_home_button(enable)
{
  if (enable) {
    window.document.images.home_button.src = "button_home.gif";
    window.document.images.home_button.alt = "Top";
  } else {
    window.document.images.home_button.src = "button_home_disabled.gif";
    window.document.images.home_button.alt = "Top Disabled";
  }
}


function enable_end_button(enable)
{
  if (enable) {
    window.document.images.end_button.src = "button_end.gif";
    window.document.images.end_button.alt = "Bottom";
  } else {
    window.document.images.end_button.src = "button_end_disabled.gif";
    window.document.images.end_button.alt = "Bottom Disabled";
  }
}




////////// Functions called by the HTML page

// Function the page should call when loaded to set the correct state.
function onLoad()
{
  if (! loaded) {
    // State has not already been set.
    var toc = get_toc();
    if (toc) {
      if (toc.loaded) {
        // the table of contents has been loaded before the buttons, so we ask that frame
	  	  // to update the buttons.
	      toc.update_buttons();
 	      loaded = true;
      }
    }
  }
}


// Change the page to the next page.
function next_page()
{
   if (window.document.images.down_button.src == "cg47dnd.gif") {
     return; 
    }
  var toc = get_toc();
  toc.next();
}


// Change the page to the previous page.
function previous_page()
{
   if (window.document.images.up_button.src == "cg47upd.gif") {
     return; 
    }
  var toc = get_toc();
  toc.previous();
}
function home_page()
{
   if (window.document.images.home_button.src == "button_home_disabled.gif") {
     return; 
    }
   var toc = get_toc();
   toc.onHome();
}
function end_page()
{
   if (window.document.images.end_button.src == "button_end_disabled.gif") {
     return; 
    }
   var toc = get_toc();
   toc.onEnd();
}
