$(function()
  {
  // karten da?
  for(i=0;i<$('.cx-google-map').length;i++)
    {
	$('.cx-google-map:eq('+i+')').gMap({ markers: [{ latitude: parseFloat($('.cx-google-map:eq('+i+')').attr('cx_gm_lat')),
                              longitude: parseFloat($('.cx-google-map:eq('+i+')').attr('cx_gm_lon')) }],
	  zoom: parseInt($('.cx-google-map:eq('+i+')').attr('cx_gm_zoom')) });
	
	}
  
  // routenplaner
  $('.cx-route-berechnen').click(function()
    {
	id_form															= $(this).parents('form').attr('id');
	anz_fehler														= cx_formular_fehler_pruefen(id_form);
	
	if(!anz_fehler)
	  {
	  $('#'+id_form+' .cx-formular-fehler').hide();
	  cx_load_and_hide('#'+id_form,'div',1);
	  
	  setDirections($('#cx_gm_rp_strasse').val()+', '+$('#cx_gm_rp_plz').val()+' '+$('#cx_gm_rp_ort').val()+' '+$('#cx_gm_rp_land').val());
	  }
	});
  });


function setDirections(fromAddress)
  {
  map																= new GMap2(document.getElementById('cx_google_map'));
  map.clearOverlays();
  gdir																= new GDirections(map, document.getElementById('cx_google_map_route'));
  gdir.load('from: ' + fromAddress + ' to: Weilerstr. 30, 78739 Hardt');
  }
