//----------------------------------------------------------------------------------------------------
//-- Pre-loads images so they are ready for use...
//-- To use type the following on a page:
//-- cmLoadImages('/folder/image1.gif', '/folder/image2.jpg');
//----------------------------------------------------------------------------------------------------
var cmImages = new Array();

function cmLoadImages()
	{ 
	for (var i = 0; i < cmLoadImages.arguments.length; i++)
		{
		cmImages[i] = new Image();
		cmImages[i].src = cmLoadImages.arguments[i];
		};
	};

function swapImage(pObjName, pImage)
	{
	var pObj = document.getElementById(pObjName);
	if (pObj)
		{
		if (pObj.src)
			{
			pObj.src = pImage;
			}
		}
	}

function createEmailAnchor(pAddress, pAddressName)
	{
	var sResult = pAddress.trim();
	var sName = "";
	if (pAddressName) {sName = pAddressName.trim(); sName = "Email " + ((sName != "") ? sName : sResult);} else {sName = "Email " + sResult;};
	if (sResult != "") {if (encodeURI) { sResult = encodeURI(sResult); }; sResult = "<a href=\"mailto:" + sResult + "\" alt=\"" + sName + "\" title=\"" + sName + "\">" + sResult + "</a>"; };
	return sResult;
	}

//----------------------------------------------------------------------------------------------------
//-- Redirect the browser to the url provided
//----------------------------------------------------------------------------------------------------
function redirectBrowser(url)
	{
	location.href = url;
	};

function isBlank(pString)
	{
	if (pString.replace(/^\s*/gi, '').replace(/\s*$/gi, '') == '')
		{ return true; }
	else
		{ return false; };
	};

String.prototype.trim = function ()
	{
	return this.replace( /^\s*(\S*(\s+\S+)*)\s*$/, "$1");
    };

function createClickPreventionDiv()
		{
		destroyClickPreventionDiv();
		var pClickDIV = document.createElement('div');
		pClickDIV.id = 'QDS_ClickPrevention';
		pClickDIV.style.position = 'absolute';
		pClickDIV.style.top = 0;
		pClickDIV.style.left = 0;
		pClickDIV.style.height = Math.round(parseInt(window.innerHeight ? window.innerHeight : (document.body.clientHeight ? document.body.clientHeight : (document.body.offsetHeight ? document.body.offsetHeight : 460)))) + 'px'
		pClickDIV.style.width = Math.round(parseInt(window.innerWidth ? window.innerWidth : (document.body.clientWidth ? document.body.clientWidth : (document.body.offsetWidth ? document.body.offsetWidth : 630)))) + 'px';
		pClickDIV.style.transparency = '100%';
		pClickDIV.zIndex = 100;
		pClickDIV.zOrder = 100;
		pClickDIV.style.background = 'none';
		pClickDIV.visibility = 'visible';
		document.body.appendChild(pClickDIV);
		}; //createClickPreventionDiv()

function destroyClickPreventionDiv()
		{
		var pClickDIV = document.getElementById('QDS_ClickPrevention');
		if (pClickDIV)
			{
			pClickDIV.style.visibility = 'hidden';
			document.body.removeChild(pClickDIV);
			};
		}; //destroyClickPreventionDiv()

function addEvent(pObj, pEventName, pFunction)
	{
	var retValue = false;
	try
		{
		if (pObj.addEventListener)
			{ pObj.addEventListener(pEventName, pFunction, true); retValue = true; }
		else if (pObj.attachEvent)
			{ retValue = pObj.attachEvent(pEventName, pFunction); }
		else
			{ pObj[pEventName] = pFunction; };
		}
	catch (ex) {};
	return retValue;
	};

function removeEvent(pObj, pEventName, pFunction)
	{
	try
		{
		if (pObj.detachEvent)
			{ pObj.detachEvent(pEventName, pFunction); }
		else
			{
			if (pObj.removeEventListener)
				{ pObj.removeEventListener(pEventName, pFunction, true); }
			else
				{ pObj[pEventName] = null; };
			};
		}
	catch (ex) {};
	};

function stopEvent(pEvent)
	{
	try
		{
		if (pEvent.stopPropagation)
			{
			pEvent.stopPropagation();
			pEvent.preventDefault();
			}
		else
			{
			if (typeof pEvent.cancelBubble != 'undefined')
				{
				pEvent.cancelBubble = true;
				pEvent.returnValue = false;
				};
			};
		}
	catch (ex) {};
	return false;
	};
