var infowindow,maps;var setDirection={options:{dirContainer:document.getElementById('dirContainer'),dirService:"",dirRenderer:"",myMarker:"",mapId:"",zoom:"",mapType:"",showCursor:""},set:function(mapId,optiones,zoom,mapType,showCursor){setDirection.options.mapId=mapId;setDirection.options.zoom=zoom;setDirection.options.mapType=mapType;setDirection.options.showCursor=showCursor;setDirection.options.myMarker=new Array();for(names in optiones)setDirection.options.myMarker[names]=optiones[names];setDirection.options.myMarker['infowindow']='<div id="ballon"><h5>'+setDirection.options.myMarker['labelTitle']+'</h5>'+setDirection.options.myMarker['infowindow']+'<br /><br />'+setDirection.options.myMarker['labelCalculate']+'<br /><a href="javascript:;" onclick="setDirection.init(\'<h5>'+setDirection.options.myMarker['labelTitle']+'</h5><br />'+setDirection.options.myMarker['labelCalculate']+'\', \''+setDirection.options.myMarker['labelFrom']+'\', \''+setDirection.options.myMarker['labelTo']+'\', \'FROM\', \''+setDirection.options.myMarker['lat']+', '+setDirection.options.myMarker['lon']+'\');" title="'+setDirection.options.myMarker['labelCalculate']+'"><strong>'+setDirection.options.myMarker['labelFrom']+'</strong></a> - <a href="javascript:;" onclick="setDirection.init(\'<h5>'+setDirection.options.myMarker['labelTitle']+'</h5><br />'+setDirection.options.myMarker['labelCalculate']+'\', \''+setDirection.options.myMarker['labelFrom']+'\', \''+setDirection.options.myMarker['labelTo']+'\', \'TO\', \''+setDirection.options.myMarker['lat']+', '+setDirection.options.myMarker['lon']+'\');" title="'+setDirection.options.myMarker['labelCalculate']+'"><strong>'+setDirection.options.myMarker['labelTo']+'</strong></a></div>';setDirection.openMap();},openMap:function(){var latlng=new google.maps.LatLng(setDirection.options.myMarker['lat'],setDirection.options.myMarker['lon']);if(setDirection.options.mapType==undefined)setDirection.options.mapType="ROADMAP";if(setDirection.options.showCursor==undefined)setDirection.options.showCursor=false;var myOptions={disableDefaultUI:setDirection.options.showCursor,mapTypeControl:false,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},zoom:setDirection.options.zoom,center:latlng,mapTypeId:google.maps.MapTypeId[setDirection.options.mapType]};maps=new google.maps.Map(document.getElementById(setDirection.options.mapId),myOptions);var myLatLng=new google.maps.LatLng(setDirection.options.myMarker['lat'],setDirection.options.myMarker['lon']);var marker=new google.maps.Marker({position:myLatLng,map:maps,icon:setDirection.options.myMarker['icon'],zIndex:10000});if(setDirection.options.myMarker['infowindow']!=""){infowindow=new google.maps.InfoWindow({content:setDirection.options.myMarker['infowindow'],maxWidth:350,position:myLatLng,zIndex:100});infowindow.open(maps,infowindow);google.maps.event.addListener(marker,"click",function(){infowindow.open(maps,infowindow);});}},init:function(myText,from,to,direction,latLan){if(document.getElementById('ballon')){setDirection.options.dirService=new google.maps.DirectionsService();setDirection.options.dirRenderer=new google.maps.DirectionsRenderer();var myFormDirection,textDirection;if(direction=="FROM"){myFormDirection='<form name="direction" action="javascript:;" method="get"><input id="from-input" type="hidden" value="'+latLan+'" />';myFormDirection+='<input id="to-input" type="text" value="" class="inputE" />';myFormDirection+='<input class="inputB" onclick="setDirection.getDirections(document.getElementById(\'from-input\').value, document.getElementById(\'to-input\').value);" type="button" value=">" /></form>';textDirection=myText+'<br /><strong>'+from+'</strong> - <a href="javascript:;" onclick="setDirection.init(\''+myText+'\', \''+from+'\', \''+to+'\', \'TO\', \''+latLan+'\');"><strong>'+to+'</strong></a>'+myFormDirection;}else{myFormDirection='<form name="direction" action="javascript:;" method="get"><input id="from-input" type="text" value="" class="inputE" />';myFormDirection+='<input id="to-input" type="hidden" value="'+latLan+'" />';myFormDirection+='<input class="inputB" onclick="setDirection.getDirections(document.getElementById(\'from-input\').value, document.getElementById(\'to-input\').value);" type="button" value=">" /></form>';textDirection=myText+'<br /><a href="javascript:;" onclick="setDirection.init(\''+myText+'\', \''+from+'\', \''+to+'\', \'FROM\', \''+latLan+'\');"><strong>'+from+'</strong></a> - <strong>'+to+'</strong>'+myFormDirection;}document.getElementById('ballon').innerHTML=textDirection;}},getDirections:function(fromStr,toStr){var dirRequest={origin:fromStr,destination:toStr,travelMode:google.maps.DirectionsTravelMode.DRIVING,unitSystem:google.maps.DirectionsUnitSystem.METRIC,provideRouteAlternatives:true};setDirection.options.dirService.route(dirRequest,setDirection.showDirections);},showDirections:function(dirResult,dirStatus){if(dirStatus!=google.maps.DirectionsStatus.OK){if(typeof(dirStatusErrora)!=undefined){alert(dirStatusError+"\n(Google reports: "+dirStatus+")");}else{alert("The address entered was not found\n(Google reports: "+dirStatus+")");}return;}setDirection.openMap();jq('html,body').animate({scrollTop:jq('#'+setDirection.options.mapId).offset().top-20},1000);setDirection.options.dirRenderer.setMap(null);setDirection.options.dirRenderer.setMap(maps);jq('#dirContainer').html('');setDirection.options.dirRenderer.setPanel(document.getElementById('dirContainer'));setDirection.options.dirRenderer.setDirections(dirResult);}}