/*$('#route').click(function(){                    
    $('#map').
    from($('#from').val()).
    to($('#to').val()).
    route('#route-text')
});

if( $("#map").length > 0 ) {

	$('#map').gvmap()
	.mapControl("large").
	typeControl().
	zoom(15).
	query(urlencode($('#to').val()), 
	$.gvmarker( $( '#contact-map-info' ).html() ) )
	
};*/

$( '.mapcontainer' ).bind( 'click', function( e ) {

	$this = $( e.target ).parent().parent().parent();
	
	if( $( e.target ).hasClass( 'route' ) ) {
	                 
  $( '.map', $this )
    .from( $( '.from', $this ).val() )
    .to( $( '.to', $this ).val() )
    .route( '.route-text', $this );
    
	}

});

$( '.mapcontainer' ).each( function() {

	$this = $( this );

	$( '.map', $this ).gvmap()
		.mapControl( 'large' )
		.typeControl()
		.zoom( 15 )
		.query(
			'48.2673802, 16.4657286'
			/*urlencode( $( '.to', $this ).val() ), 
			$.gvmarker( $( '.contact-map-info', $this ).html() )*/
		);

});

$( '#map1' ).css( 'display', 'none' );

$( '#mod_googlemaps' ).find( 'select' ).change( function() {

	var id = $( this ).val();

	if( $( '#map'+id ).css( 'display' ) != 'block' ) {
	
		$( '.mapcontainer' ).each( function() {
		
			if( $( this ).attr( 'id' ) == 'map'+id ) {
				$( this ).fadeOut( 300 ).delay( 300 ).fadeIn();
			} else {
				$( this ).fadeOut( 300 );
			}
		
		});
	
	}

});

// lat long angaben
/*if( $("#map").length > 0 ) {

	$('#map').gvmap()
	.mapControl("large")
	.typeControl()
	.query('N48.201795°, E16.370187°', 
	$.gvmarker( $( '#contact-map-info' ).html() ))
	.showMap()
	
};*/

$( '.prefilled' ).css( 'display', 'inline' ).css( 'cursor', 'text' );

$( '.from' ).each( function() {

	if( $( this ).val() != '' ) {
	
		$( '.prefilled' ).css( 'display', 'none' );
	
	}

});

$( '.toroute input' ).focus( function() {

  $( '.prefilled' ).css( 'display', 'none' );

});

$( '.toroute input' ).focusout( function() {

  if( $( this ).val() == '' ) {
    $( '.prefilled' ).css( 'display', 'inline' );
  }

});

$( '.prefilled' ).click( function() {

  $( '.toroute input' ).focus();  

});
