// JavaScript Document
var x = 1;
var y = 0;
var mapa = "si";
//función de Ajax
function nuevoAjax(){
var xmlhttp=false;
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
//función de Ajax
function cargarContenido(liga){
var preloader;
//alert ("Si entra");
//contenedor = document.getElementById('contenedor');
preloader = document.getElementById('artic');
//t1 = document.getElementById('texto1').value;
//t2 = document.getElementById('texto2').value;
ajax=nuevoAjax();
ajax.open("GET",liga,true);
//alert("Si entra 2");
ajax.onreadystatechange=function() {
//alert("Si entra 3");
if(ajax.readyState==1){
	//preloader.innerHTML = "Cargando...";
//	//modificamos el estilo de la div, mostrando una imagen de	fondo
//	preloader.style.background = "url('loading.gif') norepeat";
	}else if(ajax.readyState==4){
	if(ajax.status==200){
	//mostramos los datos dentro de la div
	preloader.innerHTML = ajax.responseText;
	//preloader.innerHTML = "Si entra";
	}else if(ajax.status==404){
	preloader.innerHTML = "La página no existe";
	}else{
	//mostramos el posible error
	preloader.innerHTML = "Error: ".ajax.status;
	}
	}
}
ajax.send(null)
}


function cargarContenido3(liga){
var preloader;
//alert ("Si entra");
//contenedor = document.getElementById('contenedor');
preloader = document.getElementById('dinfo');
//t1 = document.getElementById('texto1').value;
//t2 = document.getElementById('texto2').value;
ajax=nuevoAjax();
ajax.open("GET",liga,true);
//alert("Si entra 2");
ajax.onreadystatechange=function() {
//alert("Si entra 3");
if(ajax.readyState==1){
	//preloader.innerHTML = "Cargando...";
//	//modificamos el estilo de la div, mostrando una imagen de	fondo
//	preloader.style.background = "url('loading.gif') norepeat";
	}else if(ajax.readyState==4){
	if(ajax.status==200){
	//mostramos los datos dentro de la div
	preloader.innerHTML = ajax.responseText;
	//preloader.innerHTML = "Si entra";
	}else if(ajax.status==404){
	preloader.innerHTML = "La página no existe";
	}else{
	//mostramos el posible error
	preloader.innerHTML = "Error: ".ajax.status;
	}
	}
}
ajax.send(null)
}

//cargar imagenes en banco de imagenes
function cargarPag(liga){
var preloader;
//alert ("Si entra");
//contenedor = document.getElementById('contenedor');
preloader = document.getElementById('imagenes');
//t1 = document.getElementById('texto1').value;
//t2 = document.getElementById('texto2').value;
ajax=nuevoAjax();
ajax.open("GET",liga,true);
//alert("Si entra 2");
ajax.onreadystatechange=function() {
//alert("Si entra 3");
if(ajax.readyState==1){
	//preloader.innerHTML = "Cargando...";
//	//modificamos el estilo de la div, mostrando una imagen de	fondo
//	preloader.style.background = "url('loading.gif') norepeat";
	}else if(ajax.readyState==4){
	if(ajax.status==200){
	//mostramos los datos dentro de la div
	preloader.innerHTML = ajax.responseText;
	//preloader.innerHTML = "Si entra";
	}else if(ajax.status==404){
	preloader.innerHTML = "La página no existe";
	}else{
	//mostramos el posible error
	preloader.innerHTML = "Error: ".ajax.status;
	}
	}
}
ajax.send(null)
}


function cargarEmp(liga){
var preloader;
//alert ("Si entra");
//contenedor = document.getElementById('contenedor');
preloader = document.getElementById('preloader');
//t1 = document.getElementById('texto1').value;
//t2 = document.getElementById('texto2').value;
ajax=nuevoAjax();
ajax.open("GET",liga,true);
//alert("Si entra 2");
ajax.onreadystatechange=function() {
//alert("Si entra 3");
if(ajax.readyState==1){
	preloader.innerHTML = "<img src='images/loading2.gif' />";
//	//modificamos el estilo de la div, mostrando una imagen de	fondo
//	preloader.style.background = "url('loading.gif') norepeat";
	}else if(ajax.readyState==4){
	if(ajax.status==200){
	//mostramos los datos dentro de la div
	preloader.innerHTML = ajax.responseText;
	//preloader.innerHTML = "Si entra";
	}else if(ajax.status==404){
	preloader.innerHTML = "La página no existe";
	}else{
	//mostramos el posible error
	preloader.innerHTML = "Error: ".ajax.status;
	}
	}
}
ajax.send(null)
}
//verifica los campos en los formularios de contacto
function verificar(){

	var nombre = document.formulario.Nombre.value;
	var mail = document.formulario.email.value;
	var msg = document.formulario.Mensaje.value;
	var edo = document.formulario.lstEstado.value;
	var ciu = document.formulario.lstMunicipio.value;
	var dir = document.formulario.Direccion.value;
	var tel = document.formulario.Telefono.value;
	var fecha = document.formulario.Fecha.value;
	var empresa = document.formulario.Empresa.value;
	var diremp = document.formulario.Diremp.value;
	var pais = document.formulario.Pais.value;
	
	//alert(cono);
	if (nombre == "" ||  mail == "" || msg == "" || edo == "" || empresa == "" || ciu == ""){
		alert ("Favor de llenar todos los campos");
	}
	else{
			var x = document.formulario.lstEstado.options[document.formulario.lstEstado.selectedIndex].id;
			var y = document.formulario.lstMunicipio.options[document.formulario.lstMunicipio.selectedIndex].id;
			document.formulario.estado.value = x;
			document.formulario.ciudad.value = y;
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail)){
				document.formulario.action = "enviar.php";
			 	document.formulario.submit();
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
			 }
				
	}	

}
	
