

/**
 * Constructor for QuerySuggester.
 */
  
//sqs.initialize("/sfe/autoCompleteProxy?q=", "search_form", "completion_tooltip", "search_form_query");
//sqs.setDebugAreaId("completion_debug");


function QuerySuggester() {
	//alert("here");
    this.id = querySuggesters.length;
    querySuggesters[this.id] = this;
}

var temp_close = "completion_tooltip0";
//var temp_close = "";
var sel_close = "";
var closeflag = 1;
QuerySuggester.prototype.useInlineSuggestion = true;                // Whether or not to display the first suggestion as marked text within the search-box
QuerySuggester.prototype.clearInlineSuggestionBeforeSubmit = false; // Whether or not to remove inline suggestions before submitting

// Public functions

/**
 * Initialize the query-suggester.
 *
 * @param suggestionUrl the url to fetch suggestions from, will append the query string to it
 * @param formId        the id of the form that should be submitted if the user clicks a suggestion
 * @param tooltipId     the id of the div used to display the suggestsions
 */

/*=======================================================================================
    함수명 : initialize
    기  능 : 자동완성 URL, form id, div id, inputBox id를 받아와 정의  
    인  수 : suggestionUrl [URL] => 받아올 사전 url
    		 formId [form id] => 자동완성 보여줄 폼
    		 tooltipId id [div id] => 자동완성 감싸고 있는 div
    		 queryId [inputBox id] => 입력받아올 inputbox
    리  턴 : 
=========================================================================================*/ 
 
QuerySuggester.prototype.initialize = function(suggestionUrl, formId, tooltipId, queryId) {
//	alert("initialize");
	this.__enabled = new BackgroundLoader().isEnabled();

    if (this.__enabled) {
        this.__suggestionUrl = suggestionUrl;
        this.__form = this.byId(formId);
       
        if (!this.__form) {
            this.__enabled = false;
            this.debug("Couldn't find the form, disabling.");
        } else {
            this.__tooltip = this.byId(tooltipId);
            this.__queryId = queryId;
            this.__query = this.byId(queryId);
			//alert("tooltipId = "+tooltipId+" ,formId = "+formId+" ,queryId = "+queryId);
            if (this.__query) {
            	var oldKeyUp = this.getFunctionBody(this.__query.onkeyup);
                var oldKeyDown = this.getFunctionBody(this.__query.onkeydown);
                var suggester = this;
                this.__query.onkeyup = function(e) { if (typeof e != "undefined") event = e; eval(oldKeyUp); suggester.keyUp(event, queryId,tooltipId); };
                this.__query.onkeydown = function(e) { if (typeof e != "undefined") event = e; eval(oldKeyDown); suggester.keyDown(event, queryId); };
            }
        }
    } else {
        this.debug("Unable to instantiate XMLHttpRequest, disabling.");
    }

};

/**
 * Set the id of the textarea where debug-output is written. Initially, there is no such
 * textarea assigned to the suggester.
 *
 * @param debugAreaID the id of the textarea to print debug messages to, or boolean false
                      to disable debugging
 */
QuerySuggester.prototype.setDebugAreaId = function(debugAreaId) {
    this.__debugAreaId = debugAreaId;
};

/**
 * Set the id of the input-field to do completion for. Not really neccessary to call, as
 * the id is sent to the key handling methods.
 *
 * @param queryId the id of the search box
 */
QuerySuggester.prototype.setQueryId = function(queryId) {
    this.__queryId = queryId;
    this.__query = this.byId(queryId);
};

// Overridable functions

/**
 * Returns the url to visit to obtain suggestions for a query. By default appends the
 * query to the suggestionUrl member. Override for different behavior.
 *
 * @param quer the query for which to fetch suggestions
 * @return the url that will return the suggestions
 */
QuerySuggester.prototype.getSuggestionUrl = function(query) {
    //return this.__suggestionUrl + query;
    //alert(this.__suggestionUrl + encodeURIComponent(query));
    return this.__suggestionUrl + encodeURIComponent(query);
};

/**
 * Called when the search form should be submitted (usually because of mouse clik on one
 * of the suggestions in the list). By default submits the form specified by the formId
 * parameter of the initialize() function. Override for different behavior.
 */
QuerySuggester.prototype.submitForm = function() {
    this.__form.submit();
};

