function strLenVal(strLen) {
    ++i;
    if (i > strLen) 
	    alert("Exceed 1500 characters limit!");
}

function validateRequest(theForm) {
    if (theForm.userName.value == "" || 
		theForm.userEmail.value == "" ||
	   (theForm.userLocation.selectedIndex == 0 && theForm.deptname.selectedIndex == 0 && theForm.otherLocation.value == "") ||
	   (theForm.userLocation.selectedIndex == 2 && theForm.otherLocation.value == "") ||
	    theForm.bName.value == "" ||
		theForm.bPhone.value == "" ||  
	   (theForm.grantDev.checked == false && theForm.protocolDev.checked == false &&
		theForm.surveyAnalysis.checked == false && theForm.dataAnalysis.checked == false &&
		theForm.dataManagement.checked == false && theForm.epi.checked == false && theForm.otherType.checked == false) ||
	   (theForm.grantDev.checked && theForm.grantType.selectedIndex == 0) ||
	   (theForm.otherType.checked && theForm.otherTypeDesc.value == "") ||
	   (theForm.grantType.selectedIndex == 3 && theForm.otherGrant.value == "") ||	   
	    theForm.serviceDesc.value == "" ||
       (theForm.statsSupport[0].checked && theForm.timeLevel.value == "") ||
	    theForm.pubResult.selectedIndex == -1 ||
		theForm.scienceDesc.value == "" ||
		theForm.aimList.value == "" ||
		theForm.aimDesc.value == "" ||
	   (!theForm.irbApproval[0].checked && !theForm.irbApproval[1].checked)) {

	    var str = "";
		if (theForm.userName.value == "")
		  str += "\tName";
		if (theForm.userEmail.value == "")
		  str += "\n\tEmail";
		if (theForm.userLocation.selectedIndex == 0 && theForm.deptname.selectedIndex == 0 && theForm.otherLocation.value == "")
		  str += "\n\tDepartment/organization or specify other location";
		if (theForm.userLocation.selectedIndex == 2 && theForm.otherLocation.value == "")
		  str += "\n\tOther location";
		if (theForm.bName.value == "")
		  str += "\n\tBilling Contact Name";
		if (theForm.bPhone.value == "")
		  str += "\n\tBilling Contact Telephone";
		if (theForm.grantDev.checked == false && theForm.protocolDev.checked == false &&
		    theForm.surveyAnalysis.checked == false && theForm.dataAnalysis.checked == false &&
		    theForm.dataManagement.checked == false && theForm.epi.checked == false && theForm.otherType.checked == false)
		  str += "\n\tType of work";
	    if (theForm.otherType.checked && theForm.otherTypeDesc.value == "")
		  str += "\n\tOther type of work requested explaination";
		if (theForm.grantDev.checked && theForm.grantType.selectedIndex == 0)
		  str += "\n\tType of grant";
	    if (theForm.grantType.selectedIndex == 3 && theForm.otherGrant.value == "")
		  str += "\n\tOther type of grant";
		if (theForm.serviceDesc.value == "")
		  str += "\n\tDescribe biostatistical services"; 
		if (theForm.statsSupport[0].checked && theForm.timeLevel.value == "")
		  str += "\n\tLevel of time/support";
		if (theForm.pubResult.selectedIndex == -1)
		  str += "\n\tResults published";
		if (theForm.scienceDesc.value == "")
		  str += "\n\tScientific background";
		if (theForm.aimList.value == "")
		  str += "\n\tAims of the study";
        if (theForm.aimDesc.value == "")
		  str += "\n\tData to achieve the aims";
		if (!theForm.irbApproval[0].checked && !theForm.irbApproval[1].checked)
		  str += "\n\tIRB approval";
		  
		alert(str);		
	    return false;
	}
	else {
        if (theForm.statsSupport[0].checked && theForm.timeLevel.value > 100) {
	        alert("Level of time must be less than or equal to 100%");
		    return false;
		}
		else {
	        alert("Your request was sucessfully Submitted!");
		    return true;
		}
	}
}

function isDigit (c){
   return ((c >= "0") && (c <= "9"))
}

function validateDigits(s, n) {
    for (var i = 0; i < s.length; i++){
        var c = s.charAt(i);

        if (!isDigit(c) || (i==0 && c == "0")) {
			if (n == 1) {
			    alert("UNDNJ Index must be numbers");
		        window.document.form1["bIndex"].focus();
			}
			else {
	            alert("Level of time must be numbers");
		        window.document.form1["timeLevel"].focus();
			}
		    return false;
		}
    }
    return true;
}

