function sololetras(obj, e){
	opc = false;
	tecla = (document.all) ? event.keyCode : e.which;
 	if ((tecla < 65 || tecla > 122) & tecla != 8 & tecla !=  32 & tecla !=  13)  {opc = false; 	alert('Debe introducir únicamente letras.') ;}  else { opc = true;}
	return opc;
}
 
 function solonumeros(e) { 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    patron = /\d/; //ver nota 
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
}  
function mapa_selecto(mapa) {
	 document.getElementById("mapaes").src=mapa;
	}
var globlamapa=0;	
function mapa_original() {} 
function select_mapa(reg) {
	if (reg!="")
		{
		document.getElementById("mapaes").src='/mapa2/'+reg+'.gif';
		document.getElementById('imgidregion').src='/images/buscador_1.png'; 
		document.getElementById('imgidtipo').src='/images/buscador_2_activo.png';
		document.getElementById("idregiondiv").style.border='2px solid #FFFFFF';
		document.getElementById("alerta_com").style.visibility="hidden";
		document.getElementById("alerta_comdos").style.visibility="hidden";
		document.getElementById('idtipouno').focus();
		document.getElementById('imgnum_personas').src='/images/buscador_3.png'; 		
		globlamapa=1;
	}
	else
		{
		document.getElementById("mapaes").src='mapa2/bg.gif';
		document.getElementById('imgidregion').src='/images/buscador_1_activo.png'; 
		document.getElementById('imgidtipo').src='/images/buscador_2.png';
		document.getElementById('imgnum_personas').src='/images/buscador_3.png'; 		

		globlamapa=0;
		}
	}

function mapa_ver(reg) {
	if (globlamapa==0)
		{
		 document.getElementById("mapaes").src='/mapa2/'+reg+'.gif';	
		}
	}	
function mapa_ocultar(reg) {
	if (globlamapa==0)
		{
		 document.getElementById("mapaes").src='mapa2/bg.gif';	
		}
	}
	
function mapa_select(reg) {
	 document.getElementById("mapaes").src='/mapa2/'+reg+'.gif';
	 var indice = document.frmbuscador.idregion.length; 
   

	for (i=0;i<indice;i++) 
		{
		if (document.frmbuscador.idregion.options[i].value==reg)
			{   
			document.frmbuscador.idregion.options[i].selected=true; 
			document.getElementById('imgidregion').src='/images/buscador_1.png'; 
			document.getElementById('imgidtipo').src='/images/buscador_2_activo.png';
			document.getElementById('imgnum_personas').src='/images/buscador_3.png'; 		
			document.getElementById('idtipouno').focus();
			document.getElementById("idregiondiv").style.border='2px solid #FFFFFF';
			document.getElementById("alerta_com").style.visibility="hidden";
			document.getElementById("alerta_comdos").style.visibility="hidden";
			globlamapa=1;
			}
		}
	
	}
	
function buscadorindexdos(){
 if (document.frmbuscador.idregion.value!='') 
 	{ 

	var group1Checked =0
	for (var i=0; i<document.frmbuscador.idtipo.length; i++) {
		if (document.frmbuscador.idtipo[i].checked) {
		group1Checked = document.frmbuscador.idtipo[i].value
		}
	}
	if(group1Checked!=0){  
		document.getElementById('imgnum_personas').src='/images/buscador_3_activo.png'; 
		document.getElementById('imgidtipo').src='/images/buscador_2.png';  
		document.getElementById('imgidregion').src='/images/buscador_1.png'; 
		}
	}
}
function buscadorindex() {
	var accs=1;
	document.getElementById("idregiondiv").style.border='2px solid #FFFFFF';
	document.getElementById("alerta_com").style.visibility="hidden";
	document.getElementById('imgidregion').src='/images/buscador_1.png'; 
	document.getElementById('imgidtipo').src='/images/buscador_2.png'; 
	document.getElementById('imgnum_personas').src='/images/buscador_3.png'; 
	if (document.frmbuscador.idregion.value=="" & accs!=0){
		document.getElementById("idregiondiv").style.border='2px solid #FF0000';
	 	document.getElementById("alerta_com").style.visibility="visible";
		globlamapa=0;
		accs=0;
		}
	var group1Checked =0
	for (var i=0; i<document.frmbuscador.idtipo.length; i++) {
		if (document.frmbuscador.idtipo[i].checked) {
		group1Checked = document.frmbuscador.idtipo[i].value
		}
	}
 
	if(group1Checked==0){  
	 	document.getElementById("alerta_comdos").style.visibility="visible";
		accs=0;
 
		}
		
		
	if (accs==1) {  document.frmbuscador.submit(); 	}
 
	}

