// Cross Browser Layer Visibility / Placement Routines
// Source: http://www.htmlref.com/examples/chapter14/cross_browserJS_src.html
// test for objects
function changeDisplay(id,action)
{
	if(document.getElementById) {
		var styleobj = document.getElementById(''+id+'').style;
	} else if(document.all) {
		var styleobj = document.all[''+id+''].style;
	} else {
		return;
	}
	//alert(styleobj.display); return;
	switch(action)
	{
	case "show":
		styleobj.visibility = "visible";
		styleobj.display = "";
		break;
	case "hide":
		styleobj.visibility = "hidden";
		styleobj.display = "";
		break;
	case "none":
		styleobj.visibility = "hidden";
		styleobj.display = "none";
		break;
	case "vtoggle":
		styleobj.display = "";
		if(styleobj.visibility == "visible" || styleobj.visibility == "") {
			styleobj.visibility = "hidden";
		} else {
			styleobj.visibility = "visible";
		}
		break;
	case "dtoggle":
		if(styleobj.visibility == "visible" || styleobj.visibility == "") {
			styleobj.visibility = "hidden";
			styleobj.display = "none";
		} else {
			styleobj.visibility = "visible";
			styleobj.display = "";		
		}
		break;
	}
}
function changePosition(id,x,y)
{
	if (layerobject)
	{
		document.layers[''+id+''].left = x;
		document.layers[''+id+''].top = y;
	}
	else if (allobject)
	{
		document.all[''+id+''].style.left=x;
		document.all[''+id+''].style.top=y;
	}
	else if (dom)
	{
		document.getElementById(''+id+'').style.left=x+"px";
		document.getElementById(''+id+'').style.top=y+"px";
	}
	return;
}
// Disable/Enable form elements of the given type
function DisableFormElements(formObj, isDisabled, elementType)
{
	var i, formLength;
	if(!formObj) { return; }
	if(!formObj.elements.length) { return; }
	formLength = formObj.elements.length;
	for(i = 0; i < formLength; i++) {
		if(formObj.elements[i].type == elementType) {
			formObj.elements[i].disabled=isDisabled;
		}
	}
}

function formatCurrency(amount)
{
	if(amount == undefined || amount == null) return amount;
	amount = new String(amount);
	if(amount.charAt(0) == "-") {
		amount = amount.substring(1,amount.length);
		neg = "-";	
	} else {
		neg = "";
	}
	// handle .D
	if(amount.match(/^\.\d$/) != null) {
		return neg + "0"+amount+"0";
	}
	// handle .DD
	if(amount.match(/^\.\d\d$/) != null) {
		return neg + "0"+amount;
	}
	// strip leading zeros
	amount = amount.replace(/^0+([1-9])/,"$1");
	amount = amount.replace(/^0+\./,"0.");
	// handle N
	if(amount.match(/^\d+$/) != null) {
		return neg + amount + ".00";
	}
	// handle N.
	if(amount.match(/^\d+\.$/) != null) {
		return neg + amount + "00";
	}
	// handle N.D
	if(amount.match(/^\d+\.\d$/) != null) {
		return neg + amount + "0";
	}
	// handle N.DD
	if(amount.match(/^\d+\.\d\d$/) != null) {
		return neg + amount;
	}
	return neg + amount;
}	