function fetchCoords(){
  new ljex.Ajax({
		url: 'dealer.php5?action=fetchCoords',
		scope: this,
		callback: function(response){
			data = eval("("+response.responseText+")");
			var anz = data.length;
			for(i=0;i<anz;i++){
				var bullet = $('bullet_'+data[i]['id']);
				var divInfo = $('info_'+data[i]['id']);

				if(data[i]['x'] && data[i]['y']){

					bullet.style.left=data[i]['x']+'px';
					bullet.style.top=data[i]['y']+'px';
					
					divInfo.style.left=parseInt(data[i]['x'])+15;
					divInfo.style.top=parseInt(data[i]['y'])+15;

					bullet.style.display='block'; 
				}
		   }
        }
	}).request();
}

function buildSearchForm(){

     var form = new ljex.Form({
				url: 'dealer.php5?action=search',
				id: 'searchForm',
                style: 'background-color: transparent;',
		        renderTo: 'suchform',
                labelWidth: 50,
                labelStyle: 'color:#fff',
                items:[{
					xtype: 'textfield',
					id: 'de_plz',
                    width: 260,
					label: 'PLZ'
				},{
					xtype: 'textfield',
					id: 'de_name',
                    width: 260,
					label: 'Firma'
				}],
                footerStyle: 'background-color:transparent;border-width:0px;',
                buttons:[{
                    id: 'btn-submit',
					text: 'suchen',
					submit: 'ajax',
					handler: function(response){
                        var data=eval("("+response.responseText+")");
                        $("dealer_results").innerHTML=data.dealer;
                        
                        for(i=0;i<data.alldealer.length;i++){
							id=data.alldealer[i]['de_id'];
							$("bullet_"+id).style.display='none';
						}
						for(i=0;i<data.data.length;i++){
							id=data.data[i]['de_id'];
							$("bullet_"+id).style.display='block';
						}
					}
				}]
    });
form.render();
}

