/***********************************************************************
*                                                                      *
*               Confidentiality Information:                           *
*                                                                      *
* This module is the confidential and proprietary information of       *
* PeopleSoft, Inc.; it is not to be copied, reproduced, or transmitted *
* in any form, by any means, in whole or in part, nor is it to be used *
* for any purpose other than that for which it is expressly provided   *
* without the written permission of PeopleSoft.                        *
*                                                                      *
* Copyright (c) 1988-2000 PeopleSoft, Inc.  All Rights Reserved.       *
*                                                                      *
************************************************************************/

//////////////////////////////////////////
// Browser Version Detection
//////////////////////////////////////////

var strAgent    	= navigator.userAgent.toLowerCase();
var strVersion  	= navigator.appVersion.toLowerCase();

var gnVerMajor  	= parseInt(strVersion);
var gnVerMinor  	= parseFloat(strVersion);

var gbNS        	= ((strAgent.indexOf("mozilla") != -1) && ((strAgent.indexOf('spoofer') == -1)
			    && (strAgent.indexOf('compatible') == -1)));
var gbIE        	= (strAgent.indexOf("msie") != -1);


/////////////////////////////////////////
// Global Variables
/////////////////////////////////////////

//   layerRef and styleRef should be used for the layer objects for both borwser NS and IE.
//  e.g. eval("document" + layerRef + "['xxxx']" + styleRef + ".visibility = 'visible'");

if (gbNS) {
	layerRef 	= ".layers";
	styleRef 	= "";
} else if (gbIE) {
	layerRef 	= ".all";
	styleRef 	= ".style";
}

var origWidth = 0;
var origHeight = 0;

//if (self.location.pathname.indexOf("buttons.htm") == -1) var strPopup = "";
var bPrinting 		= false;
var oldSetting 		= "";
var strPopup 		= "";
var bBook 		= false;
var bChapter 		= false;
var bDoc 		= false;
var bLibrary 		= false;

var strTopHref          = top.location.href.toLowerCase();
strTopHref              = strTopHref.substring(0, strTopHref.indexOf(".htm") + 4);
var strFrameset         = strTopHref.substring(strTopHref.lastIndexOf("/") + 1, strTopHref.length).toLowerCase();
bBook                   = (strFrameset.toLowerCase() == "book.htm");
bChapter                = (strFrameset.toLowerCase() == "chapter.htm");
bLibrary                = (strFrameset.toLowerCase() == "index.htm");
bDoc = (strTopHref.indexOf("/htm/") != -1);
var strFrameLang 	= "";
var strFrameProd 	= "";

if (top.length > 0) {
	if (parent.frames[0].document.NavBar 
	  && top.frames[0].location.pathname.indexOf("blank.htm") == -1)

	  strPopup 	= parent.frames[0].document.NavBar.graphics.value;
}

if (bBook || bChapter) {
        strFrameLang 	= strTopHref.substring(0, strTopHref.lastIndexOf("/"));
        strFrameLang 	= strFrameLang.substring(0, strFrameLang.lastIndexOf("/"));
	strFrameLang 	= strFrameLang.substring(0, strFrameLang.lastIndexOf("/")).toLowerCase();
	strFrameLang 	= strFrameLang.substring(strFrameLang.lastIndexOf("/") + 1, strFrameLang.length);
        strFrameProd 	= strTopHref.substr(0, strTopHref.lastIndexOf("/"));
	strFrameProd 	= strFrameProd.substring(strFrameProd.lastIndexOf("/") + 1, strFrameProd.length);
} else if (bDoc) {
	strFrameLang 	= strTopHref.substring(0, strTopHref.lastIndexOf("/"));
        strFrameLang 	= strFrameLang.substring(0, strFrameLang.lastIndexOf("/")).toLowerCase();
	strFrameLang 	= strFrameLang.substring(0, strFrameLang.lastIndexOf("/")).toLowerCase();
        strFrameLang 	= strFrameLang.substring(strFrameLang.lastIndexOf("/") + 1, strFrameLang.length);
}

var strTopSearch        = top.location.search;
var strSearchFilePath   = strTopSearch.substring(strTopSearch.indexOf("File=") + 5,  strTopSearch.length);
var strSearchLang       = strSearchFilePath.substr(0, 3).toLowerCase();
var strSearchProd       = strSearchFilePath.substr(4, 2).toLowerCase();

var booknames 		= new Array();
var strIdxdFl 		= "idxdata.htm";
var popupWindow;
var testWindow;

if (gbNS && (bBook || bChapter)) {
	origWidth 	= top.innerWidth;
	origHeight 	= top.innerHeight;
	self.onresize	= frameRefresh;
}






//////////////////////////////////////
// Global Functions
//////////////////////////////////////

