$(function()
  {
  // karten da?
  for(i=0;i<$('.cx-google-map').length;i++)
    {
    str_lat                                                         = $('.cx-google-map:eq('+i+') .cx-gm-lat').html();
    str_lon                                                         = $('.cx-google-map:eq('+i+') .cx-gm-lon').html();
    str_zoom                                                        = $('.cx-google-map:eq('+i+') .cx-gm-zoom').html();
    $('.cx-google-map:eq('+i+')').html('');

	$('.cx-google-map:eq('+i+')').gMap(
	  {
	  markers: [
	    {
		latitude: parseFloat(str_lat),
		longitude: parseFloat(str_lon)
		}],
	  zoom: parseInt(str_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());
	  setDirections($('#cx_gm_rp_strasse').val().replace('Straße',' ')+', '+$('#cx_gm_rp_plz').val()+' '+$('#cx_gm_rp_ort').val()+' de');
	  }
	});
  });


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: '+$('#cx_google_map_route').attr('rel'));
  }
