/* ThinkQuest International 2006/2007
   TQ Toolkit - A web building guide for ThinkQuesters (C)
   Your TQ Guides (R)
   Visit http://library.thinkquest.org/06aug/02048/

*/

// ---------- sites ----------

var s = new Array();

s[0] = "Home^home.html^Home Page of TQ Toolkit.^trailer^tour";
s[1] = "Skin Chooser^skinchooser.html^Choose a skin for the site.^css,theme,style,switch,playground,mimic,lucidity,futura,cubic,little";
s[2] = "Download Site^download.html^Download the site to browse offline.";
s[3] = "Introduction^introduction.html^Introduction of the site. Find out whether the site is for you.^motivation,target,audience,objectives,repository,explore,deeper";
s[4] = "Toolkit^toolkit.html^Sections include site content, html, design and graphics, css, interactivity and software.^main,learn";
s[5] = "Tips^tips.html^Sections include dos and donts, file organization, web accessibility, future of thinkquest and multimedia resources.";
s[6] = "About^about.html^Sections include the team, site features, sitemap, glossary, references and terms of use.^miscellaneous,information";
s[7] = "Site Content^sitecontent.html^Sub Sections include objectives of the site, target audience, site map, language, structure of your content, handling jargons, information about your site, site index and conclusion.";
s[8] = "HTML (Home)^htmlhome.html^Sub Sections include HTML, XHTML and conclusion.";
s[9] = "Design and Graphics^design.html^Sub Sections include colors, typography, images, layout and conclusion.";
s[10] = "CSS^css.html^Sub Sections include an introduction to css, types of style, simple selectors, advanced selectors, css properties and conclusion.";
s[11] = "Interactivity^interactivity.html^Sub Sections include introduction, javascript, flash, other formats and conclusion.";
s[12] = "Software^software.html^Sub sections include introduction, web building, image editing, upload clients and conclusion.";
s[13] = "Dos and Donts^dosanddonts.html^Watch a slideshow about Dos and Donts for web developement and test your knowledge in our true or false game!^tips";
s[14] = "File Organization^file.html^Find out how to organize files on the server and play our \"File Drag and Drop\" game!^tips,structure,link,folder,naming";
s[15] = "Web Accessibility^accessibility.html^Watch a video to learn about Web Accessibility.^tips,user,agent,devices,pda,disabilities,impairment,seizure,mobility,mobile,screen,reader,refreshable,braille,display,magnifier,translation,wcag,imagemap,marquee,evaluator,taw,pizzaseo,w3c";
s[16] = "Future of ThinkQuest^future.html^Discover the truth about past ThinkQuest winners and listen to their views in our podcasts!^survey,interview";
s[17] = "Multimedia Resources^multimedia.html^Mobile content, wallpapers ,screensavers and more interactivity!^quiz,crossword";
s[18] = "Objectives of the Site^objectives.html^Decide on your topic, set objectives and define them.^brainstorm,overload";
s[19] = "Target Audience^audience.html^Consider your target audience.^age,group,gender,interests,pastimes,disability";
s[20] = "Site Map^map.html^Draw an outline of your site.^tree,branch,spider";
s[21] = "Language^language.html^Translate or not?^english";
s[22] = "Structure of your Content^structure.html^Research, write and offer good navigation.^jump";
s[23] = "Handling Jargons!^jargons.html^Define technical words for your readers.^title,attribute,rollover";
s[24] = "Information about your Site^information.html^Include the glossary, references and citations, information about team members and coaches, acknowledgements and disclaimer and other miscellaneous content";
s[25] = "Site Index^siteindex.html^Index your site.^sitemap";
s[26] = "HTML^html.html^Learn some basic HTML.^head,body,attribute,tag,meta,root,element,doctype,h1,empty,comments,nesting";
s[27] = "XHTML^xhtml.html^Learn the future language of the web.^doctype,well,xml,strict,transitional,frameset,standard,compliant,validate,tidy,dave,reggett";
s[28] = "Colors^colors.html^All about colors for the web.^primary,secondary,tertiary,analogous,complement,scheme,background,text,hex";
s[29] = "Typography^typography.html^Typeface, text size and color, white space and alignment for your website.^serif,sans,font,leading,justify";
s[30] = "Images^images.html^Graphics sources and formats.^gif,jpeg,jpg,png,sxc,stock,photo,compression,depth,transparency,animation,gimp";
s[31] = "Layout^layout.html^Find a layout most suitable for your site.^consistency,splash,header,navigation";
s[32] = "An Introduction to CSS^cssintro.html^Learn what CSS is all about.^zen,garden,style,selector,property,value";
s[33] = "Types of Style^csstypes.html^Different ways of styling your web content.^in,line,embedded,external";
s[34] = "Simple Selectors^sselectors.html^Using CSS the simplest way.^id,class,type";
s[35] = "Advanced Selectors^aselectors.html^Combining, grouping selectors and psuedo-class selectors.^visited,hover,active";
s[36] = "CSS Properties^cssproperties.html^Know a few properties to use off-hand!^padding,margin,font,type,color,float,browsers,inconsistency,hacks,rollover,preload";
s[37] = "Introduction^interactintro.html^Know the two types of scripting for the web.^server,client,side,form,verification,google,php,java,actionscript";
s[38] = "JavaScript^javascript.html^The most commonly used form of scripting.^random,quote,fact,search,browser,sniffing,technology,detection,cookies,ajax";
s[39] = "Flash^flash.html^Another common and powerful interactivity.^plug,adobe,animation,audio,video";
s[40] = "Other Formats^otherformats.html^Java and Virtual Tours^sun,object,oop,j2me,vr,ipix";
s[41] = "Introduction^softwareintro.html^Commercial and open source.";
s[42] = "Web building^webbuilding.html^HTML editors.^dreamweaver,amaya,nvu";
s[43] = "Image Editing^imageediting.html^Creating/Editing graphics for the web.^adobe,photoshop,fireworks,gimp";
s[44] = "Upload Clients^uploadclients.html^Programs to upload files to server.^filezilla,smartftp,fireftp,webdav";
s[45] = "The Team^team.html^Find out who are your TQ guides and the difficulties faced in the team.";
s[46] = "Site Features^site.html^Find out more about the site and the site highlights!^faq,use,help";
s[47] = "Sitemap^sitemap.html^Take a look at all the pages with the sitemap.";
s[48] = "Gloassry^glossary.html^A list of terms and their definition as used in the site.";
s[49] = "References^references.html^A full listing of references used by the team.^sources";
s[50] = "Terms of Use^terms.html^View the disclaimer and copyright notice of the site.";