// Input event handlers

/**
 * Event handler for key up events.
 */
 
QuerySuggester.prototype.chk_target = function(nowDivId) {
	sel_close = nowDivId;
	if(temp_close == ""){
		temp_close = sel_close;
	}else if(temp_close != "" && temp_close != sel_close){
		closeflag = "1";   
		aclose(temp_close);
		temp_close = sel_close;
	}
};



QuerySuggester.prototype.keyUp = function(event, field,tooltipId) {
	//alert("tooltipId = "+this.byId("tooltipId_" + this.__index));
	//alert("tooltip = "+this.byId("tooltip_" + this.__index));
	//this.__query.value = this.__terms[this.__index];
			//alert("this.__query.value = "+this.__terms[this.__index]);

   // this.__tooltip = this.byId(tooltipId);
   //var tool = this.byId("tooltipId_" + this.__index);
	//alert("tooltipId = "+tooltipId);
	//alert("tooltipId 변경전= "+ tooltipId);
	//alert("temp_close변경전= "+ temp_close);
	this.chk_target(tooltipId);
	
	this.__tooltip = this.byId(tooltipId);	

	var toolDivId =this.byId("tooltip_" + this.__index)							//현재 선택된 div index
	var toolDivIdNext =this.byId("tooltip_" + (this.__index+1))					//다음 선택된 div index
	var toolDivIdPre =this.byId("tooltip_" + (this.__index-1))					//이전 선택된 div index
	//alert("1111 = "+toolDivId);
	
	if (!this.__enabled) return;
    else if (field != this.__queryId) this.setQueryId(field);

    if (event) {
        if (this.__timeout) {
            clearTimeout(this.__timeout);
            this.__timeout = false;
        }
        if (event.ctrlKey || event.altKey) {
            return;
        }
        var timeout = 100;
        this.__deletePressed = false;
		switch (event.keyCode) {
	        case 9 : // Tab
            case 27 : // Escape
                this.hide();
                return;
            case 8 : // Backspace
            case 46 : // Delete
                this.__deletePressed = true;
                timeout = 200;
                break;
            case 13 : // Enter
				//alert("tooltip_ = "+this.byId("tooltip_" + this.__index).value);
				//alert("adfsaf  = "+document.getElementById("search_form_query0").value);
				
				//alert("1 = "+this.__terms[this.__index]);
				//this.__query.value = this.__terms[this.__index];
				//alert("this.__query.value = "+this.__query.value)
				//document.getElementById("search_form_query0").value="";
				//alert("Enter = "+this.__terms[this.__index]);
				//alert("Enter = "+this.__index);
				//alert("this.__query.value = "+this.__query.value);
				//this.__tooltip.style.zIndex = 1;
				//this.__query.value="";
				this.__tooltip.style.visibility = "hidden";
				//return false;

            case 16 : // Shift
            case 17 : // Ctrl
            case 18 : // Alt
            case 20 : // Caps Lock
            case 33 : // Page up
            case 34 : // Page down
            case 35 : // End
            case 36 : // Home
            case 37 : // Arrow left
            case 38 : // Arrow up
					
					if(this.__index != 9 && this.__index != -1 ){
						if(toolDivIdNext==""){
							
						}else{
							toolDivIdNext.style.background = "#FFFFFF"
						}
						
					}
					if(this.__index <6 && this.__index != -1){
						document.getElementById("auto_title").doScroll("scrollbarUp");
					}

									

            case 39 : // Arrow right
            case 40 : // Arrow down
					
					//alert("index = "+this.__index);

					//alert("toolDivId = "+toolDivId);
					
					if( this.__index  != 0 && this.__index != -1){
						toolDivIdPre.style.background = "#FFFFFF"
					}
					if(this.__index != -1){
						toolDivId.style.background = "#F3F3F3"
						
					}
					if(this.__index >= 4){
						document.getElementById("auto_title").doScroll("scrollbarDown");						
					}
					if(document.getElementById(tooltipId).style.visibility=="hidden"){
					document.getElementById(tooltipId).style.visibility="visible";
					}
					
				
			case 45 : // Insert
                return;
			case 229 : // Mouse click
				//alert("toolDivId = "+toolDivId);
				//this.__query.value = this.__terms[this.__index];

				//alert("MouseClick = "+this.__terms[this.__index]);
				//alert("this.__query.value = "+this.__query.value);
				//this.__tooltip.style.visibility = "hidden";
				//alert("1111");
				//this.hide();
				return;

            default :
                timeout = 100;
                break;
        }
        this.__index = -1;
        var qc = this;
        this.__timeout = setTimeout(function() {qc.fetchAndDisplaySuggestions();}, timeout);
    }

};

