<?php

global $google_maps_counter;
$google_maps_counter = 0;

function google_maps_func( $atts, $content ) {
	extract(shortcode_atts( array(
		'location'    => '215. W Avenue 26',
		'zoom'        => '14',
		'marker'      => '',
		'scrollwheel' => 'off',
		'dragabble'   => 'on',
		'api'         => '',
		'style'       => ''
	), $atts ));

	if( $api != '' ) {
		$api = '?key=' . $api;
	}

	wp_enqueue_script( 'gfxbucket-google-maps', 'http://maps.google.com/maps/api/js' . $api, array('jquery'), '1.0', true );
	wp_enqueue_script( 'gfxbucket-gmap3', plugins_url( 'javascript/gmap3.min.js', __FILE__ ), array('jquery'), '1.0', true );

	global $google_maps_counter;
	$google_maps_counter++;

	return '<div class="map" id="map-' . $google_maps_counter . '"></div>
		<script>
			jQuery(function($) {
				map("#map-' . $google_maps_counter . '", "' . $location . '", ' . $zoom . ', "' . $marker . '", "' . $scrollwheel . '", "' . $dragabble . '", \'' . $content . '\');
			});
		</script>
	';
}
add_shortcode( 'google_maps', 'google_maps_func' );