function verifica_login(){
	var usr = document.form1.usuario.value;
	var pss = document.form1.password.value;
	
	if(usr == "" || pss == "" || vacio(usr) == false || vacio(pss) == false){
		alert("NO DEJE NINGUN CAMPO VACIO");
		return false;
		}
	else{
		return true;
		//document.form1.submit();
		}
}
	
function submenu(llamador)
{
  var valor = llamador.parentNode.getElementsByTagName('ul')[0];
  valor.style.display = valor.style.display == 'block' ? 'none' : 'block' ;
}

function showhide3(elem1,elem2)
{ 
document.getElementById(elem1).style.display='none'; 
document.getElementById(elem2).style.display='block'; 
}



function vacio(q) { //la variable q contiene el valor del texbox
for ( i = 0; i < q.length; i++ ) { //la funcion q.length devuelve el tamaño de la palabra contenia por el textbox
	if ( q.charAt(i) != " " ) {//la funcion q.charAt nos deuelve el caracter contenido en la posicion i de la variable q
		return true
	}
}
	return false;
}


function valida_empresa1(){//verifica el registro de clientes en la pagina registro.php
	var nombre = document.form1.nombre.value;
	var direccion = document.form1.direccion.value;
	var tel = document.form1.telefonos.value;
	//var mail = document.form1.mail.value;
	//var pag = document.form1.paginaweb.value;
	var zona = document.form1.zona.value;
	var c1 = document.form1.c1_1.value;
	var c2 = document.form1.c2_1.value;
	var cont = document.form1.contacto.value;
	var res = document.form1.resumen.value;
	var key = document.form1.keywords.value;
	var file = document.form1.userfile.value;
	var num = document.form1.num.value;
	var dia = document.form1.txtInicio.value;
	var dur = document.form1.txtFin.value;
	var ar = document.form1.area.value;
	var subar = document.form1.subarea.value;
	var mail2 = document.form1.mail2.value;
	//var mapa = document.getElementByName('mapa');
	//alert(ar);
	//alert(subar);
	//alert(cono);
	//alert(vacio(nombre));
	// || file == "" || vacio(file) == false
	// || pag == "" || vacio(pag) == false
	//alert(mapa);
	if(mapa == "no"){
		c1 = nombre;
		c2 = nombre;
	}
	if (nombre == "" || zona == "" || c1 == "" || c2 == "" || cont == "" || res == "" || key == "" || vacio(nombre) == false || vacio(c1) == false || vacio(c2) == false || vacio(cont) == false || vacio(res) == false || vacio(key) == false || dia == "" || vacio(dia) == false || dur == "" || vacio(dur) == false || ar == "" || subar == "" || mail2 == "" || vacio(mail2) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail2)){	
				//alert(num);
				//document.formulario.action = "reg.php";
			 	//document.formulario.submit();
				if(mapa == "si"){
					for(var i = 1; i <= num; i++){
						an = "c1_"+i;
						//alert(an);
						al = "c2_"+i;
						
						
						ancho = document.getElementById(an).value;
						alto = document.getElementById(al).value;
						ancho = ancho.replace(/-/,"");
						alto = alto.replace(/-/,"");
						if(ancho == "" && alto == ""){
							
						}
						else{
							if(!IsDecimal(ancho) || !IsDecimal(alto)){
								//alert(ancho);
								//alert(alto);
								alert("Por favor escriba sólo números en los campos de las Coordenadas");
								return false;
							}
						}
					}
				}
				//alert("Todo bien");
				return true;
				document.getElementById('subiendo').style.display = 'block';
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }	
	}	
}

