function hasDecimals(val) {
	var indexOfDecimals = val.indexOf(".");
	var cntr = 0;
	var maxInt = 2;
    for (var i = indexOfDecimals + 1; i < val.length; i++) {
		cntr = cntr + 1;
    }
	if(cntr != maxInt) return false;
	return true;
}

function isAllNumeric(val, allowDecimal) {
	var numChars = "0123456789";
	if(allowDecimal) numChars = numChars + ".";
    for (var i = 0; i < val.length; i++) {
        if (numChars.indexOf(val.charAt(i)) == -1) {
	   	  return false;
		}
    }
	return true;
}

function isEmpty(str) {
	if(str.length == 0)
		return true;
	else
		return false;
}

function forwardPage(pageName, submitThePage) {
	location.href = pageName;
	if(submitThePage)
		frm.submit();
}

// Place focus on first text element whose text is empty
function setFocusCommon(theFormObj) {
	var elementType  = "";
	for (var i = 0; i < theFormObj.elements.length; i++) {		
		elementType = theFormObj.elements[i].type.toUpperCase();
		if( (elementType.indexOf("TEXT") > -1 ||
			 elementType.indexOf("PASSWORD") > -1) &&
			 theFormObj.elements[i].value == "") 
		{
            theFormObj.elements[i].focus();
			return;			
        }
    }
}