/*----------------------------------------------*/
/*				Ghrs Autocomplete  				*/
/*----------------------------------------------*/

/*var loc_to_input;*/ 
var ghrs_selected_loc = 0; var ghrs_time_found = 0; var ghrs_previous_selected_loc = 0; var ghrs_li_over = false; var ghrs_back_text = ''; 
var ghrs_loc_found_messages = new Array(); var ghrs_local_param = '';

/* Function called on timeout params array */
var ghrs_getDestinationsParams = new Array();
var wait_timeout;
var find_pressed = false;

/* Blinkin span array */
var time_blink_span = new Array();
time_blink_span[0] = 0;
time_blink_span[1] = 0;
time_blink_span[2] = 0;
time_blink_span[3] = 0;
time_blink_span[4] = 0;
time_blink_span[5] = 0;
time_blink_span[6] = 0;
time_blink_span[7] = 0;
time_blink_span[8] = 0;
time_blink_span[9] = 0;

/* Delay variables */
var default_delay = 1000;
var new_delay = 0; 

var requestSended = false;

/* Function called at each state change */
function ghrs_showContents(http_request,params) {
	/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[2].innerHTML = "Function  : ghrs_showContents";*/
	if (http_request.readyState == 4) {
		// If the state is ready.
		if (http_request.status == 200) {
			// If the request has been executed correctly.
			/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[2].innerHTML = "Function  : ghrs_showContents(OK)";*/
			var substring_after = http_request.responseText.indexOf("<result>");
			var substring_before = http_request.responseText.lastIndexOf("</result>");
			if(substring_after>0 && substring_before>0){
				var result = http_request.responseText.substring(substring_after+8,substring_before);
				ghrs_displayResponseAC(result);
				ghrs_showFindedLocalities(params['value'],params['event_type'],params['event_keycode']);
				requestSended = false;
				ghrs_hideAutocompleteImage();
			}
			else{
				alert("Result element not found!!!")
			}
		}
	}
}

/* Function that make the request and that is called at a key press (exactly up and down events) */
function ghrs_getDestinations(value,event_type,event_keycode,random){
	ghrs_list_random = random;
	if(value !='' && (((event_type=='keyup' || event_type=='keyUp' || (event_type=='click' && value != ghrs_back_text)) && event_keycode != 13 && event_keycode != 37 &&
		event_keycode != 38 && event_keycode != 39 && event_keycode != 40 && event_keycode != 0 && event_keycode != 27))){
		// Resetting action and locality, region and country code.
		document.getElementById("all_dest_loc_reg_code").value = '';
		document.getElementById("all_dest_loc_reg_code").name = '';
		document.getElementById("all_dest_loc_reg_code").disabled = true;
		document.getElementById("loc_country").value = '';
		document.getElementById("loc_country").disabled = true;
		if((((event_type=='keyup' || event_type=='keyUp' || (event_type=='click' && value != ghrs_back_text)) && event_keycode != 13 && event_keycode != 37 && event_keycode != 38 && event_keycode != 39 && event_keycode != 40 && event_keycode != 27))){
			// If the key pressed is a character.
			// Reset the action attribute of the form to remove landingpage
			ghrs_setAttribute(document.getElementById('check_'+ghrs_list_random),'action','?');
			var form = document.getElementById('check_'+ghrs_list_random);
			// Set the action again as locality
			if(String(ghrs_findElementInArrayByName(form.getElementsByTagName('input'),'action').value).indexOf('region')>0){
				ghrs_findElementInArrayByName(form.getElementsByTagName('input'),'action').value = String(form.getElementsByTagName('input')['action'].value).replace(new RegExp('region','gi'), 'locality');
			}
		}
		var txt = document.getElementById('loc_search_' + ghrs_list_random);
		txt.style.color = 'black';
		ghrs_getDestinationsParams = new Array();
		ghrs_getDestinationsParams[0] = value;
		ghrs_getDestinationsParams[1] = event_type;
		/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[3].innerHTML = "Call: " + event_type;*/
		ghrs_getDestinationsParams[2] = event_keycode;
		window.clearTimeout(wait_timeout);
		if(event_type!='click') ghrs_showAutocompleteImage();
		requestSended = true;
		// If the button pressed is a character.
		if(event_keycode>0){
			var loc_country = document.getElementById("loc_country");
			loc_country.disabled = true;
		}
		wait_timeout = window.setTimeout(ghrs_makeRequestAC, ((new_delay > 0)? new_delay : default_delay)/(String(value).length));
	}
	else if(!requestSended){
		ghrs_getDestinationsParams[0] = value;
		ghrs_getDestinationsParams[1] = event_type;
		ghrs_getDestinationsParams[2] = event_keycode;
		ghrs_makeRequestAC();
	}
	if(value==''){
		ghrs_getDestinationsParams[0] = value;
		ghrs_getDestinationsParams[1] = event_type;
		ghrs_getDestinationsParams[2] = event_keycode;
		ghrs_hideAutocompleteImage();
	}
}

