/***********************************************************************
*                                                                      *
*               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.       *
*                                                                      *
************************************************************************/
self.onresize=resizer;

var bResized = false;
var y = 0;
var bOpened = false;
var objP;
var objC;
var currXOff = 0;
var currYOff = 0;
var origWidth = 0;
var origHeight = 0;

function initeventtrap() {
    if(gbNS) document.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT);
    document.onmouseover=mouseOver;
    document.onmouseout=mouseOut;
}

initeventtrap();

function mouseOver(evt) {
  if (gbIE) {
	if (event.srcElement.tagName=="A") status=event.srcElement.innerText;
  } else if (gbNS) {
	if (evt.target.text) status=evt.target.text;
  }
  return true;
}

function mouseOut(evt) {
  if (gbIE && event.srcElement.tagName=="A") {
	status='';
  } else if (gbNS && evt.target.text) {
	status='';
  }
  return true;
}

if (gbNS) {
    origWidth = innerWidth;
    origHeight = innerHeight;
}

function clickPDF() {
  top.frames[0].location.reload(true);
}

function writeStyle() {
    if (gbNS) tocStyleWriteNS(); else tocStyleWriteIE();
}

function tocStyleWriteNS()  {
    document.writeln("<STYLE TYPE=\"text/css\">");
    document.writeln("P {font-family:'Arial'; font-size:9pt; margin-top:0pt; margin-bottom:0pt;color:#FF0000}");
    document.writeln("LAYER {margin: 0pt}");
    document.writeln("A {color: #333333; text-decoration: none; }");
    document.writeln("A:link {text-decoration: none; color: 000000}");
    document.writeln("A:visited {text-decoration: none; color: 333333}");
    document.writeln("A:active {text-decoration: none; background-color: #cccccc}");
    document.writeln("A:hover {text-decoration: underline; color: blue}");
    document.writeln("</STYLE>");
}

function selectCode(){
document.code.ta.focus();
document.code.ta.select();
}

function tocStyleWriteIE() {
    document.writeln("<STYLE TYPE=\"text/css\">");
    document.writeln(".P {font-size:10pt;}");
    document.writeln("BLOCKQUOTE {margin-top:0pt; margin-bottom:0pt;margin-left:10pt}");
    document.writeln("P {font-family:'Arial'; font-size:9pt; margin-top:0pt; margin-bottom:0pt;}");
    document.writeln("PRE {font-family:'Arial'; font-size:8pt; margin-top:0pt; margin-bottom:0pt;}");
    document.writeln("DIV {margin-top:0pt; margin-bottom:0pt;display:block}");
    document.writeln(".C {display:none}");
    document.writeln("A {color: #333333; text-decoration: none; }");
 //   document.writeln("A:link {text-decoration: none; color: 000000}");
//document.writeln("A:link {text-decoration: none; color: #D3AC57}");
document.writeln("A:link {text-decoration: none; color: beige}");



   document.writeln("A:visited {text-decoration: none; color: #D3AC57}");
 //   document.writeln("A:active {text-decoration: none; background-color: #cccccc}");
    document.writeln("A:hover {text-decoration: none; color: #973405}");
    document.writeln("</STYLE>");
}

function initToc() {
    if (gbNS) {
	with (document) {
	    //for (x = 0; x < layers.length; x++) if (layers[x].id.indexOf("P") != -1) layers[x].visibility="show";
	    for (x = 0; x < layers.length; x++) if (layers[x].id.substr(layers[x].id.length - 1, 1) == "P") layers[x].visibility="show";
	}
	reDraw(false);
    }
   // top.frames[1].frames[1].frames[0].tocIsLoaded(top.frames[0].tocFlag);
}

function findLayer(objNode, bookId) {
    var objFound = "";
    for (var i = 0; i < objNode.layers.length; i++) {
	if (objNode.layers[i].id == bookId) {
	    objFound = objNode.layers[i];
	    break;
	}
	if (objNode.layers[i].layers.length > 0 
	    && (objFound = findLayer(objNode.layers[i], bookId)) != "") break;
    }
    return objFound;
}

