	var initAll = function(){
	var cosAutoComp = new COS.CosAutoComp({
							containers:{
								input:"cosAddressInput",
								resultContainer:"cosSearchContainer", 
								outterContainer:"cosAddressSearch"
							}});
	cosAutoComp.setResultOutput("cosResultOutput");
	//copy this autocomplete.formatResult implementation
	var populateResultSubscribed=false;
	cosAutoComp.cosAutoCompResult.formatResult = function(aResultItem, sQuery) {
		this.cosAutoComp.query=sQuery;
		if(aResultItem[0]!="not") {	 
		  if(!populateResultSubscribed){
		  	this.containerCollapseEvent.subscribe(populateResult);
			populateResultSubscribed=true;
			this.setHeader("<h4>Please select one of the results below</h4>");
		  }
		  return cosAutoComp.handleResponse(aResultItem,sQuery);	
		}	
		else {
			this.containerCollapseEvent.unsubscribe(populateResult);
			populateResultSubscribed=false;
			this.setBody("<div id=\"cosresultsdefault\">Sorry, <span style='font-weight:bold'>\""+sQuery+"\"</span> was not found<br /> Please press \"enter\" and retype your query</div>");
			this.setHeader("");
		}
	};
	//subscribe to custom events
	cosAutoComp.cosAutoCompResult.itemSelectEvent.subscribe(cosAutoComp.cosOnItemSelect);

	// Result implementation example
	function populateResult(){
		if(typeof this.cosAutoComp.getLegalAddress()!="undefined"){			
			this.cosAutoComp.resultOutput.style.display="block";		
			var response = ["<table cellpadding='0' cellspacing='0'>",
			"<tr>",
			"<td style='font-weight:bold; text-align:right; padding-right:5px;'>Address: </td>",
			"<td>"+this.cosAutoComp.getLegalAddress()+"</td>",
			"</tr>",
			"<tr>",
			"<td style='font-weight:bold; text-align:right; padding-right:5px;'>Neighborhood: </td>",
			"<td>"+this.cosAutoComp.getNeighborhood()+"</td>",
			"</tr>",
			"<tr>",
			"<td style='font-weight:bold; text-align:right; padding-right:5px;'>Police District: </td>",
			"<td>"+this.cosAutoComp.getPoliceDistrict()+" District</td>",
			"</tr></table>"];
			document.getElementById("cosResultOutput").innerHTML=response.join("");
		}
	}
}();

