// JavaScript Document

	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; 
	}
	
function cargaContenido(ori,des){
	
		ajax=nuevoAjax();
		
		ajax.open("GET",ori, true);
		ajax.onreadystatechange=function() { 
			if ((ajax.readyState==4) && (ajax.status==200) ){ 		
				document.getElementById(des).innerHTML=ajax.responseText;
			} 
			if (ajax.readyState==1) { 
				document.getElementById(des).innerHTML = "cargando...";
			} 		
		}
		ajax.send(null);
}
function cargaContenidoc(m,a)
{

		ajax=nuevoAjax();
		ajax.open("GET","calendario.php?van=s&m="+m+"&a="+a, true);
		ajax.onreadystatechange=function() { 
			if ((ajax.readyState==4) && (ajax.status==200) )
			{ 
				document.getElementById("calendario").innerHTML=ajax.responseText;
				
			
			} 
			if (ajax.readyState==1) { 
			  document.getElementById("calendario").innerHTML="<DIV align='center'><br><br><br>Cargando...</DIV>"; 
			} 
		}
		ajax.send(null);
}
	
function cargaContenido3(ori,des)
{

		ajax=nuevoAjax();
		ajax.open("GET",ori, true);
		ajax.onreadystatechange=function() { 
			if ((ajax.readyState==4) && (ajax.status==200) )
			{ 
				document.getElementById(des).innerHTML=ajax.responseText;
			} 
			if (ajax.readyState==1) { 
			  document.getElementById(des).innerHTML="Cargando..."; 
			}			
		}
		ajax.send(null);
		
}
function cargaContenido4(ori,des)
{

		ajax=nuevoAjax();
		ajax.open("GET",ori, true);
		ajax.onreadystatechange=function() { 
			if ((ajax.readyState==4) && (ajax.status==200) )
			{ 
				opener.document.getElementById(des).innerHTML=ajax.responseText;
				close()
			} 
			if (ajax.readyState==1) { 
			  opener.document.getElementById(des).innerHTML="Cargando..."; 
			}			
		}
		ajax.send(null);
		
}

function validacion4() {

	var bien=true

	if (document.getElementById('nom').value==''){
		alert('Debe introducir un usuario.')
			bien = false
	}
	
	if (document.getElementById('contra').value==''){
		alert('Debe introducir una Contraseña.')
			bien = false
	}
	if (document.getElementById ('contra').value != document.getElementById ('contrac').value){
		alert('Error en la confirmación de la contraseña')
			bien = false
	}
	//alert('Los campos introducidos son CORRECTOS.')
	
	if(bien==true){
		
		var p="usu.php?m=si&n="+document.getElementById('nom').value+"&c="+document.getElementById('contra').value+"&nombre="+document.getElementById('nombre').value+"&uni="+document.getElementById('uni').value+"&e="+document.getElementById('email').value
		
		document.getElementById('nom').value=""
		document.getElementById('contra').value=""
		document.getElementById('contrac').value=""
		document.getElementById('nombre').value=""
		document.getElementById('uni').value=""
		document.getElementById('email').value=""
		
		cargaContenido3(p,'usu')
		
	}

}


function eliminar(id, t){
	if (confirm('Esta seguro que desea eliminar '+t)){
		var p='usu.php?e=si&id='+id
		cargaContenido3(p,'usu')
	}
}

function modi(id){
	var newWindow;
	var p="usu2.php?id="+id
	newWindow = window.open(p,'','height=280,width=580,toolbar=no,minimize=no,status=no,memubar=no,location=no,scrollbars=yes')
	
}


function validacion5() {

	var bien=true

	if (document.getElementById('nom').value==''){
		alert('Debe introducir un usuario.')
			bien = false
	}
	
	if (document.getElementById('contra').value==''){
		alert('Debe introducir una Contraseña.')
			bien = false
	}
	if (document.getElementById ('contra').value != document.getElementById ('contrac').value){
		alert('Error en la confirmación de la contraseña')
			bien = false
	}
	//alert('Los campos introducidos son CORRECTOS.')
	
	if(bien==true){
		
		var p="usu.php?mo=si&n="+document.getElementById('nom').value+"&c="+document.getElementById('contra').value+"&nombre="+document.getElementById('nombre').value+"&uni="+document.getElementById('uni').value+"&id="+document.getElementById('id').value+"&e="+document.getElementById('email').value
		
		document.getElementById('nom').value=""
		document.getElementById('contra').value=""
		document.getElementById('nombre').value=""
		document.getElementById('uni').value=""
		document.getElementById('contrac').value=""
		document.getElementById('email').value=""
		
		cargaContenido4(p,'usu')
		
	}

}


function validacion3() {

	var bien=true

	if (document.getElementById('nom').value==''){
		alert('Debe introducir un Nombre de usuario.')
			bien = false
	}
	
	if (document.getElementById('contra').value==''){
		alert('Debe introducir una Contraseña.')
			bien = false
	}
	if (document.getElementById ('contra').value != document.getElementById ('contrac').value){
		alert('Error en la confirmación de la contraseña')
			bien = false
	}
	//alert('Los campos introducidos son CORRECTOS.')
	
	if(bien==true){
		
		var p="cambio_contra.php?m=si&n="+document.getElementById('nom').value+"&c="+document.getElementById('contra').value
		cargaContenido3(p,'con')
		var element = document.getElementById ('con2');
		element.style.display = "block";
		
	}

}

function validacion2() {

	var bien=true

	if (document.getElementById('nom').value==''){
		alert('Debe introducir un usuario.')
			bien = false
	}
	
	if (document.getElementById('contra').value==''){
		alert('Debe introducir una Contraseña.')
			bien = false
	}
	if (document.getElementById ('contra').value != document.getElementById ('contrac').value){
		alert('Error en la confirmación de la contraseña')
			bien = false
	}
	//alert('Los campos introducidos son CORRECTOS.')
	
	return bien

}

function eliminar2(id, t){
	if (confirm('Esta seguro que desea eliminar '+t)){
		document.location.href=id
	}
}




function ver_documentos(id){
	
	var element = document.getElementById(id).style.display;
	
	if(element=="none"){
		document.getElementById(id).style.display="block"
	}else{
		document.getElementById(id).style.display="none"
	}
	
	
}

function window_open(urlstring){
var newWindow;
newWindow = window.open(urlstring,'','height=400, width=820, toolbar=no, minimize=no, status=no, memubar=no, location=no, scrollbars=no')
}