/* The real autocomplete request */
function ghrs_makeRequestAC(){
	window.clearTimeout(wait_timeout);
	if(!find_pressed){
		var value = ghrs_getDestinationsParams[0];
		var event_type = ghrs_getDestinationsParams[1];
		var event_keycode = ghrs_getDestinationsParams[2];
		/*if(event_type=='keyup' || event_type=='keyUp') document.getElementById('ghrs_temp_debugger').style.display = 'none';
		document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[0].innerHTML = "Event type: " + event_type;
		document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[1].innerHTML = "Event code: " + event_keycode;
		document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[2].innerHTML = "Function  : ghrs_makeRequestAC";
		document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[3].innerHTML = "Recall: " + event_type;*/
		try{
			if(value != ''  && event_keycode!=27){
				if(event_keycode!=13 && (event_type=='keydown' || event_type=='keyDown') && (event_keycode == 40 || event_keycode == 38) && ghrs_autocomplete==true){
					/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[2].innerHTML = "Function  : ghrs_makeRequestAC(KD move)";*/
					// If the key pressed is an arrow (up or down) we have to increment o decrement the value of selected_loc
					ghrs_previous_selected_loc = ghrs_selected_loc;
					var found = document.getElementById("ajax_found_count").innerHTML;
					var limit = (found > 10) ? 10 : found;
					if(event_keycode == 40 && found > 0 && ghrs_selected_loc < limit - 1){
						ghrs_selected_loc++;
					}
					if(event_keycode == 38 && found > 0 && ghrs_selected_loc > 0){
						ghrs_selected_loc--;
					}
				}
				/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[4].innerHTML = "KUp Status: (" +  (event_type=='keyup') + '||' + (event_type=='keyUp') + '||' + (event_type=='click' && value != ghrs_back_text) + ')&&' + (event_keycode != 13) +'&&'+ (event_keycode != 37) +'&&'+ (event_keycode != 38) +'&&'+ (event_keycode != 39) +'&&'+ (event_keycode != 40) +'&&'+ (event_keycode != 0);*/
				if((((event_type=='keyup' || event_type=='keyUp' || (event_type=='click' && value != ghrs_back_text)) && event_keycode != 13 && event_keycode != 37 && event_keycode != 38 && event_keycode != 39 && event_keycode != 40 && event_keycode != 0)/*||ghrs_autocomplete==false*/)){
					/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[2].innerHTML = "Function  : ghrs_makeRequestAC(KU char)";
					document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[4].innerHTML = "KUp Status: ok";*/
					// If the key pressed is a character.
					// Create the url to call.
					var url = "?bodyonly=1&action=form_locality_list&target=ajax&format=xml-ext&param[autocomplete]=1&param[internal]=" + default_internal + "&param[payment]=" + default_payment + "&param[lang]=" + lang + "&param[strictsearch]=1&param[searchstr]=" + value;
					if(ghrs_local_param!='') url = url + "&param[loc_country]=" + ghrs_local_param;
					// Make the request.
					var params = {'value':value,'event_type':event_type,'event_keycode':event_keycode};
					ghrs_makeRequest(url,'ghrs_showContents',params);
				}
				else if((event_type=='keydown' || event_type=='keyDown') && !requestSended){
					/*document.getElementById('ghrs_temp_debugger').getElementsByTagName('p')[2].innerHTML = "Function  : ghrs_makeRequestAC(KD else)";*/
					ghrs_showFindedLocalities(value,event_type,event_keycode);
				}
			}
			else if(document.getElementById('search_destinations_div')){
				// Hiding the autocomplete div and reset the autocomplete.
				document.getElementById('search_destinations_div').style.display = "none";
				document.getElementById('search_destinations_iframe').style.display = "none";
				ghrs_resetLinksClass();
				ghrs_autocomplete = false;
			}
		} catch(e){};
	}
	else find_pressed = false;
}

