function list_item (key, value) {
	this.key = key;
	this.value = value;
}

function LoadDropDownEx (f,c,d) {
	var options = '';
	for (var i = 0; i < d.length; i++) {
		options += '<option value="' + d[i].key + '">' + d[i].value + '</option>';
	}
	$("#" + f + " select[name='" + c + "']").html(options);
}

function IQ_Highlight ( n, h, c ) {
	return h.replace("(" + n + ")", "<span style='color:" + c + ";'>" + n + "</span>");
}
function IQ_Unformat_Number (value) {
	var x = new String (value);
	x = x.replace(/,/g,"");
	x = x.replace(/%/g,"");
	return x;
}

function IQ_Format_Float (value, decimals) {
	decimals = (decimals == null) ? 2 : decimals;

	var num = new NumberFormat();
	num.setInputDecimal('.');
	num.setNumber(value);
	num.setPlaces(decimals, false);
	num.setCurrency(false);
	num.setNegativeFormat(num.LEFT_DASH);
	num.setSeparators(true, ',', ',');
	return num.toFormatted();
}
function IQ_Format_Perc (value, decimals) {
	decimals = (decimals == null) ? 2 : decimals;

	var num = new NumberFormat();
	num.setInputDecimal('.');
	num.setNumber(value);
	num.setPlaces(decimals, false);
	num.setCurrency(false);
	num.setNegativeFormat(num.LEFT_DASH);
	num.setSeparators(true, ',', ',');
	return num.toFormatted() + '%';
}
function IQ_RemoveOption (f, cmb, ix) {
	document.forms[f].elements[cmb].remove(ix);
}
function IQ_IsNumeric (value) {
	value = IQ_Unformat_Number ( value );
	value = 1.0 * value;

	if (isNaN(value))
		return false;
	else
		return true;
}
function IQ_IsGTZ (value) {
	value = IQ_Unformat_Number ( value );
	value = 1.0 * value;
	if (value > 0)
		return true;
	else
		return false;
}
function IQ_ConfirmDelete(what) {
	if (confirm ("Are you sure you want to delete this " + what + "?")) {
		return true;
	} else {
		return false;
	}
}

{ /* Custom RSV Validation Functions */
	function isValidIDNumber(id_number) {
		var val1 = 0;
		var val2 = 0;
		var tmpVal = 0;
	
		for (ix = 0; ix < 13; ix += 2) {
			val1 += parseInt(id_number.charAt(ix));
		}
	
		for (ix = 1; ix < 12; ix += 2) {
			tmpVal = parseInt(id_number.charAt(ix)) * 2;
			if (tmpVal >= 10) {
				tmpVal = (tmpVal - 10) + 1;
			}
			val2 += tmpVal;
		}
	
		var iTotal = ((val1 + val2) / 10);
		tmpVal = iTotal.toString(10);
	
		var sTmp = ".";
		var iValid = tmpVal.indexOf(sTmp, 0);

		if (iValid == -1) {
			return true;
		} else {
			return false;
		}
	}
}