/**
 * Some keys also require keyDown handlers, because they never give a key up event. For
 * instance, pressing the 'tab' key will typically cause focus to leave the search input
 * box, causing the key up event to be sent to another component.
 */
QuerySuggester.prototype.keyDown = function(event, field) {
    if (!this.__enabled){
		return;
	}
    else if (field != this.__queryId){
		this.setQueryId(field);
	}

    if (event && event.keyCode) {
        switch (event.keyCode) {
            case 9 : // Tab
                this.hide();
                break;
            case 13 : // Enter
                if (this.__index == -1) this.clearInlineSuggestion();
                break;
            case 38 : // Up-arrow
                if (this.__index >= 0) this.updateSuggestions(this.__index--, -2);
                
                break;
            case 40 : // Down-arrow
			    if (this.__index < this.__terms.length - 1) this.updateSuggestions(this.__index++, -2);
                break;
        }
    }
};

QuerySuggester.prototype.mouseOver = function(index) {
    //document.getElementById('search_form_query0').focus();
    //this.__query.value = this.__terms[index];
    if (!this.__enabled) return;
    var previous = this.__mouseIndex >= 0 ? this.__mouseIndex : this.__index;
    this.__mouseIndex = index;
    this.updateSuggestions(-2, previous);
};

QuerySuggester.prototype.mouseOut = function(index) {
	 //document.getElementById('search_form_query0').onblur='javascript:autoclose()';
    if (!this.__enabled) return;
    var previous = this.__mouseIndex;
    this.__mouseIndex = -1;
    this.updateSuggestions(-2, previous);
};

QuerySuggester.prototype.mouseClick = function(index) {

	if (!this.__enabled) return;

		if (index >= 0) {
			this.__query.value = this.__terms[index];
			if(temp_close == "completion_tooltip0"){
			lf_FastSrch(); return false;
			}else if(temp_close == "completion_tooltip1"){
			return false;
			}else if(temp_close == "completion_tooltip2"){
			lf_Search(); return false;
			}else {
			return false;
			}
		
			
			this.hide();
		} else {
			this.hide();
		}
	//document.getElementById("completion_tooltip0").style.visibility="hidden";
};

// Functions for retrieving suggestions

QuerySuggester.prototype.fetchAndDisplaySuggestions = function() {
    //alert(this.__terms[this.__index]);
	//this.__query.style.color="#FF9900"
	var val = this.__query.value;
	if (this.canHandleRanges()) {
        val = val.substring(0, this.getCaretPosition());
		//this.__terms[this.__index] = val;
		//alert(this.__terms[this.__index]);
		//alert("val = "+val);
    }

    if (val.length == 0) {
        this.hide();
        this.__prev = val;
        return;
    } else {
        val = val.replace(new RegExp("\\\\", "g"), "\\\\");
    }

    this.__prev = val;
    if (this.__cache[val]) {
        this.debug("cache: " + val);
        this.displaySuggestions(this.__cache[val], this.__prev);
    } else {
        //this.debug("query: '" + val + "'");
        this.fetchSuggestion(val);
    }
};

QuerySuggester.prototype.fetchSuggestion = function(query) {
	//alert("fetchSuggestion");
    var qc = this;
    var bl = new BackgroundLoader();
    bl.setLoadedCallback(function(content){qc.parseSuggestions(content);});
    bl.setErrorCallback(function(error){qc.debug("Couldn't get suggestions:\n" + error);});
    bl.loadUrl(this.getSuggestionUrl(query));
};

// Functions for displaying suggestions

QuerySuggester.prototype.parseSuggestions = function(matches) {
	//alert("aa");
	//alert("matches = "+matches);
    if (matches == null || matches == undefined || matches == "undefined") return;
    var params = eval(matches);
    
    if (params == null || params == undefined || params == "undefined") return;
	if (params.length > 2) {
        this.__cache[params[0]] = params;
	}
    this.displaySuggestions(params, params.length > 2 ? params[0] : "");
};

