var texto = "<p>Estudio Asesores<br/>c/ Maestro Garcia Rivero 8, 1 Izda<br/>Bilbao Bizkaia<br/>tfno/fax: (+34) 94.400.04.72</p>";
var image = "./img/iconos/poweron.ico";
var shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
var event = "mouseover";

$('document').ready(function(){ 
	
	
	var aMostrar = '';
	  			aMostrar += '<div id="gmap" ></div>'
	  			aMostrar += '<div id="mydirections"></div>';
	  			aMostrar += '<div id="donde">';
	  				aMostrar += '<div class="formline">';
	  					aMostrar += '<div class="labl">';
	  						aMostrar += '<p class = "sinMargen">&iquest;D&oacute;nde est&aacute;s?</p>';
	  					aMostrar += '</div>';
	  					aMostrar += '<div class="field">';
	  						aMostrar += '<p class = "sinMargen"><input id="from" type="text" /></p>';
	  					aMostrar += '</div>';
	  				aMostrar += '</div>';
	  				aMostrar += '<div class="send">';
	  					aMostrar += '<p class = "sinMargen"><input type="submit" value="Calcular ruta" id="getDirections"></input></p>';
	  				aMostrar += '</div>';
					aMostrar += '<div class="clearboth"></div>';
				aMostrar += '</div>';
			aMostrar += '';
			
	if ( document.getElementById("cmap") ){
		$("#cmap").prepend(aMostrar);
	

		$('#mydirections').hide();
		$('#gmap').jmap({
	            maptype: G_NORMAL_MAP, 
                    center: [43.262094, -2.939151],
                    zoom: 16, 
                    control: "small", 
                    showtype: true, 
                    showoverview: false, 
                    dragging: true, 
                    scrollzoom: false, 
                    smoothzoom: true, 
                    searchfield: "#Address", 
                    searchbutton: "#findaddress" 
		});
		var c = 0;
	
		$('#gmap').addPoint('43.262094','-2.939151', texto, false, false); 
   		$("#getDirections").livequery("click", function(){
			var from = $("#from").attr('value');
			var to = '43.262283,-2.929027';
			if (from!="") {
				$("#mydirections").html("");
				//$("#gmap").directions("from: " + from + " to: " + to, "mydirections");
				//$("#gmap").searchDirections("from: " + from + " to: " + to, "mydirections");
				$("#gmap").searchDirections(from,to,"mydirections");
				//$("#gmap").showTraffic();
				if (c==0) $("#mydirections").slideDown("fast");
				c++;
			}
			return false;
		});
	}

}); 


	/*		$('document').ready(function(){
				$("#gmap").jmap();
				$("#gmap").myMap().setCenter(new GLatLng(55.958387,-3.162367), 10);
				$("#gmap2").jmap();
				$("#gmap2").myMap().setCenter(new GLatLng(55.958387,-3.162367), 10);
				var polyline = new GPolyline([
    					new GLatLng(55.958387, -3.162367),
    					new GLatLng(55.95189103287788, -3.18878173828125),
    					new GLatLng(55.9447781445014, -3.21624755859375)
				], "#FF0000", 10,1);
				$("#gmap2").addPoly(polyline);
	
				var polyline2 = new GPolyline([
					new GLatLng(55.9418941688752, -3.2910919189453125),
					new GLatLng(55.94593167462068, -3.2179641723632812),
					new GLatLng(55.922469807800354, -3.2471466064453125)
				], "#00FF00", 10, 1);
		
			$("a.addline").bind('click', function(){
				$("#gmap2").addPoly(polyline2);
				return false;
			});

			$("a.showcode").bind("click", function(){
				var showdiv = $(this).attr("href");
				$(showdiv).toggle("fast");
				return false;
			});
			
			$("a.add-kml").bind("click", function(){
				$("#gmap2").addKml("http://mapgadgets.googlepages.com/cta.kml");	
				$("#gmap2").myMap().setCenter(new GLatLng(41.88414, -87.63238), 10);
				return false;
			});
			$("#getDirections").bind("click", function(){
				var from = $("#from").attr('value');
				var to = $("#to").attr('value');
				$("#gmap").directions("from: " + from + " to: " + to, "mydirections");	
				$("#from").attr('value', to);
				$("#to").attr('value', '');
				return false;
			});
		});*/

