	var alertMsg;
	var focusControl = "";

	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	
	function addMessage(newmsg) {
		if (alertMsg=='') {
			alertMsg = newmsg;
		} else {
			alertMsg = alertMsg + '       \n' + newmsg;
		}
		return alertMsg;
	}
	
	function setCheckFocus(ctrl) {
		if (focusControl=="") {
			focusControl = ctrl
		}
	}
	
	function checkEmptyText(ctrl,newmsg) {
		retValue = true;
		if (trim(ctrl.value)=='') { // text
			addMessage(newmsg);
			retValue = false;
			setCheckFocus(ctrl);
		}
		return retValue;
	}
	
	function checkSelect(ctrl,defaultValue,newmsg) {
		retValue = true;
		if (ctrl.value==defaultValue) { // Select/DrowpDown
			addMessage(newmsg);
			retValue = false;
			setCheckFocus(ctrl);
		}
		return retValue;
	}
	
	function checkCheckbox(ctrl,newmsg) {
		retValue = true;
		if (ctrl.checked!=true) { // Checkbox
			addMessage(newmsg);
			retValue = false;
			setCheckFocus(ctrl);
		}
		return retValue;
	}
	
	function checkRadiobutton(ctrl,selectedValue,newmsg) {
		retValue = true;
		
		radioLength = ctrl.length;		
		for(var i = 0; i < radioLength; i++) {
			if(ctrl[i].checked && ctrl[i].value!=selectedValue) {
				addMessage(newmsg);
				retValue = false;
				setCheckFocus(ctrl);
			}
		}
		
		return retValue;
	}
	
