/* =================================================================================
*  FILE: cbsFuncLib.js - JavaScript routine library for concept book summary display
*    BY: Eric Edelstein - MeansBusiness, Inc.
*		 Mods by Lance Keene (LLK) Nov, 1999
*  Note: This file is loaded as a JS include in the header of the ASP page called
*        with a FID=(guid) which preloads the JS arrays used by these routines.
*		 (c) Copyright 1999 MeansBusiness, Inc.
* =================================================================================*/
//---LLK added 11/19/99 
var	mouseDownX = 0
var	mouseDownY = 0
var	mouseX = 0
var	mouseY = 0
var	mouseUpX = 0
var	mouseUpY = 0
var chapMenu;
var called_by_simple_summary = false;

// -- Create HTML formatting objects
bookJPGFMT = new Object();
titleFMT = new Object();
authFMT = new Object();
endorseFMT = new Object();
// -- wjb isbntype/extract-wordcount/title-wordcount
isbntypeFMT = new Object();
eWordCountFMT = new Object();
eGifCountFMT = new Object();
tWordCountFMT = new Object();
tGifCountFMT = new Object();

pubFMT = new Object();
pubdateFMT = new Object();
copyrightFMT = new Object();
awardFMT = new Object();
chapmenuFMT = new Object();
exdispFMT = new Object();
srelconsFMT = new Object() ;
eprevFMT = new Object();
empchapboxFMT = new Object();
offerFMT = new Object();
priceFMT = new Object();
billtoFMT = new Object();

hotsearchFMT = new Object();
Add2LibFMT = new Object();
conGraphFMT = new Object();
buybuttsFMT = new Object();
chaptNavFMT = new Object(); // LLK on 11/11/99
extNavFMT = new Object();   // LLK on 11/16/99
prevExtFMT = new Object(); //wjb 12/5/00

// -- DECLARE GLOBAL VARIABLES
var srchstr = "";   // -- used by hotsearch()
var AssSuites = new Array();
var as = new Object();

// -- default to not showing add2lib button if not defined
if(!Libraried) var Libraried = 2 ;

function exL1Name() {document.write(ifDefined(Suite.L1ConceptName));}
function exL2Name() {document.write(ifDefined(Suite.L2ConceptName));}
function exL3Name() {document.write(ifDefined(Suite.L3ConceptName));}

/* -------------------------------------------------------------------------
* GOODIES FUNCTIONS
*  -------------------------------------------------------------------------*/
function ExtractsCount(){
    var eCount = 0;
    for(var i = 0; i<tChapCount; i++) {
        eCount = eCount + eval('tChap'+i+'.tExCount');
    }
    document.write(eCount); 
}
function ChaptersCount(){ document.write(tChapCount); }
function ConceptsCount(){ document.write(tConArray.length); }
function AuthorsCount (){ document.write(tAuthorArray.length); }


