<!-- Proctor Gamble -->
function proctor_check_field(theField) {
	var doc = theField.document;
	var noError = true;

	if ((doc.sectionform) && (doc.sectionform.x_section_id) && 
			((doc.sectionform.x_section_id.value == 15839) || (doc.sectionform.x_section_id.value == 15794))) {
		var fId = theField.id;
		var fv1 = doc.getElementById("CG17236").value.replace(/[\$,]/g,"");
		var fv2 = doc.getElementById("CG60670").value.replace(/[\$,]/g,"");
		var fv3 = doc.getElementById("CG60574").value.replace(/[\$,]/g,"");
		var fv4 = doc.getElementById("CG60671").value.replace(/[\$,]/g,"");

		if (isNaN(fv1)) {
			alert("Financial Request Amount (Year One) must be a numeric value.");
			noError = false;
		} else if (isNaN(fv2)) {
			alert("Financial Request Amount (Year Two) must be a numeric value.");
			noError = false;
		} else if (isNaN(fv3)) {
			alert("MDO/GBU Amount (Year One) must be a numeric value.");
			noError = false;
		} else if (isNaN(fv4)) {
			alert("MDO/GBU Amount (Year Two) must be a numeric value.");
			noError = false;
		} else {
			if ((fId == "CG17236") || (fId == "CG60574")) {
				if ((fv1) && (fv3) && ((fv1-0) > (fv3-0))) {
					alert("MDO/GBU Amount (Year One) must be greater or equal to the Financial Request Amount (Year One).");
					noError = false;
				}
			} else if ((fId == "CG60670") || (fId == "CG60671")) {
				if ((fv2) && (fv4) && ((fv2-0) > (fv4-0))) {
					alert("MDO/GBU Amount (Year Two) must be greater or equal to the Financial Request Amount (Year Two).");
					noError = false;
				}
			}
		}
	}
	return noError;
}

function proctor_check_form(theForm) {
	var doc = theForm.document;
	var f1 = doc.getElementById("CG17236");
	var f2 = doc.getElementById("CG60670");
	var f3 = doc.getElementById("CG60574");
	var f4 = doc.getElementById("CG60671");

	if (proctor_check_field(f1) == false) 
		return false;
	else if (proctor_check_field(f2) == false) 
		return false;
	else if (proctor_check_field(f3) == false) 
		return false;
	else if (proctor_check_field(f4) == false) 
		return false;
	else
		return true;
}

function wac_cal_sum(doc) {
        var f1,f2,f3,f4,f5,f6,f7;
        var total = 0.00;

        f1 = doc.getElementById("CG70434");
        f2 = doc.getElementById("CG70436");
        f3 = doc.getElementById("CG70437");
        f4 = doc.getElementById("CG70438");
        f5 = doc.getElementById("CG70439");
        f6 = doc.getElementById("CG70440");
        f7 = doc.getElementById("CG78614");

        if ((f1) && (f2) && (f3) && (f4) && (f5) && (f6) && (f7)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");
                f3 = f3.value.replace(/[\$,]/g,"");
                f4 = f4.value.replace(/[\$,]/g,"");
                f5 = f5.value.replace(/[\$,]/g,"");
                f6 = f6.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2)) && (!isNaN(f3)) && (!isNaN(f4)) && (!isNaN(f5)) && (!isNaN(f6))) {
                        total = (f1-0) + (f2-0) + (f3-0) + (f4-0) + (f5-0) + (f6-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG78614");
        f2 = doc.getElementById("CG70442");
        f7 = doc.getElementById("CG70443");

        if ((f1) && (f2)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2))) {
                        total = (f1-0) + (f2-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG70444");
        f2 = doc.getElementById("CG70446");
        f3 = doc.getElementById("CG70447");
        f4 = doc.getElementById("CG70448");
        f5 = doc.getElementById("CG70449");
        f6 = doc.getElementById("CG70450");
        f7 = doc.getElementById("CG70451");

        if ((f1) && (f2) && (f3) && (f4) && (f5) && (f6) && (f7)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");
                f3 = f3.value.replace(/[\$,]/g,"");
                f4 = f4.value.replace(/[\$,]/g,"");
                f5 = f5.value.replace(/[\$,]/g,"");
                f6 = f6.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2)) && (!isNaN(f3)) && (!isNaN(f4)) && (!isNaN(f5)) && (!isNaN(f6))) {
                        total = (f1-0) + (f2-0) + (f3-0) + (f4-0) + (f5-0) + (f6-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG70451");
        f2 = doc.getElementById("CG70452");
        f7 = doc.getElementById("CG70453");

        if ((f1) && (f2)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2))) {
                        total = (f1-0) + (f2-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG70455");
        f2 = doc.getElementById("CG70457");
        f3 = doc.getElementById("CG70459");
        f7 = doc.getElementById("CG70460");

        if ((f1) && (f2) && (f3) && (f7)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");
                f3 = f3.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2)) && (!isNaN(f3))) {
                        total = (f1-0) + (f2-0) + (f3-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG70460");
        f2 = doc.getElementById("CG70456");
        f7 = doc.getElementById("CG85577");

        if ((f1) && (f2)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2))) {
                        total = (f1-0) + (f2-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG75128");
        f2 = doc.getElementById("CG75129");
        f3 = doc.getElementById("CG75130");
        f4 = doc.getElementById("CG75131");
        f5 = doc.getElementById("CG75132");
        f6 = doc.getElementById("CG75133");
        f7 = doc.getElementById("CG75135");

        if ((f1) && (f2) && (f3) && (f4) && (f5) && (f6) && (f7)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");
                f3 = f3.value.replace(/[\$,]/g,"");
                f4 = f4.value.replace(/[\$,]/g,"");
                f5 = f5.value.replace(/[\$,]/g,"");
                f6 = f6.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2)) && (!isNaN(f3)) && (!isNaN(f4)) && (!isNaN(f5)) && (!isNaN(f6))) {
                        total = (f1-0) + (f2-0) + (f3-0) + (f4-0) + (f5-0) + (f6-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG43215");
        f2 = doc.getElementById("CG43351");
        f7 = doc.getElementById("CG43352");

        if ((f1) && (f2)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2))) {
                        total = (f1-0) + (f2-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG78571");
        f2 = doc.getElementById("CG78570");
        f3 = doc.getElementById("CG78572");
        f4 = doc.getElementById("CG78574");
        f5 = doc.getElementById("CG78573");
        f6 = doc.getElementById("CG78569");
        f7 = doc.getElementById("CG43351");

        if ((f1) && (f2) && (f3) && (f4) && (f5) && (f6) && (f7)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");
                f3 = f3.value.replace(/[\$,]/g,"");
                f4 = f4.value.replace(/[\$,]/g,"");
                f5 = f5.value.replace(/[\$,]/g,"");
                f6 = f6.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2)) && (!isNaN(f3)) && (!isNaN(f4)) && (!isNaN(f5)) && (!isNaN(f6))) {
                        total = (f1-0) + (f2-0) + (f3-0) + (f4-0) + (f5-0) + (f6-0);
                        f7.value = total;
                }
        }

        f1 = doc.getElementById("CG43352");
        f2 = doc.getElementById("CG43353");
        f7 = doc.getElementById("CG43354");

        if ((f1) && (f2)) {
                f1 = f1.value.replace(/[\$,]/g,"");
                f2 = f2.value.replace(/[\$,]/g,"");

                if ((!isNaN(f1)) && (!isNaN(f2))) {
                        total = (f1-0) + (f2-0);
                        f7.value = total;
                }
        }

        return true;
}
