//for restricting entry of only numeric characters in a field
function CheckKeyCode(e){
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		
	if((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode == 8))
	{
	return true;
	}
	else
	{
	return false;
	}
	}
	else
	{
		
	if ((e.charCode >= 48 && e.charCode <= 57) || (e.charCode == 0))
	{
	return true;
	}
	else
	{
	return false;
	}
	}
}
//fetches the checked value or selected value from the radio object and returns the value
function getCheckedValue(radioObj) {
	if(!radioObj)
		return null;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return null;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
			break;
		}
	}
	return null;
}
//function truncate(num) transforms number to Amount format 4 becomes 4.000
function truncate(num) { 
	var str = num + ''; // Now it's a string. 
	if (str.indexOf('.') == -1) { return str + '.000'; } 
	dot = str.length - str.indexOf('.'); 
	if (dot > 4) { return str.substring(0,str.length-dot+4); } 
	else if (dot == 2) { return str + '00'; }
	else if (dot == 3) { return str + '0'; } 
	return str; 
}
//displays or hides specific row pass row Id and true to display and false to hide
function toggleRowDisplay(rowId,display_true_false){
	  var row = document.getElementById(rowId);
	   		if(display_true_false){
	 		row.style.display = '';
			}else{
			row.style.display = 'none';
			}
}
//pass (this,<fmt:message key="moeicscs_attachment_valid_filetype" />,new Array('.pdf','.jpg', '.png', '.gif'));
function LimitAttach(file_field,message,extension_Array) {
var file = file_field.value;
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extension_Array.length; i++) {
if (extension_Array[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit){ 
return true;
}
else{
alert(message);
}
return false;
}