//--- Create menu array. ---//
var activePage = 0
var cell = new Array(8) 


//--- Stuff the array entries with objects. ---// 


//--- The cell "Cell[0]" contains the data to control the copyright, the second imprint and the book title.  List the data as: --//
//--- Copyright Year, Base Imprint Logo filename, Imprint alt text, Book title, Secondary title  --//


cell[0] = new Array("2004", "PrenticeHall", "Pearson Prentice Hall","Canadian Tax Principles","2003-2004 Edition, Clarence Byrd and Ida Chen")


//--- The rest of the cells contains the data that controls the menu, and the page header.  List the data as: --//
//--- URL, ImageName, Alt  --//


cell[1] = new Array("index", "welcome", "Welcome")
cell[2] = new Array("contents", "toc", "Table of Contents")  
cell[3] = new Array("preface", "preface", "Preface")
cell[4] = new Array("new", "newimproved", "What's New and Improved") 
cell[5] = new Array("preview", "chptpreview", "Chapter Preview") 


function LeftMenu(active) {
activePage = active
	for(var i=1; i<=5; i++)	{
	
	if (i != active) {

			document.write('<A HREF="' + cell[i][0] + '.html" onMouseOver="SwapImage(this,\'im' + i + '\',\'images/buttons/' + cell[i][1] + '_over.gif\')">');
			document.write('<IMG NAME="im' + i + '" SRC="images/buttons/' + cell[i][1] + '_up.gif"  Border="0" ALT="' + cell[i][2] + '"></A><BR>');

			} else {
	
			document.write('<IMG SRC="images/buttons/' + cell[i][1] + '_act.gif"  BORDER="0" ALT="' + cell[i][2] + '"><BR>');

			}
		}
	}


//--- Rollover function. ---// 


function SwapImage(id,ident,RollOverImage) {
  if(document.images) {
    image            = document.images[ident];
    image.MouseOutImage      = new Image();
    image.RollOverImage     = new Image();
    image.MouseOutImage.src  = document.images[ident].src;
    image.RollOverImage.src = RollOverImage;
    image.src        =image.RollOverImage.src;
    id.onmouseout  = new Function("var image=document."+ident+"; image.src=image.MouseOutImage.src;");
    id.onmouseover = new Function("var image=document."+ident+"; image.src=image.RollOverImage.src;");
  }
}




//--- Header function. ---// 

function Header() {
//	for(var h=1; h<=8; h++)	{
//	if (h != active) {			
			document.write('<IMG SRC="images/headers/' + cell[activePage][1] + '_header.gif"  Border="0" ALT="' + cell[activePage][2] + '">');

			}
//		}
//	}
	
	
	
//--- Imprint function. ---// 		

function Imprint() {
	document.write('<img src="images/' + cell[0][1] + '_logo.gif" ALT="' + (cell[0][2]) + '" border="0" valign="top">');
	}
	
	
//--- Book Title function. ---// 

function Booktitle() {
	return (cell[0][3])
}


//--- Secondary Title function. ---// 

function Secondtitle() {
	return (cell[0][4])
}


//--- Copyright Date function. ---// 

function year() {
	return (cell[0][0])
}

/* START: This function will check if user is searching on the basis of Keyword and if    so the 

function will check for the searched string. If the string entered looks-like an ISBN then the search will be based on ISBN (bn) else Keyword (kw) */

 

function chkISBN(){

      frm = document.searchForm;

            selV = trim(frm.search_by_text.value);

            chngFlag = true;

            if (selV.length >= 10) {

                  selV = selV.replace(/-/g, "");      // remove all hyphens

                  selV = selV.replace(/ /g, "");      // remove all spaces

                  selV = trim(selV);

                  if (selV.search(/[^A-Za-z0-9]/gi) >= 0) { // invalid chars are there

                        chngFlag = false;

                  }

                  if (chngFlag) {                                       // check further

                        arr = selV.split('');

                        dCnt = 0;                                 // digit count

                        aCnt = 0;                                 // alpha count

                        for(i=0;i<arr.length;i++) {

                              if (i < 9) {

                                    if (arr[i].search(/[a-z]/i) >= 0 )

                                          chngFlag = false;       // invalid char found

                              }

                        } // end for

                  }

            } else {

                  chngFlag = false;

            } // end selV.length

      

            if (chngFlag){    // change

                  frm.search_by_text.value = selV;    // set the trimmed value

                  frm.search_by.options[frm.search_by.selectedIndex].value = "bn";

            } else {

                  frm.search_by_text.value = trim(frm.search_by_text.value);  // set the trimmed value

            }

      

}
 

function trim(strText) 

{     

        // this will get rid of leading spaces 

        while (strText.substring(0,1) == ' ') 

            strText = strText.substring(1, strText.length);

 

        // this will get rid of trailing spaces 

        while (strText.substring(strText.length-1,strText.length) == ' ')

            strText = strText.substring(0, strText.length-1);

 

        return strText;

}

//************************************************************************************************************************



