function key_check() {
	if (((event.keyCode >= 48) && (event.keyCode <=57)) || (event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode == 8 || event.keyCode == 16 || event.keyCode == 46) || (event.keyCode >= 35 && event.keyCode <= 40) || event.keyCode == 9) {
		event.returnValue = true;
	}
	else {
		event.returnValue = false;
	}
}
function money_check() {
	if (((event.keyCode >= 48) && (event.keyCode <=57)) || (event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode == 8 || event.keyCode == 16 || event.keyCode == 46) || (event.keyCode >= 35 && event.keyCode <= 40) || event.keyCode == 9 || event.keyCode == 190 || event.keyCode == 110) {
		event.returnValue = true;
	}
	else {
		event.returnValue = false;
	}
}
function dotstop(VAL) {
	if (VAL.indexOf(".") > -1) {
		tmpVal = VAL.substring(VAL.indexOf(".") + 1, VAL.length);
		if (tmpVal.length > 1) {
			if (event.keyCode == 8 || event.keyCode == 9) {
				event.returnValue = true;
			}
			else {
				event.returnValue = false;
			}
		}
	}
}

function addOption(Obj,Start,End,Selecting) {
	var loop = 1;
	for (i=Start;i<=End;i++) {
		newOption = new Option(i,i);
		Obj.options.add(newOption);
		if (i == Selecting) {
			Obj.options[loop-1].selected = true;
		}
		loop++;
	}
}
function trim(string) {
	var size = string.length;
	var mString = "";
	for (i=0;i<size;i++) {
		tmpstring = string.substring(i,i+1);
		if (tmpstring != " ") {
			mString += tmpstring;
		}
	}
	return mString;
}
function email_open(To,Name) {
	window.open ("../email/email.asp?mailadress=" + To + "&mailName=" + Name, "", "width=450,height=415,resizable=0,scrollbars=0,status=0");
}
function formatNumber(Numbers) {
	Numbers = String(Numbers);
	var size = (Math.floor(Numbers.length / 3));
	var modSize = Numbers.length % 3;
	if (modSize > 0) {
		var result = Numbers.substr(0,modSize) + ",";
	}
	else {
		var result = "";
	}	
	for (i=0;i<size;i++) {
		result += Numbers.substr(modSize + (3 * i), 3) + ",";
	}
	result = result.substr(0,result.length - 1);
	return result;
}

function Round(Num,Count) {
	Num = String(Num);
	var point = Num.indexOf(".");
	if (point <= 0) {
		var result = Math.round(Num);
	}
	else {
		if (point != Num.lastIndexOf(".")) {
			alert("This Function is Only Number");
		}
		else {
			var lastValue = Num.substring(point + 1,Num.length);

			if (lastValue.length == 1) {
				var result = Math.round(Num);
			}
			else {
				if (lastValue.length < Count) {
					Count = lastValue.length;
				}
				var ObjectValue = lastValue.substring(Count,Count+1);
				var RoundValue = lastValue.substring(Count,Count - 1);
				if (Number(ObjectValue) >= 5) {
					RoundValue++;
				}
				var ObjectResult = lastValue.substring(0,Count-1) + RoundValue;
				var FrontValue = Num.substring(0,point);
				if (point >= 1) {
					FrontValue = FrontValue + ".";
				}
				var result = FrontValue + String(ObjectResult)
			}
		}
	}
	return result;
}
function fn(num, w) {
	//This Function is Only plus
	var fnVal = 0;
	var zero = "";
	if (typeof(num) != "number") {
		//Num is NOT numeric
		alert("This function is only numeric");
		return false;
	}
	else {
		num = String(num);
		var numSize = num.length;
		var pointC = num.indexOf(".");
		if(pointC <= -1) {
			//num is integer
			for (i=0;i<w;i++) {
				zero += "0";
			}
			if (w <= 0) {
				fnVal = num;
			}
			else {
				fnVal = num + "." + zero;
			}
		}
		else {
			//point exisit
			var intValue = num.substring(0,pointC);
			var floatValue = num.substring(pointC+1, numSize);
			var floatSize = floatValue.length;
			if (floatSize < w) {
				for (x = 0; x < w - floatSize; x++) {
					zero += "0";
				}
				fnVal = intValue + "." + floatValue + zero;
			}
			else {
				if (floatSize == w) {
					fnVal = num;
				}
				else {
					var cutNum = floatValue.substring(0, w);
					var cutNumMore = floatValue.substring(w, w+1);

					if (cutNumMore > 4) {
						//rounding
						cutNum++;
					}
					fnVal = intValue + "." + cutNum;
				}
			}
		}
	}

	return fnVal;
}
