/*
---------------------------------------------------------------
	The Egenda Members system is provided by
	Associated Knowledge Systems Ltd,
	The Old Smithy, Heaton House, York Road, Boroughbridge,
	North Yorkshire, YO51 9HE
	www.aksbedale.co.uk 
	e-mail sales@aksbedale.co.uk 
	Tel: 01423 321450
	Fax: 01423 321451

 (c) Copyright Associated Knowledge Systems Limited, 1999 - 2008

---------------------------------------------------------------
*/

egen.CrLf = String.fromCharCode(13) + String.fromCharCode(10);
egen.ud = 'undefined';

egen.buttonwithfocus = null;

egen.gEBI = function(thisid) {
	if (document.all) {
		return document.all(thisid);
	} else {
		return document.getElementById(thisid);
	}
};

function action_onblur(thiscontrol) {
	if (thiscontrol.tagName == "INPUT") {
		if ((thiscontrol.type == "submit")
		|| (thiscontrol.type == "button")) {
			egen.buttonwithfocus = null;
		}
	}
	window.status = '';
}

function action_onfocus(thiscontrol) {
	if (thiscontrol.tagName == "INPUT") {
		if ((thiscontrol.type == "text") 
		|| (thiscontrol.type == "password")) {
			thiscontrol.select();
		}
		if ((thiscontrol.type == "submit")
		|| (thiscontrol.type == "button")) {
			egen.buttonwithfocus = thiscontrol;
		}
	}
	if (thiscontrol.tagName == "TEXTAREA") {
		thiscontrol.select();
	}
}

egen.flipdate = function (datevalue) {
	datevalue.replace(/\s+$/g, "");
	if (/(\d+)[-\/](\d+)[-\/](\d+)/.test(datevalue)) {
		datevalue = datevalue.replace(/(\d+)[-\/](\d+)[-\/](\d+)/, "$2\/$1\/$3");
	}
	return datevalue;
}

egen.addLoadListener = function (fn) {
	if (typeof window.addEventListener != 'undefined') {
		window.addEventListener('load', fn, false);
	} else if (typeof document.addEventListener != 'undefined') {
		document.addEventListener('load', fn, false);
	} else if (typeof window.attachEvent != 'undefined') {
		window.attachEvent('onload', fn);
	} else {
		var oldfn = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = fn;
		} else {
			window.onload = function() {
							oldfn();
							fn();
						};
		}
	}
};

egen.attachEventListener = function (target, eventType, functionRef, capture) {
	if (typeof target.addEventListener != "undefined") {
		target.addEventListener(eventType, functionRef, capture);
	} else if (typeof target.attachEvent != "undefined") {
		target.attachEvent("on" + eventType, functionRef);
	} else {
		eventType = "on" + eventType;
		if (typeof target[eventType] == "function") {
			var oldListener = target[eventType];
			target[eventType] = function() {
							oldListener();
							return functionRef();
						};
		} else {
			target[eventType] = functionRef;
		}
	}
	return true;
};

egen.getcookie = function (searchName) {
	var cookies = document.cookie.split(';');
	for (var i = 0; i < cookies.length; i++) {
		var cookieCrumbs = cookies[i].split("=");
		var cookieName = cookieCrumbs[0];
		cookieName = cookieName.replace(" ", "");
		var cookieValue = cookieCrumbs[1];
		if (cookieName == searchName) {
			return unescape(cookieValue);
		}
	}
	return null;
};

egen.retrieveComputedStyle = function (element, styleProperty) {
	var computedStyle = null;
	if (typeof element.currentStyle != "undefined") {
		computedStyle = element.currentStyle;
	} else {
		computedStyle = document.defaultView.getComputedStyle(element, null);
	}
	return computedStyle[styleProperty];
};

//
//	Commonly used javascript routines
//
// used to toggle a element when the desc span 
// is clicked on HTML control
function DescClick(srcElement) {
	if (srcElement.checked == false && srcElement.type == "radio") 
		srcElement.checked = true;
	 else if (srcElement.checked == true && srcElement.type == "radio") 
	 // we just ignore this, but trap it
	;
	 else {
		srcElement.checked = !srcElement.checked;
	}
}

	egen.m = document;
	egen.b = new Object;
	egen.b.k = (navigator.vendor == 'KDE');
	egen.b.d = (typeof egen.m.getElementById != egen.ud
		 &&  (typeof egen.m.createElement != egen.ud
			 ||  typeof egen.m.createElementNS != egen.ud));
	egen.b.o7 = (egen.b.d && typeof window.opera !=  egen.ud);
	egen.b.wie = (egen.b.d && typeof egen.m.all !=  egen.ud && typeof window.opera == egen.ud);
	egen.b.ns = (navigator.appName == "Netscape");
