// JavaScript Document
//array for displaying number of ../nuggets found during search... 
var numConversion = new Array();

//array for storing links to ../nuggets, nugget title, keyintropcss...
var item = new Array();

//populating the array...
for (var i=0; i<150; i++){
	numConversion[i] = i;
}

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"
//c++; item[c]=new Array("javascript:openNugget('../nuggets/windows/Chapter8//_nugget.html',670,530);","","","","");

c=0; item[c]=new Array("#","","Launching Word","Launching Word","");
c++; item[c]=new Array("#","","Saving documents for the first time using the Menu bar","Saving documents for the first time using the Menu bar","");
c++; item[c]=new Array("#","","Saving updated files using the Standard toolbar","Saving updated files using the Standard toolbar","");
c++; item[c]=new Array("#","","Opening existing documents","Opening existing documents","");
c++; item[c]=new Array("#","","Creating new documents using the Menu bar","Creating new documents using the Menu bar","");
c++; item[c]=new Array("#","","Closing files","Closing files","");
c++; item[c]=new Array("#","","Exiting Word","Exiting Word","");

c++; item[c]=new Array("#","","Adding or removing toolbars","Adding or removing toolbars","");
c++; item[c]=new Array("#","","Adding or removing Rulers","Adding or removing Rulers","");
c++; item[c]=new Array("#","","Changing to Print Layout View","Changing to Print Layout View","");
c++; item[c]=new Array("#","","Undoing changes using the Standard toolbar","Undoing changes using the Standard toolbar","");

c++; item[c]=new Array("#","","Typing over existing text using the OVR button","Typing over existing text using the OVR button","");
c++; item[c]=new Array("#","","Deleting text using the Menu bar","Deleting text using the Menu bar","");
c++; item[c]=new Array("#","","Moving text using the Menu bar","Moving text using the Menu bar","");
c++; item[c]=new Array("#","","Copying text using the Standard toolbar","Copying text using the Standard toolbar","");
c++; item[c]=new Array("#","","Inserting fields","Inserting fields","");
c++; item[c]=new Array("#","","Inserting special symbols and foreign characters","Inserting special symbols and foreign characters","");

c++; item[c]=new Array("#","","Using the Print Preview function","Using the Print Preview function","");
c++; item[c]=new Array("#","","Changing the page orientation","Changing the page orientation","");
c++; item[c]=new Array("#","","Printing entire documents using the Menu bar","Printing entire documents using the Menu bar","");

c++; item[c]=new Array("#","","Finding text","Finding text","");
c++; item[c]=new Array("#","","Replacing text","Replacing text","");

c++; item[c]=new Array("#","","Checking grammar","Checking grammar","");
c++; item[c]=new Array("#","","Checking spelling","Checking spelling","");
c++; item[c]=new Array("#","","Checking spelling and grammar using the Menu bar","Checking spelling and grammar using the Menu bar","");
c++; item[c]=new Array("#","","Setting grammar checker options","Setting grammar checker options","");
c++; item[c]=new Array("#","","Using the Thesaurus","Using the Thesaurus","");

c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/changing_fonts_using_the_menu_bar/changing_fonts_using_the_menu_bar_nugget.html',670,530);","","Changing fonts using the Menu bar","Changing fonts using the Menu bar","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/changing_font_sizes_using_the_formatting_toolbar/changing_font_sizes_using_the_formatting_toolbar_nugget.html',670,530);","","Changing font sizes using the Formatting toolbar","Changing font sizes using the Formatting toolbar","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/changing_boldface_and_italic_attributes_of_text/changing_boldface_and_italic_attributes_of_text_nugget.html',670,530);","","Changing boldface and italic attributes of text","Changing boldface and italic attributes of text","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/changing_text_color_using_the_menu_bar/changing_text_color_using_the_menu_bar_nugget.html',670,530);","","Changing text colour using the Menu bar","Changing text colour using the Menu bar","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/adding_the_strikethrough_text_attribute/adding_the_strikethrough_text_attribute_nugget.html',670,530);","","Adding the strikethrough text attribute","Adding the strikethrough text attribute","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/changing_the_outline_font_effect/changing_the_outline_font_effect_nugget.html',670,530);","","Changing the Outline font effects","Changing the Outline font effects","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/copying_the_format_attributes_of_text/copying_the_format_attributes_of_text_nugget.html',670,530);","","Copying the format attributes of text","Copying the format attributes of text","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/highlighting_text/highlighting_text_nugget.html',670,530);","","Highlighting text","Highlighting text","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/highlighting_non_contiguous_text/highlighting_non_contiguous_text_nugget.html',670,530);","","Highlighting non-contiguous text","Highlighting non-contiguous text","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/changing_highlight_colors/changing_highlight_colors_nugget.html',670,530);","","Changing highlight colours","Changing highlight colours","");
c++; item[c]=new Array("javascript:openNugget('nuggets/word/xp/intro/Chapter7/removing_highlights/removing_highlights_nugget.html',670,530);","","Removing highlights","Removing highlights","");

