	var fmtHours = "#,#0.00";
	var fmtCurrency = "$#,#0.00;-$#,#0.00";
	var fmtCurrRate = "$#,#0.00;-$#,#0.00";
	var fmtRound = "#0.00;-#0.00";
		
	var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	
	var month = new Date().getMonth();
	var year = new Date().getFullYear();
	month--;
	if(month < 0) {
		month=11;
		year--;
	}
		
	function checkRequired() {
		for(var i=0; i<required_fields.length; i++) {
			isCompleted(required_fields[i]);
		}
		displayErrorMsg();
		if($("#error_msg").css("display") == "none") { return true};
		return false;
	}
	
	function isCompleted(id) {
		removeErrorMsg(id)
		if($("#"+id).val() == '') {
			addErrorMsg(id);
			$("#"+id).addClass("error");
		}
		else $("#"+id).removeClass("error");
	}
	
	function clearErrors() {
		for(i=0; i<required_fields.length; i++) {
			removeErrorMsg(required_fields[i])
		}
		
		for(i=0; i<format_fields.length; i++) {
			removeErrorMsg(format_fields[i])
		}
		
		$(".error").removeClass("error");
	}
	
	function addErrorMsg(t) {
		$("#"+t+"_error").show();
		displayErrorMsg();
	}
	
	function removeErrorMsg(t) {
		$("#"+t+"_error").hide();
		displayErrorMsg();
	}
	
	function displayErrorMsg() {
		var display = false;
		var i = 0;
		
		for(i=0; i<required_fields.length; i++) {
			if($("#"+required_fields[i]+"_error").css("display") != "none") {
				display = true;
				break;
			}
		}
		
		for(i=0; i<format_fields.length; i++) {
			if($("#"+format_fields[i]+"_error").css("display") != "none") {
				display = true;
				break;
			}
		}
		
		if(display) $("#error_msg").show();
		else $("#error_msg").hide();
	}
	
	function move(code,id) {
		//alert(id+" received keyCode "+code);
		var index = -1;
		
		for(var i = 0; i < ids.length; i++) {
			if(id.indexOf(ids[i]) != -1) {
				index = i;
				break;
			}
		}
		
		var caret = doGetCaretPosition(document.getElementById(id));
		
		if(index != -1) {
			var i = id.replace(ids[index],"");
			switch(code) {
				case 37: //Left Arrow
					if(index == 0) {
						index = ids.length -1;
						i--;
					}
					else index--;
					caret--;
					if(i >= imin && caret < 0) {
						$("#"+id).blur();
						$("#"+ids[index]+i).focus();
					}
					break;
				case 38: //Up Arrow
					i--;
					if(i >= imin) {
						$("#"+id).blur();
						$("#"+ids[index]+i).focus();
					}
					break;
				case 39: //Right Arrow
					if(index == ids.length-1) {
						index = 0;
						i++;
					}
					else index++;
					caret++;
					if(i < imax && caret > $("#"+id).val().length) {
						$("#"+id).blur();
						$("#"+ids[index]+i).focus();
					}
					break;
				case 40: //Down Arrow
					i++;
					if(i < imax) {
						$("#"+id).blur();
						$("#"+ids[index]+i).focus();
					}
					break;
			}
		}
	}
		
	function doGetCaretPosition (ctrl) {
		var CaretPos = 0;	// IE Support
		if (document.selection) {
		ctrl.focus ();
			var Sel = document.selection.createRange ();
			Sel.moveStart ('character', -ctrl.value.length);
			CaretPos = Sel.text.length;
		}
		// Firefox support
		else if (ctrl.selectionStart || ctrl.selectionStart == '0')
			CaretPos = ctrl.selectionStart;
		return (CaretPos);
	}
	
	function setCaretPosition(ctrl, pos){
		if(ctrl.setSelectionRange)
		{
			ctrl.focus();
			ctrl.setSelectionRange(pos,pos);
		}
		else if (ctrl.createTextRange) {
			var range = ctrl.createTextRange();
			range.collapse(true);
			range.moveEnd('character', pos);
			range.moveStart('character', pos);
			range.select();
		}
	}	