/* ------------------------------------------------------------------------------
*  FUNCTION srelcons() - Display list of concept suites for results on current page
*                        Create temporary array and sort it for related concepts
*                        hierarchy.
*-------------------------------------------------------------------------------*/
function srelcons() {
    if (SuiteCount < 1) return ;

    for (var x = 0; x < SuiteCount; x++) { 
		InitAssSuites(Suites[x].Id, Suites[x].Name, Suites[x].Weight, Suites[x].L1ConceptName, Suites[x].L2ConceptName, Suites[x].L3ConceptName); 
	}
    
    SortAssSuites() // -- Sort the array
         
    // -- write sorted array values (only up to maxresults value) !
    document.write(srelconsFMT.prompt);
    var maxresults = (srelconsFMT.maxresults > AssSuites.length) ? AssSuites.length : srelconsFMT.maxresults;
    for (var x = 0; x < maxresults; x++) {
        var I = AssSuites[x].Id;
        var N = AssSuites[x].Name;
        var W = (srelconsFMT.wgtbeg) ? (srelconsFMT.wgtbeg + AssSuites[x].Weight + srelconsFMT.wgtend) : '';
        document.write(srelconsFMT.beg);
        if (!srelconsFMT.url) {
            document.write(N + srelconsFMT.sep);
        }
        else {
//			var popupContent = AssSuites[x].L1ConceptName + '<BR>' + AssSuites[x].L2ConceptName + '<BR>' + AssSuites[x].L3ConceptName;
//			var mouseStuff = ' onMouseover="Javascript:writeParentSuitesContent(\'' + popupContent +'\');parentSuites.moveTo(mouseX+(' + parentSuitesFMT.mouseOffsetX + '), mouseY+(' + parentSuitesFMT.mouseOffsetY + '));" onMouseout="javascript:parentSuites.hide();"';
			var L1 = AssSuites[x].L1ConceptName;
			var L2 = AssSuites[x].L2ConceptName;
			var L3 = AssSuites[x].L3ConceptName;
			L1 = L1.replace(/'/g, "\\'"); // Replace all single quotes with \'
			L2 = L2.replace(/'/g, "\\'");
			L3 = L3.replace(/'/g, "\\'");
			var mouseStuff = ' onMouseover="Javascript:writeParentSuitesContent(\'' + L1 +'\',\'' + L2 +'\',\'' + L3 +'\');parentSuites.moveTo(mouseX+(' + parentSuitesFMT.mouseOffsetX + '), mouseY+(' + parentSuitesFMT.mouseOffsetY + '));" onMouseout="javascript:parentSuites.hide();"';
            document.write('<a href=' + srelconsFMT.url + I + mouseStuff + '>' + N + W + '</a>' + srelconsFMT.sep);
        }
    }
    document.write(srelconsFMT.end);
}


/* -------------------------------------------------------------------------------
*  FUNCTION InitAssSuites() - Populate object "as[]" with values of associated suites
*            Call InitAssSuites() for every result from Search result page 
*            or once for each associated Suite in a product page
*            Call FinishAssSuites once at the end of the result/suite loop after all 
*            calls to InitAssSuites have been completed.
*---------------------------------------------------------------------------------*/
function InitAssSuites(Suite, Name, Weight, L1ConceptName, L2ConceptName, L3ConceptName) {
	if (!as[Suite]) {
		as[Suite] = { Weight:Weight, Name:Name, Id:Suite, L1ConceptName:L1ConceptName, L2ConceptName:L2ConceptName, L3ConceptName:L3ConceptName};
	}
	else {
	    // -- increment weight to push duplicate suite up on the weighting list!
		as[Suite].Weight = (as[Suite].Weight + Weight);
	}
}


/* --------------------------------------------------------------------
*  FUNCTION SortAssSuites() - Finalize array sort of associated suites
*                               "as[]" created by InitAssSuites()
*                             Requires sort logic for object in object array
*-----------------------------------------------------------------------*/
function SortAssSuites() {
	var i = 0;
	for (x in as) {
		AssSuites[i] = {Weight:as[x].Weight, Name:as[x].Name, Id:as[x].Id, L1ConceptName:as[x].L1ConceptName, L2ConceptName:as[x].L2ConceptName, L3ConceptName:as[x].L3ConceptName};
		i++;
	}
	as = '';    // empty out big object (save memory)
	
	// -- Sort the array descending, numerically
	AssSuites.sort(function(a,b){
					    if(a.Weight > b.Weight) return -1 ;
	                    if(a.Weight < b.Weight) return 1 ;
	                    if(a.Weight = b.Weight) return 0 ;
	                });
}


/* -------------------------------------------------------------------------
*  FUNCTION ifDefined(testdata) - return '' if data not undefined, else data
*  -------------------------------------------------------------------------*/
function ifDefined(testdata) {
    return (typeof(testdata) == 'undefined') ? '' : testdata;
}


/* --------------------------------------------------------------------
*  FUNCTION VorH() - create proper display code for vert or horiz listing
*                  Params:  "V" or "H"
*                  Returns: either a break "<BR>" or space
*  --------------------------------------------------------------------*/
function VorH(strFormat) {
    switch (strFormat) {
        case "V" : 
            strSuffix = "<BR>"; 
            break; 
        case "H" :
            strSuffix = ('&nbsp;&nbsp;');
            break;
    }
    return strSuffix
}


/* --------------------------------------------------------------------
*  FUNCTION cbsTitle() - display book title
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsTitle() {
    if(tTitle) document.write(titleFMT.beg + tTitle + titleFMT.end);
}

/* --------------------------------------------------------------------
*  FUNCTION cbsTitleWordCount() - display word count for title
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsTitleWordCount() {
    if(tWordCount) document.write(tWordCountFMT.beg + tWordCount + tWordCountFMT.end);
}

/* --------------------------------------------------------------------
*  FUNCTION cbsTitleGifCount() - display Gif count for title
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsTitleGifCount() {
    if(tGifCount) document.write(tGifCountFMT.beg + tGifCount + tGifCountFMT.end);
}

/* --------------------------------------------------------------------
*  FUNCTION cbsCopyrightString() - builds book copyright string
*                  Params:  none
*                  Returns: value of the attribute, Copyright for this title
*  --------------------------------------------------------------------*/
function cbsCopyrightString() {
    if(tCopyright) return (copyrightFMT.beg + tCopyright + copyrightFMT.end);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsCopyright() - display book copyright
*                  Params:  none
*                  Returns: value of the attribute, Copyright for this title
*  --------------------------------------------------------------------*/
function cbsCopyright() {
    if(tCopyright) document.write(cbsCopyrightString());
}


/* --------------------------------------------------------------------
*  FUNCTION cbsBookPubdate() - display book publication date
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsBookPubdate() {
    if(tPubdate) document.write(pubdateFMT.beg + tPubdate + pubdateFMT.end);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsBookJPG() - display book cover GIF graphic
*                  Params:  none
*                  Returns: image of cover as hyperlink
*  --------------------------------------------------------------------*/
function cbsBookJPG() {
    if(!bookJPGFMT.url) {
        document.write('<img src=' + bookJPGFMT.picsrc + tTitleGuid + '.JPG ' + bookJPGFMT.picfmt);
    }
    else {
        document.write('<A href=' + bookJPGFMT.url + tTitleGuid + '><img src=' + bookJPGFMT.picsrc + tTitleGuid + '.JPG ' + bookJPGFMT.picfmt + '</A>');
    }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsPublisher() - display book publisher
*                  Params:  none
*                  Returns: value of the attribute as hyperlink
*  --------------------------------------------------------------------*/
function cbsPublisher() {
    if(!pubFMT.url) {
        if(tPublisherText) document.write(pubFMT.beg + tPublisherText + pubFMT.end);
    }
    else {
        if(tPublisherText) document.write(pubFMT.beg + '<A href=' + pubFMT.linkurl + tPublisherGuid + ">" + tPublisherText + '</A>' + pubFMT.end);
    }
}

/* --------------------------------------------------------------------
*  FUNCTION cbsIsbnType() - display ISBN Type
*                  Params:  none
*				created: 11/22/00 - wjb
*  --------------------------------------------------------------------*/
function cbsIsbnType() {
	if(tIsbnType) document.write(isbntypeFMT.beg + tIsbnType + isbntypeFMT.end);
}

/* --------------------------------------------------------------------
*  FUNCTION cbsAuthorlist() - display array of authors
*                 Returns: list of authors
*  --------------------------------------------------------------------*/
function cbsAuthorlist(){ 
    if(tAuthorArray.length == 0) return ;   
    document.write (authFMT.beg);
    for (i = 0; i < tAuthorArray.length ; i++) {
        if(!bookJPGFMT.url) {
            document.write(tAuthorArray[i]);    
        }
        else {
            document.write('<A href=' + authFMT.linkurl + tAuthorGuidArray[i] + ">" + tAuthorArray[i] + "</A>");
        }
    if (i < tAuthorArray.length -1) document.write(authFMT.sep);  
    }
    document.write (authFMT.end);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsEndorserlist() - display array of endorsers
*                  Params:
*                   Calls:
*                 Returns: list of endorsers
*  --------------------------------------------------------------------*/
function cbsEndorserlist(){
    if(tEndorserArray.length == 0) return ;   
    document.write (endorseFMT.beg) ;
    for (i = 0; i < tEndorserArray.length ; i++) {
        document.write(tEndorserArray[i]);
        if (i < tEndorserArray.length -1) document.write(endorseFMT.sep);
    }
    document.write (endorseFMT.end);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsKeywordlist() - display array of keywords
*                  Params: "V" or "H"
*                   Calls: VorH()
*                 Returns: list of keywords
*  --------------------------------------------------------------------*/
function cbsKeywordlist(strFormat){
    for (i = 0; i < tKWArray.length ; i++) {
        document.write("<A href=kw.asp?FID=",tKWGuidArray[i],">" + tKWArray[i] + "</A>",VorH(strFormat));
    }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsAwardlist() - display array of awards
*                  Params: 
*                   Calls: 
*                 Returns: list of keywords
*  --------------------------------------------------------------------*/
function cbsAwardlist(strFormat){
    for (i = 0; i < tAwardArray.length ; i++) {
        document.write(awardFMT.beg + '<img src=' + awardFMT.picsrc +  ' ' + awardFMT.picfmt + '> ' + tAwardArray[i] + awardFMT.end);
    }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsConceptlist() - display array of concepts
*                  Params: "V" or "H"
*                   Calls: VorH()
*                 Returns: list of concepts
*  --------------------------------------------------------------------*/
function cbsConceptlist(strFormat){
	var i;
    for (i = 0; i < tConArray.length ; i++) {
        document.write("<A href=concept.asp?FID=",tConGuidArray[i],">",tConArray[i],"</A>",VorH(strFormat));
    }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsCompaniesMentioned() - display array of companies mentioned
*                  Params: "V" or "H"
*                   Calls: VorH()
*                 Returns: list of company names
*  --------------------------------------------------------------------*/
function cbsCompaniesMentioned(strFormat) {
	var i;
    for (i = 0; i < tCompanyArray.length ; i++) {
        document.write("<A href=company.asp?FID=",tCompanyArray[i],">",tCompanyArray[i],"</A>",VorH(strFormat));

    }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsPeopleMentioned() - display array of people mentioned
*                  Params: "V" or "H"
*                   Calls: VorH()
*                 Returns: list of names
*  --------------------------------------------------------------------*/
function cbsPeopleMentioned(strFormat) {
	var i;
    for (i = 0; i < tPeopleArray.length ; i++) {
        document.write("<A href=people.asp?FID=",tPeopleArray[i],">",tPeopleArray[i],"</A>",VorH(strFormat));
    }
}


/* --------------------------------------------------------------------
*  FUNCTION checkchapnum() -   checks FORM_DATA.chapNum value for validity
*               Parameters:  
*               Returns:     none - resets FORM_DATA.chapNum value to zero
*                            if an invalid value exists.
*  --------------------------------------------------------------------*/
function checkchapnum() {
   
    // -- test for negative value (no chapters)
    if (FORM_DATA.chapNum < 0 || tChapCount == 0) return;
    
    // -- if parameter is not passed (undefined) or is empty (no value),
    //    or is not a number, or is outside the chapter number range,
    //    default to zero
    if (!FORM_DATA.chapNum) FORM_DATA.chapNum = 0;

    if (isNaN(FORM_DATA.chapNum)) {
        //alert('Invalid chapter string(' + FORM_DATA.chapNum + ')....The first chapter will be displayed as default.');
        FORM_DATA.chapNum = 0;
    } 
    
    // -- Check to see if such a chapter number exists!
    //    If not found, default to 0
    if (FORM_DATA.chapNum >= tChapCount) {
       // commented by ls 5/27/99
       // alert('Invalid chapter number(' + FORM_DATA.chapNum + ')...The first chapter will be displayed as default.');
        FORM_DATA.chapNum = 0;
    } 
}


/* --------------------------------------------------------------------
*  FUNCTION checkexFID() -   checks FORM_DATA.exNum value for validity
*               Parameters:  
*               Returns:     none - resets FORM_DATA.exNum value to zero
*                            if an invalid value exists.
*  --------------------------------------------------------------------*/
function checkexFID() {
     
   // -- test for no chapters (negative FORM_DATA.chapNum value)
   if (FORM_DATA.chapNum < 0 || tChapCount == 0) return;
   
   // -- test for no extracts (negative value for FORM_DATA.exNum)
   if (FORM_DATA.exNum < 0) return;
   
   var test = ('tChap' + FORM_DATA.chapNum + '.Ex' + FORM_DATA.exNum); 
   if (!eval(test)){
       // commented by ls 5/27/99
       //alert('Sorry - (' + test + ' does not exist)...The first extract will be displayed as default.');
       FORM_DATA.exNum = 0;
   }
   
    // -- if parameter is not passed (undefined) or is empty (no value),
    //    default to zero  
    if (!FORM_DATA.exNum) FORM_DATA.exNum = 0;
}


/* --------------------------------------------------------------------
*  FUNCTION cbsPrintDisplay - display extract data in printing format
*                  Params: 
*                   Calls: cbsExDisplay()
*                          Loops through all viable chapters in a summary
*  --------------------------------------------------------------------*/
function cbsPrintDisplay() {
	
	var RealChapNum = 0;
	var eNonChapTitle = '';
	
    for (printchap = 0; printchap < tChapCount; printchap++) {
        exCount = eval('tChap' + printchap + '.tExCount');
        if (exCount > 0) {
            FORM_DATA.chapNum = printchap
            checkchapnum();
            //checkexFID();
    
            // -- test for negative value indicating no chapters
    
            if (FORM_DATA.chapNum < 0) {
               // commented by ls 5/27/99
               alert("Sorry - no chapters exist in this book summary");
                return;
            }
   
            // -- test for no extracts in this chapter, find first viable chapter if none in current chapter...
    
            exCount = eval('tChap' + FORM_DATA.chapNum + '.tExCount');

            if (exCount <= 0) {
                nextchapNum = findnextchapnum();
                if (nextchapNum < 0) return;
                FORM_DATA.chapNum = nextchapNum;
                var chapObj = ('tChap' + FORM_DATA.chapNum) ;
                exCount = eval(chapObj + '.tExCount') ;
            }
            else {
                var chapObj = ('tChap' + FORM_DATA.chapNum);    // example: "tChap1"
            }
            
            // -- Loop through all extracts in currently selected chapter and display
			
            for (xnum = 0; xnum < exCount; xnum++) {
                eObj = (chapObj + '.Ex' + xnum) ;     // example: "tChap1.Ex2"
                tTitle = ifDefined(eval(chapObj + '.tTitle')) ;
                eTitle = ifDefined(eval(eObj + '.title')) ;
                eCutout = ifDefined(eval(eObj + '.cutout')) ;

                // -- Chapter title display (only for first extract)
                eNonChapTitle = ifDefined(eval(chapObj + '.NonChapTitle'));

                if (xnum == 0) {
					if (eNonChapTitle.length == 0)	{
						RealChapNum++;
						document.write(exdispFMT.chapnumbeg + 'Chapter ' + RealChapNum + exdispFMT.chapnumend) ;
       				}
					else	{
						document.write(exdispFMT.chapnumbeg + eNonChapTitle + exdispFMT.chapnumend);
					}
                    if(tTitle) document.write(exdispFMT.chaptitlebeg + tTitle + exdispFMT.chaptitleend);
                    document.write(exdispFMT.chaptitlesep);
                }

                // -- Extract title display

                if(eTitle) document.write(exdispFMT.extitlebeg + eTitle + exdispFMT.extitleend);
                document.write(exdispFMT.exsep);
                    
                // -- Extract cutout display

                if(eCutout)document.write(exdispFMT.cutoutbeg + eCutout + exdispFMT.cutoutend);

                // -- paragraphs within extract  
                    
                var pcount = eval(eObj + '.parcount');
                var parObj = ('tChap' + FORM_DATA.chapNum + '.Ex' + xnum + '.Par');      
                for (i = 0; i < pcount ; i++) {
                    pagestart = ifDefined(eval(parObj + i + '.pagestart')); 
                    pageend = ifDefined(eval(parObj + i + '.pageend'));
					// 
                    displaypagestart = ifDefined(eval(parObj + i + '.displaypagestart')); 
                    displaypageend = ifDefined(eval(parObj + i + '.displaypageend'));
					
                    partype = ifDefined(eval(parObj + i + '.partype'));
                    partext = ifDefined(eval(parObj + i + '.text'));
					if (displaypagestart.length == 0)
	                    document.write(exdispFMT.prbeg + pagestart + '-' + pageend + exdispFMT.prend);
					else
	                    document.write(exdispFMT.prbeg + displaypagestart + '-' + displaypageend + exdispFMT.prend);
					//document.write('Testing ' + displaypagestart);
                    //document.write(exdispFMT.ptbeg + partype + exdispFMT.ptend);
                    document.write(exdispFMT.parbeg + partext + exdispFMT.parend);
                }

                // -- Copyright for each extract on print pages only

                var loc = (document.location.href.indexOf('print'))
                if(loc > -1) cbsCopyright() ;   

            }      // -- end loop for extracts in current chapter
        }
     }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsChaptNav - display chapter Nav bar
*                  Params: 
*                  Calls: findnextchapnum(),findprevchapnum()
*  LLK 11/11/99 -  Created
*  --------------------------------------------------------------------*/
function cbsChaptNav(chapNum) {

var nextImg = "";
var prevImg = "";
var topImg  = "";

	originalChapNum = chapNum;
    
	nextchapNum = findnextchapnum(chapNum);
	nextchapNum++;
	prevchapNum = findprevchapnum(chapNum);
	prevchapNum++;
	
	if (originalChapNum == -1) {
		currentchapNum = "Top";
		document.write('<a name="Chap' + nextchapNum + '"></a>');
	} else if (nextchapNum == 0) {
		currentchapNum = "End";
	} else {
		currentchapNum = nextchapNum;
	}  
	document.write('<a name="Chap' + currentchapNum + '"></a>');

	document.write('<div id="Chap' + currentchapNum + 'Nav">');
  	chapNum = nextchapNum-1; 
	nextchapNum = findnextchapnum(chapNum);   
	nextchapNum++;

	if (originalChapNum == -1) {
		nextImg = '<a href="#Chap' + nextchapNum + '">' + chaptNavFMT.nextchapimg + '</a>';
		topImg  = chaptNavFMT.toppageimgx;
		prevImg = chaptNavFMT.prevchapimgx;;
	} else {
		topImg = '<a href="#ChapTop">' + chaptNavFMT.toppageimg + '</a>';
		if (nextchapNum == 0) {
			nextImg = '<a href="#ChapEnd">' + chaptNavFMT.nextchapimg + '</a>';
		} else {
		    if (currentchapNum == "End") {
				nextImg = chaptNavFMT.nextchapimgx;
		    } else {
				nextImg = '<a href="#Chap' + nextchapNum + '">' + chaptNavFMT.nextchapimg + '</a>';
			}		
		}  
	    if (prevchapNum == 0) {
			prevImg = '<a href="#ChapTop">' + chaptNavFMT.prevchapimg + '</a>';
		} else {
			prevImg = '<a href="#Chap' + (originalChapNum+1) + '">' + chaptNavFMT.prevchapimg + '</a>';
		}
	}	

    document.write(chaptNavFMT.tablebeg);
	document.write('<a href="Javascript:chapMenu.moveTo(mouseX+(' + chapmenuFMT.mouseOffsetX + '), mouseY+(' + chapmenuFMT.mouseOffsetY + '));">');
	document.write(chaptNavFMT.popupimg);
	document.write('</a>');
	
    document.write(prevImg);
    document.write(nextImg);
	document.write(topImg);
 
	document.write(chaptNavFMT.tableend);
	document.write('</div>');
}


/* --------------------------------------------------------------------
*  FUNCTION findnextextnum() - finds next extract number
*                  Params: chapNum, extNum
*                 Returns: previous extract # or -1
*  LLK 11/20/99 -  Created
*  --------------------------------------------------------------------*/
function findnextextnum(chapNum, extNum){    
	var nextNum = '-1' ; 
	exCount = eval('tChap' + parseInt(chapNum) + '.tExCount');
	if (extNum < exCount-1) {	
		nextNum = extNum + 1;
	}
	return nextNum;
}


/* --------------------------------------------------------------------
*  FUNCTION findprevextnum() - finds previous extract number
*                  Params: chapNum, extNum
*                 Returns: next extract # or -1
*  LLK 11/20/99 -  Created
*  --------------------------------------------------------------------*/
function findprevextnum(chapNum, extNum) { 
	var prevNum = '-1';   
	if (extNum > 0){	// -- more extracts exist before current one
		prevNum = extNum - 1;
	}
	return prevNum;
}


/* --------------------------------------------------------------------
*  FUNCTION cbsExtNav - display chapter Nav bar
*                  Params: 
*                   Calls:
*  LLK 11/18/99 -  Created
*  --------------------------------------------------------------------*/
function cbsExtNav(chapNum, extNum, exCount) {

var nextImg = "";
var prevImg = "";
var topImg  = "";
var topChapImg  = "";

	document.write('<a name="Chap' + chapNum + '.Ex' + (extNum+1) + '"></a>');

    if (exCount <= 1) return;
    if (extNum+1 >= exCount) return;
	
	extNum++;
	         
	nextExtNum = findnextextnum(chapNum, extNum);
	prevExtNum = findprevextnum(chapNum, extNum);
	
	topImg     = '<a href="#ChapTop">' + extNavFMT.toppageimg + '</a>';
	topChapImg = '<a href="#Chap' + (chapNum+1) + '">' + extNavFMT.topchapimg + '</a>';
	if (prevExtNum == -1) {
		prevImg = extNavFMT.prevextimgx;
	} else {
		prevImg = '<a href="#Chap' + chapNum + '.Ex' + prevExtNum + '">' + extNavFMT.prevextimg + '</a>';
	}
	if (nextExtNum == -1) {
		nextImg = extNavFMT.nextextimgx;
	} else {
		nextImg = '<a href="#Chap' + chapNum + '.Ex' + nextExtNum + '">' + extNavFMT.nextextimg + '</a>';
	}  

	document.write('<div id="Ext' + extNum + 'Nav">');
    document.write(extNavFMT.tablebeg);

    document.write(prevImg);
    document.write(nextImg);
	document.write(topChapImg);
	document.write(topImg);

	document.write(extNavFMT.tableend);
	document.write('</div>');
}


/* --------------------------------------------------------------------
*  FUNCTION displayRelatedSuitesMenu() - display Related Suites popup
*                  Params: 
*                 Returns: 
*  LLK 11/22/99 -  Created
*  --------------------------------------------------------------------*/
function displayRelatedSuitesMenu (chapNum, xnum) {
    var content  = "";
    var eObj = ('tChap' + chapNum + '.Ex' + xnum) ;     // example: "tChap1.Ex2"
	var relcount = eval(eObj+'.'+['relsuitecount']);

	for (relnum=0; relnum < relcount; relnum++) {
		relsuiteObj = (eObj + '.Suite' + relnum + '.');   // "tChap[x].Ex[y].Suite[z]."
		sttext = eval(relsuiteObj+['Name']);
		stguid = eval(relsuiteObj+['Id']);
//		var popupContent = eval(relsuiteObj+['L1ConceptName']) + '<BR>' + eval(relsuiteObj+['L2ConceptName']) + '<BR>' + eval(relsuiteObj+['L3ConceptName']);
//		popupContent = popupContent.replace(/'/g, "\\'");  // Replace all single quotes with \'
		var L1 = eval(relsuiteObj+['L1ConceptName']);
		var L2 = eval(relsuiteObj+['L2ConceptName']);
		var L3 = eval(relsuiteObj+['L3ConceptName']);
		L1 = L1.replace(/'/g, "\\'"); // Replace all single quotes with \'
		L2 = L2.replace(/'/g, "\\'");
		L3 = L3.replace(/'/g, "\\'");
		content = content + '<A href="' + relSuitesMenuFMT.linkurl + stguid + '" onMouseover="Javascript:writeParentSuitesContent(\'' + L1 +'\',\'' + L2 +'\',\'' + L3 +'\');parentSuites.moveTo(mouseX+(' + parentSuitesFMT.mouseOffsetX + '), mouseY+(' + parentSuitesFMT.mouseOffsetY + '));" onMouseout="javascript:parentSuites.hide();">' + ifDefined(sttext) + '</A>' + relSuitesMenuFMT.sep;
	}
    
    writeRelatedSuitesMenuContent(content);
    relSuitesMenu.moveTo(mouseX + relSuitesMenuFMT.mouseOffsetX, mouseY + relSuitesMenuFMT.mouseOffsetY);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsExDisplay() - display extract data
*                  Params: 
*                 Returns: extract info for book summary chapter
*  LLK 11/11/99 -  Modified
*  --------------------------------------------------------------------*/
function cbsExDisplay() {
 
 var chapNum = 0;
 var ebTitle;
 //var RealChapterNum = 0;
 var ChapterNumCorrection =0;
 var NonChapTitle = '';
 
 for (currentChap=0; currentChap < tChapCount; currentChap++) {
     exCount = eval('tChap' + currentChap + '.tExCount');
     if (exCount > 0) {
         chapNum = currentChap;

         checkchapnum();
         //checkexFID();
    
         // -- test for negative value indicating no chapters
         if (chapNum < 0) {
            // commented by ls 5/27/99
            alert("Sorry - no chapters exist in this book summary");
            return;
         }
   
         // -- test for no extracts in this chapter, find first viable chapter if none in current chapter...
         exCount = eval('tChap' + chapNum + '.tExCount');

         if (exCount <= 0) {
             nextchapnum = findnextchapnum(chapNum);
             if (nextExtNum < 0) return;
             chapNum = nextchapnum;
             var chapObj = ('tChap' + chapNum);
             exCount = eval(chapObj + '.tExCount');
         }
         else {
             var chapObj = ('tChap' + chapNum);    // example: "tChap1"
         }
   
    
         // -- Loop through all extracts in currently selected chapter and display
         for (xnum = 0; xnum < exCount; xnum++) {
                
             eObj = (chapObj + '.Ex' + xnum) ;     // example: "tChap1.Ex2"
             
			 if (xnum==0) document.write('<a name="Chap' + chapNum + '.Ex' + xnum + '"></a>');

             ebTitle  = ifDefined(eval(chapObj + '.tTitle')) ;
             eTitle  = ifDefined(eval(eObj + '.title')) ;
             eCutout = ifDefined(eval(eObj + '.cutout')) ;
             eNonChapTitle = ifDefined(eval(chapObj + '.NonChapTitle'));
                
             // -- Chapter title display (only for first extract)
             if (xnum == 0) {
				if (eNonChapTitle.length == 0)	{
				
					//RealChapterNum++;
					//document.write(exdispFMT.chapnumbeg + 'Chapter ' + RealChapterNum + exdispFMT.chapnumend);
					
					// Corrects bug (above commented code) introduced by Jeff's RealChapterNum display chapter logic
					document.write(exdispFMT.chapnumbeg + 'Chapter ' + (currentChap-ChapterNumCorrection+1) + exdispFMT.chapnumend);
				}
				else	{
					document.write(exdispFMT.chapnumbeg + eNonChapTitle + exdispFMT.chapnumend);
					ChapterNumCorrection++;
				}
				if(ebTitle) document.write(exdispFMT.chaptitlebeg + ebTitle + exdispFMT.chaptitleend);
                document.write(exdispFMT.chaptitlesep);
             }
                
             // -- Extract title display
             if(eTitle) document.write(exdispFMT.extitlebeg + eTitle + exdispFMT.extitleend);
             document.write(exdispFMT.exsep);
    
             // -- Extract cutout display
             if(eCutout) document.write(exdispFMT.cutoutbeg + eCutout + exdispFMT.cutoutend);
                
             // -- paragraphs within extract  
             var pcount = eval(eObj + '.parcount');
             var parObj = ('tChap' + chapNum + '.Ex' + xnum + '.Par');      
             for (i = 0; i < pcount ; i++) {
                 pagestart = ifDefined(eval(parObj + i + '.pagestart')); 
                 pageend = ifDefined(eval(parObj + i + '.pageend'));
                 partype = ifDefined(eval(parObj + i + '.partype'));
                 displaypageend = ifDefined(eval(parObj + i + '.displaypageend'));
                 displaypagestart = ifDefined(eval(parObj + i + '.displaypagestart')); 
                 partext = ifDefined(eval(parObj + i + '.text'));
				 if (displaypagestart.length == 0)
	                 document.write(exdispFMT.prbeg + pagestart + '-' + pageend + exdispFMT.prend);
				 else
	                 document.write(exdispFMT.prbeg + displaypagestart + '-' + displaypageend + exdispFMT.prend);
                 document.write(exdispFMT.parbeg + partext + exdispFMT.parend);
             }
                
             // -- Copyright for each extract on print pages only
             var loc = (document.location.href.indexOf('print'));
             if(loc > -1) {
               document.write(cbsCopyrightString());
             }
             
			 // -- Write link to related suites
			 var relcount = eval(eObj+'.'+['relsuitecount']);
			 if (relcount > 0) {
				 if (called_by_simple_summary) {
				 } else {
				     document.write('<A href="Javascript:displayRelatedSuitesMenu(' + chapNum + ',' + xnum + ');">' + relSuitesMenuFMT.prompt+ '</A><br><br>');
				 }
			 }
			 cbsExtNav(chapNum, xnum, exCount);
           
         }      // -- end loop for extracts in current chapter
  
         cbsChaptNav(chapNum);
     }
 }  // -- end loop for chapters
}

/* --------------------------------------------------------------------
*  FUNCTION cbsPrevExtract() - displays the first extractPreviewLength # of 
*								words in an extract.  This function will
*								span paragraphs to reach the correct length.
*								extractPreviewLength is defined in common.js
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsPrevExtract()
{
	var wordcnt = 0;
	var ext_preview = '';
	var endOfExtracts = false;
	var parCnt = -1;
	var curPar = '';
	var curParLen = 0;
	var curChar = 0;
	
	getNextExtractParagraph();
	if (curPar.length == 0)
	{
		ext_preview = exdispFMT.parbeg + 'Extract Preview Not Available' + exdispFMT.parend;
	}
	else
	{
		while ((wordcnt < extractPreviewLength) && (!endOfExtracts))
		{
			if (curPar.charAt(curChar) == ' ') wordcnt++;
			ext_preview = ext_preview + curPar.charAt(curChar);
			curChar++;
			if (curChar == curParLen)
			{
				ext_preview = ext_preview + exdispFMT.parend;
				curChar = 0;
				getNextExtractParagraph();
			}
		}
	}
	document.write(ext_preview);
	
	//****** start local functions   
	function getNextExtractParagraph()
	{
		var done = false;
	
		curPar = '';	
		parCnt++;
		endOfExtracts = (parCnt >= eParCount);

		while ((!done) && (!endOfExtracts))	
		{
			curPar = eParArray[parCnt];
			curParLen = curPar.length;
			if (SafeText() != 0)
			{
				done = true;
				// check to see if paragraph has been truncated
				if (curPar.length < curParLen) 
				{
					//parCnt = eParCount;
					curPar = curPar + '...';
					curParLen = curPar.length;
				}
				ext_preview = ext_preview + exdispFMT.parbeg;
			}
			else
				parCnt++;
			endOfExtracts = (parCnt >= eParCount);
			
		}
	}// end getNextExtractParagraph()
	
	function SafeText()
	{
		var htmlLoc =-1;
		htmlLoc = curPar.indexOf("<");
		if (htmlLoc == 0) return 0;
		if (htmlLoc > 0) curPar = curPar.substring(0,htmlLoc)
		return curPar.length;
	}// end SafeText()
}

/* --------------------------------------------------------------------
*  FUNCTION cbsExtractWordCount() - display word count for Extract
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsExtractWordCount() {
    if(eWordCount) document.write(eWordCountFMT.beg + eWordCount + eWordCountFMT.end);
}

/* --------------------------------------------------------------------
*  FUNCTION cbsExtractGifCount() - display Gif count for Extract
*                  Params:  none
*                  Returns: value of the attribute
*  --------------------------------------------------------------------*/
function cbsExtractGifCount() {
    if(eGifCount) document.write(eGifCountFMT.beg + eGifCount + eGifCountFMT.end);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsChapMenu() - create popup menu of chapters and extracts
*                 Params: 
*                  Calls: 
*                Returns: 
*  LLK 11/20/99 - modified
*  --------------------------------------------------------------------*/
function cbsChapMenu() { 
	var i, x, cTitle;
    var content = "";
    var chapNum = 0;
    var RealChapNum = 0;
    var eNonChapTitle = '';
    var tempChap = '';
  
//    chapMenu = new DynLayer('chapMenuDiv');
    chapMenu.dragActive = false;
    drag.add(chapMenu);
 	initMouseEvents();
	
    content = content + chapmenuFMT.popupbeg;

	// -- start table
	content = content + chapmenuFMT.tablebeg;  
	content = content + '<FONT face="Verdana, Arial, Helvetica, sans-serif" color="#683430" size=1>';   // -- force small paragraph line spacings

    // -- force chapNum to be an integer!
    chapNum = parseInt(0);
    
    if (chapNum == 0 && tChap0.tExCount == 0) chapNum = findnextchapnum(chapNum);
    // -- display the chapters in the array
    for (i = 0; i < tChapCount ; i++) {

        var exObj = ('tChap' + i + '.Ex');
        var exCount = eval(('tChap' + i + '.tExCount'));
        cTitle = ifDefined(eval('tChap' + i + ".tTitle")); 
        
        // ============== Determine what type of chapter this is ==============
        var ttype;
        if (i  == chapNum && exCount == 0) ttype = 'currNoEx';
        if (i  == chapNum && exCount  > 0) ttype = 'currYesEx';
        if (i !== chapNum && exCount  > 0) ttype = 'notcurrYesEx';
        if (i !== chapNum && exCount == 0) ttype = 'notcurrNoEx';
        // ====================================================================

		// Check for Non-Chapter title and use that if present instead of 'Chapter' 
        eNonChapTitle = ifDefined(eval('tChap' + i + '.NonChapTitle'));
        if (eNonChapTitle == '') {
			RealChapNum++;
			tempChap = chapmenuFMT.chapnumbeg + 'Chapter ' + RealChapNum + chapmenuFMT.chapnumend;
		}
        else	{
			tempChap = chapmenuFMT.chapnumbeg + eNonChapTitle + chapmenuFMT.chapnumend;			
        }

        // -- Write chapter title depending on its type
        nextchapNum = findnextchapnum(i);
        nextchapNum++;
        switch(ttype) {
            case 'currNoEx':
                if (chapmenuFMT.showemptychap == 'true') {
                    var cmd = (chapmenuFMT.chapoffbeg + cTitle + chapmenuFMT.chapoffend);
                    content = content + tempChap;
                    content = content + '<A HREF="#Chap' + (i+1) + '" onClick="javascript:chapMenu.hide();">' + cmd + '</A>';
                }
                break;
            case 'currYesEx':
                var cmd = (chapmenuFMT.chaponbeg  + cTitle + chapmenuFMT.chaponend);
                content = content + tempChap;
                content = content + '<A HREF="#Chap' + (i+1) + '" onClick="javascript:chapMenu.hide();">' + cmd + '</A>';
                break;
            case 'notcurrYesEx':
                var cmd = (chapmenuFMT.chapoffbeg + cTitle + chapmenuFMT.chapoffend);
                content = content + tempChap;
                content = content + '<A HREF="#Chap' + (i+1) + '" onClick="javascript:chapMenu.hide();">' + cmd + '</A>';
                break;
            case 'notcurrNoEx':
                if (chapmenuFMT.showemptychap == 'true') {
                    var cmd = (chapmenuFMT.chapoffbeg + cTitle + chapmenuFMT.chapoffend);
                    content = tempChap;
                    content = content + '<A HREF="#Chap' + (i+1) + '" onClick="javascript:chapMenu.hide();">' + cmd + '</A>';
                }
                break;
         }

         // ---- display the extract titles in current chapter
         for (x = 0; x < exCount  ; x++) {
			if (exCount > 0) {
                var exTitle = ifDefined(eval(exObj + x + '.title' ));
                var exGuid  = ifDefined(eval(exObj + x + '.exguid'));
				content = content + '<A HREF="#Chap' + i + '.Ex' + x + '" onClick="javascript:chapMenu.hide();">';
				if (i == chapNum) {
                    content = content + chapmenuFMT.exonbeg  + exTitle + chapmenuFMT.exonend;
                } else {
                    content = content + chapmenuFMT.exoffbeg + exTitle + chapmenuFMT.exoffend;
                }
                content = content + '</A>';
            }
        }
        
        // ---- end display of extract titles, write chapter separator 
        if (exCount > 0)
            content = content + chapmenuFMT.chapsep;
        else if (chapmenuFMT.showemptychap == 'true') {
            content = content + chapmenuFMT.chapsepnoex;
        }
    }
    
    // ---- end display of chapter menu
    content = content + '</FONT>';
    content = content + chapmenuFMT.tableend;
    content = content + chapmenuFMT.popupend;

    chapMenu.write(content);
	drag.setGrab(chapMenu, 0, chapmenuFMT.grabwidth, chapmenuFMT.grabheight, 0)
}


/* --------------------------------------------------------------------
*  FUNCTION relSuites() - display all related suites for title
*                  Params: 
*                   Calls:
*                 Returns: display of related suite information w/links
*  --------------------------------------------------------------------*/
function relSuites() {
	var relnum, maxresults;
    // -- test for negative value indicating no chapters
    if (FORM_DATA.chapNum < 0) return ;
    if (SuiteCount == 0) return ;
    document.write(relSuitesFMT.prompt);
    document.write(relSuitesFMT.beg) ;
    maxresults = (relSuitesFMT.maxresults < SuiteCount) ? relSuitesFMT.maxresults + 1 : SuiteCount ;
    for (relnum = 0; relnum < maxresults ; relnum++) {
        sttext = ifDefined(Suites[relnum].Name);
        stguid = ifDefined(Suites[relnum].Id);
        if(!relSuitesFMT.linkurl) {
            document.write(sttext + relSuitesFMT.sep);
        }
        else {
            document.write('<A href=' + relSuitesFMT.linkurl + stguid + '>' + sttext + '</A>' + relSuitesFMT.sep);
        }
    }
    document.write(relSuitesFMT.end); 
}


/* --------------------------------------------------------------------
*  FUNCTION exrelsuitehint() - display hint if there are suites for an extract
*  --------------------------------------------------------------------*/
function exrelsuitehint(hintstr) {
	var exCount = eval('tChap' + FORM_DATA.chapNum + '.tExCount');
	var isRelSuites = 'false';
    for (var e = 0; e < exCount; e++) {
        var exObj = ('tChap' + FORM_DATA.chapNum + '.Ex' + e);  // "tChap[x].Ex[e]"
        var relcount = eval(exObj+'.'+['relsuitecount']);
        isRelSuites = (relcount > 0) ? 'true' : 'false' ;
    }
	if (isRelSuites == 'true') document.write(hintstr);
}


/* --------------------------------------------------------------------
*  FUNCTION cbsConCheckBoxes() - display checkbox form inputs for all concepts
*                  Params:
*                   Calls:
*                 Returns: 
*  --------------------------------------------------------------------*/
function cbsConCheckBoxes() {
	var i;
    for (i = 0; i < tConArray.length ; i++) {
        //var conPercent = Math.round(sConThermoArray[i]);
        //if (isNaN(conPercent)) conPercent = 0;
        document.write('<INPUT id=' + tConGuidArray[i] + ' name=relconcepts value=' + tConGuidArray[i] + ' type=checkbox >' + tConArray[i] + '<BR>');
        
        // -- draw strength graph
        //if (!conPercent == 0) document.write('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#993399><img src=../../images2/9.gif width=' + conPercent + ' height=8 vspace=2> (' + conPercent + '%)</FONT><BR>');
    }
}


/* --------------------------------------------------------------------
*  FUNCTION cbsAuthorCheckBoxes() - display checkbox form inputs for all authors
*                  Params: 
*                   Calls:
*                 Returns: 
*  --------------------------------------------------------------------*/
function cbsAuthorCheckBoxes() {
	var i;
    for (i = 0; i < tAuthorArray.length ; i++) {
        document.write('<INPUT id=' + tAuthorGuidArray[i] + ' name=authors value=' + tAuthorGuidArray[i] + ' type=checkbox >' + tAuthorArray[i] + '<BR>');
    }
}


/* --------------------------------------------------------------------
*  FUNCTION findnextchapnum() - finds next non-empty chapter number
*                  Params: chapNum
*                 Returns: number of next non-empty chapter
*                          This tests for the next chapter with extracts or
*                          runs out of chapters.  Return last valid one if none are next
*  --------------------------------------------------------------------*/
function findnextchapnum(chapNum){    
	chapNum = parseInt(chapNum);    
	var nextNum = '-1' ; 
	if (chapNum < tChapCount-1) {	// -- more chapters exist after current one
									// -- test each chapter until we get one with an extract to be the "next" one...
		for (testChap = chapNum+1; testChap <= tChapCount -1; testChap++) {
			testExCount = eval('tChap' + testChap + '.tExCount');
			if (testExCount > 0) {
				nextNum = testChap;
				break;
			}
		}
	}
	return nextNum;
}


/* --------------------------------------------------------------------
*  FUNCTION findprevchapnum() - finds previous non-empty chapter number
*                  Params: chapNum
*                 Returns: number of next non-empty chapter
*                          This tests for the previous chapter with extracts or
*                          runs out of chapters.
*  --------------------------------------------------------------------*/
function findprevchapnum(chapNum) { 
	chapNum = parseInt(chapNum);  
	var prevNum = '-1';   
	if (chapNum > 0){	// -- more chapters exist before current one
						// -- test each chapter until we get one with an extract to be the "previous" one...
		for (testChap = chapNum-1; testChap >= 0; testChap--) {
			testExCount = eval('tChap' + testChap + '.tExCount');
			if (testExCount > 0) {
				prevNum = testChap;
				break;
			}
		}
	}
	return prevNum;
}


/* --------------------------------------------------------------------
*  FUNCTION cbsExlistPrev() - display PREVIEW array of extracts
*                  Params: none
*                 Returns: list of extracts in table format
*  --------------------------------------------------------------------*/
function cbsExlistPrev(){
    var i;
    //var RealChapterNum = 0;
	var ChapterNumCorrection =0;     
    var eNonChapTitle = '';

    if(tChapCount < 1) return;
    
    document.write(eprevFMT.tablebeg);  // -- Start table
    for (i = 0; i < tChapCount ; i++) {
        // -- Chapter title
        cObj = 'tChap' + i;
        cTitle = ifDefined(eval(cObj + '.tTitle'));
        document.write(eprevFMT.chapcellbeg);
        
        eNonChapTitle = ifDefined(eval(cObj + '.NonChapTitle'));
		if (eNonChapTitle.length == 0)	{
		
			//Jeff's Chpt number display bug
			//RealChapterNum++;
			//document.write(eprevFMT.chapnumbeg + 'Chapter ' + (RealChapterNum) + eprevFMT.chapnumend);
			
			// Makes this logic similiar to cbsExDisplay function
			document.write(eprevFMT.chapnumbeg + 'Chapter ' + (i-ChapterNumCorrection+1) + eprevFMT.chapnumend);
		}
		else	{
			ChapterNumCorrection++
			document.write(eprevFMT.chapnumbeg + eNonChapTitle + eprevFMT.chapnumend);
			
		}
        document.write(cTitle + eprevFMT.chapcellend);
        
        // -- Extract Block
        var exCount = eval(cObj + '.tExCount');
        for (x = 0; x < exCount ; x++) {
            if (exCount > 0) { 
                var exObj = ('tChap' + i + '.Ex' + x);
                var exTitle = ifDefined(eval(exObj + '.title'))
                var exCutout = ifDefined(eval(exObj + '.cutout'));
			    var exLen = ifDefined(eval(exObj + '.wordcount'));              
                document.write(eprevFMT.exblockbeg);
                if(exTitle) document.write(eprevFMT.titlebeg + exTitle + eprevFMT.titleend);
			    if(exCutout) document.write(eprevFMT.cutoutbeg + exCutout + eprevFMT.cutoutend);
				document.write(eprevFMT.lengthbeg + exLen + eprevFMT.lengthend);
			    //if (ifDefined(eval(exObj + '.owned'))=='true') document.write(eprevFMT.ownedmsg) ;
                document.write(eprevFMT.exblockend);
            }
        }
        if (exCount == 0) {
            document.write(eprevFMT.noexblockbeg);
            document.write(eprevFMT.noextracts);
            document.write(eprevFMT.exblockend);
        }
    }
    document.write(eprevFMT.tableend) ; //-- Close table
}


/* --------------------------------------------------------------------
*  FUNCTION txtgrb() - get highlighted selection of text
*  --------------------------------------------------------------------*/
 function txtgrb() {
    if (navigator.appName == "Netscape") {
        srchstr = escape(document.getSelection());
    } else if ( navigator.appName == "Microsoft Internet Explorer" && document.selection.type == "Text" ) {
        txt = document.selection.createRange();
        srchstr=escape(txt.text);
    }
        
    // -- globally replace odd characters in string(single quotes, double quotes..etc.)
    srchstr = srchstr.replace(/(\%0D|\%0A|\%20)+/g,"%20");
    srchstr = srchstr.replace(/(\'|\"|%27)+/g,"");
    srchstr = srchstr.replace(/(\r\n)+/g,"%20");
}


/* --------------------------------------------------------------------
*  FUNCTION mkstr() - create string of search query from txtgrb()
*  --------------------------------------------------------------------*/
 function mkstr() {
    if (srchstr.length > 0) {
        url="summary_results2.asp?libs=Titles" + "&Page=1" + "&pageLen=10" + "&queryText=" + srchstr ;
        document.location = url;
    } 
    else { alert('Please highlight a word, sentence or entire block of text for HotSearch to work!') }
  }


/* --------------------------------------------------------------------
*  FUNCTION hotsearch() - display hotsearch prompt and button
*                  CALLS: txtgrb(), mkstr()
*  --------------------------------------------------------------------*/
function hotsearch(){
    document.write(hotsearchFMT.beg);
   	if (is.ie && is.mac) {
		document.write('<a href="javascript:alert(\'Sorry, Hot Search is unavailable on Internet Explorer for the Mac because Microsoft does not provide full DHTML objects on this platform. It will work wonderfully under Netscape 4.5+\');">');
	} else {
		document.write('<a href="search.asp" onMouseOver="txtgrb();" onClick="mkstr();return false;">');
	}
    document.write('<img src=' + hotsearchFMT.picsrc + " " + hotsearchFMT.picFMT + '></a>');
    document.write(hotsearchFMT.end);
}


/* ----------------------------------------------------------------------------
*  FUNCTION price_p() - display retail and/or discounted price for preview page
*  ----------------------------------------------------------------------------*/
function price_p(){

    // -- Do not show price if subscriber site...
    
    if(isSubscriberSite=='True' && UnitType == 'CC') return ;
    if(isSubscriberSite=='True' && UnitType == '') return ;
    
    // -- If TokenPriceAsProductUnit is True, run special price display, not this...

    //if(typeof(TokenPriceAsProductUnit) == 'undefined') {alert('testing');}
    //if(TokenPriceAsProductUnit == 'True') { }
    
    // -- Do not show price if CtokenPurchConfirm is "false" and CORP Units are available
    
    if(CtokenPurchConfirm == 'false' && UnitType == 'CORP') return ;
    
    // -- Add decimals to whole number prices if needed for display prices
    
    var RetailPrice, DiscPrice, decpos;
    
    // -- convert to string
    
    RetailPrice = TitlePrice.toString();
    DiscPrice   = DiscountPrice.toString();
    UnitPrice   = Math.floor(TitlePrice) ;
    
    // -- if price string has decimal, return substring (truncate to 2 places to right of decimal)
    // -- if no decimal, add it plus zeros to make price look nice (12.00 instead of 12)
    
    decpos = RetailPrice.indexOf('.')
    RetailPrice = (decpos>0) ? RetailPrice.substr(0,decpos + 3) : RetailPrice + '.00' ;
    decpos = DiscPrice.indexOf('.')
    if(decpos>0) DiscPrice = DiscPrice.substr(0,decpos + 3); 
    DiscPrice = (decpos>0) ? DiscPrice.substr(0,decpos + 3) : DiscPrice + '.00' ;
    if(!priceFMT.unitcalled || priceFMT.unitcalled == 'undefined') { priceFMT.unitcalled = ' ' ; }
    
    // -- if user already owns the Title (owned = 1), don't display price!

    if(!Owned) Owned = 0;   // assume no ownership if var is undefined!
    
    // -- Display price HTML based on UnitType values set by COM/ASP in InitUser.asp
    
    if(Owned < 1) {
        var UnitBalance = (UnitCount - UnitPrice);
        switch (UnitType) {
            case 'USER' :
                document.write(priceFMT.unitbeg);
                document.write(UnitPrice);
                document.write(' ' + priceFMT.unitcalled);
                document.write(priceFMT.unitend);
                // -- check to see if there are insufficient tokens!
                if(UnitBalance<1) {
                    //document.write(priceFMT.insufftokensbeg + ' (' + UnitCount + ')' + priceFMT.insufftokensend);
                    //stdofferbutts() ;
                }
                else {
                    if(priceFMT.unitbalance=='on') { document.write(priceFMT.unitbalbeg + 'You will have ' + UnitBalance + ' ' + priceFMT.unitcalled + ' left after this purchase.' + priceFMT.unitbalend); }
                }
                break;
            case 'CORP' :
                document.write(priceFMT.unitbeg);
                document.write(UnitPrice);
                document.write(' ' + priceFMT.unitcalled);
                document.write(priceFMT.unitend);
                break;
            default :
                if (PriceFactor < 1) document.write(priceFMT.discbeg + DiscPrice + priceFMT.discend);
                document.write(priceFMT.regbeg);
                document.write( (priceFMT.strikeout == 'on' && PriceFactor < 1) ? '<i><strike>' + RetailPrice + '</i></strike>' : RetailPrice );
                document.write(priceFMT.regend);
                break;
        }
    }
}

/* --------------------------------------------------------------------
*  FUNCTION price() - display retail and/or discounted price on 
*                     purchase_confirm screens.
*                     display units instead of $ if appropriate
*  --------------------------------------------------------------------*/

function price(){
    // -- Do not show price if subscriber site...
    
    if(isSubscriberSite.toLowerCase() == 'true' && UnitType == 'CC') return ;

    var RetailPrice, DiscPrice, UnitPrice, decpos;
    
    // -- convert values to strings
    // -- make UnitPrice=SuitePrice (rounded down) for now...
        
    RetailPrice = TitlePrice.toString();
    DiscPrice   = DiscountPrice.toString();
    UnitPrice   = Math.floor(TitlePrice) ;
    
    // -- if price string has decimal, return substring (truncate to 2 places to right of decimal)
    // -- if no decimal, add it plus zeros to make price look nice (12.00 instead of 12)
    
    decpos = RetailPrice.indexOf('.')
    RetailPrice = (decpos>0) ? RetailPrice.substr(0,decpos + 3) : RetailPrice + '.00' ;
    decpos = DiscPrice.indexOf('.')
    if(decpos>0) DiscPrice = DiscPrice.substr(0,decpos + 3); 
    DiscPrice = (decpos>0) ? DiscPrice.substr(0,decpos + 3) : DiscPrice + '.00' ;
    if(!priceFMT.unitcalled || priceFMT.unitcalled == 'undefined') { priceFMT.unicalled = '' }
    
    // -- if user already owns the item (owned = 1), don't display price!

    if(!Owned) Owned = 0;   // -- assume no ownership if var is undefined!
    
    // -- Display price HTML based on UnitType values set by COM/ASP in InitUser.asp
    
    if(Owned < 1) {
        var UnitBalance = (UnitCount - UnitPrice);
        switch (UnitType) {
            case 'USER' :
                document.write(priceFMT.unitbeg);
                document.write(UnitPrice);
                document.write(' ' + priceFMT.unitcalled);
                document.write(priceFMT.unitend);
                // -- check to see if there are insufficient tokens!
                if(UnitBalance<1) {
                    document.write(priceFMT.insufftokensbeg + ' (' + UnitCount + ')' + priceFMT.insufftokensend);
                    stdofferbutts() ;
                }
                else {
                    document.write(priceFMT.unitbalbeg + UnitBalance + priceFMT.unitcalled + ' will be your balance after this purchase.' + priceFMT.unitbalend);
                }
                break;
            case 'CORP' :
                document.write(priceFMT.unitbeg);
                document.write(UnitPrice);
                document.write(' ' + priceFMT.unitcalled);
                document.write(priceFMT.unitend);
                break;
            default :
                //if (PriceFactor < 1) document.write(priceFMT.discbeg + DiscPrice + priceFMT.discend);
                //document.write(priceFMT.regbeg);
                //document.write( (priceFMT.strikeout == 'on' && PriceFactor < 1) ? '<i><strike>' + RetailPrice + '</i></strike>' : RetailPrice );
                //document.write(priceFMT.regend)
                // -- *** SPECIAL HARDWIRE OF PRICING FOR INTRO ONLY! ***
                //document.write('Price: $15.00</strike> &nbsp;&nbsp;<b>Intro Price: $9.00</b>');
                document.write('<span class=TextStyleSansLg><span class=TextColorRed><b>$9.00</b> </span></span>');
                break;
        }
    }
}

/* --------------------------------------------------------------------
*  FUNCTION billto() - display method of billing for product
*  --------------------------------------------------------------------*/

function billto(){
    
    // -- Display billing HTML based on UnitType values set by COM/ASP in InitUser.asp

        switch (UnitType) {
            case 'USER' :
                document.write(billtoFMT.userunitbeg);
                document.write(Uname);
                document.write(billtoFMT.userunitend);
                break;
            case 'CORP' :
                document.write(billtoFMT.corpunitbeg);
                document.write(Uname);
                document.write(billtoFMT.corpunitend);
                break;
            default :
                document.write(billtoFMT.ccbeg);
                document.write(Uname);
                document.write(billtoFMT.ccend);
                break;
        }
}

/* -----------------------------------------------------------------------------
*  FUNCTION stdofferbutts() - display standard offer link button in purchase
*                             confirm page
*  -----------------------------------------------------------------------------*/

function stdofferbutts(){
    document.write('<a href=JavaScript:link2offer();>' + offerFMT.offerlink + '</a>');
}

/* -----------------------------------------------------------------------------
*  FUNCTION link2offer() - redirects window to offer page.
*                          Retired code is from old popup window system.
*                          offerurl var is defined and set in Preview_Inc.asp
*  -----------------------------------------------------------------------------*/

function link2offer() {
    document.location.href = offerurl ;
    //opener.location.href = offerurl ;
    //self.close();
}

/* ---------------------------------------------------------------------------------------
*  FUNCTION buybutts_p() - display buyit or viewit buttons for preview page
*           PARAMS: none
*           Do not show button if account is disabled or expired
*           Don't show buttons if account is disabled or expired.
*           Test token purchase path behavior setting (CtokenPurchConfirm) set in 
*           Dimvars.asp and written in preview_inc.asp.
*           HYPERLINK STRINGS:
*           vPrompt  = "view it" button
*           bPrompt  = "buy it" button for cash mode
*           tPrompt  = "buy it" button for token mode
*           hbPrompt = "hidden buy it" button (shows "view it" but actually executes a 
*                      purchase_confirm "buy it" path)...used for "hidden token" modes
*                      where CtokenPurchConfirm is set to "false" so user never sees
*                      token purchase confirmation screen.
*  ---------------------------------------------------------------------------------------*/

function buybutts_p(){
	// -- Test when subscription or bad CC is detected
	
    if(AccountStatus == '2' || AccountStatus == '3'){
        if(UnitType != 'CORP') return ;
    } 
    
   // -- BUILD POSSIBLE HYPERLINK PROMPT STRINGS
    
    var vPrompt, bPrompt, tPrompt, hbPrompt ;
    
    /* -- RETIRED CODE FOR POPUP PURCHASE PATH
    vPrompt  = '<a href=' + buybuttsFMT.vurl + FID + '><IMG SRC=' + buybuttsFMT.vimg + '></a>' ;
    bPrompt  = '<a href=Javascript:ppathwindow("' + buybuttsFMT.burl + FID + '")><IMG SRC=' + buybuttsFMT.bimg + '></a>' ;
    tPrompt  = '<a href=Javascript:ppathwindow("' + buybuttsFMT.burl + FID + '")><IMG SRC=' + buybuttsFMT.bimg + '></a>' ;
    hbPrompt = '<a href=Javascript:ppathwindow("' + buybuttsFMT.burl + FID + '")><IMG SRC=' + buybuttsFMT.vimg + '></a>' ;
    -- END RETIRED CODE */
    
    vPrompt  = '<a href=' + buybuttsFMT.vurl + FID + '><IMG SRC=' + buybuttsFMT.vimg + '></a>' ;
    bPrompt  = '<a href="' + buybuttsFMT.burl + FID + '")><IMG SRC=' + buybuttsFMT.bimg + '></a>' ;
    tPrompt  = '<a href="' + buybuttsFMT.burl + FID + '")><IMG SRC=' + buybuttsFMT.bimg + '></a>' ;
    hbPrompt = '<a href="' + buybuttsFMT.burl + FID + '")><IMG SRC=' + buybuttsFMT.vimg + '></a>' ;
    
    // -- IF PRODUCT IS ALREADY OWNED...show view button only
    
    if (Owned == 1) { document.write(vPrompt); return ; }
	
    // -- NOT OWNED...no user or corp token modes available (UnitType = "" or "CC")...show $-formatted "buyit" button
    if (Owned < 1 && UnitCount == 0 && (UnitType == '' || UnitType == 'CC')) {
        if (isSubscriberSite.toLowerCase() == 'false') {
            document.write(bPrompt);
		}
		else {
		    document.write(vPrompt);
		}
		return ;
    }

    // -- NOT OWNED...user or corp token mode available...show token-formatted "buyit" button
    if (Owned == 0 && (UnitType == 'USER' || UnitType == 'CORP')) {
        if (CtokenPurchConfirm == 'true') { 
            document.write(tPrompt); 
        }
        else {
            document.write(hbPrompt); 
        }
        return ;
    } 
}

/* ----------------------------------------------------------------------------------
*  FUNCTION buybutts() - display buyit or viewit buttons for purchase confirm screen
*                        Do not show buttons if account is disabled or expired
*  ----------------------------------------------------------------------------------*/
function buybutts(){

	// -- Test when subscription or bad CC is detected
	
    if(AccountStatus == '2' || AccountStatus == '3'){
        if(UnitType != 'CORP') return ;
    } 
	            
    // -- display offers button instead of buy button if personal unit balance is insufficient (UnitType="USER" only)
    
    if(UnitType == 'USER') {
        var UnitPrice   = Math.floor(TitlePrice) ;
        var UnitBalance = (UnitCount - UnitPrice) ;  
        if(UnitCount < UnitPrice) { return ; }
    }
    
    // -- If subscription site, or user owns the book summary, show view button only
    
    if(isSubscriberSite.toLowerCase() =='true' && Owned == 1) {
        document.write('<a href=' + buybuttsFMT.vurl + FID + '><IMG SRC=' + buybuttsFMT.vimg + '></a>');
        return;
    } 
    if(Owned < 1) {
        document.write('<a href=' + buybuttsFMT.burl + '><IMG SRC=' + buybuttsFMT.bimg + '></a>');
    }
    else {
        document.write('<a href=' + buybuttsFMT.vurl + FID + '><IMG SRC=' + buybuttsFMT.vimg + '></a>');
    }
}


/* --------------------------------------------------------------------
*  FUNCTION Add2Lib() - add book summary content to library
*           PARAMS:   mode (either blank or "button")
*                     blank displays form-like elements on purchase
*                     confirmation pages, while "button" displays
*                     a button which pops up a window with the form-like
*                     elements.
*  --------------------------------------------------------------------*/
function Add2Lib(mode){
    if(Libraried > 1) return;
    if(!mode) {
        document.write(Add2LibFMT.prompt1 + Add2LibFMT.promptend) ;
        document.write('<FORM name="add2libform" method="post" action="/mbscripts2/libaddcontent.asp">');
        document.write('<INPUT type="checkbox" name="add2libcheck" value="add2libfolder" checked>') ;
        document.write('<INPUT type="hidden" name="FoldId" value="">')
        document.write('<INPUT type="hidden" name="FID" value="">')
        document.write('<INPUT type="hidden" name="Dest" value="summary.asp">')
        document.write(Add2LibFMT.prompt2 + Add2LibFMT.promptend) ;
        document.write(Add2LibFMT.prompt3 + Add2LibFMT.promptend) ;
        fmenu();
        document.write(Add2LibFMT.prompt4 + Add2LibFMT.promptend) ;
        document.write('<TEXTAREA name="Comment" cols="40" rows="4" wrap="PHYSICAL"></TEXTAREA>') ;
        document.write('</FORM>');
    }
    else {
        document.write('<a href="JavaScript:addLibContDialog()"><img src="../../images2/add_to_library.gif" width="131" height="19" border="0" align="absmiddle" alt="Add to your library"></a>&nbsp;&nbsp;');
    }
}



/*--------------------------------------------------------------------------
* FUNCTION addLibContDialog() Create popup for adding content to library
*                             Sets "libs" variable depending on calling page
*---------------------------------------------------------------------------*/
function addLibContDialog(){
    var Ctype, urltest, libs ;
    urltest = document.URL.toLowerCase() ;
    if(urltest.indexOf('extract')>0) libs = 'Extracts' ;
    if(urltest.indexOf('summary')>0) libs = 'Titles' ;
    if(urltest.indexOf('suite')>0)   libs = 'Suites' ;
    var addcontent = window.open('LibAddContent_cbs.asp?FID=' + FID,'LibAddContent_cbs','width=500,height=425,scrollbars=yes,resizable=yes');
}


/* ------------------------------------------------------------------------------
*  FUNCTION BuyMe() - buys the selected product, optionally adding content
*                     to library if user selects that option.
*                     Runs purchase routine, then returns.
*                     If OK from purchase routine, check to see
*                     if user wants to add this to the library also.
*                     If so, libaddcontent.asp redirects to product page.
*                     Otherwise, we redirect to product page from here if
*  ------------------------------------------------------------------------------*/
function BuyMe(FID) {
    var FoldId, SelectedItem, a2L ;
	if(add2LibEnabled.toLowerCase() == 'true') {  
		 //-- check to see if there was a selection box rendered in fmenu()
		if (document.add2libform.folders) {
			SelectedItem = (document.add2libform.folders.options.selectedIndex);
			FoldId       = (document.add2libform.folders[SelectedItem].value) ;
		}
		else {
			FoldId = '' ;
		}
		// -- Perform trip to purchase processing page (hidden)
		// -- Is add2library (a2L) desired?
		a2L = (document.add2libform.add2libcheck.checked) ? 'true' : 'false' ;
	}	
	else { 
		a2L = 'false' ;
	} 

    document.add2libform.action = '/mbscripts2/purchase.asp?FID=' + FID + 
                                  '&mode=purchase' + 
                                  '&a2L=' + a2L + 
                                  '&faildest=profile_personal.asp' +
                                  '&SiteDir=' + SiteDir +
                                  '&Db=' + Db +
                                  '&ctype=Title' ;

    if (a2L == 'true') { 
        // -- If prep routine of the library comment returns 'false' abort this purchase routine!
        if (prepLibComment() == 'false') {return ; }
        document.add2libform.action += '&FoldId=' + FoldId +
                                       '&Comment=' + escape(document.add2libform.Comment.value) ;        
        }
                     
  document.add2libform.submit();  
}

/* --------------------------------------------------------------------------------
*  FUNCTION prepLibComment() - Prepare library comment for submission
*                              Detects if comment is more than 250 characters.
*                              If > 250 chars..presents dialog box to user so they
*                              can see the truncated version and accept it if OK.
*                              Returns "true" if OK to submit.
*                              Returns "false" if user wants to edit comment first.
*---------------------------------------------------------------------------------*/

function prepLibComment() {

    var FoldId, SelectedItem ;
    
    // -- check to see if there was a selection box rendered in fmenu()
    
    if (document.add2libform.folders) {
        SelectedItem = (document.add2libform.folders.options.selectedIndex) ;
        FoldId       = (document.add2libform.folders[SelectedItem].value) ;
    }
    else {
        FoldId = '' ;
    }
    
    // -- set values of hidden fields to be POSTed, then submit form.
    // -- form add2libform is created by Add2Lib() function embedded in the page.
    
    document.add2libform.FoldId.value = FoldId;
    document.add2libform.FID.value    = FID;
    
    // -- truncate comment to 250 chars before submittal..give user chance to edit it if too long.  
          
    var Comment, msg, truncComment ;
    Comment = document.add2libform.Comment.value ;
    truncComment = Comment.substr(0,250) ;
    
    msg = 'THE COMMENT YOU ENTERED EXCEEDS 250 CHARACTERS IN LENGTH.' + '\n\n' ;
    msg += 'Click "OK" to truncate the comment to 250 characters as shown below.' + '\n' ;
    msg += 'Click "Cancel" to edit the comment before submitting it.' + '\n\n' ;
    msg += 'You may always edit this note in your Library.' + '\n'
    msg += '_________________' + '\n\n' ;
    msg += 'ORIGINAL MESSAGE:' + '\n\n' ;
    msg += Comment + '\n\n' ;
    msg += '_________________' + '\n\n' ;
    msg += 'MESSAGE TRUNCATED TO 250 CHARACTERS  (if you press OK):' + '\n\n' ;
    msg += truncComment + '\n' ; 
    msg += '_________________'+ '\n\n' ;
    msg += 'Click OK to accept the truncated note or Cancel to edit your note before submittal.'
    
    if (Comment.length > 250) {
        if (!confirm(msg)) {
            return 'false' ;
        }
        else {
            Comment = truncComment ;
        }
    } 

    // -- globally replace odd characters in string(single quotes, double quotes..etc.)
    
    Comment = Comment.replace(/(\%0D|\%0A|\%20)+/g,"%20");
    Comment = Comment.replace(/(\'|\"|%27)+/g,"");
    Comment = Comment.replace(/(\r\n)+/g,"%20");
    
    document.add2libform.Comment.value = Comment ;  
}



/* --------------------------------------------------------------------
*  FUNCTION conGraph() - display concept percentage chart
*                  Params: gets current array index (i) from FORM_DATA.exNum
*                   Calls:
*                 Returns:
*  --------------------------------------------------------------------*/

function numberorder(a,b) {return a - b;}  // -- helper function
function conGraph() {

    document.write(conGraphFMT.thermoprompt);
    for(i=0; i<ConceptCount; i++) {
        var thermo = Math.ceil(Concepts[i].Thermo) ;
        var conName = Concepts[i].Name ;
        document.write(conGraphFMT.thermobeg);
        if (thermo <= 5) document.write('<img src="../../images2/rel1.gif"' + conGraphFMT.thermoimgfmt + '>');
        if (thermo > 5 && thermo <= 10) document.write('<img src="../../images2/rel2.gif"' + conGraphFMT.thermoimgfmt + '>');
        if (thermo > 10 && thermo <= 20) document.write('<img src="../../images2/rel3.gif"' + conGraphFMT.thermoimgfmt + '>');
        if (thermo > 20 && thermo <= 50) document.write('<img src="../../images2/rel4.gif"' + conGraphFMT.thermoimgfmt + '>');
        if (thermo > 50) document.write('<img src="../../images2/rel5.gif"' + conGraphFMT.thermoimgfmt + '>');;
        document.write('&nbsp;' + conName);
        document.write('&nbsp;(score=' + thermo + ')&nbsp;')
        document.write(conGraphFMT.thermosep);
    }
    document.write(conGraphFMT.thermoend);
}


/* ------------------------------------------------------
*  FUNCTION buybook() - link to book purchasing partner
*                       Default link is set in dimvars.asp
*                       for each partner site.
* -------------------------------------------------------*/
function buybook(buybookbeg,buybookend) {
    // -- trim string of all spaces, then check for string length >9
    var trimmedIsbn ;
    trimmedIsbn = tIsbn.replace(/ /g, "");
    if (!tIsbn || trimmedIsbn.length < 10) {
        alert('Unavailable for purchase through MeansBusiness.')
        return;
    }
    window.open(buybookbeg + trimmedIsbn + buybookend,"buybook","height=500,width=750,left=50,top=50,screenx=50,screeny=50,location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes")
}


/* ----------------------------------------------------------------------------
*  FUNCTION SetEmailLinkText() - Sets hypertext link text for emailing links!
*  ----------------------------------------------------------------------------*/
    function SetEmailLinkText() {
        var title = ifDefined(tTitle);
        var description = ifDefined(tDescription);
        document.emaillink.LinkText.value = title ;
        document.emaillink.Leadin.value = description ;
}


/* ----------------------------------------------------------------------------
*  FUNCTION authorBio() - Displays author bio information
*  ----------------------------------------------------------------------------*/
function authorBio() {
    // -- put bio data into hidden form field to pass to another page!
        
    // -- build tilde "~" separated list of authors for array to bio page
    var authlist = '' ;
    for (i=0; i<tAuthorArray.length; i++) {
        authlist = authlist + tAuthorArray[i];
        if(i < tAuthorArray.length-1) authlist = authlist + '~' ;
    }
    document.summaryFRM.tBiography.value = escape(tBiography) ;
    document.summaryFRM.tAuthors.value = escape(authlist) ;
    document.summaryFRM.tTitle.value = escape(tTitle) ;
    document.summaryFRM.submit();
}


/* --------------------------------------------------------------------
*  FUNCTION DynMouseDown() - Hooks into the Dynalib mouse events
*                 Params: 
*                  Calls: 
*  LLK 11/20/99 -  Created
*  --------------------------------------------------------------------*/
function DynMouseDown(x,y) {
	mouseDownX = x
	mouseDownY = y
	mouseX = x
	mouseY = y
	return true
}


/* --------------------------------------------------------------------
*  FUNCTION DynMouseMove() - Hooks into the Dynalib mouse events
*                 Params: 
*                  Calls: 
*  LLK 11/20/99 -  Created
*  --------------------------------------------------------------------*/
function DynMouseMove(x,y) {
	mouseX = x
	mouseY = y
	return true
}


/* --------------------------------------------------------------------
*  FUNCTION DynMouseUp() - Hooks into the Dynalib mouse events
*                 Params: 
*                  Calls: 
*  LLK 11/20/99 -  Created
*  --------------------------------------------------------------------*/
function DynMouseUp(x,y) {
	mouseUpX = x
	mouseUpY = y
	return true
}


//== RUN ROUTINES BELOW ON PAGE LOAD ==
FORM_DATA.chapNum = 0;    
FORM_DATA.exNum = 0;

