// ---------- script properties ----------

var include_num = 1;
var bold = 0;

var s = new Array();

// ---- This array stores each page to search: Title^File^Description^keyswords ---- //

s[0] = "Introduction^introduction.htm^Welcome to CapeSoft Office Messenger^introduction, about, buy, comment, trial, demo, downloads, source, source code";
s[1] = "Features^features.htm^Some of the features provided by CapeSoft Office Messenger^ features, information, general";
s[2] = "License and Copyright^License_and_Copyright.htm^Licensing and Copyright information^license, copyright, source code, evaluation, demo, source ";
s[3] = "Downloads^Free_Upgrade_Policy.htm^Download information and free upgrades^download, demo, free, trial, upgrade"
s[4] = "System Requirements^System_Requirements.htm^System requirements^installation, requirements, specifications, tcp/ip, WAN, LAN, internet, Windows";;
s[5] = "Installation Instructions^Installation_Instructions.htm^How to install and upgrade Office Messenger^install, upgrade, setup";
s[6] = "Registration^Registration.htm^Registering Office Messenger^register, buy, order, activate";
s[7] = "Operation Overview^Overview.htm^Overview of using Office Messenger^overview, using, basics, menu, starting, shortcut";
s[8] = "Main Window^Main_Window.htm^The Main Office Messenger Window^main, window, using, basics, start, initial, menu, toolbar, buttons";
s[9] = "Sending a Message^Sending_a_message.htm^How to send a message^send, new, message, recipient, to, dropdown, privacy, sendas, send as, offline";
s[10] = "Multiple Recipients^Send_to_Group.htm^Send a message to multiple recipients^multiple, recipients, group, send, many";
s[11] = "Receiving a Message^Receiving_a_Message.htm^Receiving a message^receive, message, done, print, restore";
s[12] = "Hidden (private) Messages^Receive_a_Hidden_Message.htm^Receiving a Hidden Message^hidden, private, send as, show message, show, received";
s[13] = "Defining Groups^Defining_Groups.htm^How to create groups of recipients^groups, create, multiple, recipients";
s[14] = "Using the Address Book^Using_the_Address_Book.htm^The Address Book^address, contacts, address book";
s[15] = "Message History^Message_History.htm^View all sent and recieved messages^history, old, received, sent, messages, re-activate, reactivate";
s[16] = "View a Message^View_a_Message.htm^View a message in the Message History^history, view, old, message, sent, received";
s[17] = "Options^Options.htm^Program settings and options^options, settings, configure, configuration, set, name, sound, play";
s[18] = "Remote Shutdown^Administration.htm^Warning and closing Office Messenger remotely^shut down, force, close, exit, all, remote, LAN, administration, manage";
s[19] = "FAQ^FAQ.htm^Frequently Asked Questions^FAQ, questions, frequent, sound, play, dissapears, received, message, address book, installation, corrupt, administrator, limited account, cannot install, fast user switching, terminal, citrix, multiple, already running";
s[20] = "Contact Information^COntact_Information.htm^CapeSoft contact and support information^contact, support, details, capesoft, sales, address, post, email";
s[21] = "Downloads^Download.htm^Downloads, demos, free upgrades^upgrade, free, downloads, demo, trial, buy, purchase, source, source code";
s[22] = "History^History.htm^Version history and changes^history, version, updates, changes, new, features";

// ---------- end of script properties and sites ----------


// find whether there is a "d=" in the cookie string. 
// This stores the name of the document to load with the search results
var cookies = document.cookie;
var p = cookies.indexOf("d="); 
var d;             

if (p != -1) 
{
	var st = p + 2;
	var en = cookies.indexOf(";", st);      // locates the first semi colon in the string
	if (en == -1)
		en = cookies.length;

	//var d = cookies.substring(st, en);
	d = cookies.substring(st, en);
	d = unescape(d);
}


var od = d;
var m = 0;
if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') 
	m = 1;


var r = new Array();
var co = 0;

if (m == 0) 
{
	var woin = new Array();
	var w = d.split(" ");
	for (var a = 0; a < w.length; a++) 
	{
		woin[a] = 0;
		if (w[a].charAt(0) == '-')
			woin[a] = 1;
		
	}
	
	for (var a = 0; a < w.length; a++) 
	{
		w[a] = w[a].replace(/^\-|^\+/gi, "");
	}
	
	a = 0;
	for (var c = 0; c < s.length; c++) 
	{
		pa = 0;
		nh = 0;
		for (var i = 0; i < woin.length; i++) 
		{
			if (woin[i] == 0) 
			{
				nh++;
				var pat = new RegExp(w[i], "i");
				var rn = s[c].search(pat);
				if (rn >= 0) 
					pa++;
				else 
					pa = 0;
			}
			if (woin[i] == 1) 
			{
				var pat = new RegExp(w[i], "i");
				var rn = s[c].search(pat);
				if (rn >= 0) 
					pa = 0;
				
			}
		}
		
		if (pa == nh) 
		{
			r[a] = s[c];
			a++;
		}
	}
	co = a;
}

if (m == 1) 
{
	d = d.replace(/"/gi, "");
	var a = 0;
	var pat = new RegExp(d, "i");
	for (var c = 0; c < s.length; c++) 
	{
		var rn = s[c].search(pat);
		if (rn >= 0) 
		{
			r[a] = s[c];
			a++;
		}
	}
	co = a;
}


function return_query() 
{
	if (od)
		document.jse_Form.d.value = od;	
	else
		document.jse_Form.d.value = "";
	
}

function num_jse() 
{
	if (co)
		document.write(co);
	
}

function out_jse() 
{
	if (co == 0) 
	{
		document.write('Your search did not match any documents.<p>Make sure all keywords are spelt correctly.<br>Try different or more general keywords.');
		return;
	}
	
	for (var a = 0; a < r.length; a++) 
	{
		var os = r[a].split("^");
		if (bold == 1 && m == 1) 
		{
			var br = "<b>" + d + "</b>";
			os[2] = os[2].replace(pat, br);
		}
		
		if (include_num == 1) 
			document.write(a + 1, '. <a href="', os[1], '" target="ContentsFrame">', os[0], '</a><br>', os[2], '<p>');
		else 
			document.write('<a href="', os[1], '" target="ContentsFrame">', os[0], '</a><br>', os[2], '<p>');
		
	}

}