/* This function will display the response of the request crating the div if not  
   created before */
function ghrs_displayResponseAC(text){
	var div = document.getElementById('search_destinations_div');
	if(!div){
		// If not created, create and add it!
		div = ghrs_createElementWithAttribute('div',{'id':'search_destinations_div', 'class':'search_destinations_div'},text);
		document.getElementsByTagName("body")[0].appendChild(div);
		var ifr = ghrs_createElementWithAttribute('iframe',{'id':'search_destinations_iframe', 'id':'search_destinations_iframe', 'class':'calendar_destinations', 'src':((ghrs_isExplorer6())?'.':'about:blank'), 'scrolling':'no', 'frameborder':'0', 'marginheight':'0', 'marginwidth':'0'}, null);
		document.getElementsByTagName("body")[0].appendChild(ifr);
		if(ghrs_isExplorer6()){
			self.frames['search_destinations_iframe'].document.write(""); 
			self.frames['search_destinations_iframe'].document.close();
		}
	}
	else{
		// ...otherwise sobstitute his html code.
		div.innerHTML = text;
	}
	var found = document.getElementById("ajax_found_count").innerHTML;
	if(found==1){
		ghrs_setActionLocReg(0);
	}
	// Start the blink of the count of localities found.
	ghrs_startBlinkingMoreLetters(found + ' ' + ghrs_loc_found_messages[0], found);
}

/* Function that set the position of the autocomplete elements */
function ghrs_setAJAXdivPositionAndDimension(){
	var txt = document.getElementById('loc_search_' + ghrs_list_random);
	var found = document.getElementById("ajax_found_count").innerHTML;
	var div_src = document.getElementById('search_destinations_div');
	var txt_pos = ghrs_findPosition(txt);
	// Setting div position and dimensions.
	div_src.style.width = txt.offsetWidth * 2 - 2 + 'px'; /*OffsetX*/
	if(found > 10) div_src.style.height = '154px';
	else div_src.style.height = 13 * (parseInt(found,10)) + 4 + 'px';
	div_src.style.left = txt_pos[0] + 'px';
	div_src.style.top = txt_pos[1] + txt.offsetHeight - 1 + 'px';/*+ OffsetY*/
	// Setting iframe position and dimensions.
	var ifr = document.getElementById('search_destinations_iframe');
	ifr.style.position="absolute";
	ifr.style.background="white";
	ifr.style.zIndex = 200;
	ifr.style.width = parseInt(div_src.style.width,10) + 'px';
	ifr.style.height = parseInt(div_src.style.height,10) + 'px';
	ifr.style.left = parseInt(div_src.style.left,10) + 'px';
	ifr.style.top = parseInt(div_src.style.top,10) + 'px';
}

/* This function will reset the class of the class of span in the autocomplete div */
function ghrs_resetLinksClass(){
	if(document.getElementById('search_destinations_div')){
		var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
		for(var i = 0; i < li_src.length; i++){
			ghrs_setAttribute(li_src[i], "class", "");
			ghrs_setAttribute(li_src[i].getElementsByTagName("span")[0],'class','htl_cny_cnt');
			if(li_src[i].getElementsByTagName("span")[1].getElementsByTagName("span")[0]){
				ghrs_setAttribute(li_src[i].getElementsByTagName("span")[1].getElementsByTagName("span")[0],'class','auto_found');
			}
		}
	}
}

/* This function will select the locality selected by up and down arrows */
function ghrs_setSelected(){
	var found = document.getElementById("ajax_found_count").innerHTML;
	var limit = (found > 10) ? 10 : found;
	// Adding selected properties.
	var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
	ghrs_setAttribute(li_src[ghrs_selected_loc],'class','selected_loc_li');
	ghrs_setAttribute(li_src[ghrs_selected_loc].getElementsByTagName("span")[0],'class','selected_loc_span');
	if(li_src[ghrs_selected_loc].getElementsByTagName("span")[1].getElementsByTagName("span")[0]){
		ghrs_setAttribute(li_src[ghrs_selected_loc].getElementsByTagName("span")[1].getElementsByTagName("span")[0],'class','');
	}
	document.getElementById("loc_search_" + ghrs_list_random).focus();	
}