function valida_evento1(){//verifica el registro de clientes en la pagina registro.php
	var nombre = document.form1.nombre.value;
	var direccion = document.form1.direccion.value;
	//var tel = document.form1.telefonos.value;
	//var mail = document.form1.mail.value;
	var pag = document.form1.paginaweb.value;
	var zona = document.form1.zona.value;
	var c1 = document.form1.c1_1.value;
	var c2 = document.form1.c2_1.value;
	var cont = document.form1.contacto.value;
	var res = document.form1.resumen.value;
	var key = document.form1.keywords.value;
	var file = document.form1.userfile.value;
	var num = document.form1.num.value;
	var dia = document.form1.txtInicio.value;
	var dur = document.form1.txtFin.value;
	var ar = document.form1.categoria.value;
	var mail2 = document.form1.mail2.value;
	//alert(ar);
	//alert(subar);
	//alert(cono);
	//alert(vacio(nombre));
	// || file == "" || vacio(file) == false
	// || pag == "" || vacio(pag) == false
	if(mapa == "no"){
		c1 = nombre;
		c2 = nombre;
	}
	if (nombre == "" || zona == "" || c1 == "" || c2 == "" || cont == "" || res == "" || key == "" || vacio(nombre) == false || vacio(c1) == false || vacio(c2) == false || vacio(cont) == false || vacio(res) == false || vacio(key) == false || dia == "" || vacio(dia) == false || dur == "" || vacio(dur) == false || ar == "" || mail2 == "" || vacio(mail2) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail2)){	
				//alert(num);
				//document.formulario.action = "reg.php";
			 	//document.formulario.submit();
			  if(mapa == "si"){
				for(var i = 1; i <= num; i++){
					an = "c1_"+i;
					//alert(an);
					al = "c2_"+i;
					
					
					ancho = document.getElementById(an).value;
					alto = document.getElementById(al).value;
					ancho = ancho.replace(/-/,"");
					alto = alto.replace(/-/,"");
					if(ancho == "" && alto == ""){
						
					}
					else{
						if(!IsDecimal(ancho) || !IsDecimal(alto)){
							//alert(ancho);
							//alert(alto);
							alert("Por favor escriba sólo números en los campos de las Coordenadas");
							return false;
						}
					}
				}
			  }
				//alert("Todo bien");
				return true;
				document.getElementById('subiendo').style.display = 'block';
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }	
	}	
}


function verifica_imagen(){//verifica todos los campos al publicar un comentario en blog_articulos.php
//alert(nombre);
	var tit = document.form2.pregunta.value;
	var precio = document.form2.precio.value;
	
	//alert(document.formulario.captchaid.value);
	if (tit == "" || precio == ""){
		alert ("Favor de llenar todos los campos");
	}
	else{
		//document.formulario.accion.value = nombre;
		//alert(document.formulario.accion.value);
		//document.getElementById('subiendo').style.display = 'block';
		//alert("Si entra");
		document.form2.submit();
		document.getElementById('subiendo').style.display = 'block';
	}	
}


function IsNumeric(expression)   
{   
    return (String(expression).search(/^\d+$/) != -1);   
} 

function IsDecimal(expression)   
{   
    return (String(expression).search(/^\d+(\.\d+)?$/) != -1);   
} 