// ---------- end of sites ----------
var d = "";
var od = "";
var m = 0;
var r = new Array();
var co = 0;
var pat = "";
var hitnum = new Array();

function search_form() {
	//Initialise again
	d = "";
	od = "";
	m = 0;
	r = new Array();
	co = 0;
	pat = "";
	hitnum = new Array();
	//End of init
	if (document.getElementById) {
		var keyword = document.getElementById("searchtxt");
		if (keyword.value.length > 0) 
			d = keyword.value;

od = d;

if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') {
	m = 1;
}

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++;
				pat = new RegExp(w[i], "i");
				var rn = s[c].search(pat);
				if (rn >= 0) {
					pa++;
				} else {
					pa = 0;
				}
			}
			if (woin[i] == 1) {
				pat = new RegExp(w[i], "i");
				var rn = s[c].search(pat);
				if (rn >= 0) {
					pa = 0;
				}
			}
		}
		if (pa == nh) {
			r[a] = s[c];
			hitnum[a] = c;
			a++;
		}
	}
	co = a;
}

if (m == 1) {
	d = d.replace(/"/gi, "");
	var a = 0;
	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];
			hitnum[a] = c;
			a++;
		}
	}
	co = a;
}
}
}

function getpage() {
	var memory = s[this.lastChild.getAttribute("id")].split("^");
	if (memory[1] == "skinchooser.html")
		loadobjs('scripts/skin.js');
	ajaxpage(memory[1], "content");
}

function num_jse() {
	if (document.createTextNode)
	{
		var text = document.getElementById("pagefound");
		var num = document.createTextNode(co);
		var extra = document.createTextNode(" page(s) found");
		while (text.firstChild)
			text.removeChild(text.firstChild);
		text.appendChild(num);
		text.appendChild(extra);
	}
}

function out_jse() {
	if (document.createTextNode && document.createElement) {
	var textarea = document.getElementById("result");
	while (textarea.firstChild)
		textarea.removeChild(textarea.firstChild);
	if (co == 0) {
		var nomatch = document.createTextNode("Your search did not match any documents.");	
		var makesure = document.createTextNode("Make sure all keywords are spelt correctly.");
		var diff = document.createTextNode("Try different or more general keywords.");
		textarea.appendChild(nomatch);
		textarea.appendChild(document.createElement("br"));
		textarea.appendChild(makesure);
		textarea.appendChild(document.createElement("br"));
		textarea.appendChild(diff);
	}
	else {
	var first = new Array();
	var second = new Array();
	var third = new Array();
	var bolded = new Array();
	var fourth = new Array();
	var hyplink = new Array();
	var hidden = new Array();
	for (var a = 1; a < r.length+1; a++) {
		var os = r[a-1].split("^");
		//os[1] is now the href, os[2] the description, d is the keyword, pat is /d/i
		//if (m == 1) {
		os[2] = os[2].replace(pat, d);
		if (os[2].indexOf(d) != -1) {
			var beg = os[2].substr(0, os[2].indexOf(d));
			var end = os[2].substr(os[2].indexOf(d)+d.length); }
		else {
			var beg = os[2];
			var end = "";
		}
		first[a-1] = document.createTextNode(a+". ");
		textarea.appendChild(first[a-1]);
		hyplink[a-1] = document.createElement("a");
		hyplink[a-1].setAttribute("href", "#contentarea");
		hyplink[a-1].setAttribute("class", "external");
		hyplink[a-1].setAttribute("className", "external");
		second[a-1] = document.createTextNode(os[0]);
		hyplink[a-1].appendChild(second[a-1]);
		hidden[a-1] = document.createElement("span");
		hidden[a-1].appendChild(document.createTextNode(os[1]));
		hidden[a-1].setAttribute("id", hitnum[a-1]);
		hidden[a-1].style.display = "none";
		hyplink[a-1].appendChild(hidden[a-1]);
		textarea.appendChild(hyplink[a-1]);
		textarea.appendChild(document.createElement("br"));
		third[a-1] = document.createTextNode(beg);
		textarea.appendChild(third[a-1]);
		if (os[2].indexOf(d) != -1) {
		bolded[a-1] = document.createElement("b");
		bolded[a-1].appendChild(document.createTextNode(d)); 
		textarea.appendChild(bolded[a-1]);}
		fourth[a-1] = document.createTextNode(end);
		textarea.appendChild(fourth[a-1]);
		textarea.appendChild(document.createElement("br"));
		textarea.appendChild(document.createElement("br"));
		hyplink[a-1].onclick = getpage;
	}
	}
	}
	return;
}
