// ---------- 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 BreakIn^introduction, about, buy, comment, demo, downloads";
s[1] = "Features^features.htm^Some of the features provided by CapeSoft BreakIn^ features, information, general, launch, source, command, parameters, stack, CPU";
s[2] = "License and Copyright^License_and_Copyright.htm^Licensing and Copyright information^license, copyright, demo";
s[3] = "Free Upgrade Policy^Free_Upgrade_Policy.htm^Download information and free upgrades^download, demo, free, upgrade"
s[4] = "Screenshots^Screenshots.htm^ScreenShots of CapeSoft BreakIn^screenshots, screenshot";
s[5] = "System Requirements^System_Requirements.htm^System requirements^installation, requirements, specifications, Windows";
s[6] = "Installation Instructions^Installation_Instructions.htm^How to install and upgrade CapeSoft BreakIn^install, upgrade, setup";
s[7] = "Loading your Application^ApplicationDetails.htm^Loading your Clarion Application in BreakIn^load, loading, using, application, monitor, command, line, parameters, start, directory, next, path";
s[8] = "Source Details^SourceDetails.htm^Specifying the Source Directories^source, directory, clarion, extra, back, launch, search";
s[9] = "Source Files Loading^LoadingDetails.htm^Source Files Loading ...^source, load, loading, wait";
s[10] = "Monitoring your Program^Monitor.htm^Monitoring your Clarion Application^monitor, monitoring, stack, trace, procedure, source, thread, id, cpu, time, break, button, buttons";
s[11] = "Breaking In^BreakingIn.htm^Breaking In to your program^break, in, breakin, breaking, stack, trace, procedure, source, address, thread, id, source, line, code, library, module, image, resume, list";
s[12] = "Closing your Program^ClosingProgram.htm^Closing your Program^close, exit, new, about";
s[13] = "FAQ^faq.htm^Frequently Asked Questions^frequently, asked, questions, faq, source not found, stack, trace, procedure, source, next, next failed, compiler, compiler added line, debug, DLL";
s[14] = "Contact Information^Contact_Information.htm^Contact Information^contact, information, support";
s[15] = "Free Upgrade Policy^free_upgrade_policy.htm^Download information and upgrade policy^download, free, buy, upgrade, policy";
s[16] = "History^History.htm^CapeSoft BreakIn History^history";

// ---------- 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>');
		
	}

}

