function comapcontrol(comap){
this.map = comap;

this.citysearch = document.createElement("input");
this.citysearch.type="text";
this.citysearch.value="Boulder, CO";

this.btnSearch = document.createElement('input');
this.btnSearch.type = "button";
this.btnSearch.id = "btnSearch";
this.btnSearch.value = "Lookup Location";
this.btnSearch.title = "Search Colorado";
this.btnSearch.name = "btnSearch";	
this.lastsearched;

this.resultsdiv = document.createElement('div');

this.gethikes = function(id){
	new Ajax.Updater($(this.resultsdiv), 'gethikes.php', {parameters:'offset=' + id + '',onComplete:function(){ new Effect.Appear($(this.resultsdiv));},asynchronous:true});
}

this.GetHikesByAlpha = function(alpha){
	new Ajax.Updater($(this.resultsdiv), 'gethikes.php', {parameters:'alpha=' + alpha  + '',onComplete:function(){ new Effect.Appear($(this.resultsdiv));},asynchronous:true});
}

this.show = function(div){
		this.div = div;
		this.table = document.createElement('table');
		this.table.border = "0";
		this.table.width = "100%";
		//this.table.style.backgroundColor = "#999999";
		
		this.tbody = document.createElement('tbody');
		
		this.tr1 = document.createElement('tr');

		this.td1 = document.createElement('td');
		//this.td1.style.backgroundColor = "#003366";
		//this.td1.style.fontSize = "10px";
		//this.td1.style.color = "#FFFFFF";
		//this.td1.height="10px";
		//this.td1.width = "118px";
		//this.td1.align="left";
		
		this.spanlabel = document.createElement('span');
	//	this.spanlabel.class="style7";
		this.spanlabel.id="comapctrl";
		this.spanlabel.innerHTML = "Location Information";
	
		//this.td1.appendChild(this.btnreturn);
		//this.td1.appendChild(this.spanlabel);	
		
		this.tr2 = document.createElement('tr');
		this.td2 = document.createElement('td');
		//this.td2.style.backgroundColor = "#999999";
		this.ctrlsdiv = document.createElement('div');
		this.ctrlsdiv.id="crtls";
		this.ctrlsdiv.align="center";
		
		//this.ctrlsdiv.appendChild(this.citysearch);
		//this.ctrlsdiv.appendChild(this.btnSearch);
		
		//this.resultsdiv = document.createElement('div');
		this.resultsdiv.id="results";
		this.resultsdiv.align="left";

		this.tr1.appendChild(this.td1);
		
		this.td2.appendChild(this.ctrlsdiv);
		this.td2.appendChild(this.resultsdiv);
		this.tr2.appendChild(this.td2);
		
		this.tbody.appendChild(this.tr1);
		this.tbody.appendChild(this.tr2);
		this.table.appendChild(this.tbody);
		
		//this.table.appendChild(this.tr2);
		this.div.appendChild(this.table);
		
		this.gethikes(0);
		//hammer on
		Event.observe($(this.btnSearch), 'click', function(event){
			 $(this.resultsdiv).innerHTML = "Trails:";										  
		}.bindAsEventListener(this));
}

	this.showAddress = function () 
		{
		lat.length=0;
		var search = document.getElementById("CitySearch").value;
			map.clearOverlays();
		geo.getLocations(search, function (result)
			{
				if (result.Status.code == G_GEO_SUCCESS) 
					{
					// Loop through the results, placing markers
						for (var i=0; i<result.Placemark.length; i++) 
						{
						//alert();
						document.getElementById("maplist").innerHTML = result.Placemark[i].address;	
						map.setCenter(new GLatLng(result.Placemark[i].Point.coordinates[1],result.Placemark[i].Point.coordinates[0]), 14);
						}
					} 
			});
		}
		
//end of comapcontrol
}

