function parseDec(val,places,sep) {
	val = '' + val;
	if (!sep) {sep = '.';}
	if (!places) { places = 0; }
	places = parseInt(places);
	if (!parseInt(val)) {
		val = '0';
		if (places > 0) {
			val += sep;
			while (val.substring((val.indexOf(sep))).length <= places) {
				val += '0';
			}
		}
		return val;
	}
	if ((val.indexOf('.') > -1) && (sep != '.')) {
		val = val.substring(0,val.indexOf('.')) + sep + val.substring(val.indexOf('.')+1);
	}
	if (val.indexOf(sep) > -1) {
		pre = val.substring(0,val.indexOf(sep));
		post = val.substring(val.indexOf(sep)+1);
	} else {
		pre = val;
		post = '';
	}
	if (places > 0) {
		post = post.substring(0,(places+1));
		if (post.length > places) {
			if ( parseInt(post.substring(post.length - 1)) > 4 ) {
				post = '' + Math.round(parseInt(post) / 10);
			} else {
				post = '' + Math.round(parseInt(post));
			}
		}
		if (post.length > places) {
			post = '' + Math.round(parseInt(post.substring(0,places)));
		} else if (post.length < places) {
			while (post.length < places) {
				post += '0';
			}
		}
	
	} else {
		if (parseInt((post.substring(0,1))) > 4) {
			pre = '' + (parseInt(pre) + 1);
		} else {
			pre = '' + (parseInt(pre));	
		}
		post = '';
	}
	sep = (post.length > 0) ? sep : '';
	val = pre + sep + post;
	return val;
}
function parseMoney(val,sep) {
	return parseDec(val,2,sep);
}
function sepToDec(val,sep) {
	val = '' + val;
	if ((val.indexOf(sep) > -1) && (sep != '.')) {
		val = val.substring(0,val.indexOf(sep)) + '.' + val.substring(val.indexOf(sep)+1);
	}
	return val;
}
function decToSep(val,sep) {
	val = '' + val;
	sep = '' + sep;
	if ((val.indexOf('.') > -1) && (sep.length > 0)) {
		val = val.substring(0,val.indexOf('.')) + sep + val.substring(val.indexOf('.')+1);
	}
	return val;
}