

function disableMkt() {
	var catValue = document.getElementById("dirCatID").options[document.getElementById("dirCatID").selectedIndex].value;
	var mktValue = document.getElementById("dirMktID").options[document.getElementById("dirMktID").selectedIndex].value;
	
	if (catValue == "77" || catValue == "85") {
		document.getElementById("dirMktID").options[0].value = "00";
		document.getElementById("dirMktID").options[0].text = "National";
		document.getElementById("dirMktID").options[0].selected = true;
		document.getElementById("dirMktID").disabled = true;
		document.getElementById("dirMktID").style.background = "White";
		document.getElementById("dirSubCatID").disabled = false;
		document.getElementById("dirSubCatID").style.background = "#faf99b";
		document.getElementById("dirSubCatID").focus();
		document.getElementById("dirSubCatID").options.length = 0;
		document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Select Sub-Category','');
		document.getElementById("dirSubCatID").options[0].value = "%";
				
		if (catValue == "77") {
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Aerial Imagery','21');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Construction Contract Data','31');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Consulting & Training','32');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Demographics','28');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Geographic Information Systems','30');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Location Decision Data','29');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Market Analytics','24');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Availability','23');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Comparables','26');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Marketing','27');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Rent & Sales Data','25');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Specific Data','22');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Retail Tenant Data','33');
			   
		}


		if (catValue == "85") {
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Activity Management','08');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Construction Management','02');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Customer Relationship','09');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Document Archive','10');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Document Management','17');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Financial Reporting','14');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Investment Analysis','04');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Lease Analysis','16');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Lease Management','05');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Location Planning','11');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Operations Management','03');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Project Management Tracking','07');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Accounting','12');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Inspection','13');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Management','01');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Property Tracking','15');
			   
			document.getElementById("dirSubCatID").options[document.getElementById("dirSubCatID").length] = new Option('Tenant Communication','06');
			   
		}
		
		
	}
	else {
		if (mktValue == "00") {
			document.getElementById("dirMktID").options[0].value = "%";
			document.getElementById("dirMktID").options[0].text = "Select Market:";
			document.getElementById("dirMktID").options[0].selected = true;
			document.getElementById("dirMktID").disabled = false;
			document.getElementById("dirMktID").style.background = "#faf99b";
			document.getElementById("dirMktID").focus();
			document.getElementById("dirSubCatID").disabled = true;
			document.getElementById("dirSubCatID").options[0].text = "Select Sub-Category:";
			document.getElementById("dirSubCatID").style.background = "White";
		}
	}
}



function validateSearch(theForm) {
	var reason = "";
	
	reason += validate_dirMktID(theForm.dirMktID);
	reason += validate_dirCatID(theForm.dirCatID);
	reason += validate_dirSubCatID(theForm.dirSubCatID);
	reason += validate_dirKeyword(theForm.dirKeyword);
	  
	if (reason != "") {
	alert("Some fields need correction:\n\n" + reason);
	return false;
	}
	
	return true;
}


function validate_dirMktID(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please select a Market.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}


function validate_dirCatID(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Please select a Category.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validate_dirSubCatID(fld) {
	var catValue = document.getElementById("dirCatID").options[document.getElementById("dirCatID").selectedIndex].value;
    var error = "";
 
 
    if (fld.value.length == 1 && (catValue == "77" || catValue == "85")) {
        fld.style.background = 'Yellow'; 
        error = "Please select a Sub-Category.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validate_dirKeyword(fld) {
    var error = "";
 
    if (fld.value == "City, Keyword or Company" || fld.value == "City, Keyword or Company" || fld.value == "City, Keyword or Company Name" || fld.value == "Keyword or Company Name") {
        fld.value = ''; 
    } else {
        fld.style.background = 'White';
    }
    return error;
}




