﻿ // <![CDATA[
 
//clientscripts - This service include critial client side javascript functions
var _csDefault_IgnoreZIndexsAbove=1000000;


//
//create prototype extensions for existing functions
String.prototype.cs_trim=function() { return this.replace(/^\s*|\s*$/g,''); }
String.prototype.cs_ltrim=function() { return this.replace(/^\s*/g,''); }
String.prototype.cs_rtrim=function() { return this.replace(/\s*$/g,''); }


//this function colapses/expands an object and changes the control object to +/-
function cs_collapseElement(sObject, sCtrlObject) { var oObject=document.getElementById(sObject); if(oObject.style.display=='none'){ oObject.style.display='block'; sCtrlObject.innerHTML=unescape('-'); }else{ oObject.style.display='none'; sCtrlObject.innerHTML=unescape('+'); }}

//this function colapses/expands an object and changes the ImageButton object to on and off images
function cs_collapseElement_Basic(sObject) { var oObject=document.getElementById(sObject); if(oObject.style.display=='none'){ oObject.style.display='block'; }else{ oObject.style.display='none'; }}


//
//
//package variables support
function cs_serialiseValues(vSerialValues) {
//this function returns a serial string containing the values - the function filters nulls and undefined values
var vArg, cSOH=String.fromCharCode(1), sSerialised=cSOH, cUnitSeperator=String.fromCharCode(31), cUndefined=String.fromCharCode(4), cObject=String.fromCharCode(24);
	for (var n=0; n<=((arguments.length)-1); n++) { 
		switch(typeof(arguments[n])) { case 'undefined': vArg=cUndefined; break; case 'object': vArg=cObject; break; default: vArg=arguments[n]; break; } //filter values to replace undefined, or null values
		sSerialised+=vArg; if(n<((arguments.length)-1)) { sSerialised+=cUnitSeperator; } //add end of field seperator
	}
	return(sSerialised);
}

function cs_extractValues(sSerialisedValues) {
//this function returns an array element (base 0) containing all the variables serialised - the function filters nulls and undefined values
var rsExtractValues, vValue, cSOH=String.fromCharCode(1), cUnitSeperator=String.fromCharCode(31), cUndefined=String.fromCharCode(4), cObject=String.fromCharCode(24);
	if(sSerialisedValues.substr(0,1)==cSOH) {
		sSerialisedValues=sSerialisedValues.replace(cSOH,''); rsExtractValues=sSerialisedValues.split(cUnitSeperator);
		for(var lElement in rsExtractValues) { switch(rsExtractValues[lElement]) { case cUndefined: rsExtractValues[lElement]=undefined; break; case cObject: rsExtractValues[lElement]=null; break; default: rsExtractValues[lElement]=rsExtractValues[lElement]; break; }}
	}
	return(rsExtractValues);
}



//
//
//standard support functions
function cs_IsIE() { return Prototype.Browser.IE; } //this function returns true/false

function cs_Focus(sObject) { var oObject=document.getElementById(sObject); if(oObject) { oObject.select(); oObject.focus(); }} //this function focus's the specified object
function cs_Blur(sObject) { var oObject=document.getElementById(sObject); if(oObject) { oObject.blur(); }} //this function blurs the specified object

function cs_Form(sObject) { var oObject, sName, sId; oObject=document.getElementById(sObject); if(oObject) { try { sName=oObject.form.name; } catch(err) { sName=''; } try { sId=oObject.form.id; } catch(err) { sId=''; }} return { name: sName, id: sId };} //this function returns multiple values - you must select the appropriate return code or assign the function to a variable



function cs_MaximumZ(lIgnoreLimit) {
//this functions returns the maximum zindex, uses _csDefault_ZLimit to define a limit if not supplied
var oObjects=document.getElementsByTagName('div'), lCount, lMaxZIndex=0, lZIndex=0;
	if(!cs_IsNumeric(lIgnoreLimit)) { lIgnoreLimit=_csDefault_IgnoreZIndexsAbove; }
	for(lCount=0;lCount<oObjects.length;lCount++) { try { lZIndex=cs_getObjectProperty(oObjects[lCount]).zindex; } catch(err) { lZIndex=0; }
		if((lZIndex<lIgnoreLimit) && (lZIndex>lMaxZIndex)) { lMaxZIndex=lZIndex; }
	}
	return(lMaxZIndex+1);
}



