var AjaxSearch = Class.create ({
	/*
   * Constructor !
   * @acces: public
   */
	initialize: function (pays) {
		this.pays = pays;
		this._html ();

		this._selectPays ();
		if (pays == 1) {
			this.display (this.htmlregions, 'show');
			this.display (this.htmldept, 'show');
		} else {
			this.display (this.htmlregions, 'hide');
			this.display (this.htmldept, 'hide');
		}
	},

	/*
   * Evenement de selection d'un pays diferent
   * @acces: public
   */
	evSelectPays: function (o) {
		this.initialize (o.down (o.selectedIndex).value);
	},

	/*
   * Recupere les elements html
   * @acces: private
   */
	_html: function () {
		this.htmlpays = $ ("selpays");
		this.htmlregions = $ ("selregions");
		this.htmldept = $ ("seldept");
	},

	/*
   * Selectionne par defaut le pays de l'utilisateur
   * @acces: private
   */
	_selectPays: function () {
		for (var i = 0; i < this.htmlpays.options.length; i++) {
			if (this.htmlpays.down (i).value == this.pays) {
				this.htmlpays.down (i).selected = true;
				break;
			}
		}
	},
		
	display: function (o, t) {
		eval ("o.up('div')."+t+"()");
	}
});