/* This function will select the locality selected with the mouse over event */
function ghrs_setSelectedOver(value){
	ghrs_resetBlinks();
	var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
	if(li_src[value]){
		// Adding selected properties.
		ghrs_setAttribute(li_src[value],'class','selected_loc_li');
		ghrs_setAttribute(li_src[ghrs_selected_loc].getElementsByTagName("span")[0],'class','selected_loc_span');
		if(li_src[ghrs_selected_loc].getElementsByTagName("span")[1].getElementsByTagName("span")[0]){
			ghrs_setAttribute(li_src[ghrs_selected_loc].getElementsByTagName("span")[1].getElementsByTagName("span")[0],'class','');
		}
	}
	ghrs_autocomplete = true;
	ghrs_li_over = true;
	ghrs_cursorAtEnd();
}

/* Function called when the locality is selected and then putted in the input text box */
function ghrs_setSearchInputText(value){
	ghrs_setActionLocReg(ghrs_checkSelected());
	ghrs_back_text = value;
	document.getElementById("loc_search_" + ghrs_list_random).value = value;
	ghrs_resertSearch(false);
	document.getElementById('search_destinations_div').style.display = "none";
	document.getElementById('search_destinations_iframe').style.display = "none";
	ghrs_cursorAtEnd();
}

/* This is the main function. This function manage correctly the autocomplete process */
function ghrs_showFindedLocalities(value,event_type,event_keycode){
	if(ghrs_loaded && value != '' && (!ghrs_li_over)){
		if((event_type=='keyup' || event_type=='keyUp' || event_type == 'click') && (event_keycode!=37 && event_keycode!=38 && event_keycode!=39 && event_keycode!=40 && event_keycode!=13  && event_keycode!=27  && event_keycode!=0)){
			ghrs_resetBlinks();
			// If is a keyup event and it is a character button.
			var div_src = document.getElementById('search_destinations_div');
			var ifr = document.getElementById('search_destinations_iframe');
			var txt = document.getElementById('loc_search_' + ghrs_list_random);
			var found = document.getElementById("ajax_found_count").innerHTML;
			if(value!=''){
				ghrs_selected_loc = 0;
				ghrs_autocomplete = false;
				ghrs_setAJAXdivPositionAndDimension();
				if(found>0){
					ifr.style.display = 'block';
					div_src.style.zIndex = ifr.style.zIndex + 1;
					div_src.style.display = 'block';
					txt.style.color = 'black';
				}
				else{
					div_src.style.display = 'none';
					ifr.style.display = 'none';
					txt.style.color = 'red';
				}
				ghrs_startBlinkingMatched();
			}
			else{
				div_src.style.display = 'none';
				ifr.style.display = 'none';
				txt.style.backgroundColor = 'white';
				txt.style.color = 'black';
			}
		}
		if((event_type=='keydown' || event_type=='keyDown') && (event_keycode==40 || event_keycode==38 || event_keycode==13) && (event_keycode!=27)){
			ghrs_hideAutocompleteImage();
			// If is a keyup event and it is a up or down arrow button or the enter button.
			var txt = document.getElementById('loc_search_' + ghrs_list_random);
			var div_src = document.getElementById('search_destinations_div');
			var ifr = document.getElementById('search_destinations_iframe');
			var dests_array = div_src.getElementsByTagName('li');
			var found = document.getElementById("ajax_found_count").innerHTML;
			if(event_keycode==13){
				// If it is the enter button.
				if(ghrs_checkSelected()>-1){
					var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
					ghrs_setSearchInputText(li_src[ghrs_checkSelected()].getElementsByTagName("div")[(li_src[ghrs_checkSelected()].getElementsByTagName("div").length > 1)?1:0].innerHTML);
					ghrs_getDestinations(li_src[ghrs_checkSelected()].getElementsByTagName("span")[1].innerHTML,'keyup',0);
				}
			}
			else{
				// ... otherwise is the up or down button.
				var li_src = div_src.getElementsByTagName("li");
				ghrs_resetLinksClass();
				ghrs_autocomplete = true;
				ghrs_setSelected();
				if(found>0){
					div_src.style.zIndex = ifr.style.zIndex + 1;
					ifr.style.display = 'block';
					div_src.style.display = 'block';
				}
				else{
					div_src.style.display = 'none';
					ifr.style.display = 'none';
				}
			}
		}
	}
	// ...otherwise is the ESC button.
	else{
		ghrs_setAJAXdivPositionAndDimension();
		ghrs_hideAutocompleteImage();
	}
}