function evento_enter() {
return false;
}
 mywindows=""; 
 function popup (pagina) {
  
var opciones="toolbar=no, statusbar=no, titlebar=no, location=no, directories=no, status=no, menubar=no,menubar=0, scrollbars=yes, resizable=yes, width=550, height=400, left=0, top=0";
  mywindows=window.open(pagina,"popup",opciones);

}

function nuevoAjax()
{ 
OCULTO="none";
VISIBLE="block";
    /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
    lo que se puede copiar tal como esta aqui */
    var xmlhttp=false; 
    try 
    { 
        // Creacion del objeto AJAX para navegadores no IE
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    catch(e)
    { 
        try
        { 
            // Creacion del objet AJAX para IE 
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        catch(E) { xmlhttp=false; }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

    return xmlhttp; 
}

function cargaprovincia(idregion)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxprovincia.php?idregion="+idregion+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divprovincia").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
     cargatipos('provincia',idprovincia);
}

 


function cargafiltroprovincia(idregion)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxprovinciafiltro.php?idregion="+idregion+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divprovincia").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
    document.getElementById("divmunicipio").innerHTML='<select name="idmunicipio"  id="idmunicipio" disabled="disabled"  style=" float:left; width:150px; font-size:11px"><option value="">Seleccione Municipio</option></select>';


cargatipos( 'region', idregion);
cargafiltromunicipioregion(idregion);




}
function cargafiltromunicipioregion(idregion)
{
   var mod=0;
   ajaxd=nuevoAjax();
    ajaxd.open("GET", "/ajax/ajaxmunicipioregionfiltro.php?idregion="+idregion+"&num_ale="+Math.random(), true);
    ajaxd.onreadystatechange=function() 
    { 
        if (ajaxd.readyState==4)
        { 
            document.getElementById("divmunicipio").innerHTML=ajaxd.responseText;
        } 
    }
   ajaxd.send(null);    
    
 
}
function cargamapa(idregion)
{
   var mod=0;
   ajaxdos=nuevoAjax();
    ajaxdos.open("GET", "/ajax/mapas.php?idregion="+idregion+"&num_ale="+Math.random(), true);
    ajaxdos.onreadystatechange=function() 
    { 
        if (ajaxdos.readyState==4)
        { 
            document.getElementById("divmapas").innerHTML=ajaxdos.responseText;
        } 
    }
   ajaxdos.send(null);    
  
}

 function cargaimagenver(idimagen, idpropiedad)
{
var mod=0;
ajax=nuevoAjax();
ajax.open("GET", "/ajax/ajaximagenver.php?idimagen="+idimagen+"&idpropiedad="+idpropiedad+"&num_ale="+Math.random(), true);
ajax.onreadystatechange=function() 
{ 
if (ajax.readyState==4)
{ 
document.getElementById("imagengrande").innerHTML=ajax.responseText;
  
} 
}
ajax.send(null);    
}

