﻿function popSystemMessageEdit(sMsgID) {
	if (window.parent.PopDialogFrame) {
		window.parent.PopDialogFrame("/Administration/Content/SystemMessagePopEdit.aspx?CID=0&ID=" + sMsgID, 700, 500, "Edit System Text", null, true);
	} else if (PopDialogFrame) {
		PopDialogFrame("/Administration/Content/SystemMessagePopEdit.aspx?CID=0&ID=" + sMsgID, 700, 500, "Edit System Text", null, true);
	} else {
		alert("SubModal handler not found.");
	}
}
function TrimString(str) {
	return str.replace(/^\s+/g, "").replace(/\s+$/g, "");
}
function TextAreaCntChars(textArea, maxChars) {
	var sT = TrimString(textArea.value);
	var charCnt = sT.length;
	if (charCnt > maxChars) {
		alert("You've exceeded the text limits for this field.\n\nThe max number of characters is " + maxChars + " (You have " + charCnt + ").");
		textArea.focus();
	}
}
function TextAreaShowChars(textArea, spanChars) {
	var sT = TrimString(textArea.value);
	var t;
	var charCnt = sT.length;
	document.getElementById(spanChars).innerHTML = "(Character&nbsp;Count:&nbsp;" + charCnt + ")";
}
function onlyIntNumbs(fld, e) {
	var sKey = '';
	var sCheck = '-0123456789';
	var iKeyCode;
	if (window.event) {
		iKeyCode = window.event.keyCode;
	} else if (e) {
		iKeyCode = e.which;
	} else {
		return true;
	}
	if (iKeyCode == 13) return true;
	sKey = String.fromCharCode(iKeyCode);
	if (sCheck.indexOf(sKey) == -1) return false;
	return true;
}

function onlyDecNumbs(fld, e) {
	var sKey = '';
	var sCheck = '-.0123456789';
	var iKeyCode;
	if (window.event) {
		iKeyCode = window.event.keyCode;
	} else if (e) {
		iKeyCode = e.which;
	} else {
		return true;
	}
	if (iKeyCode == 13) return true;
	sKey = String.fromCharCode(iKeyCode);
	if (sCheck.indexOf(sKey) == -1) return false;
	return true;
}

function isInteger(s) {
	var i;
	if (isEmpty(s)) {
		return false;
	} else {
		for (i = 0; i < s.length; i++) {
			var c = s.charAt(i);
			if (!isDigit(c)) {
				return false;
			}
		}
	}
	return true;
}

function isFloat(s) {
	var i;
	var iDotCnt = 0;
	if (isEmpty(s)) {
		return false;
	} else {
		for (i = 0; i < s.length; i++) {
			var c = s.charAt(i);
			if (!isDigit(c)) {
				if (c == "." && iDotCnt == 0) {
					iDotCnt = 1;
				} else {
					return false;
				}
			}
		}
	}
	return true;
}

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

function isDigit(c) {
	return ((c >= "0") && (c <= "9"))
}