/* Function to reset the research */
function ghrs_resertSearch(reset){
	if(document.getElementById('search_destinations_div')){
		document.getElementById('search_destinations_div').style.display = "none";
		document.getElementById('search_destinations_iframe').style.display = "none";
	}
	ghrs_selected_loc = 0;
	if(reset) ghrs_autocomplete= false;
}

/* This function test if a locality is selected */
function ghrs_checkSelected(){
	var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
	var i = 0;
	while(li_src[i]){
		if(li_src[i].getAttribute('class',1) == 'selected_loc_li' || li_src[i].getAttribute('className') == 'selected_loc_li') return i;
		i++;
	}
	return -1;
}


/* Function that put the cursor at the end of input text while the user is typing */
function ghrs_cursorAtEnd(){
	var txt = document.getElementById('loc_search_' + ghrs_list_random);
	if(txt){
		if(window.attachEvent && !txt.setSelectionRange){
			var gap = txt.createTextRange();
			gap.moveEnd('character', txt.value.length);
			gap.moveStart('character', txt.value.length);
			gap.collapse(true);
			gap.select();
		}
		else if(txt.setSelectionRange)
		{
			txt.focus();
			txt.value = txt.value;
		}
	}
	return false;
}

/* This function allow to lets the "More localities" statement blink */
function ghrs_startBlinkingMoreLetters(str,found){
	if(found>10){
		if(ghrs_time_found == 0) ghrs_time_found = setInterval('ghrs_blinkItCount("loc_src_blink","'+ str +'","' + ghrs_loc_found_messages[1] + '")',1000);
		else{
			ghrs_time_found = window.clearInterval(ghrs_time_found);
			ghrs_time_found = window.setInterval('ghrs_blinkItCount("loc_src_blink","'+ str +'","' + ghrs_loc_found_messages[1] + '")',1000);
		}
	}
	else if(ghrs_time_found != 0) ghrs_time_found = window.clearInterval(ghrs_time_found);
}

function ghrs_startBlinkingMatched(){
	var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
	for(var i=0; i<li_src.length; i++){
		if(li_src[i].getElementsByTagName("div").length > 1 && li_src[i].getElementsByTagName("div")[0]){
			var blink_spans = li_src[i].getElementsByTagName("div")[0].getElementsByTagName("span");
			if(time_blink_span[i] == 0){
				time_blink_span[i] = setInterval('ghrs_blinkItMatched("'+ i +'","'+ blink_spans[3].innerHTML +'","'+ blink_spans[2].innerHTML +'","'+ blink_spans[1].innerHTML +'")',1000);
			}
			else{
				time_blink_span[i] = window.clearInterval(time_blink_span[i]);
				time_blink_span[i] = window.setInterval('ghrs_blinkItMatched("'+ i +'","'+ blink_spans[3].innerHTML +'","'+ blink_spans[2].innerHTML +'","'+ blink_spans[1].innerHTML +'")',1000);
			}
		}
	}
}

/* Function that allow to let the below string (the count string) blink. */
function ghrs_blinkItCount(id,str1,str2){
	if(document.getElementById(id)){
		var elem = document.getElementById(id);
		if(elem.innerHTML == str1) elem.innerHTML = str2;
		else elem.innerHTML = str1;
	}
}

/* Function that allow to let the matched string blink. */
function ghrs_blinkItMatched(index,str1,str2,str3){
	if(index){
		var li_src_span = document.getElementById('search_destinations_div').getElementsByTagName("li")[index].getElementsByTagName("span")[1];
		var matched = new String(str1);
		if((ghrs_selected_loc!=index && ghrs_autocomplete==true)||(ghrs_selected_loc==0 && ghrs_autocomplete==false)){		
			matched = matched.replace(str3 , '<span class="auto_found">' + str3 + '</span>');
		}
		if(li_src_span.innerHTML == str2) li_src_span.innerHTML = matched;
		else li_src_span.innerHTML = str2;
	}
}

/* Function that close the autocomplet div, frame */
function ghrs_closeAutocompleteDiv(){
	if(document.getElementById('search_destinations_div')){
		document.getElementById('search_destinations_div').style.display = "none";
		document.getElementById('search_destinations_iframe').style.display = "none";
		ghrs_resetBlinks();
	}
}

