var buildList = function()
{
	var n; // Number of Offices
	var x; // counter

	this.officeList;
	this.officeList = new Array();
		this.officeList[0] = "Adams";
		this.officeList[1] = "Alamosa";
		this.officeList[2] = "Arapahoe";
		this.officeList[3] = "Archuleta";
		this.officeList[4] = "Baca";
		this.officeList[5] = "Bent";
		this.officeList[6] = "Boulder";
		this.officeList[7] = "Broomfield";
		this.officeList[8] = "Chaffee";
		this.officeList[9] = "Cheyenne";
		this.officeList[10] = "Clear Creek";
		this.officeList[11] = "Conejos";
		this.officeList[12] = "Costilla";
		this.officeList[13] = "Crowley";
		this.officeList[14] = "Custer";
		this.officeList[15] = "Delta";
		this.officeList[16] = "Denver";
		this.officeList[17] = "Douglas";
		this.officeList[18] = "Dolores";
		this.officeList[19] = "Eagle";
		this.officeList[20] = "El Paso";
		this.officeList[21] = "Elbert";
		this.officeList[22] = "Fremont";
		this.officeList[23] = "Garfield";
		this.officeList[24] = "Gilpin";
		this.officeList[25] = "Grand";
		this.officeList[26] = "Gunnison";
		this.officeList[27] = "Hinsdale";
		this.officeList[28] = "Huerfano";
		this.officeList[29] = "Jackson";
		this.officeList[30] = "Jefferson";
		this.officeList[31] = "Kiowa";
		this.officeList[32] = "Kit Carson";
		this.officeList[33] = "La Plata";
		this.officeList[34] = "Lake";
		this.officeList[35] = "Larimer";
		this.officeList[36] = "Las Animas";
		this.officeList[37] = "Lincoln";
		this.officeList[38] = "Logan";
		this.officeList[39] = "Mesa";
		this.officeList[40] = "Mineral";
		this.officeList[41] = "Moffat";
		this.officeList[42] = "Montezuma";
		this.officeList[43] = "Montrose";
		this.officeList[44] = "Morgan";
		this.officeList[45] = "Ouray";
		this.officeList[46] = "Otero";
		this.officeList[47] = "Park";
		this.officeList[48] = "Phillips";
		this.officeList[49] = "Pitkin";
		this.officeList[50] = "Prowers";
		this.officeList[51] = "Pueblo";
		this.officeList[52] = "Rio Blanco";
		this.officeList[53] = "Rio Grande";
		this.officeList[54] = "Routt";
		this.officeList[55] = "San Juan";
		this.officeList[56] = "San Miguel";
		this.officeList[57] = "Saguache";
		this.officeList[58] = "Sedgwick";
		this.officeList[59] = "Summit";
		this.officeList[60] = "Teller";
		this.officeList[61] = "Washington";
		this.officeList[62] = "Weld";
		this.officeList[63] = "Yuma";



/*

	this.officeList = new Array();
		this.officeList[0] = "Moffat";
		this.officeList[1] = "Routt";
		this.officeList[2] = "Jackson";
		this.officeList[3] = "Larimer";
		this.officeList[4] = "Weld";
		this.officeList[5] = "Morgan";
		this.officeList[6] = "Logan";
		this.officeList[7] = "Sedgwick";
		this.officeList[8] = "Phillips";
		this.officeList[9] = "Rio Blanco";
		this.officeList[10] = "Garfield";
		this.officeList[11] = "Eagle";
		this.officeList[12] = "Grand";
		this.officeList[13] = "Boulder";
		this.officeList[14] = "Broomfield";
		this.officeList[15] = "Adams";
		this.officeList[16] = "Washington";
		this.officeList[17] = "Yuma";
		this.officeList[18] = "Mesa";
		this.officeList[19] = "Pitkin";
		this.officeList[20] = "Lake";
		this.officeList[21] = "Summit";
		this.officeList[22] = "Park";
		this.officeList[23] = "Jefferson";
		this.officeList[24] = "Douglas";
		this.officeList[25] = "Arapahoe";
		this.officeList[26] = "Elbert";
		this.officeList[27] = "Lincoln";
		this.officeList[28] = "Kit Carson";
		this.officeList[29] = "Delta";
		this.officeList[30] = "Gunnison";
		this.officeList[31] = "Chaffee";
		this.officeList[32] = "Teller";
		this.officeList[33] = "El Paso";
		this.officeList[34] = "Cheyenne";
		this.officeList[35] = "Montrose";
		this.officeList[36] = "Saguache";
		this.officeList[37] = "Fremont";
		this.officeList[38] = "Pueblo";
		this.officeList[39] = "Crowley";
		this.officeList[40] = "Kiowa";
		this.officeList[41] = "San Miguel";
		this.officeList[42] = "Ouray";
		this.officeList[43] = "Hinsdale";
		this.officeList[44] = "Mineral";
		this.officeList[45] = "Rio Grande";
		this.officeList[46] = "Alamosa";
		this.officeList[47] = "Custer";
		this.officeList[48] = "Huerfano";
		this.officeList[49] = "Otero";
		this.officeList[50] = "Bent";
		this.officeList[51] = "Prowers";
		this.officeList[52] = "Dolores";
		this.officeList[53] = "San Juan";
		this.officeList[54] = "Montezuma";
		this.officeList[55] = "La Plata";
		this.officeList[56] = "Archuleta";
		this.officeList[57] = "Conejos";
		this.officeList[58] = "Las Animas";
		this.officeList[59] = "Baca";
		this.officeList[60] = "Denver";
		this.officeList[61] = "Gilpin";
		this.officeList[62] = "Clear Creek";
*/



	n = (this.officeList.length)-1;

	this.explodedList = function() {

		for(x=0; x<=n; x++)
		{
			this.officeList[x] = this.officeList[x].split('');
		}
		return this.officeList;
	};

};
function getOffice(theInput)
{
	theInput_lowerCase = theInput.toLowerCase();
	var f; // Generic Counter
	var i; // Generic Counter
	var x; // print list counter
	var outPut; // HTML that gets printed
	var listToPrint = new Array(); // this is the completed list of Offices that match the customer input
	var checkString = new Array(); // Builds the names found
	var myList = new buildList(); // Builds an object 

		// Gets the Office property from the objects
		myList = myList.officeList;
		// makes the office list explode into smaller arrays
	var explodedList = new Array();

	n = (myList.length)-1; // Number of Offices
	l = (theInput.length)-1; // number of characters input from customer.
	x = 0;
	if(theInput != "")
	{
		// build an array of 'Check Strings' based off of the first 'l' number of characters from the office names to compair to the input string
		for(f=0; f<=n; f++)
		{
			checkString[f] = "";
			explodedList[f] = myList[f].split(''); // myList[0] = "Aa Office";
			for(i=0; i<=l; i++)
			{
//alert("myList[f][1] "+myList[f][1]);
				checkString[f] += explodedList[f][i];	// this would be 'A', then "Aa", then "Aaa"
				checkString[f] = checkString[f].toLowerCase();
//alert("Made it here, checkString["+f+"] is "+ checkString[f]);
			}
//alert("Check String["+f+"] = " + checkString[f]+" and theInput(lower Case) = "+theInput_lowerCase);
			if(checkString[f] == theInput_lowerCase)
			{
//alert(checkString[f]+" == "+ theInput_lowerCase);
//alert("myList["+f+"] = " + myList[f]);
				listToPrint[x] = myList[f];
//alert("listToPrint["+x+"] = "+ listToPrint[x]);
				x++;
			}
	
		}
	document.getElementById("theList").style.display = "block";
	} else {
		document.getElementById("theList").style.display = "none";
	}
//alert("Final List to print: \n"+listToPrint);

	outPut = "";
	n = (listToPrint.length)-1; // Number of Offices
	for(f=0; f<=n; f++)
	{
		//outPut += "<li value=\"null\"><a href=\"javascript:void("+f+");\">"+listToPrint[f]+"</a></li>";
		//outPut += "<li value=\"null\"><a href=\"http://www.stewartaffiliates.com/download/1008/interactive_map/googleMap.html?county="+listToPrint[f]+"\">"+listToPrint[f]+"</a></li>";
//alert("<li value=\"null\"><a href=\"javascript:ShowGmap('"+listToPrint[f]+"');\">"+listToPrint[f]+"</a></li>");
		outPut += "<li value=\"null\"><a href=\"javascript:ShowGmap('"+listToPrint[f]+"');\">"+listToPrint[f]+"</a></li>";
		
	}
	
document.getElementById("theList").innerHTML = outPut;

}