QuerySuggester.prototype.displaySuggestions = function(matches, query) {
    if (matches.length <= 2) {
        this.noSuggestions();
        //alert(noSuggestion");
        return;
    }
    if (this.__tooltip && this.__query) {
        this.buildSuggestionsHtml(matches);
        //alert("show");
        this.show();
        //this.showInlineSuggestions(query);
    }
};

QuerySuggester.prototype.buildSuggestionsHtml = function(matches) {
	//alert("build");
	var aa = document.getElementById("completion_tooltip0");

	var text = "";
	var val1 = "";
    var length = matches.length / 2 - 1;
	var termlength=0;
	this.__tooltiplength=0; 
	this.__terms = new Array(length);
	
		text = "<table border=\"0\" height=\"25\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"BCBCBC\"><tr><td bgcolor=\"#E8E8E8\" valign=\"middle\"><span class=\"word_title\">&nbsp;검색어 자동완성</span></td>";
		text += "<td align=\"right\" bgcolor=\"E8E8E8\"><img src=\"../../img/ndsl/btn_wordclose.gif\" title=\"자동완성닫기\" onClick=\"javascript:autoclose()\" style=\"cursor:hand\" alt='자동완성닫기'></td>";
		text += "</tr></table>"
		//text += "<table height=\"5\"><tr><td></td></tr></table>"
		text += "<div id=\"auto_title\" class=\"box\" style=\"width:100%;height:92px;overflow:auto;\">";
		//text = "<div style=\"background:#FFFFCC;cursor:hand;width:200px;padding-left:150px\" ><strong>검색어 자동완성기능</strong></div>"
		//text += "<div style=\"background:#FFFFCC;cursor:hand;\" align=\"right\"><a href=\"#\" onClick=\"this.style.visibility = 'hidden'\">기능끄기</a></div>"
		var aa = "";
		
		for (var i = 0; i < length; ++i) {
			//matches = matches[i * 2 + 2].substring(0, 15));	
			val1 = matches[i * 2 + 2].substring(0, this.getCaretPosition());

	        text +=
			"<div id=\"tooltip_" + i + "\" onfocus=\"mouseOver(" + this.id + "," + i + ");this.style.background='#F3F3F3';\" onmouseover=\"mouseOver(" + this.id + "," + i + ");this.style.background='#F3F3F3';\"  onblur=\"mouseOut(" + this.id + "," + i + ");this.style.background='#FFFFFF'\" onmouseout=\"mouseOut(" + this.id + "," + i + ");this.style.background='#FFFFFF'\"  onkeypress=\"mouseClick(" + this.id + "," + i + ")\" onclick=\"mouseClick(" + this.id + "," + i + ")\" style=\"padding-left:5px;padding-top:2px;cursor:hand;\">" +"<font color=\"#FF9900\">"+val1+"</font>"+matches[i * 2 + 2].substring(this.getCaretPosition())+"</div>\n";
	        
			this.__terms[i] = matches[i * 2 + 2];
	
			termlength = this.__terms[i].length;
		
			if(termlength > this.__tooltiplength)
				this.__tooltiplength = termlength;
	
	    }
	    
		text += "</div>\n";
	    this.__tooltip.innerHTML = text;
};


function strlen(str) 
{ 
	var len = str.length; 
	var han = 0; 
	var res = 0; 
	
	for(i=0;i<len;i++) { 
		var a=str.charCodeAt(i); 
		if(a>128) 
		han++; 
	} 
	res = (len-han) + (han*2); 
	
	return res; 
} 

function BYTE(input) {
	var i, j=0;
	for(i=0;i<input.length;i++) {
		val=escape(input.charAt(i)).length;
		if(val== 6) j++;
		j++;
	}
	return j;
}

QuerySuggester.prototype.showInlineSuggestions = function(query) {
	//alert(this.__terms +"||"+this.__terms.length);

    if (this.__terms.length > 0 && this.__query.value == query && !this.__deletePressed && this.useInlineSuggestion) {
	    //alert(this.__query.value);
        this.__original = this.__query.value;
		//alert("this.__original = "+this.__original);
        if (this.canHandleRanges()) {
	        //alert(this.__term[0]);
            //this.__query.value = this.__terms[0];
            //alert(this.__terms[0] + "||" + strlen(this.__original) +"||"+ strlen(this.__query.value));
            //this.selectRange(this.__original.length, this.__query.value.length);
            //this.selectRange(strlen(this.__original), strlen(this.__query.value));
        }
    }

};

