﻿function $1(a){ $(a).style.display=''; }
function $0(a){ $(a).style.display='none'; }
function $v(a){ return $(a).value; }
/*********************************************************/

	var marker;

	var actual_url='';

        function fixPngTransparency(obj){
           if (document.body.filters){
              pattern=/.png/gi;
	      filterFix="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+obj.src+"',sizingMethod='scale');";
	      if (obj.src.search(pattern)!=-1){
		 obj.style.width=obj.offsetWidth+"px";
		 obj.style.height=obj.offsetHeight+"px";
		 obj.style.filter=filterFix;
		 obj.src="/images/blank.gif";
	      }
	   }
	}

    var facebook_pic = 0;
    var facebook = false;
    
	function ventana_form_ccl(url, ancho, alto)
	{
		if(url == 'modulos/usuarios/usuarios.php?action=MOSTRAR_REGISTRO_WEB' || url == 'modulos/usuarios/usuarios.php?action=MOSTRAR_REGISTRO_WEB_FACEBOOK')
		{
			$('div_form_centrado0').setStyles({ 'position':(window.ie6)?'absolute':'absolute' });
		} 
		else 
		{
			$('div_form_centrado0').setStyles({ 'position':(window.ie6)?'absolute':'fixed' });
		}
		
		facebook = (url == 'modulos/usuarios/usuarios.php?action=MOSTRAR_REGISTRO_WEB_FACEBOOK');
				
		var myEffects2a = new Fx.Styles($('div_form_centrado0'), {duration: 400,onComplete: function()
		{
			if($('div_form_centrado0').style.opacity==0){ $0('div_form_centrado0'); } else { $1('div_form_centrado0'); };
		}});
		
		if(window.ie6)
		{
			$$('select').setStyles({'visibility':'hidden'});
		}
		
		$('form_overlay').setStyles({'visibility':'visible','opacity':'0.8','cursor':'pointer','top':window.getScrollTop(),'height':window.getHeight()});
		
		$('form_overlay').addEvent('click', function() { ventana_form_cerrar(); });	
		
		$('div_form_centrado0').setStyles({ 'width':ancho ,'height':alto });

		$('div_form_centrado0_sombra_derecha').setStyles({ 'width':10 ,'height':alto-10 });
		$('div_form_centrado0_sombra_derecha_img').setStyles({ 'width':10 ,'height':alto-10,'display':'none' });

		$('div_form_centrado0_sombra_inferior').setStyles({ 'width':ancho ,'height':10 });
		$('div_form_centrado0_sombra_inferior_img').setStyles({ 'width':ancho ,'height':10, 'float':'left','display':'none' });
		
		var reducir = (window.ie6) ? 15 : 12;
		
		$('div_form_centrado').setStyles({ 'width':ancho-reducir ,'height':alto-12 });

		if(window.ie)	
			$('div_form_centrado').setStyles({ 'margin-bottom':-4 });

		if(actual_url == '')
		{
			actual_url = url;

			if($('div_form_centrado0').style.opacity == 0)
			{
				if(window.ie6)
				{
					var xx = ( window.getWidth()/2 ) - ( ancho/2 );
					var yy = window.getScrollTop() + ( ( window.getHeight()/2 ) - ( alto/2 ) );						
				} 
				else 
				{
					var xx = ( window.getWidth()/2 ) - ( ancho/2 );
					var yy = ( window.getHeight()/2 ) - ( alto/2 );		
				}
				
				yy = (yy < 0) ? 4 : yy;
				
				$('div_form_centrado0').setStyles({ opacity:0 ,'display':'block','top':yy,'left':xx });
				$('div_form_centrado').innerHTML='<div style="text-align:left;">' +JS_cargando+'....</div>';
				
				myEffects2a.start({ 'opacity': [0.0, 1.0] });

				new Ajax(url + "&ran="+Math.random(), { method:'get',  onComplete: function(eee)
				{
					$('div_form_centrado').innerHTML = '<div style="width:100%; height:auto; position:relative;">' + ((window.ie6)?'&nbsp;':'')+ '<a class="reg_cerrar" href="#" onclick="javascript:ventana_form_cerrar(); return false;" rel="nofollow">&nbsp;</a>'+eee+'</div>';
				
					if($('reg_foto_upload'))
					{
						if(facebook && pic_with_logo != '')
						{
							renderImagenPerfilFacebook();
						}
						else
						{
							$('reg_foto_upload').innerHTML = render_upload('usu','fot','','img/blank.jpg','modulos/media/image.upload.preview.php','img_usuario');
							
							facebook_pic = 0;
						}
					}
					
					if(url ==  'modulos/usuarios/usuarios.php?action=MOSTRAR_INICIAR_SESION')
					{
						$('login_usuario').focus();
					}
				}, 
				
				evalScripts: true  
				
				}).request();

			} 
			else 
			{
				ventana_form_cerrar();
			}

		}
		else
		{
			if(actual_url == url)
			{
				ventana_form_cerrar();
			} 
			else 
			{
				$('div_form_centrado').innerHTML='<div style="text-align:left;">'+JS_cargando+'....</div>';

				new Ajax(url, { method:'get',  onComplete: function(eee)
				{
					$('div_form_centrado').innerHTML = '<div style="width:100%; height:auto; position:relative;">' + ((window.ie6)?'&nbsp;':'')+ '<a class="reg_cerrar" href="#" onclick="javascript:ventana_form_cerrar(); return false;" rel="nofollow">&nbsp;</a>'+eee+'</div>';
					                                 
					if($('reg_foto_upload'))
					{
						if(facebook && pic_with_logo != '')
						{
							renderImagenPerfilFacebook();
						}
						else
						{
							$('reg_foto_upload').innerHTML = render_upload('usu','fot','','img/blank.jpg','modulos/media/image.upload.preview.php','img_usuario');
							
							facebook_pic = 0;
						}
					}				
				},
				
				evalScripts: true  
				
				}).request();
			}
		}
	}
	
	function renderImagenPerfilFacebook()
	{
		$('reg_foto_upload').innerHTML = '<div style="position:absolute;left:257px;">' + 
		 '<img style="borde-width: 5px; border-color: #FFFFFF;" class="img_with_border" src="' + pic_with_logo + '" />' + 
		 '</div>' +
		 
		 '<div style="padding-top: 10px;">' +
		 '<a style="color:#FFFFFF; font-size:13px; text-decoration: underline; cursor: pointer;"' +
		 "onclick=\"javascript: $('reg_foto_upload').innerHTML = render_upload('usu','fot','','img/blank.jpg','modulos/media/image.upload.preview.php','img_usuario'); return false;\">" + 
		 JS_cambiar_imagen + "</a>" +
		 '<span style="color:#FFFFFF; font-size:13px; margin-left: 50px;"> ' + JS_vista_previa + ' >> </span>' +
		 '</div>';
		
		facebook_pic = 1;		
	}

	function ventana_form_cerrar()
	{
		actual_url = '';
		
		$('form_overlay').setStyles({'visibility':'hidden','opacity':'0'});

		var myEffects2a = new Fx.Styles($('div_form_centrado0'), {duration: 400,onComplete: function()
		{
			if($('div_form_centrado0').style.opacity==0){ $0('div_form_centrado0'); } else { $1('div_form_centrado0'); };
		}});
		
		myEffects2a.start({ 'opacity': [1.0, 0] });
		
		if(window.ie6){
			$$('select').setStyles({'visibility':'visible'});	
		}

	}
	
	function ventana_go(url){
	
		new Ajax(url+"&ran="+Math.random(), { method:'get',  onComplete: function(eee){

							$('div_form_centrado').innerHTML='<div style="width:100%; height:auto;"><a class="reg_cerrar" href="#" onclick="javascript:ventana_form_cerrar(); return false;" rel="nofollow"></a>'+eee+'</div>';


		}, evalScripts: true  } ).request();
				
	}				
	
	
	
	
	
/*************************************************************************/

/* Javascript de upload de imagen */

function reset_img_foto(tab,camp)
{
	$1('image_'+tab+'_'+camp+'_controles1');
	$0('image_'+tab+'_'+camp+'_copiando');
	$1('image_'+tab+'_'+camp+'_default');
	$('image_'+tab+'_'+camp+'_img').src=$('image_'+tab+'_'+camp+'_temp').value;
	$('form_'+tab+'_'+camp).reset();
	$0('image_'+tab+'_'+camp+'_img_cerrar');
	$('upload_'+tab+'_in_'+camp).value='';
	
	if( tab!='usu' || camp!='fot'){

		show_com_form('');
	
		if(camp=='vid')
			show_com_form('video');	
	
		if(camp=='fot')
			show_com_form('foto');
	
	}	
	
}

var uploads_in_progress = 0;

function upload(ul,tab,camp)
{
	
	var sid	= $v('sid');
	
	$1('image_'+tab+'_'+camp+'_controles1');
	$1('image_'+tab+'_'+camp+'_copiando');
	
	if($('image_com_fot_copiando'))
		$0('image_com_fot_copiando');
		
	if($('image_com_vid_copiando'))
		$0('image_com_vid_copiando');		
		
	$0('image_'+tab+'_'+camp+'_default');
	$('form_'+tab+'_'+camp).submit();
	$('error_'+tab+'_'+camp).innerHTML='';
	
		
	if($('image_com_vid_copiando')){
	
		$('label_progressbar').innerHTML=JS_video_subiendo;
		
	}
	
	if($('image_com_fot_copiando')){
	
		$('label_progressbar').innerHTML=JS_imagen_subiendo;
		
	}	
	
	if($('publicar_comentario_buton'))
		$('publicar_comentario_buton').disabled=true;
		
		
	uploads_in_progress = uploads_in_progress + 1;
	var pb = document.getElementById(tab+'_'+camp+"_progress");
	pb.parentNode.style.display='block';
	new ProgressTracker(sid,{
		progressBar: pb,
		onComplete: function() {
			var inp_id = pb.id.replace("_progress","");
			uploads_in_progress = uploads_in_progress - 1;
			var inp = document.getElementById(inp_id);
			if(inp) {
				inp.value = sid;
			}
			//pb.parentNode.style.display='none';
			$(tab+'_'+camp+'_progress').setStyles({"width":"100%"});
			mover_archivo(sid);
			
			if($('image_com_vid_copiando')){
				$('label_progressbar').innerHTML=JS_video_subiendo_fin;
			}
			
			if($('image_com_fot_copiando')){
				$('label_progressbar').innerHTML=JS_imagen_subiendo_fin;
			}				
			//$('label_progressbar').innerHTML='';
		},
		onFailure: function(msg) {
			pb.parentNode.style.display='none';
			alert(msg);
			uploads_in_progress = uploads_in_progress - 1;
		}
	});

}

function mover_archivo(sid){
	url='modulos/media/receive.php';
	
	datos = {
				sid	: $v('sid')
			};
	
	new Ajax( url , { method:'post', data:datos, onComplete: function(eee){		
		//alert(eee);
		var json=eval("(" + eee + ")");
		$('sid').value=json.sid;
		 upload_terminar(json.url);
			
	}}).request();
	
}
    
function upload_err(m)
{
	tab=Ptab;
	camp=Pcamp;
	$1('image_'+tab+'_'+camp+'_controles1');
	$0('image_'+tab+'_'+camp+'_copiando');
	$1('image_'+tab+'_'+camp+'_default');
	$('error_'+tab+'_'+camp).innerHTML=m;
	$('form_'+tab+'_'+camp).reset();
	
	if($('publicar_comentario_buton'))
		$('publicar_comentario_buton').disabled=false;
	
}

function upload_terminar(i)
{
	tab=Ptab;
	camp=Pcamp;
	$0('image_'+tab+'_'+camp+'_copiando');
	$1('image_'+tab+'_'+camp+'_default');
	$('error_'+tab+'_'+camp).innerHTML='';
	$('image_'+tab+'_'+camp+'_img').src=i;
	$('upload_'+tab+'_in_'+camp).value=i;
	$0('image_'+tab+'_'+camp+'_controles1');
	$1('image_'+tab+'_'+camp+'_img_cerrar');
	
	if($('image_com_fot_controles1'))
		$1('image_com_fot_controles1');
		
	if($('image_com_vid_controles1'))
		$1('image_com_vid_controles1');			
	
	if($('image_com_vid_default'))
		$0('image_com_vid_default');	
		
	if($('publicar_comentario_buton'))
		$('publicar_comentario_buton').disabled=false;		
}


