		
if (!search)	var search = {};

function empty_fields(elem)
{
  if(elem.value=="Cerca...")
  {
   elem.value="";
  }
}

function empty_fields_adv(elem, fval)
{
  if(elem.value==fval)
  {
   elem.value="";
  }
}

search.init = function ()
{

	if ( navigator.userAgent.toLowerCase().indexOf('safari') < 0  && document.getElementById )
	{
		this.clearBtn = false;
	}
}


search.onChange = function (fldID, btnID)
{

	var fld = document.getElementById( fldID );
	var btn = document.getElementById( btnID );
	if (fld.value.length > 0 && !this.clearBtn)
	{
		btn.style.background = "transparent url('images/search/srch_r_f2.png') no-repeat top left";
		btn.fldID = fldID; // btn remembers it's field
		btn.onclick = this.clearBtnClick;
		this.clearBtn = true;
	} else if (fld.value.length == 0 && this.clearBtn)
	{
		btn.style.background = "transparent url('images/search/srch_r.png') no-repeat top left";
		btn.onclick = null;
		this.clearBtn = false;
	}
}



search.clearFld = function (fldID,btnID)
{
	var fld = document.getElementById( fldID );
	fld.value = "";
	this.onChange(fldID,btnID);
}


search.clearBtnClick = function ()
{
	search.clearFld(this.fldID, this.id);
}


