// JavaScript Document
	
	function reveal (image) {
		document.getElementById("default").style.display = "none"
		document.getElementById(image).style.display = ""
}
	
	function hide (image) {
		document.getElementById(image).style.display = "none"
				document.getElementById("default").style.display = ""
	}
	
	function clearSearchWord() {
			document.getElementById('keywordentry').value = ""
	}
	

function QueryString() {
	// PROPERTIES
	this.arg = new Array;
	this.status = false;
	
	// METHODS
	this.clear = Clear;
	this.get = Get;
	this.getAll = GetAll;
	this.getStatus = GetStatus;
	this.read = Read;
	this.set = Set;
	this.write = Write;
	
	// FUNCTIONS
	
	// Clears the array, this.arg, of all query string data
	function Clear()
	{	this.arg = new Array;
	}
	
	// Returns a named value from the query string
	function Get(sName)
	{	return this.arg[sName];
	}
	
	// Return all data as an associative array
	function GetAll()
	{	return this.arg;
	}
	
	function GetStatus()
	{	return this.status;
	}
	
	// Reads the query string into an array named this.arg
	function Read(sUrl) 
	{	var aArgsTemp, aTemp, sQuery;
		// You can pass in a URL query string
		if(sUrl)
		{	sQuery = sUrl.substr(sUrl.lastIndexOf("?")+1, sUrl.length);
		}
		// Or read it from the browser location
		else
		{	sQuery = window.location.search.substr(1, window.location.search.length);
		}
		// Check that query string exists and contains data
		// If not (length < 1) then return
		if(sQuery.length < 1) {return;}
		// Else set this.status to true and proceed
		else {this.status = true;}
		//
		aArgsTemp = sQuery.split("&");	
		for (var i=0 ; i<aArgsTemp.length; i++)
		{	aTemp = aArgsTemp[i].split("=");
			this.arg[aTemp[0]] = aTemp[1];
		}
	}
	
	// Overwrites an existing named value in the array, this.arg
	// You can also pass null to delete from array
	function Set(sName,sValue)
	{	if (sValue == null) {delete this.arg[sName];}
		else {this.arg[sName] = sValue;}
	}
	
	// Writes out a string from the data in this.arg array
	// This string can be used to pass a new query string to the browser
	// when navigating to the next page. This allows a page
	// to create and pass data to another page via JavaScript.
	function Write()
	{	var sQuery = new String(""); 
		for (var sName in this.arg)
		{	if (sQuery != "") {sQuery += "&";}
			if (this.arg[sName]) {sQuery += sName + "=" + this.arg[sName];}
		}
		if (sQuery.length > 0) {return "?" + sQuery;}
		else {return sQuery;}
	}
}

/**
* @author	http://www.webdeveloper.com/forum/showthread.php?threadid=146239
* 
* @param 	myElement:a form element
* @return	Boolean
*/
function banIllegalCharacters(myElement) {
		var inputFieldName = myElement.name;
		var elementValue = myElement.value;
		var inputFormName = myElement.form.name;
		//alert('ban: name: '+inputFieldName+' value: '+elementValue+' form name: '+inputFormName);
		var illegalCharArray = new Array("(",")","=","+","\"",";","<",">","*","#");
		var foundIllegalCharacters = new Array();
		var counter = 0;
		var errorString = "";

		for (i=0;i < illegalCharArray.length; i++) {
			if (elementValue.indexOf(illegalCharArray[i]) != -1){
				// Illegal character found - add illegal character to array
				foundIllegalCharacters[counter] = illegalCharArray[i];
				counter++;
			}
		}
		if (counter > 0) {
			// Illegal characters are present - build an alert string to notify user
			for (i=0;i < foundIllegalCharacters.length; i++) {
				if (errorString.indexOf(foundIllegalCharacters[i]) == -1) {
					errorString = errorString + foundIllegalCharacters[i] + " ";
				}
			}
			
			alert("You cannot use the following characters when filling out the form boxes:\n\n\t" + errorString + "\n\nPlease re-enter your information.");
			//change the text colour
			myElement.className = 'red';
			return false;
		}else{
			//alert('returning true');
			
			myElement.className = '';
			
			return true;
		}
}

<!-- Based on Script by hscripts.com -->
function stripHTML(formObj){
	var re = /(<([^>]+)>)/gi;
	for (i=0; i < formObj.length; i++){
		if(formObj[i].value){
			formObj[i].value=formObj[i].value.replace(re, "");
		}
	}
	return true;
}

/**
* this method will loop through a form and strip any HTML tags then check for 
* any banned characters.
*/
function checkBadHTML(formObj){
	//first strip the html from the form inputs
	var bool_stripped = stripHTML(formObj);
	//set the boolean for the banned characters
	var bool_banned = false;
	//now loop through the form inputs and check for banner characters
	//alert('the number of form elements is: '+formObj.length);
	var num_len = formObj.length
	for (k=0; k < formObj.length-3; k++){
		var obj = formObj[k];
		//alert('checking: '+obj.name);
		if(obj.value){			
			//check for banned characters
			var bool_ele = banIllegalCharacters(obj);
			//alert('checking:'+obj.name+', result is '.bool_ele);
			//set bool_banned to true if banned chars found (bool_ele = false)
			if(!bool_ele){
				bool_banned = true;
			}
		}
		//alert('k='+k);
	}
	//return true if bool_banned is false
	if(bool_banned){
		return false;
	}else{
		return true;
	}
}
/**
 * This method reveals a timer overlay on the page
 * to indicate that something is happening.
 */
function clicker(){
	/*
	var thediv=document.getElementById('displaybox');
	if(thediv.style.display == "none"){
		thediv.style.display = "";
		thediv.innerHTML = "<div id=\"timer\">test</div>";
	}else{
		thediv.style.display = "none";
		thediv.innerHTML = '';
	}
	*/
	var dialog = new Element('div');
	dialog.insert(new Element('h2').insert('Dialogue'));
	var overlay = new DialogOverlay(dialog);

	return true;
}
/**
 * source: http://mattroper.co.uk/2008/05/27/javascript-overlay-using-prototype-and-scriptaculous/
 */
function DialogOverlay(content, container) {
	 
	// Manage arguments and assign defaults,
	if (typeof container == 'undefined' ) container = document.body;
	if (null == (this.container = $(container))) throw("container is not valid");
 
	// Assign instance variables
	this.content = content;
	//this.overlay = new Element('div', { 'class': 'overlay' }).hide();
	//this.dialog = new Element('div', { 'class': 'dialog' }).hide();
	
	this.overlay = new Element('div', { 'class': 'overlay' });
	this.dialog = new Element('div', { 'class': 'dialog' });
 
	// Hide the overlay when clicked. Ignore clicks on the dialog.
	Event.observe(this.overlay, 'click', this.hide.bindAsEventListener(this));
	Event.observe(this.dialog, 'click',  function(event) { Event.stop(event) });
 
	// Insert the elements into the DOM
	this.dialog.insert(this.content);
	this.container.insert(this.overlay);
	this.container.insert(this.dialog);
 
	// Content may have been hidden if it is embedded in the page
	this.content.show();
	this.dialog.hide();
	this.show();
}
 
DialogOverlay.prototype.show = function() {
	new Effect.Appear(this.overlay, { duration: 0.5,  to: 0.8 });
	this.dialog.show();
	return this;
};
DialogOverlay.prototype.hide = function(event) {
	this.dialog.hide();
	this.overlay.hide();
	return this;
};
