function ValidZip() {
  var zip = document.lead.strZipCode.value;
  var country = document.lead.idCountry.value;

 if (country == 1) {
     if (isNotNumberString(zip) || (zip.length != 5)) {
      	alert ("The zipcode you entered is not a valid US zipcode.");
      	return false;
	 } else {
		return true;
	 }
 } else {
	return true;
 }
}

function isNotNumberString(str) {
	for (var i = 0; i < str.length; i++) {
		var ch = str.substring(i, i + 1);
		if((ch < "0" || "9" < ch)) {
			return true;
		}
	}
	return false;
}


function mmChangeInqSourceType(parent)
{
    var InqTypeList = mmInq[parent.misc_notes_inqsource.options[parent.misc_notes_inqsource.selectedIndex].value];

    clearList(parent.magazine);

    addElement(parent.magazine, 'Please Select', 0);
    if(InqTypeList)
        {
        var rgInqTypes = InqTypeList.split('#');
        for (var i = 0; i < rgInqTypes.length; i++)
            {
            if (rgInqTypes[i])
                {
                var rgInqType = rgInqTypes[i].split(',');
                addElement(parent.magazine, rgInqType[1], rgInqType[0]);
                }
            }
        parent.magazine.disabled = false;
        }
    else
        {
        parent.magazine.disabled = true;
        }

    parent.magazine.selectedIndex = 0;
}

function clearList(list)
    {
    var i = 0;
    var o = list.options;

    for (i = o.length; i >= 0; --i)
        o[i] = null;
    list.disabled = true;
    }


function addElement(list, text_in, value_in)
    {
    var o = list.options;
    var nIdx;
    if (o.length < 0) //IE for Mac 4.5 sets length to -1 if list is empty
        nIdx = 0;
    else
        nIdx = o.length;

    o[nIdx] = new Option(text_in, value_in);
    list.disabled = false;
    }

function forceEmail() {
  
}


function mmChangeSubInd(parent)
{
    var IndTypeList = mmInd[parent.misc_notes_industry.options[parent.misc_notes_industry.selectedIndex].value];

    clearList(parent.misc_notes_subindustry);

    addElement(parent.misc_notes_subindustry, 'Please Select', 0);
    if(IndTypeList)
        {
        var rgIndTypes = IndTypeList.split('#');
        for (var i = 0; i < rgIndTypes.length; i++)
            {
            if (rgIndTypes[i])
                {
                var rgIndType = rgIndTypes[i].split(',');
                addElement(parent.misc_notes_subindustry, rgIndType[1], rgIndType[0]);
                }
            }
        parent.misc_notes_subindustry.disabled = false;
        }
    else
        {
        parent.misc_notes_subindustry.disabled = true;
        }

    parent.misc_notes_subindustry.selectedIndex = 0;
}

function mmChangeSubApp(parent)
{
    var AppList = mmApp[parent.misc_notes_industry.options[parent.misc_notes_industry.selectedIndex].value];

    clearList(parent.misc_notes_subindustry);

    addElement(parent.misc_notes_subindustry, 'Please Select', 0);
    if(AppList)
        {
        var rgAppTypes = AppList.split('#');
        for (var i = 0; i < rgAppTypes.length; i++)
            {
            if (rgAppTypes[i])
                {
                var rgAppType = rgAppTypes[i].split(',');
                addElement(parent.misc_notes_subindustry, rgAppType[1], rgAppType[0]);
                }
            }
        parent.misc_notes_subindustry.disabled = false;
        }
    else
        {
        parent.misc_notes_subindustry.disabled = true;
        }

    parent.misc_notes_subindustry.selectedIndex = 0;
}

    var mmInd = new Array();
	mmInd['Fluorochemicals'] = '#AgriculturalChemical,Agricultural Chemicals#BioPharma,Bio Pharmaceutical#CatalogSales,Catalog Sales#ResalesExport,Resale or Export#Pharma,Pharmaceutical#Peptide,Peptide#Solvent,Solvent#SpecialtyChem,Specialty Chemical Production#Other,Other';
	mmInd['Oils, Greases and Waxes'] = '#Aerospace,Aerospace#Chemical,Chemical#Chlorine,Chlorine#CryogenicGases,Cryogenic Gases - Oxygen#HydraulicFluids,Hydraulic Fluids#Instrument,Instrument#LowTempFluids,Low Temperature Fluids#MetalWorking,Metal Working#ProcessSolvent,Process Solvent#VacuumPumps,Vacuum Pumps#Resale,Resale or Export#Other,Other';
	mmInd['Anesthetics'] = '#HumanUse,Human Use#Veterinary,Veterinary Use#Research,Research#Calibration,Calibration#Wholesale,Wholesale#Resale,Resale or Export';

