
var ogAutoSuggestControl;
var bgTypeAhead;
function StateSuggestions() {
this.states = [
"Africa",
"Asia",
"Australia and New Zealand",
"Central America",
"Eastern Europe",
"Europe",
"India and the subcontinent",
"Middle East",
"North America",
"Pacific Islands",
"South America",
"The Arctic / Antarctic"
    ];
}

StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl, bTypeAhead, bClicked) {
var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value.toLowerCase();
var sCurrentArrValue;

 
ogAutoSuggestControl = oAutoSuggestControl;
bgTypeAhead = bTypeAhead;
bgClicked = bClicked;


if (sTextboxValue.length > 9){
var sTextboxValue2=sTextboxValue;
var sTextboxValue=sTextboxValue.replace('type here','');

if (sTextboxValue != '' && sTextboxValue != sTextboxValue2){
oAutoSuggestControl.textbox.value=sTextboxValue;
}
}


if (sTextboxValue.length > 3 && !bClicked && sTextboxValue.indexOf('type here') < 0){
getUpdatedList(sTextboxValue); 
}
 else { 
 if ((bClicked || sTextboxValue.length==0) && this.states.length>0){
oAutoSuggestControl.autosuggest(this.states, bgTypeAhead);
}
}
};
window.onload = function () {

if (txtfieldname)

//if (document.getElementById("txtfieldname"))
{
//var txtfieldname = document.getElementById("txtfieldname").value;
//alert(txtfieldname);
//alert(document.getElementById(txtfieldname));
var oTextbox = new AutoSuggestControl(document.getElementById(txtfieldname), new StateSuggestions(), null);
}
}


function getUpdatedList(destination)
{
var textValue='';

if (txtfieldname)
//if (document.getElementById("txtfieldname"))
{
//var txtfieldname = document.getElementById("txtfieldname").value;

if (document.getElementById(txtfieldname))
{

textValue = document.getElementById(txtfieldname).value;

}

if (destination.length > 0) 
{
//Cbo3.DoCallBack(txtfieldname, '', '/Home.aspx', false);
Cbo3.DoCallBack(txtfieldname + '|getDestinationList',textValue, '/components/AJAX/AjaxHandler.aspx', false);
}
else
{
Cbo3.AbortCallBack();
}
} 
}


var Cbo3 = new CallBackObject();
Cbo3.OnComplete = Cbo_Complete;
Cbo3.OnError    = Cbo_Error;


function Cbo_Complete(responseText, responseXML)
{
var str = responseText; 
if (str != '')
{
var aSuggestions=str.split(':');
if (aSuggestions.length > 0) 
ogAutoSuggestControl.autosuggest(aSuggestions, bgTypeAhead, bgClicked);
} 
}


function Cbo_Error(status, statusText, responseText)
{
}
