// BROWSER HISTORY ********************************************************************************
var tokenDelimiter = ':';

// MASKS ******************************************************************************************

var mask = new Ext.LoadMask(Ext.getBody(), {
	id: 'page_mask',
	msg: "Attendere..."
});

function showMask()
{
    mask.show();
}

function hideMask()
{
    mask.hide();
}

// RICERCA ANNUNCI
function SearchListingsParams()
{
    this.text = textFilterDefault;
    this.house_types = houseTypeFilterDefault;
    this.building_types = buildingTypeFilterDefault;
    this.floors = floorFilterDefault;
    this.min_price = minPriceFilterDefault;
    this.max_price = maxPriceFilterDefault;
    this.latitude = latitudeFilterDefault;
    this.longitude = longitudeFilterDefault;
    this.distance = distanceFilterDefault;
    this.address = addressFilterDefault;
    this.zones = zoneFilterDefault;
    this.districts = districtFilterDefault;
    this.category_id = categoryFilterDefault;
    this.contracts = contractFilterDefault;
    this.towns = townFilterDefault;
    this.mq = squareMetersFilterDefault;
    this.min_rooms = minRoomsFilterDefault;
    this.min_baths = minBathsFilterDefault;
    this.agency_id = User.agencyId;
}

// RICERCA RICHIESTE
function SearchRequestsParams()
{
    this.text = textFilterDefault;
    this.house_types = houseTypeFilterDefault;
    this.building_types = buildingTypeFilterDefault;
    this.price = maxPriceFilterDefault;
    this.latitude = latitudeFilterDefault;
    this.longitude = longitudeFilterDefault;
    this.distance = distanceFilterDefault;
    this.address = addressFilterDefault;
    this.zones = zoneFilterDefault;
    this.districts = districtFilterDefault;
    this.category_id = categoryFilterDefault;
    this.contracts = contractFilterDefault;
    this.town_id = townFilterDefault;
    this.mq = squareMetersFilterDefault;
    this.min_rooms = minRoomsFilterDefault;
}

// RICERCA CLIENTI
function SearchCustomersParams()
{
    this.text = '';
}

var searchParams = new SearchListingsParams();
var searchRequestsParams = new SearchRequestsParams();
var searchCustomersParams = new SearchCustomersParams();

// ************************************************************************************************

// Mostra le proprieta' di un oggetto js
function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { var msg = parent + "." + i + "\n" + obj[i]; } else { var msg = i + "\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
         if (parent) { dumpProps(obj[i], parent + "." + i); } else { dumpProps(obj[i], i); }
      }
   }
}
