function SuggestBox(name,divId,inpId,url,lang){
    this.name = name;
    this.divId = divId;
    this.inpId = inpId;
    this.lang = lang;
	this.act = false;
	this.xml = null;
	this.keyDelay = 300;
	this.hideDelay = 600;
	this.keyTimer = null;
    this.hTimer = null;
	this.url = url;
	this.urlFRM = '/SeachSuggestBackFRM.asp';
	this.iFRMname = '';

    this.init = SuggestBox_init;
	this.sendRequest = SuggestBox_sendRequest;
	this.sendRequestFRM = SuggestBox_sendRequestFRM;
	this.sendRequestFRM = SuggestBox_sendRequestFRM;
    this.showSGBox = SuggestBox_showSGBox;
    this.keyUpDelay = SuggestBox_keyUpDelay;
    this.keyUp = SuggestBox_keyUp;
    this.hideSGBoxDelay = SuggestBox_hideSGBoxDelay;
    this.hideSGBox = SuggestBox_hideSGBox;
    this.breakHideSGBox = SuggestBox_breakHideSGBox;
    
}

function SuggestBox_init(frmName){
	if(frmName){
		this.iFRMname = frmName;
		this.act = true;
	}else{
		this.xml = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : null));
		if(!this.xml){
			this.act = false;
		}else{
			this.act = true;
		}
		this.encFunc = encodeURIComponent ? encodeURIComponent : escape;
	}
}
function SuggestBox_sendRequest(text){
	if(!this.act){
		return;
	}
	if(this.xml.readyState != 0){
		this.xml.abort();
	}
	//alert(this.url+"?lang="+this.lang+"&value="+escape(text));
	this.xml.open("GET",this.url+"?lang="+this.lang+"&value="+escape(text), true);
	this.xml.onreadystatechange = new Function('if ('+this.name+'.xml.readyState == 4){if ('+this.name+'.xml.status == 200){'+this.name+'.showSGBox('+this.name+'.xml.responseText);}}');
	this.xml.send('');
}
function SuggestBox_sendRequestFRM(text){
	if(this.act)
	window.frames[this.iFRMname].location.href = this.urlFRM+'?value='+text;
}
function SuggestBox_sendRequestFRM(text){
	if(this.act)
	window.frames[this.iFRMname].location.href = this.urlFRM+'?value='+text;
}
function SuggestBox_showSGBox(data) {
    if(data.length>0){
		getE(this.divId).innerHTML = data;
		getE(this.divId).style.visibility = "visible";
	}else{
        this.hideSGBox();
	}
}
function SuggestBox_keyUpDelay(){
    clearTimeout(this.keyTimer);
    this.keyTimer = null;
    var cmd = this.name+".keyUp()";
    this.keyTimer = setTimeout(cmd, this.keyDelay);
}
function SuggestBox_keyUp(){
    this.keyTimer = null;
    var txt = trim(getE(this.inpId).value);
	if(txt.length > 0){
      	if(this.iFRMname!='')
          	this.sendRequestFRM(txt)
    	else
	    	this.sendRequest(txt);
    }else{
        this.hideSGBox();
    }
}
function SuggestBox_hideSGBoxDelay(){
    this.breakHideSGBox();
    var cmd = this.name+".hideSGBox()";
    this.hTimer = window.setTimeout(cmd,this.hideDelay);
}
function SuggestBox_hideSGBox(){
    this.hTimer = null;
    getE(this.divId).style.visibility = "hidden";
}
function SuggestBox_breakHideSGBox(){
    clearTimeout(this.hTimer);
    this.hTimer = null;
}