function verifica_pago(){
	var usr = document.form2.concepto.value;
	var pss = document.form2.precio.value;
	
	if(usr == "" || pss == ""){
		alert("Los campos de concepto y cantidad son obligatorios");
		return false;
		}
	else{
		pss = pss.replace(/,/,"");
		pss = pss.replace(/$/,"");
		if(IsDecimal(pss)){
			//alert("Si es número");
			document.form2.precio.value = pss;
			return true;
			}
		else{
			alert("El campo de cantidad no es número, por favor escriba una cantidad correcta");
			return false;
			}
		//document.form2.submit();
		}
	}
	
function muestradetalle(elem1){
	
	if(document.getElementById(elem1).style.display =='block'){
		document.getElementById(elem1).style.display='none'; 
	}
	else{
		document.getElementById(elem1).style.display='block'; 
	}
	
}


function comprobar(mivalor,palabra)
{
	var mivalor = mivalor;
	var palabra = palabra;
	if(mivalor.indexOf(palabra)!=-1){
		return true;
		//alert('La frase\n'+ mivalor +' \nContiene la palabra\n'+palabra);
	}else{
		return false;
		//alert('La frase\n'+ mivalor +' \nNO Contiene la palabra\n'+palabra);
	}
}

function changeIt(num)
{
//var i = 1;
//var x = num;
x = x + num;
//alert(x);
var c1 = "c1_"+ x;
var c2 = "c2_"+ x;

//txt.innerHTML =  txt.innerHTML +"<div style='height=20px;'>Imagen " + x+ "</div>";
//my_div.innerHTML = my_div.innerHTML +"<br /><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "'>";
tab.innerHTML = tab.innerHTML + '<br \><input name="'+ c1 +'" type="text" id="'+ c1 +'" size="8" /> , <input name="'+ c2 +'" type="text" id="'+ c2 +'" size="8" />';
document.form1.num.value = x;
//alert(document.frmDatos.num.value);
}

function changeIt2(num)
{
//var i = 1;
//var x = num;
y = y + num;
//alert(y);
var nombre = "userfile"+ y;
//txt.innerHTML =  txt.innerHTML +"<div style='height=20px;'>Imagen " + x+ "</div>";
//my_div.innerHTML = my_div.innerHTML +"<br /><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "'>";
tab.innerHTML = tab.innerHTML + "<table width='100%' border='0'><tr><td height='38' align='left' class='style2'>Imagen " + y + "</td><td align='left'><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "' /></td></tr></table>";
document.form1.num.value = y;
//alert(y);
}

function changeItE(antes, numer)
{
//var i = 1;
//var x = num;
if(x == 1){
	x = x + antes;	
}
else{
	x = x + numer;
}
//alert(x);
var c1 = "c1_"+ x;
var c2 = "c2_"+ x;

//txt.innerHTML =  txt.innerHTML +"<div style='height=20px;'>Imagen " + x+ "</div>";
//my_div.innerHTML = my_div.innerHTML +"<br /><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "'>";
tab.innerHTML = tab.innerHTML + '<input name="'+ c1 +'" type="text" id="'+ c1 +'" size="8" /> , <input name="'+ c2 +'" type="text" id="'+ c2 +'" size="8" /><br \>';
document.form1.num.value = x;
//alert(document.frmDatos.num.value);
}

function changeIt2E(antes, numer)
{
//var i = 1;
//var x = num;
//y = y + numer;
if(y == 0){
	y = y + antes;	
}
else{
	y = y + numer;
}
//alert(y);
var nombre = "userfile_"+ y;
//txt.innerHTML =  txt.innerHTML +"<div style='height=20px;'>Imagen " + x+ "</div>";
//my_div.innerHTML = my_div.innerHTML +"<br /><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "'>";
tab.innerHTML = tab.innerHTML + "<table width='100%' border='0'><tr><td height='38' align='left' class='style2'>Archivo " + y + "</td><td align='left'><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "' /></td></tr></table>";
document.form1.num.value = y;
//alert(document.form1.num.value);
}

function muestra_esperando(){  //muestra mensaje de subiendo
	return true;
	document.getElementById('subiendo').style.display = 'block';
}