QuerySuggester.prototype.updateSuggestions = function(previousIndex, previousMouseIndex) {
    var previous = this.byId("tooltip_" + previousIndex);
    var previousMouse = this.byId("tooltip_" + previousMouseIndex);
    var current = this.byId("tooltip_" + this.__index);
    var currentMouse = this.byId("tooltip_" + this.__mouseIndex);
	//alert("previous = "+previous);
	//alert("previousMouse = "+previousMouse);
	//alert("current = "+this.__index);
	//alert("currentMouse = "+currentMouse);	
    if (previous) {
        if (previousIndex != this.__mouseIndex) {
            previous.className = "suggestionEntry";
        }
    }
    if (current) {
        current.className = "suggestionEntryHover";
        if (this.canHandleRanges()) {
	        //alert("this.__terms = "+this.__terms[this.__index]);
            this.__query.value = this.__terms[this.__index];
			//alert("this.__query.value = "+this.__query.value);
            this.selectRange(this.__original.length, this.__query.value.length);
			//alert("this.__original.value = "+this.__original.value);
        }
    }
    if (previousMouse && previousMouseIndex != this.__index) {
        previousMouse.className = "suggestionEntry";
    }
    if (currentMouse) {
        previousMouse.className = "suggestionEntryHover";
    }
};

/**
 * Called when the list of matches returned is empty. Default implementation will simply
 * hide the list of suggestions. Override for custom behavior.
 */
QuerySuggester.prototype.noSuggestions = function() {
    this.hide();
};

//자동완성 크기 위치 지정
QuerySuggester.prototype.show = function() {
	var tooltipwidth = this.__tooltiplength * this.__tooltipwidthrate;
if(tooltipwidth < this.__query.offsetWidth)
	tooltipwidth = this.__query.offsetWidth;
    if (this.__tooltip && this.__query) {
		//alert("show");
        //this.__tooltip.style.left = this.findPosX(this.__query) + "px";												//X축 위치
        //this.__tooltip.style.top = (this.findPosY(this.__query) + this.__query.offsetHeight) + "px";				//Y축 위치
        //this.__tooltip.style.width = this.__query.offsetWidth + "px";												//창 너비
        //this.__tooltip.style.width = tooltipwidth + "px";																
        if (typeof(sortdiv)!="undefined"){
	        if (tooltipwidth > 200)
	    		sortdiv.style.visibility='hidden';
	    	else
	    		sortdiv.style.visibility='';
		}
		//selectBoxHidden(this.findPosX(this.__query), this.findPosY(this.__query), this.__query.offsetHeight, tooltipwidth);
        this.__tooltip.style.visibility = "visible";
    }
};

QuerySuggester.prototype.hide = function() {
    if (this.__tooltip) {
        this.__terms = new Array();
        if (typeof(sortdiv)!="undefined"){
	    	sortdiv.style.visibility='';
		}
        this.__tooltip.style.visibility = "hidden";
    }
};

// Text-selection helper-functions 

QuerySuggester.prototype.canHandleRanges = function() {
    return this.__query.createTextRange || this.__query.setSelectionRange;
};

QuerySuggester.prototype.selectRange = function(from, to) {
	//alert("sr");
    if (this.__query.createTextRange) {
        var t = this.__query.createTextRange();
        t.moveStart("character", from);
        t.select();
        //alert(t.select());
    } else if (this.__query.setSelectionRange) {
        this.__query.setSelectionRange(from, to);
    } else {
        this.debug("Couldn't select range.");
    }
};

QuerySuggester.prototype.getCaretPosition = function() {
    if (document.selection) {
        var range = document.selection.createRange().duplicate();
		//alert("range = "+range);
		range.collapse(true);
        range.moveStart("character", -1000);
        return range.text.length;
    } else if (this.__query.setSelectionRange) {
        return this.__query.selectionStart;
    } else {
        this.debug("Couldn't find caret position.");
        return this.__query.value.length;
    }
};

QuerySuggester.prototype.clearInlineSuggestion = function() {
    if (this.__query && this.canHandleRanges() && this.clearInlineSuggestionBeforeSubmit) {
        this.__query.value = this.__query.value.substring(0, this.getCaretPosition());
    }
};

