

function limiarpp(){

    document.getElementById('s_id1').value='*';
    document.getElementById('s_id2').value='TODAS LAS SEDES';

    document.getElementById('j_id1').value='*';
    document.getElementById('j_id2').value='TODAS LAS JORNADAS';


    var frame = document.getElementById("preview2"),
    frameDoc = frame.contentDocument || frame.contentWindow.document;
    frameDoc.documentElement.innerHTML = "";
    
//    $('#preview2').contentWindow.Document.Body.innerHTML = '';
    
    document.getElementById('p_id1').value='';
    document.getElementById('p_id2').value='';

    document.getElementById('g_id1').value='';
    document.getElementById('g_id2').value='';

    document.getElementById('g2_id1').value='';
    document.getElementById('g2_id2').value='';


}

function get(id){
   return document.getElementById(id).value;
}


function pdf(){
    var sede=get('s_id1');

    var jornada=get('j_id1');

    var periodo=get('p_id1');

    var grad_ini=get('g_id1');
    
    if(grad_ini=='11' || grad_ini=='10')
        {
            grad_ini=parseInt(grad_ini);
        }

    var grad_fin=get('g2_id1');  
    
    if(grad_fin=='11' || grad_fin=='10')
        {
            grad_fin=parseInt(grad_fin);
        }
    
   
    
   if(sede=='')
       {
           alert('Ingrese Sede');
           exit();
       }
       
   if(jornada=='')
       {
           alert('Ingrese Jornada');
           exit();
       } 
       
   if(periodo=='')
       {
           alert('Ingrese Periodo');
           exit();
       }
       
    if(grad_ini=='')
       {
           alert('Ingrese Grado Inicial');
           exit();
       }
    
    if(grad_fin=='')
       {
           alert('Ingrese Grado Final');
           exit();
       }
       
       
      if(grad_ini>grad_fin){
          alert('El grado Inicial debe de ser\nmenor que el grado Final');
          document.getElementById('g_id1').value='';
          document.getElementById('g_id2').value='';
          document.getElementById('g2_id1').value='';
          document.getElementById('g2_id2').value='';
          document.getElementById('g_id1').focus();
          exit();
      }
       
       
    window.open("app/model/reportes/promedios_cursos.php?sede="+sede+"&jornada="+jornada+"&periodo="+periodo+"&grad_ini="+grad_ini+"&grad_fin="+grad_fin, "preview2");

}

function retornar(){
     var rd=parametro('dir'); 
    
    if(rd=='1')
        {
            location.href="../menu.php";
        }else   if(rd=='2')
        {
            var id=parametro('id');
            location.href="../menu_profesor.php?id="+id+'&dir=2';
        }else if(rd=='3')
        {
            var id=parametro('id');
            location.href="../menu_coordinador.php?id="+id+'&dir=3';
        }
}

function parametro( name ){
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp ( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null )
		return "";
	else
		return results[1];
}