function clickFolder(itmID) {
    if (gbNS) {
	clickFolderNS(itmID);
    } else {
	var child = clickFolderIE(itmID, true, false);
	var nNewScroll = document.body.scrollTop;
	if (child.style.display == "block") {
	    var nItemTop = child.offsetTop;
	    var nItemBottom = nItemTop + child.offsetHeight;
	    if (document.body.scrollTop + document.body.clientHeight < nItemBottom) 
		nNewScroll = nItemBottom - document.body.clientHeight;
	    if (nItemBottom - nItemTop > document.body.clientHeight) nNewScroll = nItemTop - 20;
	}
	document.body.scrollTop = nNewScroll;
    }
}


function clickFolderIE(elId, bChangeImg, bForceOpen) {
    var whichEl = eval(elId + "IEC");
    var whichIm = document.images[elId];
    if (whichEl == null) return null;
    if (whichEl.style.display != "block" || bForceOpen) {
	whichEl.style.display = "block";
	if (bChangeImg) whichIm.src = "http://sirwathen.com/Images/bopen.gif";
    } else {
	whichEl.style.display = "none";
	if (bChangeImg) whichIm.src = "http://sirwathen.com/Images/bclose.gif";
// parent.location.href="JSCode.html";
    }
    status="";
    return whichEl;
}




function clickFolderLink(elId, bChangeImg, bForceOpen) {
    var whichEl = eval(elId + "IEC");
    var whichIm = document.images[elId];
    if (whichEl == null) return null;
    if (whichEl.style.display != "block" || bForceOpen) {
	whichEl.style.display = "block";
	if (bChangeImg) whichIm.src = "Images/blanklayer.gif";
    } else {
	whichEl.style.display = "none";
	if (bChangeImg) whichIm.src = "Images/blanklayer.gif";
// parent.location.href="JSCode.html";
    }
    status="";
    return whichEl;
}







// ************  For Right Navigation

function clickFolderRTNav(itmID) {
    if (gbNS) {
	clickFolderNS(itmID);
    } else {
	var child = clickFolderRTNavIE(itmID, true, false);
	var nNewScroll = document.body.scrollTop;
	if (child.style.display == "block") {
	    var nItemTop = child.offsetTop;
	    var nItemBottom = nItemTop + child.offsetHeight;
	    if (document.body.scrollTop + document.body.clientHeight < nItemBottom) 
		nNewScroll = nItemBottom - document.body.clientHeight;
	    if (nItemBottom - nItemTop > document.body.clientHeight) nNewScroll = nItemTop - 20;
	}
	document.body.scrollTop = nNewScroll;
    }
}


function clickFolderRTNavIE(elId, bChangeImg, bForceOpen) {
    var whichEl = eval(elId + "IEC");
    var whichIm = document.images[elId];
    if (whichEl == null) return null;
    if (whichEl.style.display != "block" || bForceOpen) {
	whichEl.style.display = "block";
//	if (bChangeImg) whichIm.src = "bopen.gif";
    } else {
	whichEl.style.display = "none";
//	if (bChangeImg) whichIm.src = "bclose.gif";

// parent.location.href="JSCode.html";
    } 
    status="";
    return whichEl;
}

//************************* end Right Navigation



function clickFolderNS(itmID) {
    currXOff = self.pageXOffset;
    currYOff = self.pageYOffset;
    objP = findLayer(document, itmID + "P");
    objC = findLayer(document, itmID + "C");
    var origHeight = document.height;
    if (currYOff <= 18) currYOff = 0;
    if (objC.visibility == "show") {
	bOpened=false;
	objP.document.images[0].src="bclose.gif";
	closeAllSubs(objC);
    } else {
	bOpened = true;
	objP.document.images[0].src="bopen.gif";
	with (objC) {
	    for (x = 0; x < layers.length; x++)
		//if (layers[x].id.indexOf("C") != -1) closeAllSubs(layers[x]);
		if (layers[x].id.substr(layers[x].id.length - 1, 1) == "C") closeAllSubs(layers[x]);
	}
  }
    reDraw(true);
    rePosition();
    return;
}

function reDraw(bClicked) {
    y = 0;
    tocDraw(document,0,bClicked);
    return;
}

