function copyToClipboard(val) {
	holdtext.innerText = val;
	copiedVal = holdtext.createTextRange();
	copiedVal.execCommand("Copy");
}	

function changeVisibility(obj, section) {
	value = obj.value;
	elem = document.getElementById(section); 	
	
	if(section == 'list') {
		if(value == 'Show Generated Text') {
			obj.value = 'Hide Generated Text';
			elem.style.display = 'block';
		}	
		else {	
			obj.value = 'Show Generated Text';
			elem.style.display = 'none';
		}
	}
	
	if(section == 'source') {
		if(value == 'Show Source Code') {
			obj.value = 'Hide Source Code';
			elem.style.display = 'block';
		}	
		else {	
			obj.value = 'Show Source Code';
			elem.style.display = 'none';
		}
	}
}

function processTemplate(action, val) {
	document.formSettings.actionValue.value = action;
	document.formSettings.templateId.value = val;	
	
	if(action=='delete') {
		if(!confirm('Are you sure you want to delete this template?'))
			return false;
	}
	document.formSettings.submit();
}

function changeBackground(tableId, linkId, val) {
	document.getElementById(tableId).style.backgroundColor = val;
	document.getElementById(linkId).style.color = val;
}

function checkNumeric(objName) {
	var numberfield = objName;
	if (chkNumeric(objName) == false) {
		numberfield.select();
		numberfield.focus();		
		return false;
	}
	else {
		return true;
	}
}

function chkNumeric(objName) {
	// only allow 0-9 be entered
	// (can be in any order, and don't have to be comma, period, or hyphen)

	var checkOK = "0123456789";
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	
	for (i = 0;  i < checkStr.value.length;  i++) {
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
			if (j == checkOK.length) {
				allValid = false;
				break;
			}
		if (ch != ",")
			allNum += ch;
	}
	
	if (!allValid) {	
		alertsay = "Please enter only these values \""
		alertsay = alertsay + checkOK + "\" in the \"CCBill Id field."
		alert(alertsay);
		return (false);
	}
}
