    var badFields = false;
    var msgText = "";
	var busQuals = new Array(" "," "," "," "," "," "," "," "," "," ");
    var manType = new Array(" "," "," "," "," ");
    var qualSys = new Array(" "," "," "," "," "," ");

	function validateAndSubmit()
    {
        msgText += "Please check the following fields for data entry and/or format:\n\n";

		if (document.forms[0].CCRyes.checked == 0 &&
        	document.forms[0].CCRno.checked == 0)
        {
            badFields = true;
            msgText += "Please select YES or NO for CCR.\n";
        }
        if (document.forms[0].CCRyes.checked == 0 &&
        	document.forms[0].CCRno.checked == 1)
        {
            badFields = true;
            msgText += "Your business must be registered in the Central Contracting Registry in order for this form to be accepted.\n";
        }

        if (document.forms[0].ccrNumber.value.length == 0)
        {
            badFields = true;
            msgText += "See CCR Number\n";
        }


        if (document.forms[0].theName.value.length == 0)
        {
            badFields = true;
            msgText += "See Company Name\n";

        }
        if (document.forms[0].theAddress.value.length == 0)
        {
            badFields = true;
            msgText += "See Address\n";

        }
        if (document.forms[0].city.value.length == 0)
        {
            badFields = true;
            msgText += "See City\n";

        }

        if (document.forms[0].theState.value == "" && document.forms[0].province.value == "")
        {
            badFields = true;
            msgText += "See State and/or Province\n";

        }
        if (document.forms[0].theState.value != "" && document.forms[0].province.value != "")
        {
            badFields = true;
            msgText += "State AND Province cannot both be entered.\n";

        }


        if (document.forms[0].country.value.length == 0)
        {
            badFields = true;
            msgText += "See Country\n";

        }

        if (document.forms[0].zipcode.value.length == 0)
        {
            badFields = true;
            msgText += "See Zip\n";
        }
        if ( document.forms[0].zipcode.value.length == 5 && isNaN(document.forms[0].zipcode.value) )
        {
            badFields = true;
            msgText += "See Zip : A five character Zip Code must be numeric\n";
        }

        if ( document.forms[0].zipcode.value.length > 5)
        {
            if (document.forms[0].zipcode.value.indexOf("-") == -1 )
            {
            	badFields = true;
            	msgText += "See Zip : Geater than five characters must be\n";
            	msgText += "          of the form nnnnn-nnnn \n";
            }
        }

		if (document.forms[0].emailaddress.value.length == 0)
        {
            badFields = true;
            msgText += "See EMAIL (address@mailserver.ext)\n";

        }
        if (document.forms[0].emailaddress.value.indexOf("@") == -1)
        {
            badFields = true;
            msgText += "See EMAIL (address@mailserver.ext)\n";

        }
        if (document.forms[0].emailaddress.value.indexOf(".") == -1)
        {
            badFields = true;
            msgText += "See EMAIL (address@mailserver.ext)\n";

        }

		temp = document.forms[0].areaCode.value;

        if (temp.length != 3 || isNaN(temp) )
        {
            badFields = true;
            msgText += "See Phone (Area Code)\n";

        }

        temp = document.forms[0].prefix.value;

        if (temp.length != 3 || isNaN(temp) )
        {
            badFields = true;
            msgText += "See Phone(Prefix)\n";

        }

        temp = document.forms[0].phNum.value;

        if (temp.length != 4 || isNaN(temp) )
        {
            badFields = true;
            msgText += "See Phone(Number)\n";

        }

        temp = document.forms[0].extension.value;

        if (isNaN(temp) )
        {
            badFields = true;
            msgText += "See Phone(Extension)\n";

        }

        temp = document.forms[0].faxareaCode.value;

        if (temp.length != 3 || isNaN(temp) )
        {
            badFields = true;
            msgText += "See Fax(Area Code)\n";

        }

        temp = document.forms[0].faxprefix.value;

        if (temp.length != 3 || isNaN(temp) )
        {
            badFields = true;
            msgText += "See Fax(Prefix)\n";

        }

        temp = document.forms[0].faxnum.value;

        if (temp.length != 4 || isNaN(temp) )
        {
            badFields = true;
            msgText += "See Fax(Number)\n";

        }
        if (document.forms[0].theSales.value.length == 0)
        {
            badFields = true;
            msgText += "See Previous Year Sales\n";

        }
        if (document.forms[0].thePriComm.value.length == 0)
        {
            badFields = true;
            msgText += "See PrimaryCommodity\n";

        }

        if (document.forms[0].theCoClass.value.length == 0 && document.forms[0].divAffSub.value.length != 0)
        {
            badFields = true;
            msgText += "See Company Classification (pick list)\n";

        }
        if (document.forms[0].divAffSub.value.length == 0 && document.forms[0].theCoClass.value.length != 0)
        {
            badFields = true;
            msgText += "See Company Classification (input field)\n";

        }
        if (document.forms[0].majorCusts.value.length == 0)
        {
            badFields = true;
            msgText += "See Major Customers\n";

        }
        if (document.forms[0].ownerName.value.length == 0)
        {
            badFields = true;
            msgText += "See Owner Name\n";

        }
        if (document.forms[0].duns.value.length == 0)
        {
            badFields = true;
            msgText += "See DUNS Number Name\n";

        }


        if (document.forms[0].theNAICS.value.length == 0)
        {
            badFields = true;
            msgText += "See NAICS Code(s).\n";
        }
		else if (document.forms[0].theNAICS.value.length < 6)
        {
            badFields = true;
            msgText += "Bad NAICS Code(s) (each NAICS Code must be six digits).\n";
        }
        else
        {
            theNaics = document.forms[0].theNAICS.value;
            theNaics = theNaics.replace("%0D%0A" , " ");
            theNaics = theNaics.replace("%20" , " ");
            theNaics = theNaics.replace("%26" , "&");
            theNaics = theNaics.replace("," , " ");
            theNaics = theNaics.replace(";" , " ");
            theWords = new Array();
            theWords = theNaics.split(" ");
            i = 0;
            while ( i < theWords.length )
            {
                if (theWords[i].length < 6 )
                {
                    badFields = true;
                    msgText += "Bad NAICS Code(s) (each NAICS Code must be six digits).\n";
                }
                i++;
            }
        }


        if (document.forms[0].SmallBus.checked == 0 &&
        	document.forms[0].SmallBus_CSDB.checked == 0 &&
        	document.forms[0].SmallBus_C8A.checked == 0 &&
        	document.forms[0].SmallBus_WO.checked == 0 &&
        	document.forms[0].SmallBus_HUB.checked == 0 &&
        	document.forms[0].SmallBus_SDV.checked == 0 &&
        	document.forms[0].SmallBus_VSB.checked == 0 &&
        	document.forms[0].SmallBus_HBCUMI.checked == 0 &&
        	document.forms[0].LargeBusiness.checked == 0)
        {
            badFields = true;
            msgText += "Please select at least one Business Qualification\n";

        }
        else
        {
            if(document.forms[0].SmallBus.checked == 1) busQuals[0] = "X"; else busQuals[0] ="Y";
            if(document.forms[0].SmallBus_CSDB.checked == 1) busQuals[1] = "X"; else busQuals[1] ="Y";
            if(document.forms[0].SmallBus_C8A.checked == 1) busQuals[2] = "X"; else busQuals[2] ="Y";
            if(document.forms[0].SmallBus_WO.checked == 1) busQuals[3] = "X"; else busQuals[3] ="Y";
            if(document.forms[0].SmallBus_HUB.checked == 1) busQuals[4] = "X"; else busQuals[4] ="Y";
            if(document.forms[0].SmallBus_SDV.checked == 1) busQuals[5] = "X"; else busQuals[5] ="Y";
            if(document.forms[0].SmallBus_VSB.checked == 1) busQuals[6] = "X"; else busQuals[6] ="Y";
            if(document.forms[0].SmallBus_HBCUMI.checked == 1) busQuals[7] = "X"; else busQuals[7] ="Y";
            if(document.forms[0].LargeBusiness.checked == 1) busQuals[8] = "X"; else busQuals[8] ="Y";
        }
        document.forms[0].theBusQuals.value = busQuals.join("");

		if (document.forms[0].ManAssmbly.checked == 0 &&
            document.forms[0].RawMat.checked == 0 &&
            document.forms[0].Svcs.checked == 0 &&
            document.forms[0].Distr.checked == 0 &&
            document.forms[0].Lvl1.checked == 0)
        {
            badFields = true;
            msgText += "Please select at least one Manufacturing Type\n";
        }
        else
        {
            if (document.forms[0].ManAssmbly.checked == 1) manType[0] = "X";
            if (document.forms[0].RawMat.checked == 1) manType[1] = "X";
            if (document.forms[0].Svcs.checked == 1) manType[2] = "X";
            if (document.forms[0].Distr.checked == 1) manType[3] = "X";
            if (document.forms[0].Lvl1.checked == 1) manType[4] = "X";
        }
        document.forms[0].theManType.value = manType.join("");

		if (document.forms[0].NoQuality.checked == 0 &&
            document.forms[0].MIL_Q_9858.checked == 0 &&
            document.forms[0].MIL_I_45208.checked == 0 &&
            document.forms[0].EB2678.checked == 0 &&
            document.forms[0].ISOCert.checked == 0 &&
            document.forms[0].OtherCert.checked == 0)
        {
            badFields = true;
            msgText += "Please select at least one Quality System\n";
        }

        else
        {
            if (document.forms[0].NoQuality.checked == 1) qualSys[0] = "X";
            if (document.forms[0].MIL_Q_9858.checked == 1) qualSys[1] = "X";
            if (document.forms[0].MIL_I_45208.checked == 1) qualSys[2] = "X";
            if (document.forms[0].EB2678.checked == 1) qualSys[3] = "X";
            if (document.forms[0].ISOCert.checked == 1) qualSys[4] = "X";
            if (document.forms[0].OtherCert.checked == 1) qualSys[5] = "X";
        }
        document.forms[0].theQualSys.value = qualSys.join("");


		if( document.forms[0].ISOCert.checked == 1 && document.forms[0].isoCertText.value.length == 0 )
        {
            badFields = true;
            msgText += "Please enter the ISO Certification text\n";
            //alert(msgText);
        }
        if( document.forms[0].OtherCert.checked == 1 && document.forms[0].othCertText.value.length == 0 )
        {
            badFields = true;
            msgText += "Please enter the Other Certification text\n";
            //alert(msgText);
        }

        if( document.forms[0].capability.value.length == 0)
        {
            badFields = true;
            msgText += "You must enter a Capability Statement.\n";
            //alert(msgText);
        }
        else
        {
            theCap = escape(document.forms[0].capability.value);
            //alert(theCap);
            document.forms[0].theCapability.value = theCap;
            //alert("capability "+document.forms[0].capability.value);
        }

		if( document.forms[0].CertifyAccuracy.checked == 0)
        {
            badFields = true;
            msgText += "You must certify the accuracy of this form data.\n";
            //alert(msgText);
        }
        else
        {
            document.forms[0].accuracyCert.value = "X";
        }

        if (document.forms[0].SubmittedBy.value.length == 0 )
        {
            badFields = true;
            msgText += "See Submitted By.\n";
            //alert(msgText);
        }

        if (document.forms[0].SubmitTitle.value.length == 0 )
        {
            badFields = true;
            msgText += "See Title.\n";
            //alert(msgText);
        }


        if (badFields)
        {
            alert(msgText);
            history.go();
        }
        else
        {
            document.forms[0].submit();
        }
    }

    function ccrLinkDisplay(theObj)
    {
    	if(theObj.checked == 1)
		{
			document.forms[0].CCRyes.checked = 0;
        }
        url="ccrInfo.html";
        //url="public_html/idg/bobtest/ccrInfo.html";
        //alert(url);
        x= 0;
        y= 0;
        features = "width=300,height=300,scrollbars=yes,resize=yes,menubar=no";
        //w = window.open(url,"CCR Info",features);
        w = window.open(url);
        w.mainwindow = self;
        w.moveTo(x,y)
        w.focus();
	}