function cargatipos( ubicacion, id ){
//alert (ubicacion +" AQUI "+ id );	
 var mod=0;
   ajaxd2=nuevoAjax();
    ajaxd2.open("GET", "/ajax/ajaxcargatipo.php?ubicacion="+ubicacion+"&tipo=2&id="+id+"&num_ale="+Math.random(), true);
    ajaxd2.onreadystatechange=function() 
    { 
        if (ajaxd2.readyState==4)
        { 
		mod= parseInt(ajaxd2.responseText);
	//	if (mod==0){  document.getElementById("idtipo2").disabled=true;  }   else {  document.getElementById("idtipo2").disabled=false; }
        } 
    }
   ajaxd2.send(null); 
  
    ajaxd3=nuevoAjax();
    ajaxd3.open("GET", "/ajax/ajaxcargatipo.php?ubicacion="+ubicacion+"&tipo=3&id="+id+"&num_ale="+Math.random(), true);
    ajaxd3.onreadystatechange=function() 
    { 
        if (ajaxd3.readyState==4)
        {
			
		mod= parseInt(ajaxd3.responseText);
	//	if (mod==0){  document.getElementById("idtipo3").disabled=true;  }   else {  document.getElementById("idtipo3").disabled=false; }
        } 
    }
   ajaxd3.send(null); 
   
     ajaxd4=nuevoAjax();
    ajaxd4.open("GET", "/ajax/ajaxcargatipo.php?ubicacion="+ubicacion+"&tipo=4&id="+id+"&num_ale="+Math.random(), true);
    ajaxd4.onreadystatechange=function() 
    { 
        if (ajaxd4.readyState==4)
        { 
		mod= parseInt(ajaxd4.responseText);
	//	if (mod==0){  document.getElementById("idtipo4").disabled=true;  }   else {  document.getElementById("idtipo4").disabled=false; }
        } 
    }
   ajaxd4.send(null); 
 
 	ajaxd5=nuevoAjax();
    ajaxd5.open("GET", "/ajax/ajaxcargatipo.php?ubicacion="+ubicacion+"&tipo=5&id="+id+"&num_ale="+Math.random(), true);
    ajaxd5.onreadystatechange=function() 
    { 
        if (ajaxd5.readyState==4)
        { 
		mod= parseInt(ajaxd5.responseText);
	//	if (mod==0){  document.getElementById("idtipo5").disabled=true;  }   else {  document.getElementById("idtipo5").disabled=false; }
        } 
    }
   ajaxd5.send(null); 

}

function cargafiltromunicipio(idprovincia)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxmunicipiofiltro.php?idprovincia="+idprovincia+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divmunicipio").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
   cargatipos('provincia',idprovincia);
}
function mapa(idregion_activa,idprovincia_activa)
{
 
 var selObj = document.getElementById('idprovincia');
	selObj.selectedIndex = idprovincia_activa;
alert (idprovincia_activa)
  
}

function cargadisponibilidades(mes,anio,idpropiedad)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxdisponibilidades.php?mes="+mes+"&anio="+anio+"&idpropiedad="+idpropiedad+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divdisponibilidades").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}
function cargaprovincialista(region_av_bus)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxprovincialista.php?region_av_bus="+region_av_bus+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divprovincia").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}

function cargastats(idpropiedad)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxstats.php?idpropiedad="+idpropiedad+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divstats").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}

function cargastatspanel(idpropiedad)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxstatspanel.php?idpropiedad="+idpropiedad+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divstats"+idpropiedad+"").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}




function cargaimagen(idimagen,idpropiedad)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaximagen.php?idimagen="+idimagen+"&idpropiedad="+idpropiedad+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("imagengrande").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}

function cargavideo(idvideo,idpropiedad)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxvideo.php?idvideo="+idvideo+"&idpropiedad="+idpropiedad+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("videogrande").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}

function caraleido(idemail)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxmpleido.php?idemail="+idemail+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divmensaje"+idemail+"").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);    
}

function cargabuscador(id)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxbuscador.php?idemail="+idemail+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("buscador").innerHTML=ajax.responseText;
        } 
    }
   ajax.send(null);      
	
}

function cargainput(id)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxinput.php?id="+id+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divinput"+id+"").innerHTML=ajax.responseText;
 			document.formpost.cantidadinput.value=id 

        } 
    }
   ajax.send(null);    
   
}
function busqueda_nopermitir()
{
	

	document.buscaformdos.res_busqueda.value="0" 
}
function validarbuscador()
	{
 
 if (document.buscaformdos.palabra.value.length>=3){
 	document.buscaformdos.submit();
 	}	else { alert ('Es necesario que escriba más de 2 carácteres.');}
	}
	
	
