function inputValueSearch(self,initialValue,isFocus){
    if(isFocus==true){
        if(self.value==initialValue){
            self.value='';
            self.style.color = '#333';
        }

        if (self.value == '') {
            if(self.id=='location_str')  document.searchboxform.areaid.value='';
            if (self.id=='category_str') document.searchboxform.catid.value='';
        }
    }
    else{
        if(self.value.replace(/^\s+|\s+$/g,"")==''){
            self.style.color = '#aaa';
            self.value=initialValue;            
            if(self.id=='location_str')
            {
                document.searchboxform.areaid.value='';
            }
            else if (self.id=='category_str')
            {
                document.searchboxform.areaid.value='';
            }
           
        }

    }

}


new Ajax.Autocompleter("location_str","autocomplete_results","/_ed/autocomplete.php",{minChars:2,frequency:0.1});

var autoField = (msSection == 'restaurants') ? 'restName' : 'barName';
new Ajax.Autocompleter("name" ,"autocomplete_results", "/_ed/autocomplete.php", {minChars:2,frequency:0.1, paramName: autoField});

function processLocItem(text,li){
    document.searchboxform.areaid.value=li.id;
}

function resetLocID(q,d){
    if(q.value.indexOf('%')==-1){
        document.searchboxform.areaid.value="";return("location_str="+q.value);
    }

}

if(msSection=='restaurants'){
    function processCatItem(text,li){
        document.searchboxform.catid.value=li.id;
    }

    function resetCatID(q,d){
        if(q.value.indexOf('%')==-1){
            document.searchboxform.catid.value="";return("category_str="+q.value);
        }

    }

    new Ajax.Autocompleter("category_str","autocomplete_results","/_ed/autocomplete.php",{
        callback:resetCatID,afterUpdateElement:processCatItem,minChars:1,frequency:0.1
    }
    );
}

function radiusJump(ele, url)
{
	window.location = url + '&radius=' + ele.value;
}

function changeLocation(ele)
{
	var popUp = $('changeLocation');

	$('location_str').value = '';
	$('change_location_str').name = 'location_str';

	popUp.style.top  = (ele.cumulativeOffset()[1] + 18) + 'px';
	popUp.style.left = (ele.cumulativeOffset()[0] - (popUp.getWidth() / 2) + 17) + 'px';

	popUp.show();
}

function closeChangeLocation()
{
	var popUp = $('changeLocation');

	$('change_location_str').name = '';
	$('change_location_str').value = '';

	popUp.hide();
}