function AskDelete(iMsg) {
	if (iMsg != null)
		// return confirm(iMsg + "\n- there is no undo for this action.");
		return confirm(iMsg);
	else
		return confirm("Are you sure you want to delete this item?\n- there is no undo for this action.");
}
function ValidateDate(year, month, day)
{
	if (year < 0 || month <= 0 || month > 12 || day <= 0 || day > 31)
		return false;
	if (month == 2 || month == 4 || month == 6 || month == 9 || month == 11)	{
		if (day > 30)
			return false;
	}
	if (month == 2)	{
		if (day > 29)
			return false;
		if (year / 4 != parseInt(year / 4) && day > 28)
			return false;
	}
	return true;
}
function decimalFormat(num,commaFormat) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	if (commaFormat){
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
	}
//	return (((sign)?'':'-') + '$' + num + '.' + cents);
	return (((sign)?'':'-') + num + '.' + cents); // without the dollar symbol
}
function checkABN(iNum){
	// First check that the number is numeric
	//if (!Validate_int(iNum, 'Invalid ABN')) {
	if (iNum.match(/\D/g)) {
		return false;
	}
	arrWeight = new Array(10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19);
	numOrig = iNum;
	arr = iNum.split("");
	iSum = 0;
	for (i=0; i<arr.length; i++){
		arr[i] = parseInt(arr[i]);
		if (!i) arr[0] -= 1;
		iSum += arr[i] * arrWeight[i];
	}
	sCheck = String(iSum / 89);
	if (sCheck.indexOf(".") == -1)
		return true;
	else
		return false;
}
function checkACN(iNum){
	arrWeight = new Array(8, 7, 6, 5, 4, 3, 2, 1);
	iNum = iNum.replace(/\s/g, "");
	arr = iNum.split("");
	iSum = 0;
	for (i=0; i<8; i++){ // not the check
		arr[i] = parseInt(arr[i]);
		iSum += arr[i] * arrWeight[i];
	}
	sByTen = String(iSum / 10);
	aRem = sByTen.split(".");
	if (!aRem.length)
		return false;
	aRem = aRem[1].split("");
	if (10 - parseInt(aRem[0]) == arr[8]) // if the check is valid
		return true;
	else
		return false;
}
function ucfirst(s){
	if(void(0)==s||""==s)
		return "";
	if(isNaN(parseInt(s))) {
		return s.charAt(0).toUpperCase() + s.substr(1).toLowerCase();
	} else {
		return s;
	}
}
function lcfirst(s){
	if(void(0)==s||""==s)
		return "";
	if(isNaN(parseInt(s))) {
		return s.charAt(0).toLowerCase() + s.substr(1);
	} else {
		return s;
	}
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}