//
//
//string support functions
function cs_StringLength(vValue) { var sString; try { sString=String(vValue); } catch(err) { sString=''; }; return sString.length; } //this function returns the length of the specified string

function cs_splitString(sString, sSeperator) { var rsSplitArray='', lElements=-1; if(cs_StringLength(sString)>0) { rsSplitArray=sString.split(sSeperator); lElements=rsSplitArray.length; if(lElements>0) { lElements--; }} return{ string: rsSplitArray, elements: lElements };}

function cs_encodeHTML(sString) { var sEncode; sEncode=escape(sString); sEncode=sEncode.replace(/\//g,'%2F'); sEncode=sEncode.replace(/\?/g,'%3F'); sEncode=sEncode.replace(/=/g,'%3D'); sEncode=sEncode.replace(/&/g,'%26'); sEncode=sEncode.replace(/@/g,'%40'); return sEncode; }


//
//
//validation support functions
function cs_IsAlpha(vValue) { var regEx=/^[a-zA-Z\W]{0,}$/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is alpha
function cs_IsAlphaNumeric(vValue) { var regEx=/^[a-zA-Z_0-9\s\W]{0,}$/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is alphanumeric
function cs_IsNumeric(vValue) { var regEx=/^-{0,1}\d*\.{0,1}\d+$/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is numeric
function cs_IsEmail(vValue) { var regEx=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is an email format
function cs_IsPhone(vValue) { var regEx= /^(\+\d{0,})*\s*(\(\d{0,}\)\s*)*\d{0,}(-{0,1}|\s{0,1})\d{0,}(-{0,1}|\s{0,1})\d{0,}$/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is an phone format +XX (XX) XXX-XXXX etc.
function cs_IsUKDate(vValue) { var regEx=/^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is ukdate dd/mm/yyyy
function cs_IsUSDate(vValue) { var regEx=/^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/, bStatus=false; if(regEx.test(vValue)) { bStatus=true; } return bStatus; } //this function returns true/false depending on whether the vValue is usdate mm/dd/yyyy
function cs_IsBlank(vValue) { var bStatus=false; if(cs_StringLength(vValue)==0) { bStatus=true;} return bStatus;} //this function returns true/false depending on whether the vValue is blank
function cs_IsNull(sValue) { var bStatus=true, vValue=''; if(cs_IsAlphaNumeric(sValue)) { try { vValue=sValue.toString().toLowerCase(); } catch(err) { vValue='null'; } switch (vValue) { case 'undefined': break; case 'null': break; default: bStatus=false; break; }}; return(bStatus); }


function cs_ValidatePassword(vValue, lMinChars, lMaxChars, lLower, lUpper, lNumeric) { 
//this password returns the status of the specified password
var bStatus=false, lowerChars=0, upperChars=0, numericChars=0, sMessage='', lMode=0, lLength=cs_StringLength(vValue);
	if(cs_IsAlphaNumeric(vValue)) {
		if(lLength>=lMinChars && lLength<=lMaxChars) {
			sMessage='password: okay'; bStatus=true; lowerChars=(vValue.match(/[a-z]/g)); upperChars=(vValue.match(/[A-Z]/g)); numericChars=(vValue.match(/[0-9]/g)); //calculate character counts
			try { lowerChars=parseInt(lowerChars.length, 10); } catch(err) { lowerChars=0; } try { upperChars=parseInt(upperChars.length, 10); } catch(err) { upperChars=0; } try { numericChars=parseInt(numericChars.length, 10); } catch(err) { numericChars=0; }		
			if(lowerChars<lLower) { bStatus=false; sMessage='password: too few lowercase characters'; lMode=-3; } 
			if(upperChars<lUpper) { bStatus=false; sMessage='password: too few uppercase characters'; lMode=-4; } 
			if(numericChars<lNumeric) { bStatus=false; sMessage='password: too few numeric characters'; lMode=-5; }
		} else { sMessage='password: unexpected length'; lMode=-2; }
	} else { sMessage='password: invalid'; lMode=-1; }
	return{status: bStatus, message: sMessage, mode: lMode};
 }



//
//
//
//pre-built quick call object functions
function cs_setObjectVariable(sObject, sVariable, vValue) { var oObject=document.getElementById(sObject); if(oObject) { oObject.setAttribute(private_supportFilterAttributeName(sVariable), vValue); }} //this function sets the object variable/attribute
function cs_getObjectVariable(sObject, sVariable) { var oObject=document.getElementById(sObject); if(oObject) { return(oObject.getAttribute(private_supportFilterAttributeName(sVariable))); }} //this function gets the object variable/attribute
function cs_getObjectVariableA(oObject, sVariable) { if(oObject) { return(oObject.getAttribute(private_supportFilterAttributeName(sVariable))); }} //this function gets the object variable/attribute
function cs_setObjectValue(sObject, vValue) { var oObject=document.getElementById(sObject); if(oObject) { oObject.value=vValue; }} //save the objects value
function cs_getObjectValue(sObject) { var oObject=document.getElementById(sObject); if(oObject) { return(oObject.value); }} //recover the objects value
function cs_setObjectZIndex(sObject, lZIndex) { var oObject=document.getElementById(sObject); if(oObject) { oObject.style.zIndex=lZIndex;}} //this function sets the zIndex
function cs_setObjectSourceAttribute(sObject, sSource, sTitle) { var oObject=document.getElementById(sObject); if(oObject) { try { oObject.src=sSource; oObject.title=sTitle; } catch(err) {}}} //this function sets the specified objects source


function cs_setObjectColour(sObject, sBackgroundHexColour, sForgroundHexColour) { var oObject=document.getElementById(sObject); if(oObject) { oObject.style.backgroundColor=sBackgroundHexColour; oObject.style.color=sForgroundHexColour; }} //this function sets the object colour
function cs_setObjectBorder(sObject, sBorderHexColour, sBorderWidth) { var oObject=document.getElementById(sObject); if(oObject) { oObject.style.borderColor=sBorderHexColour; oObject.style.borderWidth=sBorderWidth; }} //this function sets the object border
function cs_setObjectDisabled(sObject, bDisabled) { var oObject=document.getElementById(sObject); if(oObject) { if(bDisabled) { oObject.disabled=true; } else { oObject.disabled=false; }}} //this function disables/enables the specified element



function cs_dynamicElement(sParent, sIdentification, sTag, sClass, sPosition, lLeft, lTop, lWidth, lHeight, lBottom, lZIndex, lOpacityPercent, sBackgroundColor, sBackgroundImage, bScrollBackground, sBackgroundRepeat, bOverFlowScrollX, bOverFlowScrollY, bHide, sSource) {
//this private function creates a dynamic element and returns the element id
// cs_dynamicElement('divContainer', 'myNewElement', 'img', 'shape', 'absolute', 10, 10, 100, 100, 0, 1000, '/images/shape.jpg', true | false, 'repeat' | 'no-repeat' | 'repeat-x' | 'repeat-y' | 'inherit', true | false, true | false, true | false, '/images/imagesSource.jpg')
var sId=null, bStatus=false, oElement, oParent, sBackgroundAttachment, sOverFlowX, sOverFlowY, lOpacityMoz;

	//check the type of tag
	switch(sTag) {
		case 'div': bStatus=true; break;
		case 'img': bStatus=true; break;	
	}

	if(bStatus) {
		bStatus=false;
		oElement=document.createElement(sTag);
		if(oElement) {
			oParent=document.getElementById(sParent);
			if(oParent) {
				oElement.setAttribute('id',sIdentification); //define the dynamic element id
				oParent.appendChild(oElement); //attach the dynamic element to the parent container
				sId=oElement.getAttribute('id');

				if(bScrollBackground) { sBackgroundAttachment='scroll'; } else { sBackgroundAttachment='fixed'; }
				if(bHide) { oElement.style.visibility='hidden'; }

				//define the basic style elements
				oElement.className=sClass; oElement.style.display='block'; oElement.style.position=sPosition;
				
				if(sSource.length>0) { oElement.src=sSource; }
				if(sBackgroundColor.length>0) { oElement.style.backgroundColor=sBackgroundColor; } 
				if(sBackgroundImage.length>0) { oElement.style.backgroundImage='url(\'' + sBackgroundImage + '\')'; oElement.style.backgroundAttachment=sBackgroundAttachment; oElement.style.backgroundRepeat=sBackgroundRepeat; }
				
				
				//define opacity levels
				 if(cs_IsNumeric(lOpacityPercent)) { 
					if(lOpacityPercent>99) { lOpacityPercent=100; lOpacityMoz=1; } 
					if(lOpacityPercent<1) { lOpacityPercent=0; lOpacityMoz=0; }
					if(lOpacityPercent>0 || lOpacityPercent<100) {
						lOpacityMoz=lOpacityPercent/100;
					}
				} else { 
					lOpacityPercent=0; lOpacityMoz=0; 
				}
		 
				oElement.style.opacity=lOpacityMoz; //mozilla - configuration
				oElement.style.filter='alpha(opacity=' + lOpacityPercent + ')'; //ie - configurations
				
				
				//filter absolute coordinates
				if(isNaN(lLeft)==true) { lLeft=lLeft; } else { lLeft=lLeft + 'px'; } if(isNaN(lTop)==true) { lTop=lTop; } else { lTop=lTop + 'px'; }
				if(isNaN(lWidth)==true) { lWidth=lWidth; } else { lWidth=lWidth + 'px'; } if(isNaN(lHeight)==true) { lHeight=lHeight; } else { lHeight=lHeight + 'px'; }
				if(isNaN(lBottom)==true) { lBottom=lBottom; } else { lBottom=lBottom + 'px'; }
				
				
				//configure the overflow
				switch(bOverFlowScrollX) { case true: sOverFlowX='auto'; break; case false: sOverFlowX='hidden'; break; default: sOverFlowX='visible'; }
				switch(bOverFlowScrollY) { case true: sOverFlowY='auto'; break; case false: sOverFlowY='hidden'; break; default: sOverFlowY='visible'; }		
				oElement.style.overflowX=sOverFlowX; oElement.style.overflowY=sOverFlowY; oElement.style.zIndex=lZIndex;	
				
				
				//configure the coordinates - where they contain numerical values
				if(!isNaN(parseInt(lLeft, 10))) { oElement.style.left=lLeft; } if(!isNaN(parseInt(lTop, 10))) { oElement.style.top=lTop; } if(!isNaN(parseInt(lWidth, 10))) { oElement.style.width=lWidth; } if(!isNaN(parseInt(lHeight, 10))) { oElement.style.height=lHeight; }
				if(!isNaN(parseInt(lBottom, 10))) { oElement.style.bottom=lBottom; }
				
				
				bStatus=true;	
			}	
		}
	}
	return { id: sId, left: lLeft, top: lTop, width: lWidth, height: lHeight, status: bStatus, object: oElement }
}



function cs_getObjectProperty(oObject) {
//this function returns the specified properties base on the supplied object
var oParent, sParentPositioning, oStyle, lZIndex=0, lLeftPx=0, lTopPx=0, lHeight=0, lWidth=0, lActualHeightPx=0, lActualWidthPx=0, sClassName='', sPosition='', sVisibility='', bReadOnly=false, vValue='', bStatus=false;
	if(oObject) { //confirm object
		
		oParent=oObject.parentNode;
		
		bStatus=true;
		sClassName=oObject.className; 
		bReadOnly=oObject.getAttribute('readonly');
		vValue=oObject.value; 

		//calculate coordinates - relative to parent container
		if(oParent) { //get the parent position type
			switch (cs_IsIE()) { 
				case true: sParentPositioning=oParent.currentStyle.position; break; 
				default: sParentPositioning=document.defaultView.getComputedStyle(oParent, null).getPropertyValue('position'); switch(sParentPositioning) { case 'relative': break; default: oParent.style.position='relative'; break; } break;
			}
			//FireFox - this function requires the parent object is using relative positions - to fix this the parent container is temp. switched to relative
			lLeftPx=oObject.offsetLeft; lTopPx=oObject.offsetTop; oParent.style.position=sParentPositioning;
		}
		
		lActualHeightPx=oObject.offsetHeight; 
		lActualWidthPx=oObject.offsetWidth;

		if(cs_IsIE()) { //create object shortcut - microsoft ie
			oStyle=oObject.currentStyle; 
			lZIndex=oStyle['zIndex']; //an alternative version is: lZIndex=oObject.currentStyle.zIndex;
			lHeight=oStyle.height; 
			lWidth=oStyle.width; 
			sPosition=oStyle.position; 
			sVisibility=oStyle.visibility;
		} else { //create object shortcut - non ie browsers
			oStyle=document.defaultView.getComputedStyle(oObject, null); 
			lZIndex=oStyle.getPropertyValue('z-index'); 
			lHeight=oStyle.getPropertyValue('height'); 
			lWidth=oStyle.getPropertyValue('width'); 
			sPosition=oStyle.getPropertyValue('position'); 
			sVisibility=oStyle.getPropertyValue('visibility');
		}
	}
	try { lZIndex=parseInt(lZIndex, 10); } catch(err) { lZIndex=0; } //apply numeric filtering	
	return { zindex: lZIndex, height: lHeight, width: lWidth, left: lLeftPx, top: lTopPx, actualheight: lActualHeightPx, actualwidth: lActualWidthPx, classname: sClassName, position: sPosition, visibility: sVisibility, readonly: bReadOnly, value: vValue, status: bStatus };
}

function cs_getImageProperty(oImage) {
//this function returns the property of the specified image - note: relative to parent container
var oProperty, lLeftPx=0, lTopPx=0, lHeightPx=0, lWidthPx=0;

	oProperty=cs_getObjectProperty(oImage);
	lLeftPx=oProperty.left+'px'; 	lTopPx=oProperty.top+'px'; lHeightPx=oProperty.actualheight + 'px'; lWidthPx=oProperty.actualwidth + 'px';
	return { left: lLeftPx, top: lTopPx, height: lHeightPx, width: lWidthPx };
}


//
//
//beta functions
function cs_resetValues(sForm) {
//this function resets all the selected form element values
var oForm=document.getElementById(sForm), oElement;

	for(var i=0; i<=(oForm.elements.length-1); i++) { oElement=oForm.elements[i];
		switch(oElement.type.toLowerCase()) {
			case 'button':			break;
			case 'checkbox':	if(oElement.checked) { oElement.checked=false; }; break; 
			case 'file':				break;
			case 'hidden':			break;
			case 'image':			break;
			case 'password':		oElement.value=''; break;
			case 'radio':			if(oElement.checked) { oElement.checked=false; }; break;
			case 'select-one':	oElement.selectedIndex=-1; break;
			case 'select-multiple':	oElement.selectedIndex=-1; break;
			case 'submit':			break;
			case 'text':				oElement.value=''; break;
			case 'textarea':		oElement.value=''; break;
		}
	}
}


function cs_ListAllObjectProperties(oObject) {
//this function lists all the properties in the specified object
	for (var name in oObject) {  
		alert(name); 
	}
}


function cs_ListAllElements() {
//this function lists all the elements in the current document
var oObjects=document.getElementsByTagName('*')
itot = oObjects.length

	for(var lCount=0; lCount<oObjects.length; lCount++) {
		oObjects[lCount].tagName;
	}

}


function getElementsByClassName(sClassName, sContainer) {
//this function returns all the elements in the specified container (or the body) - an example call: oObject=getElementsByClassName('shape',''); for(var i=0; i<oObject.length; i++) { alert('xx: ' + oObject[i].id); }
var oContainer, rsElements=[], oObjects;

	oContainer=document.getElementById(sContainer);
	if(!oContainer) { 
		oContainer=document.getElementsByTagName("body")[0]; 
	} //use body - if no container specified    
	
	oObjects=document.getElementsByTagName('*');
	for(var lCount=0; lCount<oObjects.length; lCount++) { 
		if(oObjects[lCount].className==sClassName) {
			rsElements.push(oObjects[lCount]); 
		}
	}
	return rsElements;
}



function getElementsByAttribute(sAttribute, sValue, sContainer) {
//this function returns all the elements in the specified container (or the body) - an example call: oObject=getElementsByClassName('shape',''); for(var i=0; i<oObject.length; i++) { alert('xx: ' + oObject[i].id); }
var oContainer, rsElements=[], sAttributeValue, oObjects;

	oContainer=document.getElementById(sContainer);
	if(!oContainer) { 
		oContainer=document.getElementsByTagName("body")[0]; 
	} //use body - if no container specified    
	
	oObjects=document.getElementsByTagName('*');
	for(var lCount=0; lCount<oObjects.length; lCount++) {
	
		sAttributeValue=cs_getObjectVariableA(oObjects[lCount], sAttribute);
		if(cs_IsAlphaNumeric(sAttributeValue)) {		
			if(sAttributeValue==sValue) { 
				rsElements.push(oObjects[lCount]);
			}
		}
	}
	return rsElements;
}



//
//
//cookie services
function cs_deleteCookie(sName) { cs_deleteCookie(sName,"-1", -1); } //remove a cookie by setting its expiry date to the passed
function cs_setCookie(sName, vValue, lDays) { var dToday = new Date(), dExpire = new Date(); if (lDays==null || lDays==0) { lDays=1; } dExpire.setTime(dToday.getTime() + 3600000*24 * lDays); document.cookie = sName+"="+escape(vValue) + ";expires="+dExpire.toGMTString(); } //set a cookie that will expire in lDays
function cs_readCookie(sName) { var sCookie=""+document.cookie, ind=sCookie.indexOf(sName), ind1=sCookie.indexOf(';',ind); if (ind==-1 || sName=="") { return ""; } if (ind1==-1) { ind1=sCookie.length; } return unescape(sCookie.substring(ind+sName.length+1,ind1)); } //read a cookie
function cs_cookiesActive() { var lStatus=0; cs_setCookie('ActiveTest', 1); if(cs_readCookie('ActiveTest')==1) { lStatus=1; cs_deleteCookie('ActiveTest');} return lStatus; } //this tests whether cookies are active on the users browser, returns 0 if disabled



//
//
//conversion functions
function cs_convertBooleanBit(bBoolean) { switch(bBoolean) { case true: return(1); break; default: return(0); }} //this function converts a javascript boolean into a 1 or 0
function cs_convertBitBoolean(lBit) { try{ lBit=parseInt(lBit, 10); } catch(err) { lBit=0; }; switch(lBit) { case 1: return(true); break; case -1: return(true); break; default: return(false); }} //this function converts a 1 or -1 into a javascript boolean true
function cs_convertYESNOBoolean(sString) { var bStatus=false, sValue; if(cs_IsAlphaNumeric(sString)) { sValue=sString.toLowerCase(); switch(sValue) { case 'yes': bStatus=true; break; case 'y': bStatus=true; break; default: bStatus=false; break; }}; return bStatus; }
function cs_appendString(sOriginal, sAppend, sPrefix) { var sString=''; if(cs_IsAlphaNumeric(sOriginal)) { sString=sOriginal;} if(!cs_IsAlphaNumeric(sPrefix)) { sPrefix='';} if(cs_IsAlphaNumeric(sAppend)) { if(cs_StringLength(sAppend)>0) { if(cs_StringLength(sString)>0) { sString=sString + sPrefix; } sString=sString + sAppend; }}; return(sString); } //this function returns the appended string to the specified original


//
//
//html management functions
function cs_fireEvent(oObject, sEvent) { var csEvent; if(cs_IsIE()) { csEvent=document.createEventObject(); return oObject.fireEvent('on'+sEvent, csEvent); } else { csEvent=document.createEvent('HTMLEvents'); csEvent.initEvent(sEvent, true, true); 	return !oObject.dispatchEvent(csEvent); }} //this function creates a dynamic event call

function cs_switchCheckbox(oObject) { switch(oObject.checked) { case true: oObject.value="Yes"; break; case false: oObject.value="No"; break; }} //this function switches the specified checkbox value depending on the user clicking
function cs_disableElement_ViaCheckbox(sObjectCheckbox, sObjectElement) { switch(document.getElementById(sObjectCheckbox).value) { case "Yes": document.getElementById(sObjectElement).disabled=false; break; case "No": document.getElementById(sObjectElement).disabled=true; break; } } //this function disables the specified checkbox
function cs_launchBrowserWindow(sURL, sTitle) { window.open(sURL, sTitle, "height=300, width=300, left=10, top=10, menubar=no, toolbar=no, scrollbars=yes, status=no, resizeable=no, dependent=yes, location=no") }
function cs_launchUploaderWindow(sURL, sTitle) { window.open(sURL, sTitle, "height=230, width=500, left=10, top=10, menubar=no, toolbar=no, scrollbars=yes, status=no, resizeable=no, dependent=yes, location=no") }


//
//
//private support functions
function private_supportFilterAttributeName(sAttribute) { return(sAttribute); }

// ]]>