c++; item[c]=new Array("#","","Changing paragraph indents using the Menu bar","Changing paragraph indents using the Menu bar","");
c++; item[c]=new Array("#","","Creating first line indents and hanging indents","Creating first line indents and hanging indents","");
c++; item[c]=new Array("#","","Aligning text using the Formatting toolbar","Aligning text using the Formatting toolbar","");
c++; item[c]=new Array("#","","Changing line spacing","Changing line spacing","");
c++; item[c]=new Array("#","","Adding borders to text using the Menu bar","Adding borders to text using the Menu bar","");
c++; item[c]=new Array("#","","Adding page borders","Adding page borders","");
c++; item[c]=new Array("#","","Adding custom page borders","Adding custom page borders","");
c++; item[c]=new Array("#","","Adding shading to text","Adding shading to text","");

c++; item[c]=new Array("#","","Inserting page breaks","Inserting page breaks","");
c++; item[c]=new Array("#","","Deleting page breaks","Deleting page breaks","");
c++; item[c]=new Array("#","","Margins","Margins","");

c++; item[c]=new Array("#","","Inserting tables using the Menu bar","Inserting tables using the Menu bar","");
c++; item[c]=new Array("#","","Displaying gridlines","Displaying gridlines","");
c++; item[c]=new Array("#","","Hiding gridlines","Hiding gridlines","");
c++; item[c]=new Array("#","","Inserting text in tables","Inserting text in tables","");

c++; item[c]=new Array("#","","Changing width of columns in tables","Changing width of columns in tables","");
c++; item[c]=new Array("#","","Inserting rows using the Menu bar","Inserting rows using the Menu bar","");
c++; item[c]=new Array("#","","Inserting rows using the Standard toolbar","Inserting rows using the Standard toolbar","");
c++; item[c]=new Array("#","","Adding rows","Adding rows","");
c++; item[c]=new Array("#","","Adding columns","Adding columns","");
c++; item[c]=new Array("#","","Deleting rows","Deleting rows","");
c++; item[c]=new Array("#","","Deleting columns","Deleting columns","");
c++; item[c]=new Array("#","","Deleting cell contents","Deleting cell contents","");
c++; item[c]=new Array("#","","Deleting tables","Deleting tables","");

c++; item[c]=new Array("#","","Cell borders","Cell borders","");
c++; item[c]=new Array("#","","Shading cells in a table","Shading cells in a table","");


/*******************************************************************************
	Function Name:	search();
	Arguments:			frm - form object containing the search keywords entered by the user.
	Description:			This function is used to search for nuggets using the search value entered by
								the user in the Search field. It matches the search string with the nugget title
								and its corresponding keywords and displays the link for the nugget if a match 
								is found. This function is called when the Search button is clicked.
********************************************************************************/

page =  ' 	<html> 																															'
page +=	'  		<head> 																														'
page += '			<link rel="stylesheet" type="text/css" href="css/ie-stylesheet.css"> 						'
page +=	' 			<script language="JavaScript1.2" src="scripts/nugget.js"></script> 							'
page +=	' 			<script language="JavaScript1.2" src="scripts/functions.js"></script> 							'
page +=	' 			<title>Search Results: Word XP eLearning Nuggets</title> 										'	
page +=	' 		</head>																														'
page +=	' 		<body onUnload="setFocus();"> 																														'
page +=	'			<img class="srchLogo" src="images/search_logo.gif">													'
page +=	' 			<div id="srchMain"> 																								';

function search(frm) {
	
	//search string to display in the search window...
  	srchTxt = frm.srchVal.value;

	//search string to be used for matching with nugget title and keywords...	
  	txt = frm.srchVal.value.toLowerCase();

	//splitting search sentences using space as a delimiter and storing it as an array...
  	txt = txt.split(" ");
  	fnd = new Array(); 
	total=0;

	//searching for a match...
	for (i = 0; i < item.length; i++) {
     	fnd[i] = 0; 
   		for (k = 0; k < txt.length; k++)
   	  		if (item[i][3].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
       			fnd[i] += (1);
     }

	//creating a window in which the search results will be displayed...
  	win = window.open("","","scrollbars, width=625, height=300");
	
	//writing/rendering the heading section of the search window...	
  	win.document.write(page);

	//finding and formatting links for display in the search window...
     for (i = 0; i < fnd.length; i++) {
     	n = 0; 
		w = -1;
        
		for (j = 0;j < fnd.length; j++)
         	if (fnd[j] > n) { n = fnd[j]; w = j; };
            	if (w > -1) 
			   		total += show(w, win);
               	fnd[w] = 0;
     }

	//rendering the rest of the page...	
	win.document.write('<br></div>');
		
	//displaying the heading in the search window... 
	win.document.write('<span class="srchWndHeading1">Search text: '+srchTxt+'</span><br>');
	win.document.write('<span class="srchWndHeading2">Total number of eLearning Nuggets found: '+numConversion[total]+'</span>');
	win.document.write('</body></html>');
	win.document.close();
}

/*****************************************************************************************************
	Function Name:	show();
	Arguments:			which 	- the element in the item array containing all the links.
								wind 	- the window in which to display the links.
	Description:			This function is used to format and display all the matching links in the
								search window.
******************************************************************************************************/

function show(which,wind) {

	link = item[which][1] + item[which][0];
   	if (link.indexOf("#") > -1)
		line = '<span class="disabled">'+item[which][2]+'</span><br>';
   	else
		line = '<a class="enabled" onFocus="loseFocus(this);" href="'+link+'">'+item[which][2]+'</a><br>';

   wind.document.write(line);
   return 1;
}	//Function show()