//Common javascript functions...

function test() {
	alert('ok');
}

// aka document.getElementById(id)
function get(id) {
	return document.getElementById(id);
}

function show(id) {
	if (get(id)) {
		get(id).style.display = 'block';
	}
}

function showInline(id) {
	if (get(id)) {
		get(id).style.display = 'inline';	
	}
}

function hide(id) {
	if (get(id)) {
		get(id).style.display = 'none';
	}
}

function isVisible(id) {
	return get(id).style.display != 'none';
}

function focus(id) {
	get(id).focus();	
}

function enable(id) {
	get(id).disabled = false;
}

function disable(id) {
	var e = get(id);
	e.disabled = true;
}

// get the checked value from a radio button control
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 "";
}



function formatCurrency(num) {
    if (isNaN(num)) { num = "0"; }
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    num = Math.floor(num/100).toString();
    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 );
}

String.prototype.endsWith = function(s){
	var reg = new RegExp(s + "$");
	return reg.test(this);
}
