// JavaScript Document
var FIELD_FOCUS="focus";
var FIELD_BLUR="blur";

if(!document.getElementById){
	if(!document.all){
		document.getElementById=function(id){
			return(document.layers[id]);
		}
	}else{
		document.getElementById=function(id){
			return(document.all[id]);
		}
	}
}

function gravy_duplicate(str,num) {
	ret = "";
	for (var c = 1; c<=num; c++) {
		ret += str;
	}
	return (ret);
}

function gravy_insertStr(strToInsert, strDestination, afterCharInd) {
	return (strDestination.substring(0, afterCharInd)+strToInsert+strDestination.substring(afterCharInd));
}

function gravy_round(n, dp, f) {
	dp = (dp == null) ? 2 : dp;
	var num = Math.round(n*Math.pow(10, dp))/Math.pow(10, dp);
	var arNum = num.toString().split(".");
	if (arNum.length == 1) {
		arNum.push(gravy_duplicate("0", dp));
	} else if (arNum[1].length != dp) {
		arNum[1] += gravy_duplicate("0", dp-arNum[1].length);
	}
	if (f) {
		for (var roundC = arNum[0].length; roundC>=1; roundC -= 3) {
			arNum[0] = (roundC<arNum[0].length) ? gravy_insertStr(",", arNum[0], roundC) : arNum[0];
		}
	}
	if (dp<1) {
		return (arNum[0]);
	} else {
		return (arNum[0]+"."+arNum[1]);
	}
}

function helper_default_value(field,text,axn){
	if(axn==FIELD_FOCUS){
		if(field.value==text){
			field.value="";
		}
	}else{
		if(field.value==""){
			field.value=text;
		}
	}
}

function urldecode(value){
	var result=unescape(value);
	result=result.replace(/\+/gi," ");
	return(result);
}

function showToolTip(elm,text){
	var tt=document.getElementById(elm);
	if(tt){
		tt.style.display="block";
		tt.innerHTML=text;
	}
}

function hideToolTip(elm){
	var tt=document.getElementById(elm);
	if(tt){
		tt.style.display="none";
	}
}