function tocDraw(objNode,depth,bClicked) {
    for (var i = 0; i < objNode.layers.length; i++) {
	if (bClicked) {
	    objNode.layers[i].bgColor="#f7f3ef";
	    if (objP.id == objNode.layers[i].id) objNode.layers[i].document.bgColor = "silver";
	}
	if (objNode.layers[i].visibility == "show" || (bClicked && objC.id == objNode.layers[i].id && bOpened)) {
	    var x = depth;
	    if (objNode.layers[i].id.substr(objNode.layers[i].id.length - 1, 1) == "C") x++;
	    objNode.layers[i].pageX = x * 18 + 3;
	    objNode.layers[i].pageY = y;
	    if (objNode.layers[i].layers.length == 0) {
		y += objNode.layers[i].clip.height;
	    } else {
		y += (objNode.layers[i].document.height ? objNode.layers[i].document.height - 19 : 0);
	    }
	    for (l = 0; l < objNode.layers[i].layers.length; l++) 
		objNode.layers[i].clip.bottom += objNode.layers[i].layers[l].document.images.length * 18; 
	    if (!bClicked && objNode.layers[i].id.substr(objNode.layers[i].id.length - 1, 1) == "C" && objNode.layers[i].visibility == "show") 
		objNode.layers[i-1].document.images[0].src="bopen.gif";
	    if (objNode.layers[i].id.substr(objNode.layers[i].id.length - 1, 1) == "C" && bOpened) {
		objNode.layers[i].visibility="show";
		for (l = 0; l < objNode.layers[i].layers.length; l++) {
		    //if (objNode.layers[i].layers[l].id.indexOf("P") != -1) 
		    if (objNode.layers[i].layers[l].id.substr(objNode.layers[i].layers[l].id.length - 1, 1) == "P")
			objNode.layers[i].layers[l].visibility="show";
		}
	    }
	    tocDraw(objNode.layers[i], depth + 1, bClicked);
    	}
    }
}

function rePosition() {
    if (document.width - 10 > self.innerWidth) {
	var scrollbar = 12;
    } else {
	var scrollbar = 0;
    }
    var bChanged = false;
    for (t = 0; t < 10000; t++) {}
    if (bOpened || self.pageYOffset == 0  || (!bOpened && y < self.innerHeight - scrollbar)) {
  	if ((document.height < self.innerHeight - scrollbar && y < document.height) || (!bOpened && y < self.innerHeight - scrollbar && currYOff==0)) {
	    document.height = self.innerHeight;
  	} else {
	    if (y >= document.height || (self.pageYOffset == 0)) {
		bChanged = true
		    document.height = y + scrollbar;
	    }
  	}
    }
    var docHeight = objC.document.height + 18;
    for (x = 0; x < objC.layers.length; x++) 
	if (objC.layers[x].visibility == "show") 
	    docHeight += objC.layers[x].document.height;
    if (bOpened) {
	for (t = 0; t < 5000; t++) {}
	if (bChanged) self.scrollTo(currXOff, currYOff - 1);
	if (docHeight > self.innerHeight - scrollbar) {
	    self.scrollTo(0, objP.pageY - 8);
	} else if (docHeight + objC.pageY > currYOff + self.innerHeight - scrollbar) {
	    self.scrollBy(0, (objP.pageY + docHeight) - (currYOff + self.innerHeight - scrollbar) + 6);
	}
    } else if (currYOff == 0) {
	self.scrollTo(0,0);
    }
}

function closeAllSubs(thisLayer) {
    if (thisLayer.layers.length > 0) {
	for (x = 0; x < thisLayer.layers.length; x++) {
	    thisLayer.layers[x].visibility="hide";
	    //if (thisLayer.layers[x].id.indexOf("P") != -1 )
	    if (thisLayer.layers[x].id.substr(thisLayer.layers[x].id.length - 1, 1) == "P")
		thisLayer.layers[x].document.images[0].src="bclose.gif";
	}
	if (thisLayer.layers.length > 1) closeAllSubs(thisLayer.layers[1]);
    }
    thisLayer.visibility="hide";
    return true;
}


function resizer() {
    if (gbNS && (innerWidth != origWidth || innerHeight != origHeight)) {
	bResized = true;
	origWidth = innerWidth;
	origHeight = innerHeight;
	reDraw(false);
    }
    return true;
}


/*function showLinkText(l) {
    if (gbNS) {
	if (l.text) status = l.text;
    } else if (gbIE) {
	status = l.innerText;
    }
    return false;
}

function clearStatus() {
    status = "";
    return true;
}*/





