$(function() {
		
	    //dialogo para buscar
		$("#div-buscar").dialog({
		     width:400,
			 height: 300,
		     modal: true,
		     autoOpen: false,
		     title: 'Seleccione los criterios de Busqueda'
			
		});
	    //link para mostrar el dialogo de buscar
		$('#buscar')
			.click(function() {
				$('#div-buscar').dialog('open');
			});
			
	  });


function tamano_campos (tamano){

	if(tamano >= 250){ 
		alert('Ha superado el tamaño máximo permitido!!!!');
	}else{
		return false;
	};


}

function cambia_imagen1() {


if(document.getElementById('Peva').value >= 0 && document.getElementById('Peva').value <= 59){
	valor = 0;
}
if(document.getElementById('Peva').value >= 60 && document.getElementById('Peva').value <= 70){
	valor = 2;
}
if(document.getElementById('Peva').value >= 71 && document.getElementById('Peva').value <= 80){
	valor = 3;
}
if(document.getElementById('Peva').value >= 81 && document.getElementById('Peva').value <= 90){
	valor = 4;
}
if(document.getElementById('Peva').value >= 91){
	valor = 5;
}

for(var i=0;i<=5;i++) { 
	if(i==0){
			imagen=new Image
			imagen.src= "images/0.png"
			document.images['2-1'].src=imagen.src
	}else{
		if(i==1){
		
		}else{
		   imagen=new Image
			imagen.src= "images/"+i+".png"
			document.images['2-'+i].src=imagen.src
		}
	}
	
	
}

if(valor == 0){
	imagen=new Image
	imagen.src= "images/0.png"
	seleccion=new Image
	seleccion.src="images/1_0.png"


		if (document.images['2-1'].src == imagen.src){
			document.images['2-1'].src=seleccion.src
		}else{
			document.images['2-1'].src=imagen.src;
	
		}
}else{
	imagen=new Image
	imagen.src= "images/"+valor+".png"
	seleccion=new Image
	seleccion.src="images/1_"+valor+".png"


		if (document.images['2-'+valor].src == imagen.src){
			document.images['2-'+valor].src=seleccion.src
		}else{
			document.images['2-'+valor].src=imagen.src;
		
		}
}

}
function cambia_imagen(valor) {



 for(var i=1;i<=5;i++) { 
	if(i==4){
			imagen=new Image
			imagen.src= "images/3.png"
			document.images['1-'+i].src=imagen.src
	}else{
			imagen=new Image
			imagen.src= "images/"+i+".png"
			document.images['1-'+i].src=imagen.src
	}
	} 


if(valor == 4){
	imagen=new Image
	imagen.src= "images/3.png"
	seleccion=new Image
	seleccion.src="images/1_3.png"


		if (document.images['1-4'].src == imagen.src){
			document.images['1-4'].src=seleccion.src
		}else{
			document.images['1-4'].src=imagen.src;
		i=1;
		}
}else{
	imagen=new Image
	imagen.src= "images/"+valor+".png"
	seleccion=new Image
	seleccion.src="images/1_"+valor+".png"


		if (document.images['1-'+valor].src == imagen.src){
			document.images['1-'+valor].src=seleccion.src
		}else{
			document.images['1-'+valor].src=imagen.src;
	
		}
}

}

function valores(valor, fila){
	document.getElementById('20-'+fila).value = "0";
	document.getElementById('20-'+fila).value = valor;	

var total = 0;	
for(var i = 1; i<16; i++){
	var sumando = document.getElementById('20-'+i).value;
	total = parseInt(sumando) + parseInt(total); 
	}
 
	document.getElementById('22-1').value = total;
	document.getElementById('subtotal2').value = total;
	
	var subtotal1 = document.getElementById('subtotal1').value;
	var subtotal2 = document.getElementById('subtotal2').value;
	var total26 = parseInt(subtotal1) + parseInt(subtotal2);
	
	document.getElementById('total26').value = total26;
	
	var categoria = document.getElementById('total26').value;
	
	if(categoria > 95){
		document.images["Excelente"].src ="images/Excelente26.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
	}
	if(categoria > 84 && categoria < 96){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno26.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
	}
	if(categoria > 74 && categoria < 85){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno26.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
	}
	if(categoria > 59 && categoria < 75){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular26.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
	}
	if(categoria < 60){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio26.png";
	}
	
	



imagen1=new Image
imagen1.src= "images/selec.png"

var subtotal = 0;

for(cont=1;cont<6;cont++){

	for(i=6;i<21;i = i + 2){
	imagen2=new Image
	imagen2.src= document.images[i+"-"+cont].src
		if(imagen2.src == imagen1.src ){
			subtotal++;
					
		}
	}
	for(i=7;i<21;i = i + 2){
	imagen3=new Image
	imagen3.src= document.images[i+"-"+cont].src
		if(imagen3.src == imagen1.src ){
			subtotal++;
					
		}
	}
	subtotal = parseInt(subtotal) * parseInt(cont);
	document.getElementById('21-'+cont).value = subtotal ;
	subtotal = 0;
}

acciones();

}

