// Generated from /realEstate/proxy.phtml?showstub=true&objectname=RealEstateFrontendController, DO NOT EDIT!
if(typeof(RealEstateFrontendController) == 'undefined')
    RealEstateFrontendController = new Object();

Object.extend(RealEstateFrontendController,
{
    _callback4a4dcd1505c77: "/realEstate/proxy.phtml",

    _getJSON: function(r, j)
    {
        j = (j || r.headerJSON || r.responseJSON);
        if(j == null)
            return null;
        if(j.errors || j.failed)
        {
            var f = function(a, c)
            {
                var e = $(c);
                if(a.length > 0)
                {
                    var s = '<ul>';
                    $(a).each(function(e){ s += '<li>'+e+'</li>'; });
                    s += '</ul>';
                    if(e){ e.update(s); e.show(); }
                }
                else
                {
                    if(e){ e.hide(); }
                }
            }
            if(!j.errors)
            {
                j.errors = {error: [], warning: [], info: []}
                if(j.failed)
                    j.errors.error[0] = j.message;
            }

            f(j.errors.error, 'globuleError');
            f(j.errors.warning, 'globuleWarning');
            f(j.errors.info, 'globuleInfo');
        }
        return j;
    },

    _proxy: function(callbackurl, methodName, args, sync)
    {
        var targs = $H();
        for(var i = 0; i < args.length-1; i++){ targs.set('args[' + i + ']', args[i]); }
        callback = args[args.length-1];
        var ar = new Ajax.Request(callbackurl + '?method=' + methodName,
        {
            method: 'post',
            asynchronous: (!sync),
            parameters: targs,
            onComplete: (sync)?null:callback,
            onException: function(request, e){console.debug(request, e);}
        });
        if(sync)
            return new Ajax.Response(ar);
    },

    _getlocation: function(){ this._proxy(this._callback4a4dcd1505c77, '_getlocation', arguments, false); },
    _getlocation_sync: function(){ return this._proxy(this._callback4a4dcd1505c77, '_getlocation', arguments, true); },

    _t: ''
});
// End of generated code

Object.extend(RealEstateFrontendController,
{

	getLocation: function(type,lang)
	{
			var params = type;
			var lang = lang;
			
			this._getlocation(params, lang, function(r, j)
	        {
	            j = this._getJSON(r, j);
	            
	            if(!j || j.failed)
	                return;
	            
	            var out = j.out;
	            var t = '';
	            out.each(function(city)
	            {
	            	t +='<label class="pc_checkbox pc_check_unchecked"><input  type="checkbox" value="'+city.translation+'" name="location['+city.translation+']" style="position: absolute; left: -9999px;" />'+city.translation+'</label>'; 
            	
	            });
	            t+='<hr style="visibility:hidden;height:160px;"/>';
	            Element.update('c2', t);
	            
	            // on met à jour la ville courante de l'input hidden
	            // réécriture d'url en application
	            
	            var cityselected = $('city')[$('city').selectedIndex].innerHTML;
	            $('cityselected').value = cityselected.toLowerCase();
	            
	            
	            new ProtoCheck();

	        }.bind(this));
		},
		
});