var Ptab; 
var Pcamp;
function render_upload(tb,campo,id,img_default,script,input_file)
{
	//'usu','fot','','img/blank.jpg','modulos/media/image.upload.preview.php','img_usuario');
	var sid=$v('sid');

	var id2 = (id=='') ? '' : '_'+id;
	Pcamp = campo + id2;
	Ptab = tb;
	
	facebook_pic_link = (facebook && facebook_pic) ? '<div style="padding-top: 0px;"><a style="color:#FFFFFF; font-size:13px; text-decoration: underline; cursor: pointer;" onclick="renderImagenPerfilFacebook();">' + JS_imagen_facebook + ' >></a></div>' : '';
	
	var html='';
	
	html+=	'<input type="hidden" id="upload_'+tb+'_in_'+campo+id2+'" />'+
			'<input type="hidden" id="image_'+tb+'_'+campo+id2+'_temp"  value="'+img_default+'" />'+
	
			'<form id="form_'+tb+'_'+campo+id2+'" action="/cgi-bin/upload.cgi?sid='+sid+'" enctype="multipart/form-data" method="post" target="iframe_upload_'+tb+'_'+campo+id2+'" >'+
	
				'<div style="position:relative;">'+
		
					'<div style="position:absolute;top:31px;left:257px;">'+
						
						'<table id="image_'+tb+'_'+campo+id2+'_default" cellpadding="0" border="0" cellspacing="0"  class="upload_table1" >'+
							'<tr>'+
								'<td align="center" valign="middle" class="upload_table2">'+
									'<img src="'+img_default+'" id="image_'+tb+'_'+campo+id2+'_img" class="upload_img_default" height="80" width="80" />'+
								'</td>'+
							'</tr>'+
						'</table>'+
			
						'<a href="#" style="display:none;" class="upload_img_cerrar" id="image_'+tb+'_'+campo+id2+'_img_cerrar"  onclick="reset_img_foto(\''+tb+'\',\''+campo+id2+'\');return false;" title="cambiar">' + ( (campo=='vid')?JS_CANCELAR_VIDEO:JS_CANCELAR_IMAGEN ) + '</a>'+
			
						'<span  class="upload_copiando" style=" display:none;" id="image_'+tb+'_'+campo+id2+'_copiando">'+
							
							'<span class="upload_preview">vista previa</span><br />'+
							
							'<img src="img/load.gif" />'+
			
						'</span>'+
					
					'</div>'+
			
					'<div class="upload_controles1" id="image_'+tb+'_'+campo+id2+'_controles1">'+
				
						'<input id="upload_input" type="file" name="'+input_file+'" onchange="if(this.value!=\'\') upload(this,\''+tb+'\',\''+campo+id2+'\'); " class="upload_input_file"  autocomplete="off" style="width:250px;" />'+
						
						'<div id="error_'+tb+'_'+campo+id2+'" class="upload_error"></div>'+
						
						facebook_pic_link +
			
					'</div>'+
					
				'</div>'+
			
			'</form>'+
	
	'<div style="display: none;" class="' + ( ( tb=='usu' )?'progresscontainer2':'progresscontainer' ) + '">'+
		'<div id="'+tb+'_'+campo+'_progress" class="progressbar">'+
		'</div>'+
	'</div>'+
	
	'<div id="label_progressbar"></div>'+
	
	'<iframe width="300" height="300" frameborder="0" style="position: absolute; display:none;" name="iframe_upload_'+tb+'_'+campo+id2+'" id="iframe_upload_'+tb+'_'+campo+id2+'"></iframe>';
	
	return html;

		
}
								
 /* Fin de Javascript de upload de imagen */
 
 
 
 /* Inicio map */
 
     function initialize_map() {
	  
	  var pais=pais_default;
	  
      if(GBrowserIsCompatible()) {
	  
        map = new GMap2(document.getElementById("map"),{ size: new GSize(300,300) });		
		
        var customUI = map.getDefaultUI();
        // Remove MapType.G_HYBRID_MAP
        //customUI.maptypes.hybrid = false;
        map.setUI(customUI);

  		
        geocoder = new GClientGeocoder();

		
		$('map').setStyles({'visibility':'hidden'});
		
		if( $v(camp_latitud)=='' && $v(camp_longitud)=='' && $v(camp_zoom)==''){
		
		var point = new GLatLng(37.4419, -122.1419);
		
        map.setCenter(point, 0);

		createMarkerDra(point);
		
		showAddress(pais);
		
		} else {

		
		var point = new GLatLng($v(camp_latitud), $v(camp_longitud));
		
        map.setCenter(point,$v(camp_zoom)*1);

		createMarkerDra(point);		
		
  	    $("map").setStyles({"visibility":"visible"});
		
			
		}
		
		
		GEvent.addListener(map, "moveend", function() {

			marker.remove();
			
			var po=map.getCenter();
			
			createMarkerDra(po);	 	


		});
		
      }
			  
    }
	
		function putll(lat,lon,zoom){
			
			if($(camp_latitud))		{ $(camp_latitud).value=lat;  }
			if($(camp_longitud))	{ $(camp_longitud).value=lon; }
			if($(camp_zoom))		{ $(camp_zoom).value=zoom;    }
			
		}



		function showAddress(address) {
			
			geocoder.getLocations(
			  address,
			  function(response) {
				if(response.Status.code!=200){
				  //alert(address + " not found");
				} else {
				  place = response.Placemark[0];
				  accuracy = place.AddressDetails.Accuracy;
				  
				  point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
				  				
				  map.setCenter(point, tabAccuracy[accuracy]);
				  
				  marker.remove();
				  createMarkerDra(point);
		  		  $("map").setStyles({"visibility":"visible"});
				}
			  }
			);
		}	
		
		function get_point_by_address(address)
		{
			if(address==text_ruta){ return false; }			
			
			geocoder = new GClientGeocoder();
			
			geocoder.getLocations(address, function(response) 
			{
				if(response.Status.code != 200)
				{
				  alert(address + " not found");
				}
				else 
				{
				  place = response.Placemark[0];
				  accuracy = place.AddressDetails.Accuracy;
				  				  				
				  $('UsuGeoLat').value=place.Point.coordinates[1];
				  $('UsuGeoLon').value=place.Point.coordinates[0];

				  como_llegar();
				}
			});			
		}
			
		function showAddress2(address) {
			if(address==text_ruta){ return false; }			
			geocoder.getLocations(
			  address,
			  function(response) {
				if(response.Status.code!=200){
				  //alert(address + " not found");
				} else {
				  place = response.Placemark[0];
				  accuracy = place.AddressDetails.Accuracy;
				  
				  point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
				  				
				  map2.setCenter(point, tabAccuracy[accuracy]);
				  
				  if(marker)
				  marker.remove();
				  createMarkerDra2(point);
		  		  $("map_como_llegar").setStyles({"visibility":"visible"});
				  
				  como_llegar(); 
				  //marker.openInfoWindowHtml(point.lat()+","+point.lng());
				}
			  }
			);
		}		
		
		function showAddress3(address) {
			if(address==text_ruta){ return false; }
			geocoder.getLocations(
			  address,
			  function(response) {
				if(response.Status.code!=200){
				  //alert(address + " not found");
				} else {
					
				  place = response.Placemark[0];
				  
				  accuracy = place.AddressDetails.Accuracy;
				  
				  point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
				  				
				  map3.setCenter(point, tabAccuracy[accuracy]);
				  
				  marker.remove();
				  
				  createMarkerDra33(point);
				  
		  		  $("map_que_visitar").setStyles({"visibility":"visible"});
				  //marker.openInfoWindowHtml(point.lat()+","+point.lng());
				}
			  }
			);
		}				

		function showAddress33(address) {
			if(address==text_ruta){ return false; }
			geocoder.getLocations(
			  address,
			  function(response) {
				if(response.Status.code!=200){
				  //alert(address + " not found");
				} else {
					
				  place = response.Placemark[0];
				  
				  accuracy = place.AddressDetails.Accuracy;
				  
				  point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
				  				
				  map.setCenter(point, tabAccuracy[accuracy]);
				  
				  marker.remove();
				  
				  createMarkerDra33(point);
				  
		  		  $("map_que_visitar").setStyles({"visibility":"visible"});
				  //marker.openInfoWindowHtml(point.lat()+","+point.lng());
				}
			  }
			);
		}				

		function createMarkerDra(point){
		
		  marker = new GMarker(point,{ draggable: true, title: 'Arrastra el marcador rojo', bouncy:true} );
		  map.addOverlay(marker);
		  
		  putll(point.lat(),point.lng(),map.getZoom());
		  
			GEvent.addListener(marker, "dragstart", function() {
		
			});
		
			GEvent.addListener(marker, "dragend", function() {
		
				var pt =marker.getPoint();
				putll(pt.lat(),pt.lng(),map.getZoom())
				
				map.panTo(new GLatLng(pt.lat(), pt.lng()));
		
			});
		
		}		
		
		function createMarkerDra2(point){
		
		  marker = new GMarker(point,{ draggable: true, title: JS_arrastra_marcador , bouncy:true} );
		  map2.addOverlay(marker);
		  
		  putll(point.lat(),point.lng(),map2.getZoom());
		  
			GEvent.addListener(marker, "dragstart", function() {
		
			});
		
			GEvent.addListener(marker, "dragend", function() {
		
				var pt =marker.getPoint();
				putll(pt.lat(),pt.lng(),map2.getZoom())
				
				map2.panTo(new GLatLng(pt.lat(), pt.lng()));
		
			});
		
		}	
		
		function createMarkerDra3(point){
		
		  marker = new GMarker(point,{ draggable: true, title: JS_arrastra_marcador, bouncy:true} );
		  map3.addOverlay(marker);
		  
		  putll(point.lat(),point.lng(),map3.getZoom());
		
		}	
		
		function createMarkerDra33(point){
		
		  marker = new GMarker(point,{ draggable: true, title: JS_arrastra_marcador, bouncy:true} );
		  map.addOverlay(marker);
		  
		  putll(point.lat(),point.lng(),map.getZoom());
		
		}			
	
	function iniciar_map(id){
	
		$(id).innerHTML=""
		+"    <div id=\"map\"></div>"
		+"	  <div style=\"margin-top:4px;\">"
		+"    <input type=\"button\" value=\"buscar\"  onclick=\"showAddress($('mapsearch').value)\" style=\"width:100px;background-color:#fff;float:right;\" />"
		+"    <input type=\"text\" value=\""+JS_buscar_lugar+"\" id=\"mapsearch\" style=\"margin-right:2px; width:185px;background-color:#fff; color:#cccccc\"  "
		+"    onkeyup=\"if(event.keyCode=='13'){ showAddress(this.value); return false; }\""
		+"    onfocus=\"if(this.value=='"+JS_buscar_lugar+"'){ this.value=''; this.style.color='#000000'; } \" "
		+"    onblur=\"if(this.value==''){ this.style.color='#cccccc'; this.value='"+JS_buscar_lugar+"'; } \" "
		+"    />"
		+"    </div>    "
		+"";
	
		initialize_map(); 
	
	}


 /* */


 function confirmarEliminar(mensaje,url){
	
	if(confirm(mensaje)){ 
		location.href=url; 
	} else {
		return false;	
	}
	
 }
 
 
 /* */
 	   var bounds;
 
      function initialize_map_home(xlat,xlon,xzoom,w,h) {
		  
	  
      	if(GBrowserIsCompatible()) {
			bounds = new GLatLngBounds(); 
			map = new GMap2(document.getElementById("mappp"),{ size: new GSize(w,h) });		

			var customUI = map.getDefaultUI();

			map.setUI(customUI);		
				
			var point = new GLatLng(xlat, xlon);
			map.setCenter(point,xzoom*1);
	
			createMarker(point);		
			
			GEvent.addListener(map, "moveend", function() {
				if(winopen==0 && updatinmapa==0){
					buscar_locales_mapa_bounds(); 	
				}
			});
			winopen=0;
			GEvent.addListener(map, "infowindowopen", function() {
				winopen=1; 	
			});	
			GEvent.addListener(map, "infowindowclose", function() {
				winopen=0; 	
			});		
			buscar_locales_mapa_bounds(); 
				
		  }
				   	
		}
      
      function initialize_map_actividades(xlat,xlon,xzoom,w,h) 
      {
		   	if(GBrowserIsCompatible()) 
        	{
	  			bounds = new GLatLngBounds(); 
	  			map = new GMap2(document.getElementById("mappp"),{ size: new GSize(w,h) });		
	
	  			var customUI = map.getDefaultUI();
	
	  			map.setUI(customUI);		
	  				
	  			var point = new GLatLng(xlat, xlon);
	  			map.setCenter(point,xzoom*1);
	  	
	  			//createMarker(point);		
	  			
	  			GEvent.addListener(map, "moveend", function() {
	  				if(winopen==0 && updatinmapa==0){
	  					buscar_actividades_mapa_bounds(); 	
	  				}
	  			});
	  			winopen=0;
	  			GEvent.addListener(map, "infowindowopen", function() {
	  				winopen=1; 	
	  			});	
	  			GEvent.addListener(map, "infowindowclose", function() {
	  				winopen=0; 	
	  			});		
	  			buscar_actividades_mapa_bounds();  				
  		  }
  				   	
      }      
		
	function buscar_lugares_mapa_bounds(){
	
		var Htmlfill="";
		json='';
		
		url="modulos/lugares/lugares.php";
		
		var bounds = map3.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		
		var lat2 = northEast.lat();
		var lat1 = southWest.lat();		
		var lon2 = northEast.lng();
		var lon1 = southWest.lng();		
		
		//alert(lat1+"-"+lat2+","+lon1+"-"+lon2);
		
		/*
		
		if(mar1) mar1.remove();
		if(mar2) mar2.remove();
		if(mar3) mar3.remove();
		if(mar4) mar4.remove();

		mar1 = new GMarker(new GLatLng(lat1,lon1)); 
		mar2 = new GMarker(new GLatLng(lat1,lon2)); 		
		mar3 = new GMarker(new GLatLng(lat2,lon1)); 
		mar4 = new GMarker(new GLatLng(lat2,lon2)); 
				 
		map.addOverlay(mar1);		  
		map.addOverlay(mar2);		  
		map.addOverlay(mar3);		  
		map.addOverlay(mar4);		  

		return;
		
		*/
		
		datos = { 
					lat_1		: lat1,
					lon_1		: lon1,					
					lat_2		: lat2,
					lon_2		: lon2,
					action		: 'BUSQUEDA_AREA_ESQUINAS',
					ajax		: '1'
					
				};	
			
		new Ajax(url, { method:'get', data:datos, onComplete: function(eee)
		{
			for(var e=0;e<marcas2.length;e++){
				
				marcas2[e].remove();
				
			}				
			
				if(eee.trim()!=''){
					
					
					var json=eval("(" + eee + ")");
					
					$('lugares_visitar').innerHTML = "<b class='pesta_lugares' id='pesta_lugares'>"+JS_lugares+"</b><a href='#' id='link_volver' style='display:none;' class='link_volver' onclick=\"javascript:volver_lista_lugares(); return false;\" rel='nofollow'>"+JS_volver_lugares+"</a><ul class='lista_lugares' id='lista_lugares'>";
		
					for(var e=0;e<json.n;e++){
						
						markerpunto_lugares(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].lat,json.items[e].lon,json.items[e].tipo,json.items[e].img);						
						
						Htmlfill += "<tr><td>"+json.items[e].nom+"</td><td>"+json.items[e].lat+"</td><td>"+json.items[e].lon+"</td></tr>";
						
					}
					
					$('lugares_visitar').innerHTML = $('lugares_visitar').innerHTML + "</ul><div class='clear'></div><div class='clear'></div><div id='rutas_lugares' style='display:none; clear:left;'></div>";
					
					//$('plus_open').innerHTML=json.n;					
					//map.setZoom(map.getBoundsZoomLevel(bounds)-1);
					//map.setCenter(bounds.getCenter());				
				}
					/*	
					$('debugger').setSyles({display:'block'});
					$('debugger').innerHTML = "<table style='float:left;'>"
					+"<tr><th></th><th>"+lat1+"</th><th>"+lon1+"</th></tr>"
					+"<tr><th></th><th>"+lat2+"</th><th>"+lon2+"</th></tr>"		
					+Htmlfill
					+"</table>";	
					*/
		
		} } ).request();
		
		
	
	}	
	
	
		function buscar_locales_mapa_bounds_2(container, tipo)
		{
			var items_container = $(container);
			var Htmlfill="";
			json='';
			
			url="modulos/locales/locales.php";
			
			var bounds = map.getBounds();
			var southWest = bounds.getSouthWest();
			var northEast = bounds.getNorthEast();
			
			var lat2 = northEast.lat();
			var lat1 = southWest.lat();		
			var lon2 = northEast.lng();
			var lon1 = southWest.lng();	
			
			var type = '';
			var typeString = '';
			var icono = '';
			
			if(tipo == 'donde_comer')
			{
				type = 'Restaurante';
				typeString = JS_restaurantes;
				icono = "img/restaurante.gif";
			}
			else
			{
				type = $v('SelectTipo');
				typeString = JS_hoteles;
				icono = "img/ico_evasion_map.gif";
			}
			
			datos = { 
						tipo 		: type,		
						lat_1		: lat1,
						lon_1		: lon1,					
						lat_2		: lat2,
						lon_2		: lon2,
						action		: 'BUSQUEDA_AREA_ESQUINAS',
						ajax		: '1'
					};	
				
			new Ajax(url, { method:'get', data:datos, onComplete: function(eee)
			{
				for(var e=0; e<marcas2.length; e++)
				{
					marcas2[e].remove();
				}	
				
				if(eee.trim()!='')
				{
					var json=eval("(" + eee + ")");
					
					items_container.innerHTML = "<b class='pesta_lugares' id='pesta_lugares'>"+ typeString +"</b><a href='#' id='link_volver' style='display:none;' class='link_volver' onclick=\"javascript:volver_lista_lugares(); return false;\" rel='nofollow'>voler a lista de "+ typeString +"</a><ul class='lista_lugares' id='lista_lugares'>";
		
					for(var e=0; e<json.n; e++)
					{
						markerpunto_locales(e, new GLatLng(json.items[e].lat,json.items[e].lon), json.items[e].nom, json.items[e].des, json.items[e].id,json.items[e].cod,json.items[e].img, json.items[e].lat,json.items[e].lon, icono);						
						Htmlfill += "<tr><td>"+json.items[e].nom+"</td><td>"+json.items[e].lat+"</td><td>"+json.items[e].lon+"</td></tr>";
					}
					
					items_container.innerHTML = items_container.innerHTML + "</ul><div class='clear'></div><div class='clear'></div><div id='rutas_lugares' style='display:none; clear:left;'></div>";
				} 
				else 
				{
					items_container.innerHTML = "<b class='pesta_lugares' id='pesta_lugares'>"+ typeString +"</b><a href='#' id='link_volver' style='display:none;' class='link_volver' onclick=\"javascript:volver_lista_lugares(); return false;\" rel='nofollow'>"+JS_volver_lugares+"</a><ul class='lista_lugares' id='lista_lugares'>";
				}
				
			} } ).request();
		}	
	
	function buscar_locales_mapa_bounds(){
	
		var Htmlfill="";
		json='';
		
		url="modulos/locales/locales.php";
		
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		
		var lat2 = northEast.lat();
		var lat1 = southWest.lat();		
		var lon2 = northEast.lng();
		var lon1 = southWest.lng();		
		
		
		datos = { 
					tipo 		: $v('SelectTipo'),
					lat_1		: lat1,
					lon_1		: lon1,					
					lat_2		: lat2,
					lon_2		: lon2,
					action		: 'BUSQUEDA_AREA_ESQUINAS'
					
				};	
			
		new Ajax(url, { method:'get', data:datos, onComplete: function(eee){
				
			
				bounds.extend(markerx.getPoint());

				if(eee.trim()!=''){
					
					
					var json=eval("(" + eee + ")");
					
					for(var e=0;e<marcas.length;e++){
					
						marcas[e].remove();
						
					}				
		
					
					for(var e=0;e<json.n;e++){
						
						markerpunto(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].cod , '', json.items[e].img );
						
						Htmlfill += "<tr><td>"+json.items[e].nom+"</td><td>"+json.items[e].lat+"</td><td>"+json.items[e].lon+"</td></tr>";
						
					}

				}

		
		} } ).request();
		
		
	
	}	
	
	function buscar_actividades_mapa_bounds(){
		
		var Htmlfill="";
		json='';
		
		url="modulos/actividades/actividades.php";
		
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		
		var lat2 = northEast.lat();
		var lat1 = southWest.lat();		
		var lon2 = northEast.lng();
		var lon1 = southWest.lng();		
		
		
		datos = { 
					tipo 		: $v('SelectTipo'),
					lat_1		: lat1,
					lon_1		: lon1,					
					lat_2		: lat2,
					lon_2		: lon2,
					action		: 'BUSQUEDA_AREA_ESQUINAS'
					
				};	
			
		new Ajax(url, { method:'get', data:datos, onComplete: function(eee){
				
			
				bounds.extend(markerx.getPoint());

				if(eee.trim()!=''){
					
					
					var json=eval("(" + eee + ")");
					
					for(var e=0;e<marcas.length;e++){
					
						marcas[e].remove();
						
					}				
		
					
					for(var e=0;e<json.n;e++){
						
						markerpunto_actividad(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].cod , 'img/actividad.png', json.items[e].img );
						
						Htmlfill += "<tr><td>"+json.items[e].nom+"</td><td>"+json.items[e].lat+"</td><td>"+json.items[e].lon+"</td></tr>";
						
					}

				}

		
		} } ).request();
		
		
	
	}				



		var markerx;
		function createMarker(point)
		{
		
		  markerx = new GMarker(point,{ title: '' } );
		  
		  map.addOverlay(markerx);		  
		
		}
		var wifiIco_2;

		function markerpunto_locales(e,point,nombre,des,id_local,cod,img,lat,lon, icono)
		{
			var icono = (icono == '') ? "img/ico_evasion_map.gif" : icono;
			
		wifiIco_2 = new GIcon();
		wifiIco_2.image = icono;
		wifiIco_2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		wifiIco_2.iconSize = new GSize(20, 20);
		wifiIco_2.shadowSize = new GSize(0, 0);
		wifiIco_2.iconAnchor = new GPoint(10, 15);
		wifiIco_2.infoWindowAnchor = new GPoint(5, 1);
	
		
		
		  marcas2[e] = new GMarker(point,{ title: nombre, bouncy:true, icon:wifiIco_2 } );
		  
		  var html=''+
		  '<div class="globo" style="height:auto;">'+
		  '<a href="modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local='+id_local+'&cod='+cod+'">'+nombre+'</a><br>'+
		  '<div class="content_img_globo"><a href="modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local='+id_local+'&cod='+cod+'"><img src="'+img+'" /><span class="ico_play" style="top:20px; left:45px;"></span></a></div>'+
		  '<div style="overflow:hidden;height:70px; float:left; width:140px; ">'+des+'</div>'+
		  '<div class="clear"></div>'+		  
		  '</div>';
		  
		  var html2=''+
		  "<li "+
		  //" onmouseover=\"click_lugares('"+e+"');\" "+
		  ">"+
//		  "<a href=\"#\"  onclick=\"javascript:click_lugares('"+e+"'); return false;\" rel=\"nofollow\">"+
		  "<a href=\"modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local="+id_local+"&cod="+cod+"\" >"+
		  "<img src='img/img/ico_evasion_map.gif' align='absmiddle' style='margin-right:4px;width:13px;' />"+nombre+"</a>"+
		  "<div style='text-align:right:height:16px;'>"+
		  "<a class='iconos_text_right ico_ir' title=\"modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local="+id_local+"\" href=\"modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local="+id_local+"&cod="+cod+"\" style='color:#000; padding-left:16px;'  >"+JS_ir+"</a>"+
		  "</div>"+
		  "<a class='iconos_text_right ico_brujula' href='#' onclick=\"como_llegar_a_local('"+lat+"','"+lon+"'); return false;\" rel='nofollow' style='color:red;'>ver ruta</a>"+
		  '</li>';
		  
		  $('lista_lugares').innerHTML = $('lista_lugares').innerHTML + html2;
		  
		  GEvent.addListener(marcas2[e], "mouseover", function() {
			marcas2[e].openInfoWindowHtml(html);
		  });		  

		  map.addOverlay(marcas2[e]);
		  
		  bounds.extend(marcas2[e].getPoint());
		
		}		
		
		function markerpunto(e,point,nombre,des,idlocal,cod,icono,img)
		{	
			if(icono == '')
				icono = "img/ico_evasion_map.gif";
			
			wifiIco_2 = new GIcon();
			wifiIco_2.image = icono;
			wifiIco_2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			wifiIco_2.iconSize = new GSize(30, 30);
			wifiIco_2.shadowSize = new GSize(0, 0);
			wifiIco_2.iconAnchor = new GPoint(6, 20);
			wifiIco_2.infoWindowAnchor = new GPoint(5, 1);
			
			  marcas[e] = new GMarker(point,{ title: nombre, bouncy:true, icon:wifiIco_2 } ); 
			  
			  var html=''+
			  '<div class="globo" style="height:auto;">'+
			  '<a href="modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local='+idlocal+'&cod='+cod+'">'+nombre+'</a><br>'+
			  '<div class="content_img_globo"><a href="modulos/locales/locales.php?action=MOSTRAR_LOCAL&id_local='+idlocal+'&cod='+cod+'"><img src="'+img+'" /><span class="ico_play" style="left:45px; top:20px;"></span></a></div>'+
			  '<div style="overflow:hidden;height:70px; float:left; width:140px; ">'+des+'</div>'+
			  '<div class="clear"></div>'+
			  '</div>';
			  
			  GEvent.addListener(marcas[e], "mouseover", function() {
				marcas[e].openInfoWindowHtml(html);
			  });
			
			  map.addOverlay(marcas[e]);
			  
			  bounds.extend(marcas[e].getPoint());
		
		}
		
		function markerpunto_actividad(e,point,nombre,des,idActividad,cod,icono,img)
		{
			wifiIco_2 = new GIcon();
			wifiIco_2.image = 'img/actividad.png';
			wifiIco_2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			wifiIco_2.iconSize = new GSize(20, 20);
			wifiIco_2.shadowSize = new GSize(0, 0);
			wifiIco_2.iconAnchor = new GPoint(10, 15);
			wifiIco_2.infoWindowAnchor = new GPoint(5, 1);
			
			  marcas[e] = new GMarker(point,{ title: nombre, bouncy:true, icon:wifiIco_2 } ); 
			  
			  var html=''+
			  '<div class="globo" style="height:auto;">'+
			  '<a href="modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad='+idActividad+'&cod='+cod+'">'+nombre+'</a><br>'+
			  '<div class="content_img_globo"><a href="modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad='+idActividad+'&cod='+cod+'"><img src="'+img+'" /><span class="ico_play" style="left:45px; top:20px;"></span></a></div>'+
			  '<div style="overflow:hidden;height:70px; float:left; width:140px; ">'+des+'</div>'+
			  '<div class="clear"></div>'+
			  '</div>';
			  
			  GEvent.addListener(marcas[e], "mouseover", function() {
				marcas[e].openInfoWindowHtml(html);
			  });

			  map.addOverlay(marcas[e]);
			  
			  bounds.extend(marcas[e].getPoint());
			
		}		
		
		function click_lugares(i) {
			if(eeee!=i){	
				GEvent.trigger(marcas2[i], "mouseover");
				eeee=i;
			}
		}		
		
		var iconos_a = new Array();
		if(window.ie6){
		iconos_a['Calle']='calle.gif';
		iconos_a['Ciudad']='ciudad.gif';
		iconos_a['Lugar_Interes']='lugar-de-interes.gif';
		iconos_a['Actividad']='actividad.gif';
		iconos_a['Bodega']='bodega.gif';
		iconos_a['Lugar_Interes']='lugar-de-interes.gif';
		iconos_a['Monumento']='monumento.gif';
		iconos_a['Museo']='museo.gif';
		iconos_a['Parque']='parque.gif';
		iconos_a['Playa']='playa.gif';
		iconos_a['Pueblo']='pueblo.gif';
		iconos_a['Restaurante']='restaurante.gif';
		iconos_a['Rio']='rio.gif';
		iconos_a['Via_Verde']='via_verde.gif';
		} else {
		iconos_a['Calle']='calle.png';
		iconos_a['Ciudad']='ciudad.png';
		iconos_a['Lugar_Interes']='lugar-de-interes.png';
		iconos_a['Actividad']='actividad.png';
		iconos_a['Bodega']='bodega.png';
		iconos_a['Lugar_Interes']='lugar-de-interes.png';
		iconos_a['Monumento']='monumento.png';
		iconos_a['Museo']='museo.png';
		iconos_a['Parque']='parque.png';
		iconos_a['Playa']='playa.png';
		iconos_a['Pueblo']='pueblo.png';
		iconos_a['Restaurante']='restaurante.png';
		iconos_a['Rio']='rio.png';
		iconos_a['Via_Verde']='via_verde.png';			
		}

		var eeee='';
		function markerpunto_lugares(e,point,nombre,des,idlugar,lat,lon,tipo,img){
			
			
		//img=img.replace("_3","_2");
		wifiIco_2 = new GIcon();
		wifiIco_2.image = "img/"+iconos_a[tipo];
		wifiIco_2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		wifiIco_2.iconSize = new GSize(20, 20);
		wifiIco_2.shadowSize = new GSize(0, 0);
		wifiIco_2.iconAnchor = new GPoint(10, 15);
		wifiIco_2.infoWindowAnchor = new GPoint(5, 1);
	
		
		
		  marcas2[e] = new GMarker(point,{ title: nombre, bouncy:true, icon:wifiIco_2 } );
		  
		  var html=''+
		  '<div class="globo" style="height:auto;">'+
		  '<a href="modulos/lugares/lugares.php?action=MOSTRAR_LUGAR&id_lugar='+idlugar+'&id_local='+$v('IDLocal')+'">'+nombre+'</a><br>'+
		  '<div class="content_img_globo"><a href="modulos/lugares/lugares.php?action=MOSTRAR_LUGAR&id_lugar='+idlugar+'&id_local='+$v('IDLocal')+'"><img src="'+img+'" /><span class="ico_play" style="top:20px; left:45px;"></span></a></div>'+
		  '<div style="overflow:hidden;height:70px; float:left; width:140px; ">'+des+'</div>'+
		  '<div class="clear"></div>'+		  
		  '</div>';
		  
		  var html2=''+
		  "<li "+
		  //" onmouseover=\"click_lugares('"+e+"');\" "+
		  ">"+
//		  "<a href=\"#\"  onclick=\"javascript:click_lugares('"+e+"'); return false;\" rel=\"nofollow\">"+
		  "<a href=\"modulos/lugares/lugares.php?action=MOSTRAR_LUGAR&id_lugar="+idlugar+"&id_local="+$v('IDLocal')+"\" >"+
		  "<img src='img/"+iconos_a[tipo]+"' align='absmiddle' style='margin-right:4px;width:13px;' />"+nombre+"</a>"+
		  "<div style='text-align:right:height:16px;'>"+
		  "<a class='iconos_text_right ico_ir' title=\"modulos/lugares/lugares.php?action=MOSTRAR_LUGAR&id_lugar="+idlugar+"&id_local="+$v('IDLocal')+"\" href=\"modulos/lugares/lugares.php?action=MOSTRAR_LUGAR&id_lugar="+idlugar+"&id_local="+$v('IDLocal')+"\" style='color:#000; padding-left:16px;'  >"+JS_ir+"</a>"+
		  "</div>"+
		  "<a class='iconos_text_right ico_brujula' href='#' onclick=\"como_llegar_a_lugar('"+lat+"','"+lon+"'); return false;\" rel='nofollow' style='color:red;'>ver ruta</a>"+
		  '</li>';
		  
		  $('lista_lugares').innerHTML = $('lista_lugares').innerHTML + html2;
		  
		  GEvent.addListener(marcas2[e], "mouseover", function() {
			marcas2[e].openInfoWindowHtml(html);
		  });		  

		  map3.addOverlay(marcas2[e]);
		  
		  bounds.extend(marcas2[e].getPoint());
		
		}	
		
		function marker_actividades(e,point,nombre,des,idActividad,lat,lon,tipo,img){
			
			
			//img=img.replace("_3","_2");
			wifiIco_2 = new GIcon();
			wifiIco_2.image = "img/actividad.png";
			wifiIco_2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			wifiIco_2.iconSize = new GSize(20, 20);
			wifiIco_2.shadowSize = new GSize(0, 0);
			wifiIco_2.iconAnchor = new GPoint(10, 15);
			wifiIco_2.infoWindowAnchor = new GPoint(5, 1);
		
			
			
			  marcas2[e] = new GMarker(point,{ title: nombre, bouncy:true, icon:wifiIco_2 } );
			  
			  var html=''+
			  '<div class="globo" style="height:auto;">'+
			  '<a href="modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad='+idActividad+'">'+nombre+'</a><br>'+
			  '<div class="content_img_globo"><a href="modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad='+idActividad+'"><img src="'+img+'" /><span class="ico_play" style="top:20px; left:45px;"></span></a></div>'+
			  '<div style="overflow:hidden;height:70px; float:left; width:140px; ">'+des+'</div>'+
			  '<div class="clear"></div>'+		  
			  '</div>';
			  
			  var html2=''+
			  "<li>"+
			  "<a href=\"modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad="+idActividad+"\" >"+
			  "<img src='img/actividad.png' align='absmiddle' style='margin-right:4px;width:13px;' />"+nombre+"</a>"+
			  "<div style='text-align:right:height:16px;'>"+
			  "<a class='iconos_text_right ico_ir' title=\"modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad="+idActividad+"\" href=\"modulos/actividades/actividades.php?action=MOSTRAR_ACTIVIDAD&id_actividad="+idActividad+"\" style='color:#000; padding-left:16px;'  >"+JS_ir+"</a>"+
			  "</div>"+
			  "<a class='iconos_text_right ico_brujula' href='#' onclick=\"como_llegar_a_actividad('"+lat+"','"+lon+"'); return false;\" rel='nofollow' style='color:red;'>ver ruta</a>"+
			  '</li>';
			  
			  $('lista_actividades').innerHTML = $('lista_actividades').innerHTML + html2;
			  
			  GEvent.addListener(marcas2[e], "mouseover", function() {
				marcas2[e].openInfoWindowHtml(html);
			  });		  

			  map3.addOverlay(marcas2[e]);
			  
			  bounds.extend(marcas2[e].getPoint());
			
			}		

	var marcas = new Array();
	var marcas2 = new Array();
	var updatinmapa=0;
	function buscar_locales_mapa(){
	
		url="modulos/locales/locales.php";
	
		updatinmapa=1;
		datos = { 
					tipo 		: $v('SelectTipo'),
					radio		: $v('SelectRadio'),
					centro_lat	: $v('GeoLat'),
					centro_lon	: $v('GeoLon'),
					action		: 'BUSQUEDA_AREA'
					
				};	
		new Ajax(url, { method:'get', data:datos, onComplete: function(eee){

			if(eee.trim()!=''){

				bounds.extend(markerx.getPoint());
				
				var json=eval("(" + eee + ")");
				
				for(var e=0;e<marcas.length;e++){
					if(marcas[e])
					marcas[e].remove();
				}				
				
				for(var e=0;e<json.n;e++){
					
					markerpunto(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].cod , '', json.items[e].img );
					
				}
				
				map.setZoom(map.getBoundsZoomLevel(bounds));
				
      			map.setCenter(bounds.getCenter());
				
				for(var e=marcas.length-4;e<marcas.length;e++){
				
					marcas[e].remove();
				}					
				updatinmapa=0;
			}
	
		} } ).request();
	
	}
	
	function buscar_actividades_mapa(){
		
		url="modulos/actividades/actividades.php";
	
		updatinmapa=1;
		datos = { 
					tipo 		: $v('SelectTipo'),
					radio		: $v('SelectRadio'),
					centro_lat	: $v('GeoLat'),
					centro_lon	: $v('GeoLon'),
					action		: 'BUSQUEDA_AREA'
					
				};	
		new Ajax(url, { method:'get', data:datos, onComplete: function(eee){

			if(eee.trim()!=''){

				bounds.extend(markerx.getPoint());
				
				var json=JSON.parse(eee);
				
				for(var e=0;e<marcas.length;e++){
					if(marcas[e])
					marcas[e].remove();
				}				
				
				for(var e=0;e<json.n;e++){
					
					markerpunto_actividad(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].cod , '', json.items[e].img );
					
				}
				
				map.setZoom(map.getBoundsZoomLevel(bounds));
				
      			map.setCenter(bounds.getCenter());
				
				for(var e=marcas.length-4;e<marcas.length;e++){
				
					marcas[e].remove();
				}					
				updatinmapa=0;
			}
	
		} } ).request();
	
	}		
	
	/*****************************/
	
		var geocoder = null;
		var tabAccuracy = new Array(2,4,6,10,12,13,16,16,17);		
		var camp_latitud;
		var camp_longitud;
		var camp_zoom;	

		var text_ruta=JS_nueva_direccion;

	var  tabb_paquetes_ok=0;
	window.addEvent('domready',function(){ tabb_paquetes_ok=1; });

	var alternateContent = '<div class="getflash">'+JA_INSTALAR_FLASH+'.<BR>'
	+ '<br><a href="http://www.adobe.com/go/getflash/"><img src="/img/flash.jpg"  alt="GET FLASH" border="0" style="margin-bottom:10px;" /></a></div>';
	
	function tabb_paquetes(ta,auto){
		
		if(auto==null){ auto=1;}
		if(auto==''){ auto=0; }
		
		
		if(tabb_paquetes_ok==0){ return; }

		$('tabb_'+tab).className='noselected';
		$('tabb_'+ta).className='selected';
		tab=ta;
		switch(ta){
		case "video":
		if (hasReqestedVersion) {
		$('video_thumbs').innerHTML='<embed height="443" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDPaquete')+'&amp;tipo=paquete' + ( (auto==1)?'&amp;autoplay=true':'&amp;autoplay=false' )+ '" src="'+videoplayer+'"  />';
		} else {
		$('video_thumbs').innerHTML=alternateContent;
		}
		break;
		case "fotos":	
		if (hasReqestedVersion) {
		$('video_thumbs').innerHTML='<embed height="515" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDPaquete')+'&amp;tipo=paquete&autoplay=true" src="'+fotoplayer+'"  />';		
		} else {
		$('video_thumbs').innerHTML=alternateContent;
		}
		break;	
		
		case "que_visitar":		   
		$('video_thumbs').innerHTML='<div id="map_que_visitar" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
		'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="lugares_visitar"></div></div>';
		$('video_thumbs').innerHTML+=''
		+"	  <div class='geoposicionaror_caja linea'>"
		+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
		+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
		+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
		+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
		+"    />"
		+"    </div> ";
		
		camp_latitud  = "GeoLat";
		camp_longitud = "GeoLon";
		camp_zoom     = "UsuGeoZoom";
		
		que_visitar();	
		break;
		case "como_llegar":		   
		$('video_thumbs').innerHTML='<div id="map_como_llegar" style="width:495px;height:430px; float:left;margin-left:5px !important;margin-left:2px;"></div>'+
		'<div  style=" margin-left:5px; width:217px !important; width:210px; height:443px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="path"></div></div>';
		$('video_thumbs').innerHTML+=''
		+"	  <div class='geoposicionaror_caja linea'>"
		+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
		+"    onkeyup=\"if(event.keyCode=='13'){ showAddress2(this.value); return false; }\""
		+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
		+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
		+"    />"
		+"    </div> ";	
		
		camp_latitud  = "UsuGeoLat";
		camp_longitud = "UsuGeoLon";
		camp_zoom     = "UsuGeoZoom";	

		get_point_by_address($v('UsuCiudad'));
		
		
		break;	
		
		case "actividades":		   
			$('video_thumbs').innerHTML='<div id="map_actividades" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
			'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="actividades_visitar"></div></div>';
			$('video_thumbs').innerHTML+=''
			+"	  <div class='geoposicionaror_caja linea'>"
			+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
			+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
			+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
			+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
			+"    />"
			+"    </div> ";
			
			camp_latitud  = "GeoLat";
			camp_longitud = "GeoLon";
			camp_zoom     = "UsuGeoZoom";
			
			actividades();			
		break;			
		}		
	}
	
	var  tabb_ok=0;
	window.addEvent('domready',function(){ tabb_ok=1; });	
	
	function tabb(ta,auto)
	{
		if(auto==null){ auto=1;}
		if(auto==''){ auto=0; }
		
		if(tabb_ok==0){ return; }

		$0('span_paquetes_content');
		$('tabb_'+tab).className='noselected';
		$('tabb_'+ta).className='selected';
		tab=ta;
		
		switch(ta)
		{
			case "paquetes":		   
				$('video_thumbs').innerHTML='';	
				$1('span_paquetes_content');
			break;	
			
			case "video":
				if (hasReqestedVersion) 
				{		
					$('video_thumbs').innerHTML='<embed height="443" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDLocal')+'&amp;tipo=local' + ( (auto==1)?'&amp;autoplay=true':'&amp;autoplay=false' )+ '" src="'+videoplayer+'"  />';
				} 
				else 
				{
					$('video_thumbs').innerHTML=alternateContent;			
				}
			break;
			
			case "fotos":		   
				if (hasReqestedVersion) 
				{				
					$('video_thumbs').innerHTML='<embed height="515" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDLocal')+'&amp;tipo=local&autoplay=true" src="'+fotoplayer+'"  />';		
				} 
				else 
				{
					$('video_thumbs').innerHTML=alternateContent;			
				}
			break;
			
			case "que_visitar":		   
				$('video_thumbs').innerHTML='<div id="map_que_visitar" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
				'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="lugares_visitar"></div></div>';
				$('video_thumbs').innerHTML+=''
				+"	  <div class='geoposicionaror_caja linea'>"
				+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
				+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
				+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
				+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
				+"    />"
				+"    </div> ";
				
				camp_latitud  = "GeoLat";
				camp_longitud = "GeoLon";
				camp_zoom     = "UsuGeoZoom";
				
				que_visitar();			
			break;
			
			case "actividades":		   
				$('video_thumbs').innerHTML='<div id="map_actividades" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
				'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="actividades_visitar"></div></div>';
				$('video_thumbs').innerHTML+=''
				+"	  <div class='geoposicionaror_caja linea'>"
				+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
				+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
				+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
				+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
				+"    />"
				+"    </div> ";
				
				camp_latitud  = "GeoLat";
				camp_longitud = "GeoLon";
				camp_zoom     = "UsuGeoZoom";
				
				actividades();			
			break;			
			
			case "como_llegar":	
				
				$('video_thumbs').innerHTML='<div id="map_como_llegar" style="width:495px;height:430px; float:left;margin-left:5px !important;margin-left:2px;"></div>'+
				'<div  style=" margin-left:5px; width:217px !important; width:210px; height:443px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="path"></div></div>';
				$('video_thumbs').innerHTML+=''
				+"	  <div class='geoposicionaror_caja linea'>"
				+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
				+"    onkeyup=\"if(event.keyCode=='13'){ showAddress2(this.value); return false; }\""
				+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
				+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
				+"    />"
				+"    </div> ";	
				
				camp_latitud  = "UsuGeoLat";
				camp_longitud = "UsuGeoLon";
				camp_zoom     = "UsuGeoZoom";	
				
				get_point_by_address($v('UsuCiudad'));			
			break;	
		}
		
	}
	
	var  tabbactividades_ok=0;
	window.addEvent('domready',function(){ tabbactividades_ok=1; });	
	
	
	function tabbactividades(ta,auto)
	{
		if(auto==null){ auto=1;}
		if(auto==''){ auto=0; }
		
		if(tabbactividades_ok==0){ return; }

		$('tabb_'+tab).className='noselected';
		$('tabb_'+ta).className='selected';
		tab=ta;
		
		switch(ta)
		{

			case "video":
				if (hasReqestedVersion) 
				{		
					$('video_thumbs').innerHTML='<embed height="443" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDActividad')+'&amp;tipo=actividad' + ( (auto==1)?'&amp;autoplay=true':'&amp;autoplay=false' )+ '" src="'+videoplayer+'"  />';
				} 
				else 
				{
					$('video_thumbs').innerHTML=alternateContent;			
				}
			break;
			
			case "fotos":		   
				if (hasReqestedVersion) 
				{				
					$('video_thumbs').innerHTML='<embed height="515" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDActividad')+'&amp;tipo=actividad&autoplay=true" src="'+fotoplayer+'"  />';		
				} 
				else 
				{
					$('video_thumbs').innerHTML=alternateContent;			
				}
			break;
			
			case "que_visitar":		   
				$('video_thumbs').innerHTML='<div id="map_que_visitar" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
				'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="lugares_visitar"></div></div>';
				$('video_thumbs').innerHTML+=''
				+"	  <div class='geoposicionaror_caja linea'>"
				+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
				+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
				+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
				+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
				+"    />"
				+"    </div> ";
				
				camp_latitud  = "GeoLat";
				camp_longitud = "GeoLon";
				camp_zoom     = "UsuGeoZoom";
				
				que_visitar();			
			break;
			
			case "como_llegar":		   
				$('video_thumbs').innerHTML='<div id="map_como_llegar" style="width:495px;height:430px; float:left;margin-left:5px !important;margin-left:2px;"></div>'+
				'<div  style=" margin-left:5px; width:217px !important; width:210px; height:443px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="path"></div></div>';
				$('video_thumbs').innerHTML+=''
				+"	  <div class='geoposicionaror_caja linea'>"
				+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
				+"    onkeyup=\"if(event.keyCode=='13'){ showAddress2(this.value); return false; }\""
				+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
				+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
				+"    />"
				+"    </div> ";	
				
				camp_latitud  = "UsuGeoLat";
				camp_longitud = "UsuGeoLon";
				camp_zoom     = "UsuGeoZoom";	
		
				get_point_by_address($v('UsuCiudad'));			
			break;	
		}
		
	}	
	
	var  tabblugares_ok=0;
	window.addEvent('domready',function(){ tabblugares_ok=1; });	
	
	function tabblugares(ta,auto){
		
		if(auto==null){ auto=1;}
		if(auto==''){ auto=0; }
		
		if(tabblugares_ok==0){ return; }

		if($('tabb_'+tab))
			$('tabb_'+tab).className='noselected';
		
		$('tabb_'+ta).className='selected';
		tab=ta;
		switch(ta){
		case "video":		   
		if (hasReqestedVersion) {						
		$('video_thumbs').innerHTML='<embed height="443" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDLugar')+'&amp;tipo=lugar' + ( (auto==1)?'&amp;autoplay=true':'&amp;autoplay=false' )+ '" src="'+videoplayer+'"  />';
		} else {
		$('video_thumbs').innerHTML=alternateContent;						
		}
		break;
		case "fotos":		
		if (hasReqestedVersion) {								
		$('video_thumbs').innerHTML='<embed height="515" align="middle" width="722" type="application/x-shockwave-flash" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent" allowscriptaccess="sameDomain" name="VideoPlayer" bgcolor="#000000" quality="high" id="VideoPlayer" flashvars="ver='+$v('IDLugar')+'&amp;tipo=lugar&autoplay=true" src="'+fotoplayer+'"  />';		
		} else {
		$('video_thumbs').innerHTML=alternateContent;						
		}
		break;
		case "que_visitar":		   
		$('video_thumbs').innerHTML='<div id="map_que_visitar" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
		'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="lugares_visitar"></div></div>';
		$('video_thumbs').innerHTML+=''
		+"	  <div class='geoposicionaror_caja linea'>"
		+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#cccccc\"  "
		+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
		+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
		+"    onblur=\"if(this.value==''){ this.style.color='#cccccc'; this.value='"+text_ruta+"'; } \" "
		+"    />"
		+"    </div> ";			
		camp_latitud  = "GeoLat";
		camp_longitud = "GeoLon";
		camp_zoom     = "UsuGeoZoom";
		
		que_visitar();	
		break;
		case "como_llegar":		   
		$('video_thumbs').innerHTML='<div id="map_como_llegar" style="width:495px;height:430px; float:left;margin-left:5px !important;margin-left:2px"></div>'+
		'<div  style=" margin-left:5px; width:217px !important; width:210px; height:443px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="path"></div></div>';
		$('video_thumbs').innerHTML+=''
		+"	  <div class='geoposicionaror_caja linea'>"
		+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#cccccc\"  "
		+"    onkeyup=\"if(event.keyCode=='13'){ showAddress2(this.value); return false; }\""
		+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
		+"    onblur=\"if(this.value==''){ this.style.color='#cccccc'; this.value='"+text_ruta+"'; } \" "
		+"    />"
		+"    </div> ";			
		camp_latitud  = "UsuGeoLat";
		camp_longitud = "UsuGeoLon";
		camp_zoom     = "UsuGeoZoom";

		get_point_by_address($v('UsuCiudad'));

		break;
		
		case "donde_dormir":		  
			
			$('video_thumbs').innerHTML=''+
	    	'<select id="SelectTipo" onchange="buscar_locales_mapa_bounds_2(document.getElementById(\'lugares_visitar\'), \'donde_dormir\');" style="border:1px solid; position:absolute; left:130px; top:11px; background-color:#A3B8BD; z-index:10;">'+
			OpcionesTipos+
	    	'</select>'+
			'<div id="map_que_visitar" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
			'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="lugares_visitar"></div></div>';
			
			$('video_thumbs').innerHTML+=''
			+"	  <div class='geoposicionaror_caja linea' style='display:;'>"
			+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
			+"    onkeyup=\"if(event.keyCode=='13'){ showAddress33(this.value); return false; }\""
			+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
			+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
			+"    />"
			+"    </div> ";
			
			camp_latitud  = "GeoLat";
			camp_longitud = "GeoLon";
			camp_zoom     = "UsuGeoZoom";
			
			donde_dormir($v('GeoLat'),$v('GeoLon'),$v('GeoZoom')-1);
					
			buscar_locales_mapa_bounds_2(document.getElementById("lugares_visitar"), 'donde_dormir');

		break;
		
		case "donde_comer":		  
			
			$('video_thumbs').innerHTML = '<div id="map_donde_comer" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
										  '<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" >'+
										      '<div id="restaurantes"></div>'+
										  '</div>';
			
			$('video_thumbs').innerHTML+=''
			+"	  <div class='geoposicionaror_caja linea' style='display:;'>"
			+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
			+"    onkeyup=\"if(event.keyCode=='13'){ showAddress33(this.value); return false; }\""
			+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
			+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
			+"    />"
			+"    </div> ";
			
			camp_latitud  = "GeoLat";
			camp_longitud = "GeoLon";
			camp_zoom     = "UsuGeoZoom";
			
			donde_comer($v('GeoLat'),$v('GeoLon'),$v('GeoZoom')-1);
					
			buscar_locales_mapa_bounds_2(document.getElementById("restaurantes"), 'donde_comer');

		break;		
		
		case "actividades":		   
			
			$('video_thumbs').innerHTML='<div id="map_actividades" style="width:495px;height:430px; float:left;margin-left:5px;"></div>'+
			'<div  style="margin-left:5px; width:217px !important; width:210px; height:430px; float:left; overflow:scroll; background-color:#fff; " id="path_0" ><div id="actividades_visitar"></div></div>';
			$('video_thumbs').innerHTML+=''
			+"	  <div class='geoposicionaror_caja linea'>"
			+"    <input type=\"text\" value=\""+text_ruta+"\" id=\"mapsearch\" style=\"margin-right:2px; width:495px;background-color:#fff; color:#000000\"  "
			+"    onkeyup=\"if(event.keyCode=='13'){ showAddress3(this.value); return false; }\""
			+"    onfocus=\"if(this.value=='"+text_ruta+"'){ this.value=''; this.style.color='#000000'; } \" "
			+"    onblur=\"if(this.value==''){ this.style.color='#000000'; this.value='"+text_ruta+"'; } \" "
			+"    />"
			+"    </div> ";
			
			camp_latitud  = "GeoLat";
			camp_longitud = "GeoLon";
			camp_zoom     = "UsuGeoZoom";
			
			actividades();		
			
		break;			
		}
		
	}
	
	
      function donde_dormir(xlat,xlon,xzoom) {
	  
      	if(GBrowserIsCompatible()) {
	  		
			bounds = new GLatLngBounds(); 
			
			map = new GMap2(document.getElementById("map_que_visitar"),{ size: new GSize(495,430) });		
			
			var customUI = map.getDefaultUI();

			map.setUI(customUI);		
				
			var point = new GLatLng(xlat, xlon);
			
			map.setCenter(point,xzoom*1);
	
			createMarker(point);		
			
			GEvent.addListener(map, "moveend", function() {
				if(winopen==0 && updatinmapa==0){
					buscar_locales_mapa_bounds_2(document.getElementById("lugares_visitar"), 'donde_dormir'); 	
				}
			});
			winopen=0;
			GEvent.addListener(map, "infowindowopen", function() {
				winopen=1; 	
			});	
			GEvent.addListener(map, "infowindowclose", function() {
				winopen=0; 	
			});			
			
				
		  }
				   	
		}	
      
      function donde_comer(xlat,xlon,xzoom) 
      {
        	if(GBrowserIsCompatible()) 
        	{
	  			bounds = new GLatLngBounds(); 
	  			map = new GMap2(document.getElementById("map_donde_comer"),{ size: new GSize(495,430) });		
	  			var customUI = map.getDefaultUI();
	  			map.setUI(customUI);		
	  			var point = new GLatLng(xlat, xlon);
	  			map.setCenter(point,xzoom*1);
	  			createMarker(point);
	  			
	  			GEvent.addListener(map, "moveend", function() 
	  			{
	  				if(winopen==0 && updatinmapa==0)
	  				{
	  					buscar_locales_mapa_bounds_2(document.getElementById("restaurantes"), 'donde_comer'); 	
	  				}
	  			});
	  			
	  			winopen=0;
	  			GEvent.addListener(map, "infowindowopen", function(){winopen=1;});	
	  			GEvent.addListener(map, "infowindowclose", function(){winopen=0;});			
  		  	}
      }	      
	  
	var map2;
	
	function como_llegar()
	{
			$1('path_0');
			
			bounds = new GLatLngBounds(); 
			
			map2 = new GMap2(document.getElementById("map_como_llegar"),{ size: new GSize(495,443) });		
			
			var customUI = map2.getDefaultUI();

			map2.setUI(customUI);		
			
			geocoder = new GClientGeocoder();
			
			var point = new GLatLng($v('GeoLat'), $v('GeoLon'));
			
			map2.setCenter(point,9);

		    document.getElementById('path').innerHTML='';

			  var gdir=new GDirections(map2, document.getElementById("path"));
		
			  GEvent.addListener(gdir,"error", function() {

				$0('path_0');
				map2 = new GMap2(document.getElementById("map_como_llegar"),{ size: new GSize(718,443) } );	
				
				var customUI = map2.getDefaultUI();
	
				map2.setUI(customUI);		
					
				var point = new GLatLng($v('GeoLat'), $v('GeoLon'));
				
				map2.setCenter(point,$v('GeoZoom')*1);
								
				marcarpunto2(new GLatLng($v('GeoLat'), $v('GeoLon')));				
				//alert($v('GeoZoom'));
				
			  });
		
			  var poly;
			  GEvent.addListener(gdir, "load", function() {
																		
				if (poly) map.removeOverlay(poly);
				poly = gdir.getPolyline();
				map2.addOverlay(poly);
				
			  });  
			
	        gdir.load("from: "+ new GLatLng($v('UsuGeoLat'), $v('UsuGeoLon')).toUrlValue(6) + " to: " + new GLatLng($v('GeoLat'), $v('GeoLon')).toUrlValue(6), {getPolyline:true, "locale": $v('UsuLan')});
	
	}


	var map2;
	var json_lugares;
	var winopen3;
	var winopen;
	function que_visitar(){
				
		bounds = new GLatLngBounds();  
		
		map3 = new GMap2(document.getElementById("map_que_visitar"),{ size: new GSize(495,430) });		

		geocoder = new GClientGeocoder();
		
		var customUI = map3.getDefaultUI();

		map3.setUI(customUI);		
					
		var point = new GLatLng($v('GeoLat'), $v('GeoLon'));
		
		map3.setCenter(point,$v('GeoZoom')*1);
		
		var marr = new GMarker(point,{ title: '' } );
		  
		map3.addOverlay(marr);		

		bounds.extend(marr.getPoint());

		if(json_lugares != '' ){

		//var json=eval('(' + json_lugares + ')');
		
		//var json=JSON.parse(json_lugares);
		
		var json = json_lugares;
		
		$('lugares_visitar').innerHTML = "<b class='pesta_lugares' id='pesta_lugares'>Lugares</b><a href='#' id='link_volver' style='display:none;' class='link_volver' onclick=\"javascript:volver_lista_lugares(); return false;\" rel='nofollow'>"+JS_volver_lugares+"</a><ul class='lista_lugares' id='lista_lugares'>";
		
		for(var e=0;e<json.n;e++){
			
			markerpunto_lugares(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].lat,json.items[e].lon,json.items[e].tipo,json.items[e].img);
			
		}
		
		$('lugares_visitar').innerHTML = $('lugares_visitar').innerHTML + "</ul><div id='rutas_lugares' style='display:none; clear:both; '></div>";

		map3.setZoom(map3.getBoundsZoomLevel(bounds));
		map3.setCenter(bounds.getCenter());
		
			GEvent.addListener(map3, "moveend", function() {
				if(winopen3==0){
					buscar_lugares_mapa_bounds(); 	
				}
			});	
			winopen3=0;
			GEvent.addListener(map3, "infowindowopen", function() {
				winopen3=1; 	
			});	
			GEvent.addListener(map3, "infowindowclose", function() {
				winopen3=0; 	
			});				
		}
	
	}
	
	var json_actividades;
	
	function actividades(){
		
		bounds = new GLatLngBounds();  
		
		map3 = new GMap2(document.getElementById("map_actividades"),{ size: new GSize(495,430) });		

		geocoder = new GClientGeocoder();
		
		var customUI = map3.getDefaultUI();

		map3.setUI(customUI);		
					
		var point = new GLatLng($v('GeoLat'), $v('GeoLon'));
		
		map3.setCenter(point,$v('GeoZoom')*1);
		
		var marr = new GMarker(point,{ title: '' } );
		  
		map3.addOverlay(marr);		

		bounds.extend(marr.getPoint());

		if(json_actividades != '' )
		{
			var json = json_actividades;
			
			$('actividades_visitar').innerHTML = "<b class='pesta_actividades' id='pesta_actividades'>"+JS_Actividades+"</b>" +
												 "<a href='#' id='link_volver_actividades' style='display:none;' class='link_volver'" +
												 " onclick=\"javascript:volver_lista_actividades();" +
												 " return false;\" rel='nofollow'>"+JS_volver_actividades+"</a>" +
												 "<ul class='lista_lugares' id='lista_actividades'>";
			
			for(var e=0;e<json.n;e++)
			{
				marker_actividades(e, new GLatLng(json.items[e].lat,json.items[e].lon) , json.items[e].nom, json.items[e].des, json.items[e].id, json.items[e].lat,json.items[e].lon,json.items[e].tipo,json.items[e].img);
			}
			
			$('actividades_visitar').innerHTML = $('actividades_visitar').innerHTML + "</ul><div id='rutas_actividades' style='display:none; clear:both; '></div>";
	
			map3.setZoom(map3.getBoundsZoomLevel(bounds));
			map3.setCenter(bounds.getCenter());
			
			GEvent.addListener(map3, "moveend", function() {
				if(winopen3==0){
					buscar_actividades_mapa_bounds(); 	
				}
			});	
			winopen3=0;
			GEvent.addListener(map3, "infowindowopen", function() {
				winopen3=1; 	
			});	
			GEvent.addListener(map3, "infowindowclose", function() {
				winopen3=0; 	
			});				
		}
	
	}	

	function volver_lista_actividades(){
		$1('lista_actividades');
		$0('rutas_actividades');
		$1('pesta_actividades');
		$0('link_volver_actividades');
	}
	
	function volver_lista_lugares(){
		$1('lista_lugares');
		$0('rutas_lugares');
		$1('pesta_lugares');
		$0('link_volver');
	}
	
    var poly_lugar;
	var gdir;
	function como_llegar_a_lugar(lat,lon){
		  
		  if(gdir){
    	  	gdir.clear();
		  }
		  
		  document.getElementById('rutas_lugares').innerHTML='';
		  
		  gdir=new GDirections(map3,document.getElementById('rutas_lugares'));
	
		  GEvent.addListener(gdir,"error", function() {
			
		  });
	
		  GEvent.addListener(gdir, "load", function() {
			if (poly_lugar){ 
			map3.removeOverlay(poly_lugar);
			}
			poly_lugar = gdir.getPolyline();
			map3.addOverlay(poly_lugar);
			
			//alert(gdir.getSummaryHtml());
			
			$0('lista_lugares');
			$1('rutas_lugares');
			$0('pesta_lugares');
			$1('link_volver');	

		  });  		
		
		gdir.load("from: "+ new GLatLng($v('GeoLat'), $v('GeoLon')).toUrlValue(6) + " to: " + new GLatLng(lat,lon).toUrlValue(6), {preserveViewport:true,getPolyline:true, "locale": $v('UsuLan')});
	}
	
	var poly_actividad;	
	function como_llegar_a_actividad(lat,lon){
		  
		  if(gdir){
  	  	gdir.clear();
		  }
		  
		  document.getElementById('rutas_actividades').innerHTML='';
		  
		  gdir=new GDirections(map3,document.getElementById('rutas_actividades'));
	
		  GEvent.addListener(gdir,"error", function() {
			
		  });
	
		  GEvent.addListener(gdir, "load", function() {
			if (poly_actividad){ 
			map3.removeOverlay(poly_actividad);
			}
			poly_actividad = gdir.getPolyline();
			map3.addOverlay(poly_actividad);
			
			//alert(gdir.getSummaryHtml());
			
			$0('lista_actividades');
			$1('rutas_actividades');
			$0('pesta_actividades');
			$1('link_volver_actividades');	

		  });  		
		
		gdir.load("from: "+ new GLatLng($v('GeoLat'), $v('GeoLon')).toUrlValue(6) + " to: " + new GLatLng(lat,lon).toUrlValue(6), {preserveViewport:true,getPolyline:true, "locale": $v('UsuLan')});
	}	
	
	function como_llegar_a_local(lat,lon){
		  
		  if(gdir){
    	  	gdir.clear();
		  }
		  
		  document.getElementById('rutas_lugares').innerHTML='';
		  
		  gdir=new GDirections(map,document.getElementById('rutas_lugares'));
	
		  GEvent.addListener(gdir,"error", function() {
			
		  });
	
		  GEvent.addListener(gdir, "load", function() {
			if (poly_lugar){ 
			map.removeOverlay(poly_lugar);
			}
			poly_lugar = gdir.getPolyline();
			map.addOverlay(poly_lugar);
			
			//alert(gdir.getSummaryHtml());
			
			$0('lista_lugares');
			$1('rutas_lugares');
			$0('pesta_lugares');
			$1('link_volver');	

		  });  		
		
		gdir.load("from: "+ new GLatLng($v('GeoLat'), $v('GeoLon')).toUrlValue(6) + " to: " + new GLatLng(lat,lon).toUrlValue(6), {preserveViewport:true,getPolyline:true, "locale": $v('UsuLan')});
		

		
	}
	
	
	function marcarpunto2(point){
		
	  var mark = new GMarker(point);
		  
	  map2.addOverlay(mark);
		
	}

	function publicar_comentario(tipo)
	{
		$('error_block_title_external').empty();
		$('error_block_url_external').empty();
		$('error_block_com').empty();
		
		if($('comentario_text').value.trim()==''){
			$('error_block_com').innerHTML=JS_escribir_comentario;
			return false;
		}
			 
		var media = ($('com_chek_foto').checked==false && $('com_chek_video').checked==false)?'':( ($('com_chek_foto').checked)?'imagen':'video' ) ;
		
		if(media=='imagen')
		{
			if($('upload_input').value.trim()=='')
			{
				$('error_block_com').innerHTML=JS_seleccionar_imagen;
				return false;
			}			
			if($('com_ima_nombre').value.trim()=='')
			{
				$('error_block_com').innerHTML=JS_escribir_nombre_imagen;
				return false;
			}	
		}
		
		if(media=='video')
		{
			if($('com_chek_local').checked)
			{
				if($('upload_input').value.trim()=='')
				{
					$('error_block_com').innerHTML=JS_seleccionar_video;
					return false;
				}
				if($('com_vid_nombre').value.trim()=='')
				{
					$('error_block_com').innerHTML=JS_escribir_nombre_video;
					return false;
				}				
			}
			else
			{
				if($('url_external').value.trim()=='' || !videoObtenido)
				{
					$('error_block_url_external').innerHTML=JS_obtener_video + ' ' + videoProviders[$('external_type').value].name;
					return false;
				}				
				if($('external_title').value.trim()=='')
				{
					$('error_block_title_external').innerHTML=JS_escribir_nombre_video;
					return false;
				}
			}
		}		
		
		
		var url='';
		var nombre='';
		var descripcion='';
		var external_thumbnail = '';
		var external_type = '';
		
		if(media=='imagen')
		{
			url = $v('upload_com_in_fot');
			nombre = $v('com_ima_nombre');
		}
		if(media=='video')
		{
			if($('com_chek_local').checked)
			{
				url = $v('upload_com_in_vid');
				nombre = $v('com_vid_nombre');
			}
			else
			{
				url = $v('url_external');
				nombre = $v('external_title');	
				external_thumbnail = $v('external_thumbnail');
				external_type = $v('external_type');
			}
		}		

		datos = { 
					action		: 'INSERTAR_COMENTARIO',
					comentario 	: $v('comentario_text'),
					media_tipo	: media,
					media_url	: url,
					media_nombre: nombre,
					external_type: external_type,
					external_thumbnail: external_thumbnail,
					valoracion  : $v('com_votacion'),
					ajax		: '1'
				};	

		eval("datos0={"+tipo+": $v('com_id')};");
		datos = $merge(datos0, datos);
		$('error_block_com').innerHTML='';
		$('mensaje_exito').innerHTML='';
		url="modulos/comentarios/comentarios.php?ran="+Math.random();
		$('publicar_comentario_buton').value=JS_publicando;
		$('publicar_comentario_buton').disabled=true;
		
		new Ajax(url, { method:'post', data:datos, onComplete: function(eee)
		{
			$('publicar_comentario_buton').disabled=false;
			$('publicar_comentario_buton').value=JS_publicar;
			var media = ($('com_chek_foto').checked==false && $('com_chek_video').checked==false)?'':( ($('com_chek_foto').checked)?'imagen':'video' ) ;
			$('comentario_text').value='';
			show_com_form('');
			$('com_chek_foto').checked=false;
			$('com_chek_video').checked=false;
			
			if(eee=='')
			{
				if(media=='video' && external_type == '')
				{
					$('mensaje_exito').innerHTML='Comentario publicado exitosamente<br>Tu vídeo está siendo procesado, y te avisaremos cuando sea subido.';
				}
				setTimeout("$('mensaje_exito').innerHTML='';","10000");
				
				pintar_comentarios(tipo,$v('com_id'));
				
			} 
			else 
			{
				var json=eval("(" + eee + ")");
				if(json.header=='Error')
				{
					$('error_block_com').innerHTML=json.message;
				}
			}
			
		}}).request();							
		
	}

	function mostrarComentarios(tipo,id,pagina){
		

		datos = { 
					action		: 'MOSTRAR_COMENTARIOS',			
					page		: pagina,			
					ajax		: '1'
					
				};								
		
		eval("datos0={"+tipo+": id};");
		
		datos = $merge(datos0, datos);

		new Ajax('modulos/comentarios/comentarios.php', { method:'get', data:datos, onComplete: function(eee){		
				
				$('list_comentarios').innerHTML=eee;
				
		}}).request();
		
	}
	
	function pintar_comentarios(tipo,id){
		
		datos = { 
					action		: 'MOSTRAR_COMENTARIOS',
					ajax		: '1'										
				};									
		
		eval("datos0={"+tipo+": id};");
		
		datos = $merge(datos0, datos);
		
		new Ajax('modulos/comentarios/comentarios.php', { method:'get', data:datos, onComplete: function(eee){		
				
				$('list_comentarios').innerHTML=eee;
				
		}}).request();
		
	}
	
	function EliminarFavorito(id,usuario){
		

		datos = { 
					action		: 'ELIMINAR_FAVORITO',
					id_usuario	: usuario,				
					id_favorito	: id,
					ajax		: '1'
					
				};								
				
		new Ajax('modulos/usuarios/usuarios.php', { method:'post', data:datos, onComplete: function(eee){		
				
				if(eee.trim()==''){
					
					$0('favorito_'+id);
					 
				} else {
				
					var json=eval("(" + eee + ")");
					if(json.header=='Error'){
						$('errorEliminar_'+id).innerHTML="<span style='color:red;'>"+json.message+"</span>";
					}		
					
				}
				
		}}).request();
		
	}	
	
	function chek_com_form(dis)
	{
		videoObtenido = false;
		if($('videoScript'))
			$('videoScript').remove();
		
		if( ($('com_chek_foto').checked==false) && ($('com_chek_video').checked==false) )
		{
			show_com_form('');
		} 
		else 
		{
			if(dis.checked)
			{
				if(dis.id=='com_chek_foto')
				{ 
					$('com_chek_video').checked=false; 
					show_com_form('foto');
				}
				if(dis.id=='com_chek_video')
				{ 
					$('com_chek_foto').checked=false; 
					show_com_form('video');
				}
			}					
		}
		
		return false;
	}
	//-------------------------------------------------------------
	var videoObtenido = false;
	
	function show_video_form(type)
	{
		$('com_chek_local').checked = false;
		$('com_chek_youtube').checked = false;
		$('com_chek_vimeo').checked = false;
		$('com_chek_dailymotion').checked = false;
		$('com_chek_metacafe').checked = false;
		$('com_vid_nombre').value = '';
		$('url_external').value = '';
		$('external_title').value = '';
		$('error_block_url_external').setText('');
		$('error_block_title_external').setText('');
		$0('com_local');
		$0('com_external');
		$1('com_content_video');
		videoObtenido = false;
		$('external_button').disabled = false;
		if($('videoScript'))
			$('videoScript').remove();
		$('comment-player').empty();
		$0('comment-player');
		
		if(type === 'local')
		{

				$('com_chek_local').checked = true;
				$1('com_local');
				
				$('com_video_upload').innerHTML = render_upload('com','vid','','img/blank.jpg','modulos/media/video.upload.preview.php','vid_coment');														
				
				if($('image_com_vid_default'))
					$0('image_com_vid_default'); 
					
				$('com_content_video').setStyles({
												 "padding-left":"3px",
												 "padding-top":"10px",
												 //"padding-right":"10px",
												 "height":"140px",
												 "width":"610px"
												 });
		}
		else
		{
			$('com_chek_' + type).checked = true;
			$1('com_external');
			$1('comment-player');
			$('comment-player').style.display = 'block';
			$('external_type').value = type;
		}
		
		$('bl_comment').setStyles({"height":"245px"});
	}
	
	var videoProviders = {
						  youtube: {name:'Youtube', regex:/https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&amp;(?:amp;)?)*v(?:&lt;[A-Z]+&gt;)?=([0-9a-zA-Z\-\_]+))/i}, 
						  vimeo: {name:'Vimeo' , regex:/http:\/\/(www\.)?vimeo.com\/([0-9]+)/i},
						  dailymotion: {name:'Dailymotion' , regex:/http:\/\/(www\.)?dailymotion.com\/video\/(.+)/i},
						  metacafe: {name:'Metacafe' , regex:/http:\/\/(www\.)?metacafe.com\/watch\/([0-9]+)\/(.+)/i}
						 };
	
	function visualize_video(type)
	{
		$('comment-player').empty();
		$('error_block_url_external').empty();
		
		if($('url_external').value == '')
		{
			$('error_block_url_external').setHTML('Debe insertar la URL del video');
			return false;
		}
		
		if(!videoProviders[type].regex.test($('url_external').value))
		{
			$('error_block_url_external').setHTML('Debe insertar la URL de un video de ' + videoProviders[type].name + ' válida');
			return false;
		}
		
		insertVideo($('url_external').value, type, 'parseOEmbedResponse');
	}
	
	var vidType = '';
	function insertVideo(videoURL, videoType, callback) 
	{
		vidType = videoType;
		var endpoint = 'http://oohembed.com/oohembed/';
		var url = endpoint + '?url=' + videoURL + '&callback=' + callback;
		
		if($('videoScript'))
			$('videoScript').remove();
		
		var js = document.createElement('script');
		js.setAttribute('type', 'text/javascript');
		js.setAttribute('src', url);
		js.setAttribute('id', 'videoScript');
		document.getElementsByTagName('head').item(0).appendChild(js);
	}	
	
	function parseOEmbedResponse(oEmbedResponse)
	{
		if(oEmbedResponse == '' ||  oEmbedResponse.title === undefined)
		{
			$('error_block_url_external').setHTML('El video indicado no existe');
			return false;
		}
		
		$('external_title').value = oEmbedResponse.title;
		oEmbedResponse.html = resizePlayer(oEmbedResponse.html, vidType, 160, 120);
		$('comment-player').setHTML(oEmbedResponse.html);
		videoObtenido = true;
		$('external_button').disabled = true;
		$('external_thumbnail').value = oEmbedResponse.thumbnail_url;
	}
	
	function renderExternalPlayer(oEmbedResponse)
	{
		if(oEmbedResponse == '' ||  oEmbedResponse.title === undefined)
		{
			$1('caja_aviso');
			$1('caja_aviso').setHTML('<span class="corner_1"></span><span class="corner_2"></span><span class="corner_3"></span><span class="corner_4"></span>' + JS_error_video);
			return false;
		}
		
		oEmbedResponse.html = resizePlayer(oEmbedResponse.html, vidType, 722, 443);
		$('content_embed').setHTML(oEmbedResponse.html);
	}	
	
	function videoURLChange()
	{
		videoObtenido = false;
		$('external_button').disabled = false;
		$('comment-player').empty();
		if($('videoScript'))
			$('videoScript').remove();		
	}
	
	function resizePlayer(playerCode, type, width, height)
	{
		playerCode = playerCode.replace(/(width\s*=\s*["'])[0-9]+(["'])/ig, "width='" + width + "'");
		playerCode = playerCode.replace(/(height\s*=\s*["'])[0-9]+(["'])/ig,  "height='" + height + "'");
		playerCode = playerCode.replace(/(width\s*:\s*)[0-9]+(px)/ig, "width: " + width + "px");
		playerCode = playerCode.replace(/(height\s*:\s*)[0-9]+(px)/ig,  "height: " + height + "px");
		
		if(type === 'dailymotion')
		{
			playerCode = playerCode.match(/<object.*?<\/object>/i);
		}
		
		return playerCode;
	}
	//--------------------------------------------------------------
	function show_com_form(tab)
	{
		$('error_block_com').innerHTML='';						
		$0('com_content_foto');
		$0('com_content_video');
		$('com_foto_upload').innerHTML='';
		$('com_video_upload').innerHTML='';
		$('com_ima_nombre').value='';
		$('com_ima_descri').value='';							
		$('com_vid_nombre').value='';
		$('com_vid_descri').value='';
		$('bl_comment').setStyles({"height":"100px"});
		
		switch(tab)
		{
			case "foto":
				
				$1('com_content_foto');
				
				$('com_foto_upload').innerHTML=render_upload('com','fot','','img/blank.jpg','modulos/media/image.upload.preview.php','img_coment');																						
				
				$('com_content_foto').setStyles({
												"padding-left":"3px",
												"padding-top":"10px",
												//"padding-right":"10px",
												"height":"140px",
												"width":"610px"
												});
				
				$('bl_comment').setStyles({"height":"245px"});
				
			break;
			
			case "video":
			
				show_video_form('local');
				
			break;						
		}
		
	}
	
	function agregar_favorito(tipo,id){
		
		if(tipo=='local'){
			
			url="modulos/usuarios/usuarios.php?ran="+Math.random();			
			datos = {
					id_local	: id,
					action		: "AGREGAR_FAVORITOS",
					ajax		: "1"
					}
			mensaje = JS_mensaje_local_favoritos;	
					
		} else if(tipo=='lugar'){
			
			url="modulos/usuarios/usuarios.php?ran="+Math.random();						
			datos = {
					id_lugar	: id,
					action		: "AGREGAR_FAVORITOS",				
					ajax		: '1'
					}			
			mensaje = JS_mensaje_lugar_favoritos;	
					
		}

		new Ajax(url, { method:'post', data:datos, onComplete: function(eee){

			$0('link_favorito');
				if(eee==''){
					$('mensaje_favorito').innerHTML=mensaje;
				} else {
					var json=eval("(" + eee + ")");
					if(json.header=='Error'){
						$('mensaje_favorito').innerHTML="<span style='color:red;'>"+json.message+"</span>";
					}					
				}			
			
		} } ).request();
	
	}
	
	function agregar_newsletter(){
		
		$('newsletter_mensaje').innerHTML='';
		$('newsletter_button').disabled==true;
		if($('newsletter_check').checked==false){

			$('newsletter_button').disabled==false;
			$('newsletter_mensaje').innerHTML='<span style="color:red;">'+JS_aceptar_condiciones+'</span>';
			
		} else { 
		
			url="modulos/usuarios/usuarios.php?ran="+Math.random();
			
			datos = {
					email		: $v('newsletter_email'),
					action		: "SUSCRIBIR_NEWSLETTER",
					ajax		: "1"
					}
						
			new Ajax(url, { method:'post', data:datos, onComplete: function(eee){

				$('newsletter_button').disabled==false;
				$('newsletter_check').checked=false;
				$('newsletter_email').value='';
				if(eee==''){
					$('newsletter_mensaje').innerHTML=JS_suscripcion_realizada;
				} else {
					var json=eval("(" + eee + ")");
					if(json.header=='Error'){
						$('newsletter_mensaje').innerHTML="<span style='color:red;'>"+json.message+"</span>";
					}					
				}
				
			} } ).request();
		
		}
		
	}


/* Scripts Bloque reservas */

function reserva_activar(ok)
{
	if(ok==1)
	{
		$('disponible').setStyles({'display':'block'});
		$('no_disponible').setStyles({'display':'none'});		
		$('reserva-boton').innerHTML = '<a onclick="validar_reserva();" href="javascript:void(0);" id="confirmacion_reserva_enviar2">'+JS_RESERVAR+'</a>';
		$('reserva-boton').setOpacity(1);
		$('bloque-reserva-pruebafecha').setStyles({'display':'none'});	
		$('bloque-reserva-soloxhab').setStyles({'display':'block'});
	}else if(ok==0){
		$('reserva-boton').setOpacity(0.20);
		$('reserva-boton').innerHTML = '<img src="/img/boton_reservar.gif" />';
		$('disponible').setStyles({'display':'none'});
		$('no_disponible').setStyles({'display':'block'});
		$('bloque-reserva-precio').innerHTML = '';
		$0('bloque-reserva-precio');
		$('bloque-reserva-pruebafecha').setStyles({'display':'block'});
		$('bloque-reserva-soloxhab').setStyles({'display':'none'});
	}
	
}


function un_dia_mas(dia){
	var diamasY = dia.substr(0,4);
	var diamasM = eval(1*dia.substr(5,2));
	var diamasD = eval(1*dia.substr(8,2) + 1 );	
	dia=diamasY+","+diamasM+","+diamasD;
	//alert(dia);
	diamasY = new Date(dia).getFullYear();
	diamasM = eval(new Date(dia).getMonth() + 1);
	diamasD = new Date(dia).getDate();
	diamasM = (diamasM<10)?"0"+diamasM:diamasM;
	diamasD = (diamasD<10)?"0"+diamasD:diamasD;
	return diamasY+"-"+diamasM+"-"+diamasD;
}

function disponibilidad()
{	

	$('bloque-reserva-soloxhab').innerHTML='';
	$1('bloque-reserva-soloxhab');
	
	if (TTipo=='local')
	{
	   var hoydia = new Date().getDate();
	   var hoyano = new Date().getFullYear();
	   var hoymes = new Date().getMonth() + 1;
	   var hoy=10000*hoyano + 100*hoymes + 1*hoydia;
	   var fechaentrada=10000*$('fechaentrada').value.substr(0,4) + 100*$('fechaentrada').value.substr(5,2) + 1*$('fechaentrada').value.substr(8,2);
	   var fechasalida=10000*$('fechasalida').value.substr(0,4) + 100*$('fechasalida').value.substr(5,2) + 1*$('fechasalida').value.substr(8,2);
	
	
	   if(fechasalida<=fechaentrada){
		
		if(vfechaentrada != $('fechaentrada').value){
			$('fechasalida').value = un_dia_mas($('fechaentrada').value);
		} else if(vfechasalida != $('fechasalida').value){
			$('fechasalida').value = vfechasalida;
		}			
		
	   }
	
	
	   vfechaentrada = $('fechaentrada').value;
	   vfechasalida = $('fechasalida').value;
	}


	if($('res_tipo').value=="") return false;	
	if($('res_tipo').value=="-") return false;
	
	
	if(TTipo=='local')
	{
	   url="/modulos/reservas/reservas.php?action=VERIFICAR_DISPONIBILIDAD_PRECIO&ran="+Math.random();
	   datos = {
		fecha_entrada: $('fechaentrada').value,
		fecha_salida: $('fechasalida').value,
		id_tipo_estancia: parseInt($('res_tipo').value),
		numero_habitaciones: parseInt($('habitaciones').value),
		numero_personas: parseInt($('res_pax').value)
	   };
	}
	else
	{
	   url="/modulos/paquetes/paquetes.php?action=VERIFICAR_DISPONIBILIDAD_PRECIO_PAQUETE&ran="+Math.random();
	   datos = {
		id_fecha_paquete: $('fechas_paquetes').value,
		id_tipo_estancia: parseInt($('res_tipo').value),
		numero_habitaciones: parseInt($('habitaciones').value),
		numero_personas: parseInt($('res_pax').value)
	   };
	}
	new Ajax(url, { method:'post', data:datos, onComplete: function(eee){

		var json=eval("(" + eee + ")");
		$('bloque-reserva-soloxhab').setStyles({'display':'none'});	
		
		if(TTipo=='local')
		{
			var estancia_minima = json.estancia_minima;
			if(estancia_minima > 1)
			{
				$1('estancia_minima');
				$('noches').innerHTML = estancia_minima;
			}		
			else
			{
				$0('estancia_minima');
				$('noches').innerHTML = '';			
			}
		}
		
		var disp = json.disponible;
		if(disp == 0)
		{
			reserva_activar(0);
			
		} 
		else if(disp == 1)
		{
			var precio = json.precio;
			
			$('bloque-reserva-precio').innerHTML = "Total " + precio + "&euro;";
			$1('bloque-reserva-precio');

			reserva_activar(1);
			
			var estancias_disponibles = json.estancias_disponibles;
			if(estancias_disponibles>0 && estancias_disponibles<=5)
			{
				$('bloque-reserva-soloxhab').innerHTML = "s&oacute;lo queda(n) " + estancias_disponibles + " habitacion(es)!";
				$('bloque-reserva-soloxhab').setStyles({'display':'block'});
			}
		}

		var dias = json.dias;
		if(dias < estancia_minima)
		{
			$('reserva-boton').setOpacity(0.20);
			$('reserva-boton').innerHTML = '<img src="/img/boton_reservar.gif" />';	
		}
		

	} } ).request();
}
function cambiar_tipo_hab()
{
	var tipo = $('res_tipo').value;
	if(tipo == "-")
	{
		$('res_pax').empty();
		$('habitaciones').empty();
		reserva_activar(0);
	}else{
		// $('habitaciones').empty();
		var numhab = disp_est[tipo];
		var strhab = '<select style="width:50px;" name="habitaciones" id="habitaciones" onchange="cambiar_num_hab(); disponibilidad();">';
		for(i=1; i<=disp_est[tipo]; i++)
		{
			strhab = strhab + "<option value='" + i + "'>" + i + "</option>\r\n";
		}
		strhab = strhab + '</select>';
		$('combohabitaciones').innerHTML = strhab;
		
		// $('res_pax').empty();
		var numpax = maxpax[tipo];
		var strmaxpax = '<select name="personas" id="res_pax" onchange="disponibilidad();">';
		for(i=maxpax[tipo]; i>=1; i--)
		{
			if (i!=2)
			   strmaxpax = strmaxpax + "<option value='" + i + "'>" + i + "</option>\r\n";
			else
			   strmaxpax = strmaxpax + "<option selected value='" + i + "'>" + i + "</option>\r\n";
		}
		strmaxpax = strmaxpax + '</select>';
		$('combopersonas').innerHTML = strmaxpax;
	}
}
function cambiar_num_hab()
{
	var tipo = $('res_tipo').value;
	$('res_pax').empty();
	var numpax = maxpax[tipo];
	var numhab = $('habitaciones').value;
	
	numpax = numpax * numhab;
	defaultnumpax = 2 * numhab;
	
	// var strmaxpax = "";
	var strmaxpax = '<select name="personas" id="res_pax" onchange="disponibilidad();">';
	// for(i=1; i<=numpax; i++)
	for(i=numpax; i>=numhab; i--)
	{
	        if (i==defaultnumpax)
		   strmaxpax = strmaxpax + "<option selected value='" + i + "'>" + i + "</option>\r\n";
		else
		   strmaxpax = strmaxpax + "<option value='" + i + "'>" + i + "</option>\r\n";
	}
	strmaxpax = strmaxpax + '</select>';
	$('combopersonas').innerHTML = strmaxpax;
	// $('res_pax').innerHTML = strmaxpax;
}
var caja_validando=0;
function validar_reserva()
{	
	if(caja_validando==1){
		return false;	
	}
	caja_validando=1;
	if($('buton_confirmar_loader').innerHTML==""){
	
		$('buton_confirmar_loader').innerHTML=JS_reservando+"...";
		

		if(TTipo=='local'){
		        var url = "/modulos/reservas/reservas.php?action=RESERVAR&ran="+Math.random();
			
			datos = {
				fecha_entrada: $('fechaentrada').value,
				fecha_salida: $('fechasalida').value,
				id_tipo_estancia: $('res_tipo').value,
				numero_habitaciones: $('habitaciones').value,
				numero_personas: $('res_pax').value
			};
		
		} else if(TTipo=='paquete'){
		        var url = "/modulos/paquetes/paquetes.php?action=RESERVAR_PAQUETE&ran="+Math.random();
			
			datos = {
				id_fecha_paquete: $('fechas_paquetes').value,
				id_tipo_estancia: $('res_tipo').value,
				numero_habitaciones: $('habitaciones').value,
				numero_personas: $('res_pax').value
			};			
			
		}
		
		new Ajax(url, { method:'post', data:datos, onComplete: function(eee){
	
			$('buton_confirmar_loader').innerHTML="";
			
			var json=eval("(" + eee + ")");
			
			var action = json.action;
			if(action=='error'){
				// $('error_block').innerHTML=json.message;
				alert("Error:" + json.value);
				caja_validando=0;
			}else if(action=='login'){
				ventana_form_ccl('modulos/usuarios/usuarios.php?action=MOSTRAR_INICIAR_SESION',440,390);
				caja_validando=0;
			}else if(action=='redirect'){
				window.location = json.value;
			}
	
		} } ).request();
	
	}
	
}

function over_face(a){
$('caritas_celeste').setStyles({'background-position': eval(25*a - 125)+'px 0px'});
}
function clic_face(a){
$('com_votacion').value=a;
$('caritas_celeste').setStyles({'background-position': eval(25*a - 125)+'px 0px'});
}	
function out_face(){
$('caritas_celeste').setStyles({'background-position': eval(25*$v('com_votacion') - 125)+'px 0px'});
}			
						
var vopen_bloque_clima=0;
function open_bloque_clima(){
	if(vopen_bloque_clima==1){
		new Fx.Styles($('clima_marco'), {duration:500, onComplete: function(){ 
		vopen_bloque_clima=0;
		$('clima_marco').setStyles({'display':'none'});
		//$('clima_marco').setStyle('height', 80); fxx2.start({ 'height':80}); 
		} } ).start({ 'height':0 });		
	} else {
		$('clima_marco').setStyles({'display':''});	
		new Fx.Styles($('clima_marco'), {duration:500, onComplete: function(){ 
		vopen_bloque_clima=1;			
		//$('clima_marco').setStyle('height', 80); fxx2.start({ 'height':80}); 
		} } ).start({ 'height':80 });
	}
}

/* Fin Scripts Bloque Reservas */


	function CallBackFechaBuscador(){
		
	$('mensaje_error_fechas').innerHTML='';
	if($('from').value!='' && $('from').value!='Entrada'){
		$1('limpiar_desde');
	}								
	if($('to').value!='' && $('to').value!='Salida'){
		$1('limpiar_hasta');
	}
	
	var hoydia = new Date().getDate();
	var hoyano = new Date().getFullYear();
	var hoymes = new Date().getMonth() + 1;
	var hoy=10000*hoyano + 100*hoymes + 1*hoydia;
	var from=10000*$('from').value.substr(0,4) + 100*$('from').value.substr(5,2) + 1*$('from').value.substr(8,2);
	var to=10000*$('to').value.substr(0,4) + 100*$('to').value.substr(5,2) + 1*$('to').value.substr(8,2);
	
	if( ($('from').value!='') && ($('to').value!='') && (to<from) ){
	$('mensaje_error_fechas').innerHTML=JS_mensaje_de_fecha;
	limpiar_hasta();
	}
	
	if( ($('from').value!='') && (from<hoy) ){
	$('mensaje_error_fechas').innerHTML=JS_mensaje_de_fecha_2;
	limpiar_desde();
	}
	
	if(  ($('to').value!='') &&  (to<hoy) ){
	$('mensaje_error_fechas').innerHTML=JS_mensaje_de_fecha_3;
	limpiar_hasta();
	}
	
	if( ($('from').value=='') && ($('to').value!='') ){
	$('mensaje_error_fechas').innerHTML=JS_marque_fecha_entrada;
	limpiar_hasta();
	}									
//	setTimeout("$('mensaje_error_fechas').innerHTML='';",10000);		
	
	}
	
	function limpiar_desde(){
	$0('limpiar_desde');
	$0('limpiar_hasta');
	$('from').value='Entrada';
	$('to').value='Salida';	
	$('from').setStyles({'color':'#ccc'});
	$('to').setStyles({'color':'#ccc'});	
	}
	function limpiar_hasta(){
	$0('limpiar_hasta');
	$('to').value='Salida';
	$('to').setStyles({'color':'#ccc'});
	}			
	
	function plus_open(){
	var hh = $('descripcion_content').getStyle('height');
	$0('plus_open');
	new Fx.Styles($('descripcion_over'), {duration:500, onComplete: function(){ 
		$1('plus_close');
	} } ).start({ 'height':hh });
	}
	function plus_close(){
	$0('plus_close');
	new Fx.Styles($('descripcion_over'), {duration:500, onComplete: function(){ 
		$1('plus_open');
	} } ).start({ 'height':69 });		
	}		
		
	function clear_busqueda(){
	//if($('caja-busqueda').value=='Establecimiento'){ $('caja-busqueda').value=''; }
	/*
	if($('caja-busqueda').value=='Lugares'){ $('caja-busqueda').value=''; }
	if($('from')){ if($('from').value=='Entrada'){ $('from').value=''; } }
	if($('to')){ if($('to').value=='Salida'){ $('to').value=''; } }
	$('srch-frm').submit();
	*/ 
	}
	function suscribirme_a_idea(id){
		
		datos = { action : 'SUSCRIBIR_IDEA_EVASION', id_idea : id  }
		new Ajax("modulos/ideas/ideas.php?ran="+Math.random(), { method:'post',  data:datos, onComplete: function(eee){
			var json=eval("(" + eee + ")");
			if(json.estado=='ok'){
			$0('sus_'+id);
			$('susnum_'+id).innerHTML=json.suscritos;			
			}
		} } ).request();
		
		
	}
	var IDIDEA;
	function mostrar_enviar_email_idea(id_idea){
	
		IDIDEA = id_idea;
		
		ventana_form_ccl('modulos/ideas/ideas.php?action=MOSTRAR_ENVIAR_EMAIL_IDEA',540,400);
	
	}
	
	function open_login(){
		
		ventana_form_ccl('modulos/usuarios/usuarios.php?action=MOSTRAR_INICIAR_SESION',440,390);
	
	}
							
							
    function eliminarComentario(confirmar,id){
	$0('bloque_mens');
	$('bloque_mens').innerHTML='';
	if(!confirm(confirmar)){ return; }
	else {
				datos = { 
					action		: 'ELIMINAR_COMENTARIO',
					id_comentario 	: id,
					ajax		: '1'
				};	
				new Ajax("modulos/comentarios/comentarios.php", { method:'post', data:datos,  onComplete: function(eee){

				if(eee.trim()==''){
					
					$0('item_'+id);
					$1('bloque_mens');
					$('bloque_mens').innerHTML=JS_mensaje_eliminar_comentario;
					 
				} else {
				
					var json=eval("(" + eee + ")");
					if(json.header=='Error'){
						$1('bloque_mens');
						$('bloque_mens').innerHTML="<span style='color:red;'>"+json.message+"</span>";
					}		
					
				}		
									
				} } ).request();
					
	}
	}							


   function activaMarquesina()
   {
      
   }
   	
   	var pic_big_with_logo = '';
   	var pic_with_logo = '';
   	
	function afterFacebookLogin()
	{
		url="modulos/usuarios/usuarios.php?action=FACEBOOK_LOGIN_SCENARIOS&ran=" + Math.random();
	
		datos = {ajax : '1'};
			
		new Ajax(url, { method:'post', data:datos, onComplete: function(eee)
		{
			var json = JSON.parse(eee);
			
			if(json.scenario == 1)
			{
				ventana_form_cerrar(); 
				location.reload(true);
			} 
			else if(json.scenario == 2)
			{
	    		var box_url = "modulos/usuarios/usuarios.php?action=MOSTRAR_VINCULAR_FACEBOOK_SIN_SESSION&login="+json.login;
				ventana_form_ccl(box_url, 440, 390);
			}
			else if(json.scenario == 3)
			{
				pic_big_with_logo = json.pic_big_with_logo;
				pic_with_logo = json.pic_with_logo;
				
				ventana_form_ccl('modulos/usuarios/usuarios.php?action=MOSTRAR_REGISTRO_WEB_FACEBOOK', 566, 808);
			}    			
	
		} } ).request();        	
	}   