function cambia_imagen2(valor) {

	var contador = 5; 

 for(var i=1;i<=6;i++) { 

	
		imagen=new Image
			imagen.src= "images/"+contador+".png"
			document.images['3-'+i].src=imagen.src
	  contador -= 1;
	  }


	
if(valor == 5){
	valor1= 1;
}
if(valor ==4){
	valor1 =2;
}
if(valor ==3){
	valor1 =3;
}
if(valor ==2){
	valor1 = 4;
}
if(valor == 1){
	valor1 = 5;
}
if(valor == 0){
	valor1 = 6;
}


	imagen=new Image
	imagen.src= "images/"+valor+".png"
	seleccion=new Image
	seleccion.src="images/1_"+valor+".png"


		if (document.images['3-'+valor1].src == imagen.src){
			document.images['3-'+valor1].src=seleccion.src
		}else{
			document.images['3-'+valor1].src=imagen.src;
	
		}


}

function cambia_imagen3(valor) {

	var contador = 5; 

 for(var i=1;i<=5;i++) { 

	
		imagen=new Image
			imagen.src= "images/"+contador+".png"
			document.images['4-'+i].src=imagen.src
	  contador -= 1;
	  }


	
if(valor == 5){
	valor1= 1;
}
if(valor ==4){
	valor1 =2;
}
if(valor ==3){
	valor1 =3;
}
if(valor ==2){
	valor1 = 4;
}
if(valor == 1){
	valor1 = 5;
}



	imagen=new Image
	imagen.src= "images/"+valor+".png"
	seleccion=new Image
	seleccion.src="images/1_"+valor+".png"


		if (document.images['4-'+valor1].src == imagen.src){
			document.images['4-'+valor1].src=seleccion.src
		}else{
			document.images['4-'+valor1].src=imagen.src;
	
		}


}

function cambia_imagen4(valor,valor26) {

if(valor == 3){
	valor1 = 1;
var posicion = 5;
}else{
	valor1 = 2;
	posicion = 6;

}

if(valor26 == 0 || valor26 == 1){

imagen=new Image
	imagen.src= "images/"+valor+".png"

	document.images['5-'+valor1].src=imagen.src;
	document.getElementById('P'+posicion).value = 0;
	
}else{

	seleccion=new Image
	seleccion.src="images/1_"+valor+".png"

	document.images['5-'+valor1].src=seleccion.src
	document.getElementById('P'+posicion).value = valor;
}


	

}
function cambia_imagen26(posicion,color,fila) {

  
for(var i=1;i<=5;i = i + 2) {
		imagen=new Image
		imagen.src= "images/fondo_1.png"
		document.images[fila+'-'+i].src=imagen.src
	}
	
for(var i=2;i<=5;i = i + 2) {
		imagen=new Image
		imagen.src= "images/fondo_2.png"
		document.images[fila+'-'+i].src=imagen.src
	}


imagen=new Image
	imagen.src= "images/fondo_"+color+".png"
seleccion=new Image
	seleccion.src="images/selec.png"


		if (document.images[fila+'-'+posicion].src == imagen.src){
		
			document.images[fila+'-'+posicion].src=seleccion.src
		}else{
			document.images[fila+'-'+posicion].src=imagen.src;
		
		}

	
	
}
function cambia_imagen261(posicion,color,fila) {

  
for(var i=1;i<=5;i = i + 2) {
		imagen=new Image
		imagen.src= "images/fondo_2.png"
		document.images[fila+'-'+i].src=imagen.src
	}
	
for(var i=2;i<=5;i = i + 2) {
		imagen=new Image
		imagen.src= "images/fondo_1.png"
		document.images[fila+'-'+i].src=imagen.src
	}


imagen=new Image
	imagen.src= "images/fondo_"+color+".png"
seleccion=new Image
	seleccion.src="images/selec.png"


		if (document.images[fila+'-'+posicion].src == imagen.src){
		
			document.images[fila+'-'+posicion].src=seleccion.src
		}else{
			document.images[fila+'-'+posicion].src=imagen.src;
		
		}

	acciones();
	
}