// General helper-functions

/**
 * Helper-function that extracts the body of a function, by converting it to a string, and
 * extracting the substring from after the first { to the last }. If the func argument
 * isn't a function, an empty string is returned.
 *
 * @param func the function whose body to extract
 * @return the body of func
 */
QuerySuggester.prototype.getFunctionBody = function(func) {
	//alert("func = "+func);
    var body = "";
    if (typeof func == "function") {
        body = func.toString();
        body = body.substring(body.indexOf("{") + 1, body.lastIndexOf("}"));
    }
    return body;
};

//자동완성 position 만드는 함수
QuerySuggester.prototype.findPosX = function(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft;
            obj = obj.offsetParent;
        }
    } else if (obj.x)
        curleft += obj.x;
    return curleft;
};

QuerySuggester.prototype.findPosY = function(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    } else if (obj.y) {
        curtop += obj.y;
    }
    return curtop;
};

QuerySuggester.prototype.byId = function(id) {
    var element = document.getElementById ? document.getElementById(id) : false;
    return element && element != null ? element : false;
};

QuerySuggester.prototype.debug = function(message) {
    if (this.__debugAreaId) {
        var err = this.byId(this.__debugAreaId);
        if (err) {
            err.value += message + "\n";
        }
    }
};

// Private members

QuerySuggester.prototype.__suggestionUrl = false;   // The url to fetch suggestions from
QuerySuggester.prototype.__form = false;            // The form
QuerySuggester.prototype.__query = false;           // The query input field
QuerySuggester.prototype.__queryId = false;         // The id of the query input field
QuerySuggester.prototype.__tooltip = false;         // The tooltip div
QuerySuggester.prototype.__debugAreaId = false;     // Text-area for debugging

QuerySuggester.prototype.__tooltiplength = 0;		// for the flexible tooltipbox size
QuerySuggester.prototype.__tooltipwidthrate = 8;	// a character per pixel


QuerySuggester.prototype.__timeout = false;         // The current timeout
QuerySuggester.prototype.__prev = "";               // The previously sent term
QuerySuggester.prototype.__original = "";           // The term before panning into the suggestions
QuerySuggester.prototype.__index = -1;              // The index of the text cursor in the list of suggestions
QuerySuggester.prototype.__mouseIndex = -1;         // The position of the mouse in the list of suggestions
QuerySuggester.prototype.__terms = new Array();     // The list of suggestions
QuerySuggester.prototype.__cache = new Array();     // A result-cache
QuerySuggester.prototype.__enabled = false;
QuerySuggester.prototype.__deletePressed = false;   // Delete or backspace has been pressed



// Global stuff


// Global array of all instantiated query-suggesters
var querySuggesters = new Array();

// Global mouse-handling function
function mouseOver(id, index) {
closeflag =0;
//alert('over = '+closeflag);
    if (id >= 0 && id < querySuggesters.length) {
        querySuggesters[id].mouseOver(index);
    }
}

// Global mouse-handling function
function mouseOut(id, index) {

closeflag = 1;
//alert("out = "+querySuggesters.length);
    if (id >= 0 && id < querySuggesters.length) {
        querySuggesters[id].mouseOut(index);
    }
}

//자동완성 닫기 기능
function autoclose(){
		if(closeflag == 1)
		{	
			document.getElementById(temp_close).style.visibility="hidden";
			//document.getElementById("completion_tooltip0").style.display="none"; 
		} 
		
}

function aclose(field){
 
		if(closeflag == 1)
		{	
			
			document.getElementById(field).style.visibility="hidden";
			//document.getElementById("completion_tooltip0").style.display="none"; 
			
		} 
		
}

// Global mouse-handling function
function mouseClick(id, index) {
	if(id < 0 || id > 2 || index < 0 || index > 9){
		//alert("a");
	}else{
		//alert("id = "+id+" index = "+index);
		if (id >= 0 && id < querySuggesters.length) {
			querySuggesters[id].mouseClick(index);
			//alert("id = "+querySuggesters[id]);
		} else if (id == -1 && index == -1) {
			for (var i = 0; i < querySuggesters.length; ++i) {
				querySuggesters[i].mouseClick(index);
			}
		}
	}
}
 