// 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("#","","Understanding the Internet","Understanding the Internet","");
c++; item[c]=new Array("#","","Internet services","Internet services","");
c++; item[c]=new Array("#","","IP Addresses and Domains","IP Addresses and Domains","");
c++; item[c]=new Array("#","","The World Wide Web","The World Wide Web","");
c++; item[c]=new Array("#","","URLS","URLS","");
c++; item[c]=new Array("#","","HTML","HTML","");

c++; item[c]=new Array("#","","Launching Internet Explorer","Launching Internet Explorer","");
c++; item[c]=new Array("#","","Exiting Internet Explorer","Exiting Internet Explorer","");
c++; item[c]=new Array("#","","Using the Address bar","Using the Address bar","");
c++; item[c]=new Array("#","","Stopping downloads using the Menu bar","Stopping downloads using the Menu bar","");
c++; item[c]=new Array("#","","Stopping downloads using the Standard toolbar","Stopping downloads using the Standard toolbar","");
c++; item[c]=new Array("#","","Refreshing pages","Refreshing pages","");
c++; item[c]=new Array("#","","Returning to the home page","Returning to the home page","");
c++; item[c]=new Array("#","","Navigating through previously visited pages using the Standard toolbar","Navigating through previously visited pages using the Standard toolbar","");
c++; item[c]=new Array("#","","Displaying the History folder","Displaying the History folder","");
c++; item[c]=new Array("#","","Hiding the History folder","Hiding the History folder","");
c++; item[c]=new Array("#","","Navigating with the History folder","Navigating with the History folder","");
c++; item[c]=new Array("#","","Navigating with the Favorites menu","Navigating with the Favorites menu","");

c++; item[c]=new Array("#","","Adding entries to the Favorites menu","Adding entries to the Favorites menu","");
c++; item[c]=new Array("#","","Adding entries by creating new folders in the Favorites menu","Adding entries by creating new folders in the Favorites menu","");
c++; item[c]=new Array("#","","Adding entries to existing folders in the Favorites menu","Adding entries to existing folders in the Favorites menu","");
c++; item[c]=new Array("#","","Creating new folders in the Favorites menu","Creating new folders in the Favorites menu","");
c++; item[c]=new Array("#","","Moving items in the Favorites menu","Moving items in the Favorites menu","");
c++; item[c]=new Array("#","","Renaming items in the Favorites menu","Renaming items in the Favorites menu","");
c++; item[c]=new Array("#","","Deleting items from the Favorites menu","Deleting items from the Favorites menu","");

c++; item[c]=new Array("#","","Subject search engines","Subject search engines","");
c++; item[c]=new Array("#","","Keyword search engines","Keyword search engines","");
c++; item[c]=new Array("#","","Spatial search engines","Spatial search engines","");
c++; item[c]=new Array("#","","Searching with Internet Explorer","Searching with Internet Explorer","");

c++; item[c]=new Array("#","","Creating MSN Hotmail accounts","Creating MSN Hotmail accounts","");
c++; item[c]=new Array("#","","Signing in","Signing in","");
c++; item[c]=new Array("#","","Signing out","Signing out","");
c++; item[c]=new Array("#","","Composing e-mail messages","Composing e-mail messages","");
c++; item[c]=new Array("#","","Sending e-mail messages with carbon copies","Sending e-mail messages with carbon copies","");
c++; item[c]=new Array("#","","Reading e-mail messages","Reading e-mail messages","");
c++; item[c]=new Array("#","","Closing e-mail messages","Closing e-mail messages","");
c++; item[c]=new Array("#","","Deleting e-mail messages","Deleting e-mail messages","");
c++; item[c]=new Array("#","","Inserting attachments in e-mail messages","Inserting attachments in e-mail messages","");
c++; item[c]=new Array("#","","Removing attachments","Removing attachments","");
c++; item[c]=new Array("#","","Opening attachments","Opening attachments","");
c++; item[c]=new Array("#","","Adding e-mail addresses to the Address Book","Adding e-mail addresses to the Address Book","");
c++; item[c]=new Array("#","","Deleting contacts from the Address Book","Deleting contacts from the Address Book","");
c++; item[c]=new Array("#","","Sending e-mail messages using the Address Book","Sending e-mail messages using the Address Book","");

c++; item[c]=new Array("#","","Signing in","Signing in","");
c++; item[c]=new Array("#","","Signing out","Signing out","");
c++; item[c]=new Array("#","","Adding contacts","Adding contacts","");
c++; item[c]=new Array("#","","Sending instant messages","Sending instant messages","");
c++; item[c]=new Array("#","","Receiving instant messages","Receiving instant messages","");
c++; item[c]=new Array("#","","Inviting others to an instant messaging session","Inviting others to an instant messaging session","");
c++; item[c]=new Array("#","","Changing fonts","Changing fonts","");
c++; item[c]=new Array("#","","Adding Emoticons to instant messages","Adding Emoticons to instant messages","");
c++; item[c]=new Array("#","","Sending files or pictures","Sending files or pictures","");
c++; item[c]=new Array("#","","Receiving files or pictures","Receiving files or pictures","");
c++; item[c]=new Array("#","","Opening files or pictures from the MSN Messenger window","Opening files or pictures from the MSN Messenger window","");
c++; item[c]=new Array("#","","Sending e-mail messages","Sending e-mail messages","");
c++; item[c]=new Array("#","","Receiving e-mail messages","Receiving e-mail messages","");
c++; item[c]=new Array("#","","Starting voice conversations","Starting voice conversations","");
c++; item[c]=new Array("#","","Ending voice conversations","Ending voice conversations","");
c++; item[c]=new Array("#","","Taking breaks","Taking breaks","");
c++; item[c]=new Array("#","","Blocking contacts","Blocking contacts","");
c++; item[c]=new Array("#","","Unblocking contacts","Unblocking contacts","");


/*******************************************************************************
	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: Internet 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()