function evaluado(){

	var bandera = 1;
	var evaluado = document.getElementById('cat_evaluado').value 
	
		if(evaluado == ""){
			alert("Ingrese el Numero de Catalogo del Oficial a Evaluar");
				bandera = 0;
				document.getElementById('cat_evaluado').focus();
		}
			
		if (bandera == 1){
			
			trae_menu();
			var evaluado = 0;
			evaluado = document.getElementById('cat_evaluado').value;
			
			//xajax_busca_agregados(fecha, dependencia);
				$.post("evaluado.php",{variable:evaluado}, function(data){
			       // Ponemos la respuesta de nuestro script en el DIV recargado
			    $("#evaluado").html(data);
			   
			    });
		
		
		timer = setTimeout("mensaje()", 1000);
		
		
		}
		
		
		
}
function eva_arr_dem(){

	var evaluado = document.getElementById('cat_evaluado').value 
		
			//xajax_busca_agregados(fecha, dependencia);
				$.post("eva_arr_dem.php",{variable:evaluado}, function(data){
			       // Ponemos la respuesta de nuestro script en el DIV recargado
			    $("#DIV-demeritos").html(data);
			   
			    });
	
		
			//xajax_busca_agregados(fecha, dependencia);
				$.post("Cat_Per_Comte.php",{variable:evaluado}, function(data){
			       // Ponemos la respuesta de nuestro script en el DIV recargado
			    $("#DIV-percomte").html(data);
			   
			    });	
		
		
}
function evinm(e) {
	tecla = (document.all) ? e.keyCode : e.which;
  
	if (tecla==13)
		evaluador();
}
function evaluador(){

	var bandera = 1;
	var evaluador = document.getElementById('cat_evaluador').value 
	
		if(evaluador == ""){
			alert("Ingrese el Numero de Catalogo del Oficial que esta fungiendo como Oficial Evaluador");
				bandera = 0;
				document.getElementById('cat_evaluador').focus();
		}
			
		if (bandera == 1){
			
			
			var evaluado = 0;
			evaluador = document.getElementById('cat_evaluador').value;
			
			//xajax_busca_agregados(fecha, dependencia);
				$.post("evaluador.php",{variable:evaluador}, function(data){
			       // Ponemos la respuesta de nuestro script en el DIV recargado
			    $("#evaluador").html(data);
			   
			    });
		
		
		timer = setTimeout("mensaje2()", 1000);
		
		
		}
		
		
		
}
function mensaje(){

	var valor = document.getElementById('validacion').value;
	
	if(valor ==  0 ){
		alert ("Ingrese un número de Catálogo Válido");
		document.getElementById('cat_evaluado').value = "";
		document.getElementById('cat_evaluado').focus();
		document.getElementById('validacion').value = 1;
	}else{
		
		eva_arr_dem();
	}
	


}
function mensaje2(){

	var valor = document.getElementById('validacion1').value;
	
	if(valor ==  0 ){
		alert ("Ingrese un número de Catálogo Válido");
		document.getElementById('cat_evaluador').value = "";
		document.getElementById('cat_evaluador').focus();
		document.getElementById('validacion1').value = 1;
	}
	


}


//funciones que hay que revisar





$(function() {	    	    
					$("#dialog-modal").dialog({
						 width:1000,
						 height:1000,
						 modal: true,
						 autoOpen: false,
						 title: 'Seleccion de Opciones'
					});
				});