/* Function that reset the blinking statment */
function ghrs_resetBlinks(){
	var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
	for(var j=0; j<time_blink_span.length; j++){
		time_blink_span[j] = window.clearInterval(time_blink_span[j]);
	}
	for(var i=0; i<li_src.length; i++){
		if(li_src[i].getElementsByTagName("div")[0]){
			if(li_src[i].getElementsByTagName("div")[0].length > 1 && li_src[i].getElementsByTagName("div")[0]){
				li_src[i].getElementsByTagName("span")[1].innerHTML = li_src[i].getElementsByTagName("div")[0].getElementsByTagName("span")[0].innerHTML;		
			}
		}
		if(li_src[i].getElementsByTagName("span")[1].getElementsByTagName("span")[0]){ 
			ghrs_setAttribute(li_src[i].getElementsByTagName("span")[1].getElementsByTagName("span")[0],'class','auto_found');
		}
	}
}

/* Function that has the rule of choose if the user is serching a locality, a region or a landing page. */ 
function ghrs_setActionLocReg(li_index){
	var li_src = document.getElementById('search_destinations_div').getElementsByTagName("li");
	var form = document.getElementById('check_'+ghrs_list_random);
	var form_type = li_src[li_index].getElementsByTagName("span")[0].getElementsByTagName("p")[1].innerHTML;
	if(form_type=='idreg' || form_type=='reg_landp'){
		var action_input = ghrs_findElementInArrayByName(form.getElementsByTagName('input'),'action');
		action_input.value = String(action_input.value).replace(new RegExp('locality','gi'), 'region');
	}
	if(form_type=='loc_landp'||form_type=='reg_landp'||form_type=='landp'){
		ghrs_setAttribute(form,'action',li_src[li_index].getElementsByTagName("span")[0].getElementsByTagName("p")[0].innerHTML + '?');
	}
	else{
		document.getElementById("all_dest_loc_reg_code").value = li_src[li_index].getElementsByTagName("span")[0].getElementsByTagName("p")[0].innerHTML;
		document.getElementById("all_dest_loc_reg_code").name = 'param['+form_type+']';
		document.getElementById("all_dest_loc_reg_code").disabled = false;
		if(li_src[li_index].getElementsByTagName("span")[0].getElementsByTagName("p").length==3){
			document.getElementById("loc_country").value = li_src[li_index].getElementsByTagName("span")[0].getElementsByTagName("p")[2].innerHTML;
			document.getElementById("loc_country").disabled = false;
		}
	}
}

function ghrs_showAutocompleteImage(){
	/*var image = document.getElementById('img_autocomplete');
	if(!image){*/
		/* If not created, create and add it! */
		/*image = ghrs_createElementWithAttribute('img',{'id':'img_autocomplete'},'');
		document.getElementsByTagName("body")[0].appendChild(image);
		image.style.position = 'absolute';
		var txt = document.getElementById('loc_search_' + ghrs_list_random);
		var txt_pos = ghrs_findPosition(txt);
		image.style.height = '19px';
		image.style.width ='29px';
		image.style.left = txt_pos[0] + txt.offsetWidth + 2 + 'px';
		image.style.top = txt_pos[1] + 1 + 'px';
		image.style.zIndex = txt.style.zIndex;
		image.style.backgroundImage = "url(cmn/img/form/kybrd.gif)";*/
		/*image = ghrs_createElementWithAttribute('img',{'id':'img_autocomplete', 'src':'http://img4.6waves.com/guerre-di-banda/loading.gif');'},'');
		document.getElementsByTagName("body")[0].appendChild(image);
		image.style.position = 'absolute';
		var txt = document.getElementById('loc_search_' + ghrs_list_random);
		var txt_pos = ghrs_findPosition(txt);
		image.style.height = txt.offsetHeight - 3 + 'px';
		image.style.width = txt.offsetHeight - 3 + 'px';
		image.style.left = txt_pos[0] + txt.offsetWidth - txt.offsetHeight + 3 + 'px';
		image.style.top = txt_pos[1] + 2 + 'px';
	}
	else{*/
		/* ...otherwise sobstitute his html code */
		/*image.style.display = '';
	}
	//http://img4.6waves.com/guerre-di-banda/loading.gif*/
}

function ghrs_hideAutocompleteImage(){
	/*var image = document.getElementById('img_autocomplete');
	if(image){
		image.style.display = 'none';
	}*/
}
