﻿Locator.AutoComplete = function() {
	this.oDS = {};
	this.oAC = {};
	this.citiesArray = [];
	this.loadFiles(this);
};
Locator.AutoComplete.prototype.loadFiles = function(o) {
	var loader = new YAHOO.util.YUILoader({
		base: Locator.Config.yuiBase,
		require: ["autocomplete"],
		loadOptional: true,
		onSuccess: function() {
			o.init(o);
		},
		timeout: 10000
	});
	loader.addModule({ 
		name: "ac_citydata",
		type: "js",
		fullpath: Locator.Config.citiesDataPath,
		varName: "AC_CITYDATA"
	});
	loader.require(['ac_citydata']);
	loader.insert();	
};
Locator.AutoComplete.prototype.init = function(o) {
    // Use a LocalDataSource
    var oDS = new YAHOO.util.LocalDataSource(Locator.citiesArray[Locator.setActiveCountry()]);
    // Optional to define fields for single-dimensional array
    oDS.responseSchema = {fields : ["state"]};;
    // Instantiate the AutoComplete
    var oAC = new YAHOO.widget.AutoComplete("searchZip", "citycontainer", oDS);
    oAC.prehighlightClassName = "yui-ac-prehighlight";
    oAC.useShadow = true;
    
    o.oDS = oDS;
	o.oAC = oAC;
};
Locator.acCity = new Locator.AutoComplete();

 


