function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function openwindow(imagen){
	window.open('/popup.php?imagen='+imagen,'Imagen','resizable=yes,menubar=no,toolbar=no,scrollbars=yes,width=468,height=300,top=50,left=50');
}

function cambiarfondo(Objeto) {
	document.getElementById(Objeto).style.backgroundColor='#cc004f';
}

function restaurarfondo(Objeto) {
	document.getElementById(Objeto).style.backgroundColor='#44001a';
}

function CorregirFormulario(elemento,Variable) {
	if (document.getElementById(elemento).value==Variable) {
		document.getElementById(elemento).value="";
	}
}

function Ir(canal) {
parent.top.location = canal;
} 	

function validarEmail(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {
    alert("La dirección de Email es incorrecta.");
    return (false);
  }
}
function ComprobarFormAlta(form){
	if(document.getElementById('Nombre').value==''){
		alert('El campo Nombre es obligatorio.');
		return false;
	}
	if(document.getElementById('EmailA').value==''){
		alert('El campo Email es obligatorio.');
		return false;
	}
	if(!validarEmail(document.getElementById('EmailA').value)){
		return false;
	}
	if(document.getElementById('PasswordA').value==''){
		alert('El campo Clave es obligatorio.');
		return false;
	}
	if(document.getElementById('Sector_ID').value==''){
		alert('El campo Sector es obligatorio.');
		return false;
	}
	return true;
}

function validarEmailModificar(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {
    alert("La dirección de Email es incorrecta.");
    return (false);
  }
}

function ComprobarFormModificar(form){
	if(document.getElementById('EmailM').value==''){
		alert('El campo Email es obligatorio .');
		return false;
	}
	if(!validarEmailModificar(document.getElementById('EmailM').value)){
		return false;
	}
	if(document.getElementById('PasswordM').value==''){
		alert('El campo Clave es obligatorio.');
		return false;
	}
	return true;
}


function validarEmailModificar(valor) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
    return (true)
  } else {
    alert("La dirección de Email es incorrecta.");
    return (false);
  }
}


function ComprobarFormBaja(form){
	if(document.getElementById('EmailB').value==''){
		alert('El campo Email es obligatorio .');
		return false;
	}
	if(!validarEmailModificar(document.getElementById('EmailB').value)){
		return false;
	}
	if(document.getElementById('PasswordB').value==''){
		alert('El campo Clave es obligatorio.');
		return false;
	}
	return true;
}

function ConfirmarSalir(Ruta) {
	if (confirm("¿Está seguro de que desea salir?")){
		window.location = Ruta + "salir.php";
	}
}

function ConfirmarBaja(Ruta) {
	if (confirm("¿Está seguro de que desea darse de baja?")){
		window.location = Ruta + "baja.php";
	}
}

function VerPestanna(IdPestanna,IdActivo) {
	var milista1=document.getElementById('MenuPestannas');
	var ListaDePestannas= milista1.getElementsByTagName('a')	
	for (i=0; i<ListaDePestannas.length; i++) {
			if (ListaDePestannas[i].id==IdPestanna) {
				ListaDePestannas[i].className="Activo";
			}else{
				ListaDePestannas[i].className="Inactivo";
			}
	}	
	
	var milista2=document.getElementById('CajaDatosPestannas');
	var ListaDeCajaDatos= milista2.getElementsByTagName('div')
	for (i=0; i<ListaDeCajaDatos.length; i++) {
			if (ListaDeCajaDatos[i].id==IdActivo) {
				ListaDeCajaDatos[i].style.display="block";
			}else{
				ListaDeCajaDatos[i].style.display="none";
			}
	}
	
	
}

function RedimensionarFoto(IdImagen,TamanoFoto) {
		if (document.getElementById(IdImagen).width>TamanoFoto) {
			document.getElementById(IdImagen).style.width=TamanoFoto+"px";
		}else{
			document.getElementById(IdImagen).style.width=document.getElementById('FotoMostrada').width;
		} 
}


function MostrarTodoEltexto(NombreCapa,NombreCapaMini) {
	document.getElementById(NombreCapaMini).style.display = "none";
	document.getElementById(NombreCapa).style.display = "block";	
}

function OcultarTodoEltexto(NombreCapa,NombreCapaMini) {
	document.getElementById(NombreCapa).style.display = "none";
	document.getElementById(NombreCapaMini).style.display = "block";	
}