function verifica_usuario(){
	var nombre = document.form1.nombre.value;
	var direccion = document.form1.direccion.value;
	var tel = document.form1.telefono.value;
	var mail = document.form1.correo.value;
	var pag = document.form1.txtInicio.value;
	var usuario = document.form1.usuario.value;
	var psswd = document.form1.password.value;
	
	if (nombre == "" || direccion == "" || tel == "" || mail == "" || pag == "" || usuario == "" || psswd == "" || vacio(nombre) == false || vacio(direccion) == false || vacio(tel) == false ||  vacio(mail) == false || vacio(pag) == false || vacio(usuario) == false || vacio(psswd) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail) && regex.test(mail2)){					
				return true;				
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }	
	}	
	
}



function valida_banner1(){

	var nombre = document.form1.nombre.value;
	var mail = document.form1.mail2.value;
	var pag = document.form1.paginaweb.value;
	var cont = document.form1.contacto.value;
	var file = document.form1.userfile.value;
	var dia = document.form1.txtInicio.value;
	var dur = document.form1.txtFin.value;
	
	
	//alert(cono);
	if (nombre == "" ||  mail == "" || pag == "" || cont == "" || file == "" || dia == "" || dur == "" || vacio(nombre) == false || vacio(mail) == false || vacio(pag) == false || vacio(cont) == false || vacio(file) == false || vacio(dia) == false || vacio(dur) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail)){
				return true;
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }
				
	}	

}

function valida_banner2(){

	var nombre = document.form1.nombre.value;
	var mail = document.form1.mail2.value;
	var pag = document.form1.paginaweb.value;
	var cont = document.form1.contacto.value;
	var dia = document.form1.txtInicio.value;
	var dur = document.form1.txtFin.value;
	
	
	//alert(cono);
	if (nombre == "" ||  mail == "" || pag == "" || cont == "" || dia == "" || dur == "" || vacio(nombre) == false || vacio(mail) == false || vacio(pag) == false || vacio(cont) == false|| vacio(dia) == false || vacio(dur) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail)){
				return true;
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }
				
	}	

}


function modal(enlace,id){ //popup para la descarga de archivos pagina archivos.php
	
//var setupWindow = 'center:yes;resizable:no;status:no;dialogWidth:500px;dialogHeight:280px;';
//var setupWindow = 'resizable:no;status:no;dialogWidth:500px;dialogHeight:280px;';
var en = "archivos.php?desde=" + enlace + "&amp;id=" + id;
//var en = "localhost/password/password/" + enlace;
//alert(en);
//window.showModalDialog(en,"",setupWindow);
//var v1 = window.open(en,"","width=500px height=280px resizable=0 status=0 location=0 statusbar=0 scrollbars=0");
var v1 = window.open(en,"","");
//var v1 = window.open(en,"","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=70,height=50,left = 390,top = 260'");
//document.form2.js.value = enlace;
//alert(document.form2.js.value);

}

function cambiarlugar()
{

var inf = document.form1.local.value;
//alert(inf);
var info = document.getElementById(inf).value;
//alert(info);
//txt.innerHTML =  txt.innerHTML +"<div style='height=20px;'>Imagen " + x+ "</div>";
//my_div.innerHTML = my_div.innerHTML +"<br /><input type='file' class='textos' name='"+ nombre + "' id='"+ nombre + "'>";
tab.innerHTML = '<textarea name="lugar" cols="40" rows="4" id="lugar">'+ info +'</textarea>';
//alert(document.frmDatos.num.value);
}


function valida_partido(){

	var local = document.form1.local.value;
	var visit = document.form1.visitante.value;
	var hora = document.form1.hora.value;
	var dia = document.form1.txtInicio.value;
	var lugar = document.form1.lugar.value;
	
	
	//alert(cono);
	if (local == "" ||  visit == "" || hora == "" || dia == "" || lugar == "" || vacio(local) == false || vacio(visit) == false || vacio(hora) == false || vacio(dia) == false|| vacio(lugar) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
		 	if (local != visit){
				return true;
			 }
			else{
			 	alert("POR FAVOR ELIJA EQUIPOS DIFERENTES DE LOCAL Y VISITANTE");
				return false;
			 }
				
	}	

}

function pregunta(){	
		return confirm("¿Deseas eliminar el registro?");		
	}
	
