//*******************************************************************
// Kappa Solutions Ltd. Javascript Library.
// (c) 2000-2009 Kappa Solutions Ltd. except where credited
//*******************************************************************

var KSL;
if (!KSL) KSL = {};
if (!KSL.Utils) KSL.Utils = {};
if (!KSL.Forms) KSL.Forms = {};

//*******************************************************************
// Arguments Class Def.
//
//	This class holds member variables corresponding to the
//	arguments in the query string of a document URL. The variables 
//	are created by the constructor.
//*******************************************************************
KSL.Utils.Args = function () {
	// This constructor method creates member variables for each
	// argument passed in the document URL.

	// Strip the leading q-mark and make an array of the argument
	// name/value pairs...
	var search = unescape(document.location.search.replace(/^\?/, ""));

	var list = search.split("&");
	for (var entry in list) {
		// For each pair, create a member variable and store the
		// value (stripping start and end quotes and plus signs if 
		// neccessary)...
		var pair = list[entry].split("=");
		if (pair.length > 1) {
			this[pair[0]] = pair[1].replace(/\+/g, " ").replace(/^'/, "").replace(/'$/, "");
		}
	}
}

//*******************************************************************
//	Advert Manager class definition.
//
//	This class has methods to write Googel search box.
//*******************************************************************
KSL.Utils.AdvertMgr = function () {
}

// Get Google (AdSense) Search Box **********************************
KSL.Utils.AdvertMgr.prototype.getGoogleSearchBox = function() {
	var html = "<p>Search aeroalliance.uk.com</p><!-- SiteSearch Google -->" 
			+ "<form action=\"http://www.aeroalliance.uk.com/search.htm\" id=\"cse-search-box\">"
			+ "<div>"
			+ "<input type=\"hidden\" name=\"cx\" value=\"partner-pub-3970732487942762:8beesdh033d\" />"
			+ "<input type=\"hidden\" name=\"cof\" value=\"FORID:10\" />"
			+ "<input type=\"hidden\" name=\"ie\" value=\"ISO-8859-1\" />"
			+ "<input type=\"text\" name=\"q\" size=\"25\" />"
			+ "<input type=\"submit\" class=\"searchbtn\" name=\"sa\" value=\" Search \" />"
			+ "</div>"
			+ "</form>"
			+ "<p>&nbsp;</p><!-- SiteSearch Google -->";

	return html;
}

//*******************************************************************
//	Form Validator class definition.
//
//	This class has methods to validate input forms.
//*******************************************************************
KSL.Forms.Validator = function(form, cols) {
	this._form = form;
	this._cols = cols;
}
KSL.Forms.Validator.prototype.validate = function () {
		var msg = "";
		var f = this._form;
		for (var i=0; i<this._cols.length; i++) {
			var val = this._trim(f[this._cols[i].name].value);
			if (!val) msg += "\n" + this._cols[i].msg;
		}
	
		if (msg) {
			msg = "The form cannot be submitted for the following reason(s):" + msg;
			msg += "\n\nPlease ensure that all data is correctly entered and re-submit.";
			alert(msg);
			return false;
		}
		return true;
}
KSL.Forms.Validator.prototype._trim = function (val) {
	return val.replace(/^\s+/, "").replace(/\s+$/, "");
}

//*******************************************************************
