
// **********************************************************************
// Functions For Validating Fields
// **********************************************************************

//  check for valid numeric strings	
function IsNumeric(strString,allowdot) {
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	
	if(allowdot) strValidChars = strValidChars + ".";
	if (strString.length == 0) return false;

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++) {
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}
	return blnResult;
}


function TypeJustCurrency(e,allowdot){
	var keynum;
	var keychar;
	var numcheck;
	if(window.event){
		// IE

		keynum = e.keyCode;
	} else if(e.which) {
		// Netscape/Firefox/Opera
		keynum = e.which;
	}
	keychar = String.fromCharCode(keynum);
	return IsNumeric(keychar,allowdot);
}


// **********************************************************************
// Change Focus
// **********************************************************************

function change_focus(limit, currentId, nextId){
	var element = document.getElementById(currentId);
	if(element.value.length >= limit){
		document.getElementById(nextId).focus();
	}
}

function assembly_phone_from_parts(id) {
	var i = document.getElementById(id);
	var i1 = document.getElementById(id+'-part1');
	var i2 = document.getElementById(id+'-part2');
	var i3 = document.getElementById(id+'-part3');
		
	if(i1 && i2 && i3) {
		i.value = "(" + i1.value + ") " + i2.value + "-" + i3.value;
	}
}