function ventana(enlace){ //popup para la descarga de archivos pagina archivos.php
	
//var setupWindow = 'center:yes;resizable:no;status:no;dialogWidth:500px;dialogHeight:280px;';
//var setupWindow = 'resizable:no;status:no;dialogWidth:500px;dialogHeight:280px;';
//var en = "archivos.php?desde=" + enlace + "&amp;id=" + id;
//var en = "localhost/password/password/" + enlace;
//alert(en);
//window.showModalDialog(en,"",setupWindow);
//alert(enlace);
//var v1 = window.open(en,"","width=500px height=280px resizable=0 status=0 location=0 statusbar=0 scrollbars=0");
var v1 = window.open(enlace,"","");
//var v1 = window.open(en,"","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=70,height=50,left = 390,top = 260'");
//document.form2.js.value = enlace;
//alert(document.form2.js.value);

}

function valores(pagina){
	document.frmB.nump.value = pagina;
	document.frmB.submit();
}

function valida_busquedaa(){
var tb = document.form1.tbusqueda.value;
var ar = document.form1.area.value;
var su = document.form1.subarea.value;
var zo = document.form1.zona.value;

if((vacio(tb) == false || tb == "") && ar == "" && su == "" && zo == ""){
	alert("Por favor especifique su búsqueda");
	return false;
}
else{
	//alert("Todo bien");
	return true;
}

}

function valida_busquedae(){
	var tb = document.fcategoria.tbusqueda.value;
	var ar = document.fcategoria.categoria.value;
	var su = document.fcategoria.txtInicio.value;
	var zo = document.fcategoria.zona.value;

	if((vacio(tb) == false || tb == "") && ar == "" && su == "" && zo == ""){
		alert("Por favor especifique su búsqueda");
		return false;
	}
	else{
		return true;
	}
}
function esconde(elem1){
	
	if(document.getElementById(elem1).style.display =='block'){
		document.getElementById(elem1).style.display='none'; 
	}
	else{
		document.getElementById(elem1).style.display='block'; 
	}
	
}

function muestra(elem1){
		document.getElementById(elem1).style.display='block'; 
}

function oculta(elem1){
		document.getElementById(elem1).style.display='none'; 
}


function valida_enviar(){

	var nombre = document.frmEnviar.nom.value;
	var mail = document.frmEnviar.email.value;	
	
	//alert(cono);
	if (nombre == "" ||  mail == "" || vacio(nombre) == false || vacio(mail) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail)){
				return true;
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }
				
	}	

}

function valida_contacto(){

	var nombre = document.frmContacto.nom.value;
	var mail = document.frmContacto.email.value;	
	var tel = document.frmContacto.tel.value;	
	var msg = document.frmContacto.msg.value;	
	
	//alert(cono);
	if (nombre == "" ||  mail == "" ||  tel == "" ||  msg == "" || vacio(nombre) == false || vacio(mail) == false || vacio(tel) == false || vacio(msg) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail)){
				return true;
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }
				
	}	

}

function valida_rec(){

	var nombre = document.frmRec.nom2.value;
	var mail = document.frmRec.email2.value;	
	var fecha = document.frmRec.fecha2.value;	
	
	//alert(cono);
	if (nombre == "" ||  mail == "" ||  fecha == "" || vacio(nombre) == false || vacio(mail) == false || vacio(fecha) == false){
		alert ("Favor de llenar todos los campos");
		return false;
	}
	else{
			
			var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		 	var regex = new RegExp(emailReg);
		 	if (regex.test(mail)){
				return true;
			 }
			else{
			 	alert("FAVOR DE INTRODUCIR UNA DIRECCION E-MAIL VALIDA");
				return false;
			 }
				
	}	

}

function subuscados1(val){
	document.frmMas1.texto.value = val;
	document.frmMas1.submit();
}

function subuscados2(ar1, sar1){
	document.frmMas2.tbusqueda.value = "";
	document.frmMas2.area.value = ar1;
	document.frmMas2.subarea.value = sar1;
	document.frmMas2.submit();
}

function cambiaMapa(val){
	mapa = val;
	}
	
function vaciar(elem){
	if (elem.value == "Escribe aquí lo que estás buscando"){
		elem.value = "";	
	}
}

function llenar(elem,texto){	
	if(elem.value == ""){
		elem.value = texto;	
	}
}