window.onload = initForm;

function initForm() {
   document.getElementById("state-select").selectedIndex = 0;
   document.getElementById("counties").selectedIndex = 0;
   document.getElementById("state-select").onchange = populateCounties;
    }

function populateCounties() {

if (this.options[this.selectedIndex].value == 'KY'){
var countiesState = new Array(
'All Counties', 
'Adair',
'Boone',
'Bracken',
'Breathitt',
'Breckinridge',
'Calloway',
'Carter',
'Christian',
'Clark',
'Clay',
'Elliott',
'Estill',
'Floyd',
'Gallatin',
'Garrard',
'Graves',
'Grayson',
'Green',
'Harlan',
'Harrison',
'Henderson',
'Jefferson',
'Kenton',
'Knott',
'Knox',
'Laurel',
'Lee',
'Leslie',
'Letcher',
'Logan',
'Madison',
'Magoffin',
'Martin',
'McCreary',
'Meade',
'Montgomery',
'Ohio',
'Owsley',
'Perry',
'Pike',
'Pulaski',
'Rockcastle',
'Scott',
'Trigg',
'Whitley',
'Wolfe');  
}

if (this.options[this.selectedIndex].value == 'WV'){
var countiesState = new Array(
'All Counties', 
'Barbour',
'Boone',
'Braxton',
'Cabell',
'Clay',
'Fayette',
'Kanawha',
'Lincoln',
'Logan',
'Mason',
'McDowell',
'Mercer',
'Mingo',
'Nicholas',
'Putnam',
'Tucker',
'Wayne',
'Wood',
'Wyoming');
}

if (this.options[this.selectedIndex].value == 'AL'){
var countiesState = new Array(
'All Counties', 
'Russell');
}

if (this.options[this.selectedIndex].value == 'MO'){
var countiesState = new Array(
'All Counties', 
'Ripley');
}

if (this.options[this.selectedIndex].value == 'OH'){
var countiesState = new Array(
'All Counties', 
'Butler');
}

if (this.options[this.selectedIndex].value == 'TN'){
var countiesState = new Array(
'All Counties', 
'Benton',
'Haywood',
'Henry',
'Houston',
'Humphreys',
'Stewart');
}

if (this.options[this.selectedIndex].value == 'VA'){
var countiesState = new Array(
'All Counties', 
'Buchanan');
}

if (this.options[this.selectedIndex].value == 'All States'){
var countiesState = new Array(
'All Counties');
}

var selectedState = this.options[this.selectedIndex].value;
var theState = parseInt(selectedState);
document.getElementById("counties").options.length = 0;
for(var i=0; i<countiesState.length; i++) {
 document.getElementById("counties").options[i] = new Option(countiesState[i]);
 }

document.getElementById("counties").selectedIndex = 0;

} 




