

    updateLocalite = function () {
         new Ajax.Updater(
            'localitecontainer',
            '/commercant/ajax/localite', {
            parameters: {                
                'codepostal': $F('codepostal'),
                'sellocalite': $F('selLocalite')
            },
            evalScripts: true,
            onLoading: function () {
                //$('lindicator').update('<img src="/img/indicator.gif" />');
            },

            onComplete: function() {                 
                 //$('lindicator').update('');                            
                 callstack.push(updateRue);         
            }                                   
        });  
    }
    
    updateSelLocalite = function () {
    	
         new Ajax.Updater(
            'localitecontainer',
            '/commercant/ajax/localite', {
            parameters: {                
                'codepostal': $F('codepostal'),
                'sellocalite': $F('localite')
            },
            evalScripts: true,
            onLoading: function () {
                //$('lindicator').update('<img src="/img/indicator.gif" />');
            },

            onComplete: function() {                 
                 //$('lindicator').update('');                           
                 callstack.push(updateRue);
            }                                   
        });  
    }
    
    updateRue = function() {                        
          new Ajax.Updater(
                   'ruecontainer',
                   '/commercant/ajax/rue', {
                   parameters: {
                       'codepostal': $F('codepostal'),
                       'localite':  $F('localite'),
                       'selrue': $F('selRue')
                   },
                   evalScripts: true,
                   onLoading: function () {
                       //$('rindicator').innerHTML = '<img src="/img/indicator.gif" />';
                   },
                   onComplete: function () {
                       //$('rindicator').innerHTML = '';                                                              
                       jumpto($F('codepostal'), $F('numero'), $F('rue'), $F('localite'));
                   }
          });                      
    } 
    
    function jumpto(codepostal, numero, rue, localite) {
                         
        if(initialized == false) {
            
            initialized = true;              
              
            if($F('longitude').length != 0 && $F('latitude').length != 0 && $F('longitude') != 0 && $F('latitude') != 0) {
                center = new GLatLng($F('latitude'), $F('longitude'));
                map.setCenter(center, 15);
                marker.setPoint(center);           
                return;
            }            
        }      

        new Ajax.Request(
            '/commercant/map/geocode',{
            parameters: {
                rue: rue,
                numero: numero,
                codepostal: codepostal,
                localite: localite
            },
            onSuccess: function(transport, json) {
                
            	json = transport.responseText.evalJSON();
            	
                var zoom = 15;
                var code = parseInt(json.Status.code);
                
                if(code != 200) {
                     
                    center = new GLatLng(49.637221199822,6.1642158963869);
                    zoom = 10;
                    
                } else {
                   
	                point = json.Placemark[0].Point.coordinates;
	
	                $('latitude').value = point[1];
	                $('longitude').value = point[0];
	
	                center = new GLatLng(point[1], point[0]);  	        	                  
                }
                
                map.setCenter(center, zoom);
                marker.setPoint(center);
                
                if(code != 200) {
                    marker.openInfoWindowHtml(errortext);
                } else {
                    marker.openInfoWindowHtml(htmltext);
                }
              
                                
            }
        });
    }
    
    function getscroll() {
        return (document.all)?  (document.documentElement.scrollTop ?
		document.documentElement.scrollTop :
		document.body.scrollTop ):window.pageYOffset;        
    }
    
    
    function doclick(url) {
        window.location.href = url + '&sy=' + getscroll();        
    }

    
    
	var degsparams = new Array();
  	  	
  	degsparams[0]  =  new Array();
  	degsparams[0]['i_width'] = 37;
  	degsparams[0]['i_height'] = 49;
  	degsparams[0]['s_width'] = 57;
  	degsparams[0]['s_height'] = 49;
  	degsparams[0]['a_left'] = 18;
  	degsparams[0]['a_top'] = 49;
  	
  	degsparams[20]  =  new Array();
  	degsparams[20]['i_width'] = 36;
  	degsparams[20]['i_height'] = 50;
  	degsparams[20]['s_width'] = 52;
  	degsparams[20]['s_height'] = 50;
  	degsparams[20]['a_left'] = 6;
  	degsparams[20]['a_top'] = 49;
  	
  	degsparams[40]  =  new Array();
  	degsparams[40]['i_width'] = 37;
  	degsparams[40]['i_height'] = 45;
  	degsparams[40]['s_width'] = 53;
  	degsparams[40]['s_height'] = 45;
  	degsparams[40]['a_left'] = 0;
  	degsparams[40]['a_top'] = 44;
  	
  	degsparams[60]  =  new Array();
  	degsparams[60]['i_width'] = 44;
  	degsparams[60]['i_height'] = 37;
  	degsparams[60]['s_width'] = 53;
  	degsparams[60]['s_height'] = 37;
  	degsparams[60]['a_left'] = 1;
  	degsparams[60]['a_top'] = 35;

	degsparams[80]  =  new Array();
  	degsparams[80]['i_width'] = 49;
  	degsparams[80]['i_height'] = 38;
  	degsparams[80]['s_width'] = 59;
  	degsparams[80]['s_height'] = 38;
  	degsparams[80]['a_left'] = 0;
  	degsparams[80]['a_top'] = 24;  	
  	
  	degsparams[280]  =  new Array();
  	degsparams[280]['i_width'] = 51;
  	degsparams[280]['i_height'] = 37;
  	degsparams[280]['s_width'] = 51;
  	degsparams[280]['s_height'] = 37;
  	degsparams[280]['a_left'] = 50;
  	degsparams[280]['a_top'] = 24;
 
 	degsparams[300]  =  new Array();
  	degsparams[300]['i_width'] = 48;
  	degsparams[300]['i_height'] = 35;
  	degsparams[300]['s_width'] = 48;
  	degsparams[300]['s_height'] = 35;
  	degsparams[300]['a_left'] = 47;
  	degsparams[300]['a_top'] = 34;
  	
  	degsparams[320]  =  new Array();
  	degsparams[320]['i_width'] = 40;
  	degsparams[320]['i_height'] = 40;
  	degsparams[320]['s_width'] = 40;
  	degsparams[320]['s_height'] = 40;
  	degsparams[320]['a_left'] = 39;
  	degsparams[320]['a_top'] = 39;
  	
  	degsparams[340]  =  new Array();
  	degsparams[340]['i_width'] = 36;
  	degsparams[340]['i_height'] = 47;
  	degsparams[340]['s_width'] = 36;
  	degsparams[340]['s_height'] = 47;
  	degsparams[340]['a_left'] = 29;
  	degsparams[340]['a_top'] = 46;