//funcion que se utiliza para los tabs

$(document).ready(function()
{
	$(".tab_content").hide();
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show();

	$("ul.tabs li").click(function()
       {
		$("ul.tabs li").removeClass("active");
		$(this).addClass("active");
		$(".tab_content").hide();

		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
});
//aqui finaliza la funcion que se utiliza para lños tabs




function trae_menu(){


var evaluado = 0;
			evaluado = document.getElementById('cat_evaluado').value;
			periodo = document.getElementById('periodo').value;
				
			//xajax_busca_agregados(fecha, dependencia);
				$.post("trae_menu.php",{variable:evaluado,variable2:periodo}, function(data){
			       // Ponemos la respuesta de nuestro script en el DIV recargado
			    $("#DIVmenu1").html(data);
			   
			    });      

}
		

function acciones(){

var cat = 0;
var categoria = document.getElementById('total26').value;

	if(categoria > 95){
		cat = 1;
	}
	if(categoria > 84 && categoria < 96){
		cat = 2;
	}
	if(categoria > 74 && categoria < 85){
		cat = 3;
	}
	if(categoria > 59 && categoria < 75){
		cat = 4;	
	}
	if(categoria < 60){
		cat = 5;
	}


	
			//xajax_busca_agregados(fecha, dependencia);
				$.post("acciones.php",{variable:cat}, function(data){
			       // Ponemos la respuesta de nuestro script en el DIV recargado
			    $("#prado26").html(data);
			   
			    });      


}		
			

		

function cerrar(){
	//$("#dialog-modal").dialog.hide(); 
	$("#dialog-modal").dialog( "close" );
}








function suma1(numero,valor) {
	var total = document.getElementById('total').value = 0;
		for (i=1; i < 7; i++){
			var suma = document.getElementById('P'+i).value;
			
			if(suma == ""){
				suma = 0;
			}
			total = parseInt(total) + parseInt(suma);
		}
		
		if(document.getElementById('P1').value == 4){
				total = total - 1; 	
		}
		

	document.getElementById('total').value = total;

	document.getElementById('subtotal1').value = total;

	var subtotal1 = document.getElementById('subtotal1').value;
	var subtotal2 = document.getElementById('subtotal2').value;
	var total26 = parseInt(subtotal1) + parseInt(subtotal2);
	
	document.getElementById('total26').value = total26;
	
	
	var categoria = document.getElementById('total26').value;
	
	if(categoria > 95){
		document.images["Excelente"].src ="images/Excelente26.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
		
	}
	if(categoria > 84 && categoria < 96){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno26.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
		
	}
	if(categoria > 74 && categoria < 85){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno26.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
		
	}
	if(categoria > 59 && categoria < 75){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular26.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio.png";
		
	}
	if(categoria < 60){
		document.images["Excelente"].src ="images/Excelente.png";
		document.images["MuyBueno"].src ="images/MuyBueno.png";
		document.images["Bueno"].src ="images/Bueno.png";
		document.images["Regular"].src ="images/Regular.png";
		document.images["Insatisfactorio"].src ="images/Insatisfactorio26.png";
		
	}
	
	acciones();
	
}
function asigna(){

	var valor = 0;
	
if(document.getElementById('Peva').value >= 0 && document.getElementById('Peva').value <= 59){
	valor = 0;
}
if(document.getElementById('Peva').value >= 60 && document.getElementById('Peva').value <= 70){
	valor = 2;
}
if(document.getElementById('Peva').value >= 71 && document.getElementById('Peva').value <= 80){
	valor = 3;
}
if(document.getElementById('Peva').value >= 81 && document.getElementById('Peva').value <= 90){
	valor = 4;
}
if(document.getElementById('Peva').value >= 91){
	valor = 5;
}

document.getElementById('P2').value = valor;
}


function verif1(n){
	permitidos=/[^0-9]/;
		if(permitidos.test(n.value)){
			alert ('Ingrese solo numeros');
			n.value="";
			n.focus();
		}
}

function modificar(){
var evaluador = document.getElementById('cat_evaluador').value;
var grado_evaluador = document.getElementById('grado_evaluador').value;
var perfil = document.getElementById('P1').value;
var pafe = document.getElementById('P2').value;
var dem = document.getElementById('P3').value;
var arrestos = document.getElementById('P4').value;
var mot = document.getElementById('acc_mot').value;
var corr = document.getElementById('acc_cor').value;
var comte = document.getElementById('cat_comte').value;
var personal = document.getElementById('cat_per').value;
var band = true;
var bandera = true;
var i = 1;
	if(evaluador == ""){
		alert ('El Campo del Oficial que funge como evaluador debe de estar lleno ');
				document.getElementById('cat_evaluador').style.background='#F6CECE'
				document.getElementById('cat_evaluador').style.borderColor='red';
				band = false;
	}
	if(band == true){ 
		if(grado_evaluador == ""){
			alert ('El Campo del Grado del Oficial que funge como evaluador debe de estar lleno ');
					document.getElementById('grado_evaluador').style.background='#F6CECE'
					document.getElementById('grado_evaluador').style.borderColor='red';
					band = false;
		}
	}
	

	if(band == true){
		if(perfil == "" || perfil == 0){
			alert ('Debe seleccionar una nota para el Perfil Biofisico ');
			band = false;
		}
	}
	if(band == true){
		if(pafe == ""){
			alert ('Debe seleccionar una nota para la P.A.F.E. ');
			band = false;
		}
	}
	if(band == true){
		if(dem == ""){
			alert ('Debe seleccionar una nota segun los demeritos obtenidos');
			band = false;
		}
	}
	if(band == true){
		if(arrestos == "" || arrestos == 0){
			alert ('Debe seleccionar una nota segun los arrestos obtenidos');
			band = false;
		}
	}

	if(band == true){

		for(i = 1; i<= 15; i++){
			if(bandera == true ){
				if(document.getElementById('20-'+i).value == 0){
					alert("El concepto numero "+ " " + i + " " + "no tiene calificacion");
					bandera = false;
					band = false;
				}
			}
		}
	}
	if(band == true){
		if(mot == 0 && corr == ""){
			alert ("Debe escoger una accion motivadora");
			band = false;
		}
	}
	if(band == true){
		if(corr == 0 && mot == ""){
			alert ("Debe escoger una accion correctiva");
			band = false;
		}
	}
	if(band == true){
		if(comte == ""){
			alert ("Ingrese el Numero de Catalogo del Comandante");
			band = false;
		}
	}
	if(band == true){
		if(personal == ""){
			alert ("Ingrese el Numero de Catalogo del Oficial de Personal");
			band = false;
		}
	}
	if(band == true){ 
		document.form1.submit();
	}	
	
}

function guardar(){
var evaluador = document.getElementById('cat_evaluador').value;
var grado_evaluador = document.getElementById('grado_evaluador').value;
var perfil = document.getElementById('P1').value;
var pafe = document.getElementById('P2').value;
var dem = document.getElementById('P3').value;
var arrestos = document.getElementById('P4').value;
var mot = document.getElementById('acc_mot').value;
var corr = document.getElementById('acc_cor').value;
var comte = document.getElementById('cat_comte').value;
var personal = document.getElementById('cat_per').value;
var band = true;
var bandera = true;
var i = 1;
	if(evaluador == ""){
		alert ('El Campo del Oficial que funge como evaluador debe de estar lleno ');
				document.getElementById('cat_evaluador').style.background='#F6CECE'
				document.getElementById('cat_evaluador').style.borderColor='red';
				band = false;
	}
	if(band == true){ 
		if(grado_evaluador == ""){
			alert ('El Campo del Grado del Oficial que funge como evaluador debe de estar lleno ');
					document.getElementById('grado_evaluador').style.background='#F6CECE'
					document.getElementById('grado_evaluador').style.borderColor='red';
					band = false;
		}
	}
	

	if(band == true){
		if(perfil == "" || perfil == 0){
			alert ('Debe seleccionar una nota para el Perfil Biofisico ');
			band = false;
		}
	}
	if(band == true){
		if(pafe == ""){
			alert ('Debe seleccionar una nota para la P.A.F.E. ');
			band = false;
		}
	}
	if(band == true){
		if(dem == ""){
			alert ('Debe seleccionar una nota segun los demeritos obtenidos');
			band = false;
		}
	}
	if(band == true){
		if(arrestos == "" || arrestos == 0){
			alert ('Debe seleccionar una nota segun los arrestos obtenidos');
			band = false;
		}
	}

	if(band == true){

		for(i = 1; i<= 15; i++){
			if(bandera == true ){
				if(document.getElementById('20-'+i).value == 0){
					alert("El concepto numero "+ " " + i + " " + "no tiene calificacion");
					bandera = false;
					band = false;
				}
			}
		}
	}
	if(band == true){
		if(mot == 0 && corr == ""){
			alert ("Debe escoger una accion motivadora");
			band = false;
		}
	}
	if(band == true){
		if(corr == 0 && mot == ""){
			alert ("Debe escoger una accion correctiva");
			band = false;
		}
	}
	if(band == true){
		if(comte == ""){
			alert ("Ingrese el Numero de Catalogo del Comandante");
			band = false;
		}
	}
	if(band == true){
		if(personal == ""){
			alert ("Ingrese el Numero de Catalogo del Oficial de Personal");
			band = false;
		}
	}
	
	if(band == true){ 
		document.form1.submit();
	}	
}
function principal (cat){

var catalogo = cat;

if (catalogo == 0){
 catalogo = document.getElementById('cat').value;
}
if (catalogo == 1){
 catalogo = document.getElementById('cat1').value;
}
 
	document.form1.submit();

}
function formato (cat){

var catalogo = cat;

document.getElementById('form1').action = 'formato.php';
		document.getElementById('form1').submit();

}


function modificar2(){

	var bandera=0;

	if(document.getElementById('periodo').value == 0){
		alert('Debe Seleccionar un periodo de Evaluacion');
		bandera = 1;
	}

	if(document.form1.proyeccion.value  == 0){
		alert('Debe Seleccionar una proyeccion de carrera ');
		document.getElementById('proyeccion').style.background='#F6CECE'
		document.getElementById('proyeccion').style.borderColor='#F6CECE'
		bandera = 1;
	}

	for (i=1; i < 4; i++){
		a = 3;
			document.getElementById( a + '-' + i).style.background='white'
			document.getElementById( a + '-' + i).style.borderColor='white'	
		if (document.getElementById( a + '-' + i).value == ""){
			alert ('Los campos de las funciones del Puesto tienen que estar llenos ');
			document.getElementById( a + '-' + i).style.background='#F6CECE'
			document.getElementById( a + '-' + i).style.borderColor='red'
			bandera = 1;
			break;
		}
	}
	
	for (i=1; i < 4; i++){
		a = 4;
			document.getElementById( a + '-' + i).style.background='white'
			document.getElementById( a + '-' + i).style.borderColor='white'	
		if (document.getElementById( a + '-' + i).value == ""){
			alert ('Los campos de los Objetivos del Puesto tienen que estar llenos ');
			document.getElementById( a + '-' + i).style.background='#F6CECE'
			document.getElementById( a + '-' + i).style.borderColor='red'
			bandera = 1;			
			break;
		}
	}
	
	for (i=1; i < 4; i++){
		a = 6;
		
		if(i==2){
		
		}else{
			
				document.getElementById( a + '-' + i).style.background='white'
				document.getElementById( a + '-' + i).style.borderColor='white'	
			if (document.getElementById( a + '-' + i).value == ""){
				alert ('Los campos de los Conceptos de los Evaluadores tienen que estar llenos ');
				document.getElementById( a + '-' + i).style.background='#F6CECE'
				document.getElementById( a + '-' + i).style.borderColor='red'
				bandera = 1;			
				break;
			}
		}
	}
	
	if(bandera == 0){
		document.getElementById('form1').action = 'modifica.php';
		document.getElementById('form1').submit();
	}
}



function regresa_menu(){
	document.getElementById('form1').action = 'menu.php';
	document.getElementById('form1').submit();
}
function direcciona_formatos(){
	document.getElementById('form1').action = 'formatos.php';
	document.getElementById('form1').submit();
}
 
function impresion(){

	var evaluado = document.getElementById('cat_evaluado').value;
	var evaluador = document.getElementById('cat_evaluador').value;
	var anio = document.getElementById('anio').value;
	var clasificacion = document.getElementById('clasificacion').value;

		window.open('impresion1.php?evaluado='+evaluado+'&anio='+anio+'&clasificacion='+clasificacion+'&evaluador='+evaluador);
		timer = setTimeout("impresion2()", 1000);
	
}


function impresion2(){
	
var evaluado = document.getElementById('cat_evaluado').value;
	var evaluador = document.getElementById('cat_evaluador').value;
	var anio = document.getElementById('anio').value;
	var clasificacion = document.getElementById('clasificacion').value;

		window.open('impresion2.php?evaluado='+evaluado+'&anio='+anio+'&clasificacion='+clasificacion+'&evaluador='+evaluador);
}
var catalogo = 0;
var anio = 0;
function formato1(cat,ano){

	 catalogo = cat;
	 anio = ano;
 
		window.open('Formato1.php?evaluado='+catalogo+'&anio='+anio);
		timer = setTimeout("formato2()", 1000);
	
}


function formato2(){


		window.open('Formato2.php?evaluado='+catalogo+'&anio='+anio);
}


function impresion_formato(){

	var bandera=0;

	if(document.getElementById('periodo').value == 0){
		alert('Debe Seleccionar un periodo de Evaluacion');
		bandera = 1;
	}

		document.getElementById('catalogo').style.background='white'
		document.getElementById('catalogo').style.borderColor='white'	
	if(document.getElementById('catalogo').value == ""){
		alert('Debe Ingresar el Catalogo del Oficial a Evaluar');
		document.getElementById('catalogo').style.background='#F6CECE'
		document.getElementById('catalogo').style.borderColor='red'
		bandera = 1;
	}
		document.getElementById('cat_inmediato1').style.background='white'
		document.getElementById('cat_inmediato1').style.borderColor='white'	
	if(document.getElementById('cat_inmediato1').value == ""){
		alert('Debe Ingresar el Catalogo del Oficial Evaluador Inmediato');
		document.getElementById('cat_inmediato1').style.background='#F6CECE'
		document.getElementById('cat_inmediato1').style.borderColor='red'
		bandera = 1;
	}
	
		document.getElementById('cat_final').style.background='white'
		document.getElementById('cat_final').style.borderColor='white'	
	if(document.getElementById('cat_final').value == ""){
		alert('Debe Ingresar el Catalogo del Oficial Evaluador final');
		document.getElementById('cat_final').style.background='#F6CECE'
		document.getElementById('cat_final').style.borderColor='red'
		bandera = 1;
	}
	
	var cat = document.getElementById('catalogo').value;
	var per = document.getElementById('periodo').value;
	var cat_inm = document.getElementById('cat_inmediato1').value;
	var cat_int = document.getElementById('cat_intermedio').value;
	var cat_fin = document.getElementById('cat_final').value;
	

	if(bandera == 0){
		window.open('impresion1_formato.php?cat_evaluado='+cat+'&periodo='+per+'&cat_inmediato='+cat_inm+'&cat_intermedio='+cat_int+'&cat_final='+cat_fin);
		timer = setTimeout("formato2()", 1000);
	}
}


function formato25(){

	var cat = document.getElementById('catalogo').value;
	var per = document.getElementById('periodo').value;
			window.open('impresion2_formato.php?cat_evaluado='+cat+'&periodo='+per);
}
 
 	function suma(){

var valor1 =  document.getElementById('1eva').value;
var valor2 =  document.getElementById('2eva').value;
var valor3 =  document.getElementById('3eva').value;
var valor4 =  document.getElementById('4eva').value;
var suma = 0;;
var contador = 0;
var promedio = 0;



if(valor1 != ""){
	suma += parseInt(valor1);
	contador ++;
}
 if(valor2 != ""){
	suma += parseInt(valor2);
	contador ++;
}
if(valor3 != ""){
	suma += parseInt(valor3);
	contador ++;
}
if(valor4 != ""){
	suma += parseInt(valor4);
	contador ++;
}
 
promedio = (suma/contador);

document.getElementById('Reva').value = suma;
document.getElementById('Peva').value = promedio.toFixed(2);
 
cambia_imagen1();

}




