$(document).ready(function() {

	if (GBrowserIsCompatible()) {


		// Default values make for easy debugging
		var lat = 38.912925;
		var lng = -0.553823;

		// arrays to hold copies of the markers and html used by the side_bar
		// because the function closure trick doesnt work there
		var gmarkers = [];
		var htmls = [];

		// arrays to hold variants of the info window html with get direction forms open
		var to_htmls;
		var from_htmls;
		// Creates a marker at the given point with the given number label
		function createMarker(point,html) {
			var marker = new GMarker(point);

			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(html);
			});


			return marker;

		}


		// create the map
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(38.912925,-0.553823), 12);
		map.enableDoubleClickZoom();
		map.enableContinuousZoom();


		var point = new GLatLng(lat,lng);
		var ref = 1;
		var html = '<div id="direccion" ><strong>VIVER-VID SELECCIONADOR, S.L.</strong><br/>Calle Maestro Serrano, 12 <br/>46850 L\'Olleria, (Valencia)<br/>';
		// The info window version with the "to here" form open
		to_html = '';
		// The info window version with the "to here" form open
		from_html = '';

		html = html + '';
		html = html + to_html + from_html;
		// The inactive version of the direction info
		var marker = createMarker(point,html);
		map.addOverlay(marker);
		//map.addOverlay(createMarker(point,html,icon,ref));
	//	marker.openInfoWindowHtml(html);

		// functions that open the directions forms
		$('.tohere').click(function() {
			$('#cal_rutas').hide();
			$('#desde_aqui_form').hide();
			$('#hasta_aqui_form').show();
			//marker.openInfoWindowHtml(to_htmls);

		});
		$('.fromhere').click(function() {
			$('#cal_rutas').hide();
			$('#hasta_aqui_form').hide();
			$('#desde_aqui_form').show();
			//markers.openInfoWindowHtml(from_htmls);

		});


	}

});