function CheckPrint() {
  if (top.length > 0 && (top.frames[0].location.pathname.indexOf("blank.htm") != -1)) {
	top.frames[0].givePopup();
	top.frames[0].location.replace("../../buttons.htm");
  }
  if (top.length > 0) {
  	if (parent.frames[0].document.NavBar) {
		parent.frames[0].location.replace("../../buttons.htm");
		parent.frames[0].document.NavBar.graphics.value=strPopup;
  	}
  }
  if (strPopup.substr(0, 5) == "print") {
	strPopup.substring("Popup test=" + strPopup.length - 5, strPopup.length)
	oldSetting = strPopup.substring(strPopup.length - 5, strPopup.length);
	bPrinting = true;
	if (gbIE) {
		parent.frames[0].document.NavBar.graphics.value=oldSetting;
		strPopup = oldSetting;
		parent.doc_frame.focus();
	}
	parent.doc_frame.print();
	if (gbIE) {
		parent.doc_frame.location.reload(true);
	} else if (gbNS) {
		parent.doc_frame.focus();
	}
  } else if (top.length > 0) {
  	if (parent.frames[0].document.NavBar) top.doc_frame.focus();
  }
  return true;
}


function AfterPrint() {
  if (gbNS && bPrinting) {
	parent.frames[0].document.NavBar.graphics.value=oldSetting;
	bPrinting = false;
	parent.doc_frame.location.reload(true);
  }
  return true;
}


function frameRefresh() {
  if (gbNS && (top.innerWidth != origWidth || top.innerHeight != origHeight)) {
	origWidth = top.innerWidth;
	origHeight = top.innerHeight;
	//top.location.reload();
  }
}


function showLinkText(l) {
  //if (l.href) {
  if (gbNS) {
	status = l.text;
   } else if (gbIE) {
	status = l.innerText;
  }
  //}
  return true;
}


function clearStatus() {
  status ="";
  return true;
}


function returnLink(link, popup) {
  top.location.replace(link);
  popup.close();
}


function ShowPopup (imgtag, title) {

  // This displays a graphic in a popup window

  var strDimensions = imgtag.substr(imgtag.toUpperCase().indexOf("WIDTH="), imgtag.length).toUpperCase();
  var strWidth = strDimensions.substring(strDimensions.indexOf("WIDTH=") + 6, strDimensions.indexOf(" "));
  var strHeight = strDimensions.substring(strDimensions.indexOf("HEIGHT=") + 7, strDimensions.indexOf(">"));
  var newtag = imgtag;
  /*if (screen.width < 1024) {
	//var scale = screen.width / 1024;
	scale = 1
  } else {
	var scale = 1;
  }*/
  title = unescape(title);
  if (title == "") title = "Exhibit";
  //var Width = (Number(strWidth)) * scale;
  var Width = (Number(strWidth));
  //var Height = (Number(strHeight)) * scale;
  var Height = (Number(strHeight));
  if (Width > screen.width * 0.85) {
	Width = screen.width * 0.85;
	Height += 15;
  }
  if (Height > screen.height * 0.85) {
	Height = screen.height * 0.85;
	Width += 15;
  }
  strWidth = (Width + 20).toString();
  strHeight = (Height + 27).toString();
  var strFeatures = "menubar=no,resizable=yes,scrollbars=yes,width=" + strWidth + ",height=" 
    + strHeight + ",top=20,left=20";
  popupWindow=window.open("","popupWindow",strFeatures);
  with (popupWindow) {
  if (gbIE) resizeTo(Number(strWidth) + 32, Number(strHeight) + 35);
  document.close();
  document.write("<HEAD><TITLE>"+ title + "</TITLE></HEAD><BODY>");
  document.write("<P>" + newtag + "</P></BODY>")
  focus();
  }
}

