/* start module: pyjamas.gmaps.Utils */
$pyjs['loaded_modules']['pyjamas.gmaps.Utils'] = function (__mod_name__) {
	if($pyjs['loaded_modules']['pyjamas.gmaps.Utils']['__was_initialized__']) return $pyjs['loaded_modules']['pyjamas.gmaps.Utils'];
	if(typeof $pyjs['loaded_modules']['pyjamas.gmaps'] == 'undefined' || !$pyjs['loaded_modules']['pyjamas.gmaps']['__was_initialized__']) $p['___import___']('pyjamas.gmaps', null);
	var $m = $pyjs['loaded_modules']['pyjamas.gmaps.Utils'];
	$m['__repr__'] = function() { return '<module: pyjamas.gmaps.Utils>'; };
	$m['__was_initialized__'] = true;
	if ((__mod_name__ === null) || (typeof __mod_name__ == 'undefined')) __mod_name__ = 'pyjamas.gmaps.Utils';
	$m['__name__'] = __mod_name__;
	$pyjs['loaded_modules']['pyjamas.gmaps']['Utils'] = $pyjs['loaded_modules']['pyjamas.gmaps.Utils'];


	$m['translateGmapsObject'] = function(obj, fieldName, fields, pyToJs) {


    //console['log']("translateGmapsObject " + fieldNameXXX+"("+pyToJs+")")

    if (! (fieldName in fields))
    {
      //console['log']("nothing")
      return obj;
    }
    else{
        $m['action'] = fields[fieldName]
        //console['log']("action=" + action)

        if ($m['action'] == 'd')
        {
          //console['log']("is dict")
          // this newobj can be used in js and also in python,
          // like this "newobj['field']"
          var newobj = {}
          for (var i in obj)
             // vai ficar disponivel como uma propriedade, no python!
             newobj[i] = $m['translateGmapsObject'](obj[i], i, fields, pyToJs);
          return newobj

        }
        else if ($m['action'] == 'l')
        {
          if (pyToJs) {
              var newobj = $m['listToJs'](obj)
              //console['log']("is list py->js")
              for (var i in newobj){
                 newobj[i]=$m['translateGmapsObject'](
                    newobj[i], fieldName + "[]", fields,pyToJs ) ;
              }
              return newobj
          }else{
              //console['log']("is list js->py")
              var newobj = $p['list']([])
              for (var i in obj)
                 newobj['append']($m['translateGmapsObject'](
                     obj[i], fieldName + "[]", fields,pyToJs ));
              return newobj
          }
        }
        else
        {
          //console['log']("is special")
          return $m['action'](obj)
        }
    }
    
	};
	$m['translateGmapsObject']['__name__'] = 'translateGmapsObject';

	$m['translateGmapsObject']['__bind_type__'] = 0;
	$m['translateGmapsObject']['__args__'] = [null,null,['obj'],['fieldName'],['fields'],['pyToJs']];
	$m['dictToJs'] = function(dict) {
		var obj,$iter1_type,value,$iter1_iter,$pyjs_try_err,$iter1_array,key,$iter1_nextval,$iter1_idx;
		obj = {};
		try {
			$iter1_iter = dict;
			$iter1_nextval=$p['__iter_prepare']($iter1_iter,false);
			while (typeof($p['__wrapped_next']($iter1_nextval)['$nextval']) != 'undefined') {
				key = $iter1_nextval['$nextval'];
				value = dict['__getitem__'](key);
obj[key] = value
			}
		} catch($pyjs_try_err) {
			var $pyjs_try_err_name = (typeof $pyjs_try_err['__name__'] == 'undefined' ? $pyjs_try_err['name'] : $pyjs_try_err['__name__'] );
			$pyjs['__last_exception__'] = {'error': $pyjs_try_err, 'module': $m};
			if (true) {
			}
		}
		return obj;
	};
	$m['dictToJs']['__name__'] = 'dictToJs';

	$m['dictToJs']['__bind_type__'] = 0;
	$m['dictToJs']['__args__'] = [null,null,['dict']];
	$m['listToJs'] = function(list) {
		var $iter2_nextval,$iter2_type,$iter2_iter,i,$iter2_idx,obj,$iter2_array;
		obj = [];
		$iter2_iter = list;
		$iter2_nextval=$p['__iter_prepare']($iter2_iter,false);
		while (typeof($p['__wrapped_next']($iter2_nextval)['$nextval']) != 'undefined') {
			i = $iter2_nextval['$nextval'];
			obj['push'](i);
		}
		return obj;
	};
	$m['listToJs']['__name__'] = 'listToJs';

	$m['listToJs']['__bind_type__'] = 0;
	$m['listToJs']['__args__'] = [null,null,['list']];
	$m['createListenerMethods'] = function(obj) {

		obj['addListener'] = (typeof __addListener == "undefined"?$m['__addListener']:__addListener);
		obj['removeListener'] = (typeof __removeListener == "undefined"?$m['__removeListener']:__removeListener);
		obj['clearListeners'] = (typeof __clearListeners == "undefined"?$m['__clearListeners']:__clearListeners);
		obj['clearInstanceListeners'] = (typeof __clearInstanceListeners == "undefined"?$m['__clearInstanceListeners']:__clearInstanceListeners);
		obj['__listeners'] = $p['dict']([]);
		return null;
	};
	$m['createListenerMethods']['__name__'] = 'createListenerMethods';

	$m['createListenerMethods']['__bind_type__'] = 0;
	$m['createListenerMethods']['__args__'] = [null,null,['obj']];
	$m['__dumpListeners'] = function() {
		var $add2,$iter3_idx,$iter4_idx,$iter4_nextval,self,$iter3_type,list,eventName,$add3,$add1,$iter3_iter,$iter4_type,$iter3_array,$iter4_array,$add4,$iter4_iter,$iter3_nextval;
		self = this;
		$p['printFunc'](['DUMP'], 1);
		$iter3_iter = $p['getattr'](self, '__listeners');
		$iter3_nextval=$p['__iter_prepare']($iter3_iter,false);
		while (typeof($p['__wrapped_next']($iter3_nextval)['$nextval']) != 'undefined') {
			eventName = $iter3_nextval['$nextval'];
			$p['printFunc']([$p['__op_add']($add1='  ',$add2=eventName)], 1);
			$iter4_iter = $p['getattr'](self, '__listeners')['__getitem__'](eventName);
			$iter4_nextval=$p['__iter_prepare']($iter4_iter,false);
			while (typeof($p['__wrapped_next']($iter4_nextval)['$nextval']) != 'undefined') {
				list = $iter4_nextval['$nextval'];
				$p['printFunc']([$p['__op_add']($add3='    ',$add4=$p['str'](list))], 1);
			}
		}
		return null;
	};
	$m['__dumpListeners']['__name__'] = '__dumpListeners';

	$m['__dumpListeners']['__bind_type__'] = 0;
	$m['__dumpListeners']['__args__'] = [null,null];
	$m['__addListener'] = function(eventName, callback) {
		var self,thelist;
		self = this;
		thelist = 
       $wnd['google']['maps']['event']['addListener'](this, eventName, function(event) {
         callback(event);
       })
    ;
		if ($p['bool']($p['getattr'](self, '__listeners')['__contains__'](eventName))) {
			$p['getattr'](self, '__listeners')['__getitem__'](eventName)['append'](thelist);
		}
		else {
			$p['getattr'](self, '__listeners')['__setitem__'](eventName, $p['list']([thelist]));
		}
		return thelist;
	};
	$m['__addListener']['__name__'] = '__addListener';

	$m['__addListener']['__bind_type__'] = 0;
	$m['__addListener']['__args__'] = [null,null,['eventName'],['callback']];
	$m['__removeListener'] = function(list) {
		var $iter5_nextval,$iter5_array,self,eventName,$iter5_iter,$iter5_idx,$iter5_type;
		self = this;
		$iter5_iter = $p['getattr'](self, '__listeners');
		$iter5_nextval=$p['__iter_prepare']($iter5_iter,false);
		while (typeof($p['__wrapped_next']($iter5_nextval)['$nextval']) != 'undefined') {
			eventName = $iter5_nextval['$nextval'];
			if ($p['bool']($p['getattr'](self, '__listeners')['__getitem__'](eventName)['__contains__'](list))) {
$wnd['google']['maps']['event']['removeListener'](list);
				$p['getattr'](self, '__listeners')['__getitem__'](eventName)['remove'](list);
				return null;
			}
		}
		return null;
	};
	$m['__removeListener']['__name__'] = '__removeListener';

	$m['__removeListener']['__bind_type__'] = 0;
	$m['__removeListener']['__args__'] = [null,null,['list']];
	$m['__clearListeners'] = function(eventName) {
		var self;
		self = this;
$wnd['google']['maps']['event']['clearListeners'](this, eventName)
		if ($p['bool']($p['getattr'](self, '__listeners')['__contains__'](eventName))) {
			$p['getattr'](self, '__listeners')['__delitem__'](eventName);
		}
		return null;
	};
	$m['__clearListeners']['__name__'] = '__clearListeners';

	$m['__clearListeners']['__bind_type__'] = 0;
	$m['__clearListeners']['__args__'] = [null,null,['eventName']];
	$m['__clearInstanceListeners'] = function() {
		var self;
		self = this;
$wnd['google']['maps']['event']['clearInstanceListeners'](this)
		self['__listeners'] = $p['dict']([]);
		return null;
	};
	$m['__clearInstanceListeners']['__name__'] = '__clearInstanceListeners';

	$m['__clearInstanceListeners']['__bind_type__'] = 0;
	$m['__clearInstanceListeners']['__args__'] = [null,null];
	return this;
}; /* end pyjamas.gmaps.Utils */


/* end module: pyjamas.gmaps.Utils */


