// JavaScript Document
function menuprincipal()
{	
	document.frmdatos.action='../administrador/menu.php';
	document.frmdatos.submit();	
}
function popupeditarexamen(Identificador_Xmod_Examen_Int)
{
	var cadena="";
	cadena="editarexamen.php?idexamen="+Identificador_Xmod_Examen_Int;
	secondwindow=open(cadena,'Editar','height=900,width=600,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}

function popupverexamen(Identificador_Xmod_Examen_Int)
{
	var cadena="";
	cadena="verexamen.php?idexamen="+Identificador_Xmod_Examen_Int;
	secondwindow=open(cadena,'Editar','height=220,width=680,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function popupverexamenvermas(Identificador_Xmod_Examen_Int)
{
	var cadena="";
	cadena="verexamenvermas.php?idexamen="+Identificador_Xmod_Examen_Int;
	secondwindow=open(cadena,'Editar','height=620,width=680,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}


function editarexamen(valor)
{
	if(valor==0){cargar();setTimeout("salir()",4500);}	
}

function cargar(){
document.getElementById('qq').innerHTML="<table border='0' align='center'><tr><td>&nbsp;</td><td><strong>--------------Guardando-------------</strong></td><td>&nbsp;</td></tr><tr><td>0%</td><td><dl><dd><span><em style='left:200px'>100%</em></span></dd></dl></td><td>100%</td></tr></table>";
}
function salir(){
window.opener.location.reload();
window.close();
}

function eliminarexamen(Identificador_Xmod_Examen_Int)
{
	if(confirm("Realmente desea eliminar este Examen"))
	{
		document.frmdatos.action='eliminarexamen.php';
		document.getElementById('Id_Xmod_Examen_Int').value=Identificador_Xmod_Examen_Int;
		document.frmdatos.submit();			
	}	
}

function examenes()
{	
	document.getElementById('examen').style.display ="none";
	document.getElementById('mens').style.display ="";
	document.getElementById('oficina').style.display ="none";
	/*document.frmdatos.action='registromensajeseventos.php';
	document.frmdatos.submit();	*/
}
function asignarcorreo()
{
	document.getElementById('examen').style.display ="none";
	document.getElementById('mens').style.display ="none";
	document.getElementById('oficina').style.display ="";
}

function guardamensajes()
{
	$(document).ready(
				function()
				{				
					$.post("ajaxmensajesexamenes.php",{mensajebda:$("#mensajebda").val(),descripcionbda:$("#descripcionbda").val(),mensajedda:$("#mensajedda").val(),descripciondda:$("#descripciondda").val(),mensajebdaing:$("#mensajebdaing").val(),descripcionbdaing:$("#descripcionbdaing").val(),mensajeddaing:$("#mensajeddaing").val(),descripcionddaing:$("#descripcionddaing").val()},
								function(data)
								{ 	
									alert("Los Mensajes se guardaron satisfactoriamente");
									//$('form')[0].reset();								
								}
							);						
				}
	);	
}
function guardausuarioscorreos()
{
	cadena="emailinm,nombredc";
	if(verificarcampos2(cadena)==1)
	{		
		$(document).ready(
					function()
					{				
						$.post("ajaxusuariocosrreos.php",{nombredc:$("#nombredc").val(),correodc:$("#emailinm").val(),master:$("#master").val()},
									function(data)
									{ 
										alert("Los datos se guardaron satisfactoriamente");
										//$('form')[0].reset();								
									}
								);						
					}
		);
	}
	else
	{
		alert("llene los campos e color rojo");	
	}
}
function vermas(Identificador_Xmod_Examen_Int,Idioma)
{
//	alert(Identificador_Xmod_Examen_Int);
	$(document).ready(
				function()
				{				
					$.post("xmod_eventos/ajaxeventos.php",{Identificador_Xmod_Examen_Int:Identificador_Xmod_Examen_Int,Idioma:Idioma},
								function(data)
								{ 																			
									$("#subseccion").html(data);
								}
							);						
				}
	);	
}
function crearexamengaleriafotos(Identificador_Xmod_Examen_Int_Galeria)
{	
	document.getElementById('Identificador_Xmod_Examen_Int_Galeria').value=Identificador_Xmod_Examen_Int_Galeria;
	document.frmdatos.action='creaexamengaleriafotos.php';
	document.frmdatos.submit();	
}

function verexamenatras(Idioma)
{
	
$(document).ready(
				function()
				{				
					$.post("xmod_examenes_int/ajaxexamenatras.php",{Idioma:Idioma},
								function(data)
								{ 																			
									$("#subseccion").html(data);
								}
							);						
				}
	);	
}
function creaexamen()
{
	document.getElementById('examen').style.display ="";
	document.getElementById('mens').style.display ="none";
	document.getElementById('oficina').style.display ="none";
	document.frmdatos.action='creaexamen.php';
	document.frmdatos.submit();		
}


function recargarmasterexamen()
{	
	IdMaster=document.getElementById('master').value;
	document.frmdatos.method='get';
	document.frmdatos.action='menuexamenes.php?IdMaster='+IdMaster;
	document.frmdatos.submit();	
}
function verificarcampos2(cadena)
{	
	vec=cadena.split(',');
	cont=vec.length;
	cont2=vec.length;
	
	for (i=0;i<vec.length;i++)
	{
		if(vec[i]!="emailinm")
		{
			if(Trim(document.getElementById(vec[i]).value) =="")
			{
				document.getElementById(vec[i]).style.background="red";
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
				cont=cont-1;
			}
			else
			{
				document.getElementById(vec[i]).style.background="";
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
			}			
		}
		else
		{
			if( Trim(document.getElementById('emailinm').value) =="" ||  valEmail(document.getElementById('emailinm').value)==false)
			{
				document.getElementById(vec[i]).style.background="red";
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
				cont=cont-1;		
			}
			else
			{
				document.getElementById(vec[i]).style.background="";	
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
			}						
		}
	}
	if(cont==cont2)
	{
		return 1;
	}
	else
	{
		return 0;
	}	
}
//funcion para validar espacios 
function Trim( str )
{
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}
//funcion para validar espacios por izquierda
function TrimLeft( str )
{
	var resultStr = "";
	var i = len = 0;
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;
	// Make sure the argument is a string
	str += "";
	if (str.length == 0) 
		resultStr = "";
	else {	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;
   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}
  	return resultStr;
}
//funcion para validar espacios por derecha
function TrimRight( str )
{
	var resultStr = "";
	var i = 0;
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;
	// Make sure the argument is a string
	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		// Loop through string starting at the end as long as there
  		// are spaces.
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
 		// When the loop is done, we're sitting at the last non-space char,
 		// so return that char plus all previous chars of the string.
  		resultStr = str.substring(0, i + 1);
  	}  	
  	return resultStr;  	
}
//funcion para validar correo
function valEmail(valor)
{
	re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; 
    if(!re.exec(valor))
	{
        return false;
    }else
	{
        return true;
    }
}
function valorfecha(valor,valor2)
{
	var sel = document.getElementById(valor2);
	for (var i = 0; i < sel.length; i++) {
		if(sel[i].value==valor)
		{
			sel[i].selected=true;
		}
	}
}	

function verexamen(Id_Xmod_Examen_Int,Idioma)
{
$(document).ready(
				function()
				{				
					$.post("xmod_examenes_int/ajaxexamenes.php",{Id_Xmod_Examen_Int:Id_Xmod_Examen_Int,Idioma:Idioma},
								function(data)
								{ 																			
									$("#subseccion").html(data);
								}
							);						
				}
	);	
}
function verexamen2(Id_Xmod_Examen_Int,Idioma)
{
scrollBy(0,400);	
document.getElementById("front1").style.display ="none";
document.getElementById("front2").style.display ="";
$(document).ready(
				function()
				{				
					$.post("xmod_examenes_int/ajaxexamenes.php",{Id_Xmod_Examen_Int:Id_Xmod_Examen_Int,Idioma:Idioma},
								function(data)
								{ 																			
									$("#subseccion").html(data);
								}
							);						
				}
	);	
}


function popupformulario(Id_Xmod_Examen_Int)
{
var cadena="";
	cadena="xmod_examenes_int/formularisolicitudexamen.php?Id_Xmod_Examen_Int="+Id_Xmod_Examen_Int;
	secondwindow=open(cadena,'Editar','height=470,width=580,scrollbars=no,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);	
}

function registrarinscripcion()
{				
	cadena="emailinm,nombre";
	if(verificarcamposn(cadena)==1)
	{				
		$(document).ready(
					function()
					{				
						$.post("ajaxnotificarregistroinscripcion.php",{emailinm:$("#emailinm").val(),nombre:$("#nombre").val(),direccion:$("#direccion").val(),ciudad:$("#ciudad").val(),pais:$("#pais").val(),telefono:$("#telefono").val(),celular:$("#celular").val(),observacion:$("#observacion").val()},
									function(data)
									{ 
										alert("La solicitud de inscripcion se envio satisfactoriamente");										
										window.close();			
										//$('form')[0].reset();								
									}
								);						
					}
		);
	}
	else
	{
		alert("llene los campos e color rojo");	
	}
}
function verificarcamposn(cadena)
{	
	vec=cadena.split(',');
	cont=vec.length;
	cont2=vec.length;
	
	for (i=0;i<vec.length;i++)
	{
		if(vec[i]!="emailinm")
		{
			if(Trim(document.getElementById(vec[i]).value) =="")
			{
				document.getElementById(vec[i]).style.background="red";
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
				cont=cont-1;
			}
			else
			{
				document.getElementById(vec[i]).style.background="";
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
			}			
		}
		else
		{
			if( Trim(document.getElementById('emailinm').value) =="" ||  valEmail(document.getElementById('emailinm').value)==false)
			{
				document.getElementById(vec[i]).style.background="red";
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
				cont=cont-1;		
			}
			else
			{
				document.getElementById(vec[i]).style.background="";	
				document.getElementById(vec[i]).value =Trim(document.getElementById(vec[i]).value);
			}						
		}
	}
	if(cont==cont2)
	{
		return 1;
	}
	else
	{
		return 0;
	}	
}
function cargarnotas2()
{
	var cadena="";
	cadena="carganotas.php?temp=1";
	secondwindow=open(cadena,'Editar','height=220,width=680,scrollbars=yes,directories=NO,location=NO,alwaysRaised');
    secondwindow.moveTo(150,120);
}
function guardarcargarnotas()
{	
	cadena="archivo";
	vericampos=document.getElementById('archivo').value;
	if(vericampos!="")
	{
		document.frmdatos.action='ReadExcellPHP/guardarcarganotas.php';
		document.frmdatos.submit();	
	}
	else
	{
		alert("por favor seleccione un aerchivo a adjuntar");
	}	
}
function editarnotas(valor)
{
	if(valor==0){cargar();setTimeout("salir()",4500);}	
}

function cargarnotas()
{
	ced=Trim(document.getElementById('cedula').value);	
	if(ced!="")
	{				
		$(document).ready(
					function()
					{				
						$.post("xmod_examenes_int/ajaxvernotas.php",{cedula:$("#cedula").val()},
									function(data)
									{ 		
										if(data==1)
										{											
											alert("SU DOCUMENTO NO ESTÁ REGISTRADO, POR FAVOR ACTUALICE SUS DATOS EN SECRETARIA O LLAMÁNDONOS AL TELÉFONO PBX: (7) 634 3300 / FAX: (7) 645 3374");																		
										}
										else
										{	
											scrollBy(0,-550);	
											document.getElementById("idcabezote").style.display ="none";
											document.getElementById("idcabezoteint").style.display ="";
											document.getElementById("idlateral").style.display ="";
											document.getElementById("front1").style.display ="none";
											document.getElementById("front2").style.display ="";										
											$("#subseccion").html(data);
											document.getElementById('cedula').value="";		
										}										
									}
								);						
					}
		);
	}
	else
	{
		alert("ingrese un  valor adecuado");	
	}	 
}

function descarganotas(Archivo_xmod_Notas_Archivos)
{
	//alert(Archivo_xmod_Notas_Archivos);
	document.getElementById('descarga1').value=Archivo_xmod_Notas_Archivos;
	document.frmdatosdes.action='xmod_notas/descarga.php';
	document.frmdatosdes.submit();		
}