function busqueda_nopermitir2()
{
	
	
	document.buscaformdos.res_busqueda.value="0" 
}
function validarbuscador2()
	{
 
 if (document.buscaformdos.palabra.value.length>=3){
 	document.buscaformdos.submit();
 	}	else { alert ('Es necesario que escriba más de 2 carácteres.');}
	}	
	
function cargainputvideo(id)
{
   var mod=0;
   ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxinputvideo.php?id="+id+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divinputvideo"+id+"").innerHTML=ajax.responseText;
 			document.formpost.cantidadinputvideo.value=id 

        } 
    }
   ajax.send(null);    
   
}


function cargamunicipio(idprovincia)
{
    ajax=nuevoAjax();
    ajax.open("GET", "/ajax/ajaxmunicipio.php?idprovincia="+idprovincia+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        { 
            document.getElementById("divmunicipio").innerHTML=ajax.responseText;
        } 
    }
    ajax.send(null);       
}
function depurar(t){
t.value=t.value.replace(/\r\n/,". ");
}

function checklength()
{

var max = 2000;
var txt;
txt=document.getElementById('descripcion');
var n = txt.value.length;
if (n>max) //i is the maxlength of textarea which we have set to 80
{ 
txt.value = txt.value.substring(0, max); 
return false;
}
document.formpost.caracteres.value=document.formpost.descripcion.value.length 
}
function checklengthcontacto()
{

var max = 800;
var txt;
txt=document.getElementById('mensaje');
var n = txt.value.length;
if (n>max) //i is the maxlength of textarea which we have set to 80
{ 
txt.value = txt.value.substring(0, max); 
return false;
}
document.formcont.caracteres.value=document.formcont.mensaje.value.length 
}
 
	

function buscar_index(){    
var accs=1;
	if (document.buscaform.idregion.value=="" & accs!=0){
		alert("Debes ingresar una region.");
		document.buscaform.idregion.focus();  
		accs=0;
		}
	if (accs==1) { document.buscaform.submit();}
	}
	
 
	
function buscar_listado(){    
var accs=1;
var pagina='';
	if (document.buscaform.region_av_bus.value=="" & accs!=0){
		alert("Debes ingresar una region.");
		document.buscaform.region_av_bus.focus();  
		accs=0;
		}
	else{ pagina="/"+document.buscaform.region_av_bus.value+"/";
			if (document.buscaform.provincia_av_bus.value!="")
				{
				pagina=pagina+document.buscaform.provincia_av_bus.value+"/";
				}
		}
	if (accs==1) { location.href = pagina; }
	}
// definiciones basicas
OCULTO="none";
VISIBLE="block";
	
 
  
function efectoprovincia(){

   var el = document.getElementById("divprovincias"); //se define la variable "el" igual a nuestro div
el.style.display = (el.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
	 

  }
  
  
  
  function mostrartemporada(idtemporada)
{
var el = document.getElementById("linktemporada-"+idtemporada+""); //se define la variable "el" igual a nuestro div
el.style.display = 'none';
 
var elz = document.getElementById("temporada-"+idtemporada+""); //se define la variable "el" igual a nuestro div
elz.style.display = (elz.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
  }

  function ocultartemporada(idtemporada)
{
var el = document.getElementById("linktemporada-"+idtemporada+""); //se define la variable "el" igual a nuestro div
el.style.display = 'block';
 
var elz = document.getElementById("temporada-"+idtemporada+""); //se define la variable "el" igual a nuestro div
elz.style.display = (elz.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
  }
  
  
  
  
  function divmostrar(divid){   
 var el = document.getElementById(divid); //se define la variable "el" igual a nuestro div
el.style.display = (el.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
}

function verimagen(imagen,activa)
{
 
    document.getElementById("divimagen").style.backgroundImage =  document.getElementById("grande-thumb"+activa+"").style.backgroundImage;
	var cantidad=parseInt(document.getElementById("cantidadthumb").value);
 
 	for (i=0; i<cantidad; i++) {
		document.getElementById("mini-thumb"+i+"").style.border='2px solid #ffffff';
		}
		document.getElementById("mini-thumb"+activa+"").style.border='2px solid #000000';

//document.getElementById("divimagen").innerHTML='<img src="/thumbs-grande/'+imagen+'" />';
}
