
var tdb_bInitComune = false;
function rtSearchSetVis(name, sv) {
	var c = document.getElementById(name);
	if(c != null)
		c.style.visibility = sv;
	
	//r.visible = false;	r.selected = -1;
}

function rtRicercaPatch()
{
	var obj = document.getElementById('wpRicerca');
	var obj_v = '';
	if( obj!= null)
	{
		obj_v = obj.value;
	}
	return obj_v;
}

function rtSearchTypeSel(path,id) {
	var selector = document.getElementById(id);
	if (selector.selectedIndex > 0 &&
		selector.options[selector.selectedIndex].value == "" ) {
		// Browser is broken, doesn't respect disabled attribute on <option>
		selector.selectedIndex = 0;
	}
	
//	var idSpecial = "wpComune";
	
	if(selector.selectedIndex == 0)
		tdb_bInitComune = true;
	else
		tdb_bInitComune = false;
	var mysack = new sack(  path + "/rt_search_action.php" );    

  mysack.execute = 1;
  mysack.method = 'POST';
  mysack.setVar( "search_id", selector.selectedIndex); 
  mysack.setVar( "search_box_id", 'rtSearchBox'); 
  
  var curr_v = rtRicercaPatch();
  if(curr_v!='')
  	mysack.setVar( "search_curr_v", curr_v); 
  
  mysack.onError = function() { alert('Ajax error' )};
  mysack.runAJAX();

  return true;

}

function rtSearchFocusComune()
{
	if(tdb_bInitComune)
	{
		tdb_bInitComune = false;
		os_MWSuggestInit();
	}
}
function refreshUpload()
{
}

function rtSearchOnLoad()
{
	var id = "rtSearchType";
	var selector = document.getElementById(id);
	//	selector.selectedIndex = 0;
	rtSearchTypeSel(rtBaseUrl, id);
}
window.onload = rtSearchOnLoad;