/*
// without graphic borders
function PopupLogic (imgtag, caption, id) {

  // This controls how graphics appear in the document depending on the Popups parameter
  if (strPopup.substr(0, 5) == "print") {
	// Show popup graphics inline and scaled to 69%
	var newtag = imgtag
	var strDimensions = imgtag.substring(imgtag.toUpperCase().indexOf("WIDTH="), imgtag.length).toUpperCase();
  	var strWidth 	  = strDimensions.substring(strDimensions.indexOf("WIDTH=") + 6, strDimensions.indexOf(" "));
  	var Width 	  = Number(strWidth);
	var strHeight	  = strDimensions.substring(strDimensions.indexOf("HEIGHT=") + 7, strDimensions.indexOf(">"));
	var Height	  = Number(strHeight);
	var Scale = 0.69;
	Height = (Height * Scale);
	Width = (Width * Scale);
	newtag = imgtag.substr(0, imgtag.toUpperCase().indexOf("WIDTH=") + 6) + Width.toString() + " " + imgtag.substr(imgtag.indexOf("HEIGHT="), 7) + Height.toString() + " BORDER=0>";
	document.write(newtag + "</P><P CLASS=CAPTION ID=" + id + "> " + unescape(caption) + "</P>");
  } else if (id == "" || strPopup.substring(strPopup.length - 5, strPopup.length) == "large") {
	// Show popup graphics inline
	var newtag = imgtag */


	/*
	var strDimensions = imgtag.substring(imgtag.toUpperCase().indexOf("WIDTH="), imgtag.length).toUpperCase();
  	var strWidth 	  = strDimensions.substring(strDimensions.indexOf("WIDTH=") + 6, strDimensions.indexOf(" "));
  	var Width 	  = Number(strWidth);
	var strHeight	  = strDimensions.substring(strDimensions.indexOf("HEIGHT=") + 7, strDimensions.indexOf(">"));
	var Height	  = Number(strHeight);
	if (gbNS) {
		var frameWidth = top.doc_frame.innerWidth - 40;
	} else if (gbIE) {
		var frameWidth = top.doc_frame.document.body.clientWidth - 40;
	}
	if (Width > frameWidth) {
		var Scale = frameWidth / Width;
	} else {
		var Scale = 1;
	}
	Height = (Height * Scale);
	Width = (Width * Scale);
	newtag = imgtag.substr(0, imgtag.toUpperCase().indexOf("WIDTH=") + 6) + Width.toString() + " " + imgtag.substr(imgtag.indexOf("HEIGHT="), 7) + Height.toString() + " BORDER=0>"; */
	
	/*
	if (id == "") {
		document.write(newtag + "</P>");
	} else {
		document.write(newtag + "</P><P CLASS=CAPTION ID=" + id + "> " + unescape(caption) + "</P>");
	}
  } else if (id == "popup" && (bBook || bChapter)) {
	// Show popup graphics as popup icons
	document.write("<A HREF=\"javascript:ShowPopup('" + imgtag + "','" + escape(caption) + "')\"><IMG SRC=../../img/panel_icon.gif BORDER=0></A> " + unescape(caption) + "</P>"); 
  } else {
	// Only used for writer preview
	document.write("<A HREF=\"javascript:ShowPopup('" + imgtag + "','" + escape(caption) + "')\"><IMG SRC=../img/panel_icon.gif BORDER=0></A> " + unescape(caption) + "</P>"); 
  }
} 
*/

//with graphic borders
function PopupLogic (imgtag, caption, id) {

  // This controls how graphics appear in the document depending on the Popups parameter

  if (strPopup.substr(0, 5) == "print") {
	//alert("print");
	// Show popup graphics inline and scaled to 69%
	var newtag = imgtag
	var strDimensions = imgtag.substring(imgtag.toUpperCase().indexOf("WIDTH="), imgtag.length).toUpperCase();
  	var strWidth 	  = strDimensions.substring(strDimensions.indexOf("WIDTH=") + 6, strDimensions.indexOf(" "));
  	var Width 	  = Number(strWidth);
	var strHeight	  = strDimensions.substring(strDimensions.indexOf("HEIGHT=") + 7, strDimensions.indexOf(">"));
	var Height	  = Number(strHeight);
	var Scale = 0.69;
	Height = (Height * Scale);
	Width = (Width * Scale);
	newtag = imgtag.substr(0, imgtag.toUpperCase().indexOf("WIDTH=") + 6) + Width.toString() + " " 
	  + imgtag.substr(imgtag.indexOf("HEIGHT="), 7) + Height.toString() + " BORDER=1>";
	document.writeln(newtag + "</P><P CLASS=CAPTION>" + unescape(caption) + "</P>");
  } else if (id == "" || strPopup.substring(strPopup.length - 5, strPopup.length) == "large") {

	// Show graphics inline

	var newtag = imgtag
	newtag = imgtag.substr(0, imgtag.length - 1) + " BORDER=1>";

	/* The following code can scale inline graphics to fit in the frame.  Disabled for 8.1.
	var strDimensions = imgtag.substring(imgtag.toUpperCase().indexOf("WIDTH="), imgtag.length).toUpperCase();
  	var strWidth 	  = strDimensions.substring(strDimensions.indexOf("WIDTH=") + 6, strDimensions.indexOf(" "));
  	var Width 	  = Number(strWidth);
	var strHeight	  = strDimensions.substring(strDimensions.indexOf("HEIGHT=") + 7, strDimensions.indexOf(">"));
	var Height	  = Number(strHeight);
	if (gbNS) {
		var frameWidth = top.doc_frame.innerWidth - 40;
	} else if (gbIE) {
		var frameWidth = top.doc_frame.document.body.clientWidth - 40;
	}
	if (Width > frameWidth) {
		var Scale = frameWidth / Width;
	} else {
		var Scale = 1;
	}
	Height = (Height * Scale);
	Width = (Width * Scale);
	newtag = imgtag.substr(0, imgtag.toUpperCase().indexOf("WIDTH=") + 6) + Width.toString() + " " 
	  + imgtag.substr(imgtag.indexOf("HEIGHT="), 7) + Height.toString() + " BORDER=1>"; */

	if (id == "") {
		document.writeln(newtag + "</P>");
	} else {
		document.writeln(newtag + "</P><P CLASS=CAPTION>" + unescape(caption) + "</P>");
	}
  } else if (id == "popup" && (bBook || bChapter)) {

	// Show popup graphics as popup icons

	document.writeln("<A HREF=\"javascript:ShowPopup('" + imgtag + "','" 
	  + escape(caption) + "')\"><IMG SRC=../../img/panel_icon.gif BORDER=0 ID=" + id + "></A> " 
	  + unescape(caption) + "</P>"); 
  }
}



