function ActivarPestanna(IdMenu) {
	document.getElementById(IdMenu).className='Activo';
}

function toggle(obj) {
        var el = document.getElementById(obj);
        if ( el.style.display != 'none' ) {
           el.style.display = 'none';
        }else {
           el.style.display = '';
        }
}

function mostrarDiv(idelement) {
	document.getElementById(idelement).style.display = 'inline';
	document.getElementById(idelement).style.overflow = 'hidden';
}
function ocultarDiv(idelement) {
	document.getElementById(idelement).style.display = 'none';	
	document.getElementById(idelement).style.overflow = 'hidden';
}			

function VerificarMail(strMail) {
//La siguiente funcion da error si se introduce algo.usuario@dominio.es
	var patMail = /^(.+)@(.+)$/;
	var patUser = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)*$/;
	var patDomainIP = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
	var patDomain = /^[a-zA-Z\d_-]+(\.[a-zA-Z\d_-]+)+$/;
	var matchArray = strMail.match(patMail);
	if(matchArray == null){return false;}
	var user = new String(matchArray[1]);
	var domain = new String(matchArray[2]); 
	if(user.match(patUser) == null){return false;}
	var IPArray = domain.match(patDomainIP);
	if(IPArray != null){ 
		 for (var i=1;i<=4;i++) {
		  if(IPArray[i]>255){return false;}
		 }
		 return true; 
	}
	var domainArray = domain.match(patDomain);
	if(domainArray == null) {return false;}
	if(domainArray[domainArray.length - 1].length < 3 || domainArray[ domainArray.length - 1].length > 5) { return false;}
	return true;
}

function validarEntero(valor){
	if(valor!=0){
		valor = parseInt(valor);
		if (isNaN(valor)) {
			return "";
		}
	}
	return valor;
}

function charactermax(id,idreturn){
	var longit = document.getElementById(id).value.length;
	if(!longit) {longit = '0';}
	document.getElementById(idreturn).innerHTML = longit;

	if (longit>2500) {
		document.getElementById('Contador').style.color= '#990000';
		document.getElementById('Contador').style.fontWeight= 'bold';
	}else{
		if (longit>2200 && longit<2500) {
			document.getElementById('Contador').style.color= '#ff6000';
		}else{
			document.getElementById('Contador').style.color= '#999999';
		}
		document.getElementById('Contador').style.fontWeight= 'normal';
	}
}

/*Boletin*/
function ConfirmarBaja(Ruta) {
	if (confirm("¿Está seguro de que desea darse de baja?")){
		window.location = Ruta + "baja.php";
	}
}
function ConfirmarSalir(Ruta) {
	if (confirm("¿Está seguro de que desea salir?")){
		window.location = Ruta + "salir.php";
	}
}
