/* LISTADO DE FUNCIONES */

function abreVentana(url,target,width,height){
	var h=(screen.height-height)/2;
	var w=(screen.width-width)/2;
	var woptions='toolbar=no,directories=no,menubar=no,location=no,resizable=no,top='+h+',left='+w+',scrollbars=yes,status=no,width=' + width + ',height=' + height;
	var FLOAT=open(url,target,woptions);
	if (FLOAT.focus!=null) FLOAT.focus();
}


function tamdiv(){
	var cuerpo_tam = document.getElementById('cuerpo').offsetHeight;
	var col_izq = document.getElementById('col_izq_menu');
	col_izq.style.height=cuerpo_tam+"px";
}

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 mostrarComentarios(id_div){
	var div = document.getElementById(id_div);
	if(div.style.display=='block'){
		div.style.display='none';
	}else{
		div.style.display='block';
	}
	tamdiv();
}

function linkear(id_not){
	location="index.php?contenido=ver_curso.php&id_curso="+id_not;
}

function enviarComentario(){
	var des, nom, email, comentario, num_noticia, area, enviado;
	enviado = document.getElementById('enviado');
	nom = document.getElementById('nombre').value;
	email = document.getElementById('email').value;
	comentario = document.getElementById('comentario').value;
	num_noticia = document.getElementById('num_noticia').value;
	area = document.getElementById('area').value;
	if( (nom=="") || (email=="") || (comentario=="") ){
		enviado.innerHTML = "<p class='rojo'>:: Falta completar datos ::</p>";
	}else{
		ajax=nuevoAjax();
		ajax.open("POST", "contenidos/enviar_comentario.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==1) {
				enviado.innerHTML = '<img src=img/precarga.gif />'
			}
	
			else if (ajax.readyState==4) {
				enviado.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		//ajax.setRequestHeader("Accept-Charset", "ISO-8859-1;q=0.7");
		ajax.send("nom="+nom+"&email="+email+"&comentario="+comentario+"&num_noticia="+num_noticia+"&area="+area)
	}
}

function enviarNota(){
	var des, nom, enviado;
	enviado = document.getElementById('enviado');
	nom = document.getElementById('nombre').value;
	des = document.getElementById('destinatario').value;
	if( (nom=="") || (des=="") ){
		enviado.innerHTML = "<p class='rojo'>:: Falta completar datos ::</p>";
	}else{
		ajax=nuevoAjax();
		ajax.open("POST", "contenidos/enviar_nota.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==1) {
				enviado.innerHTML = '<img src=img/precarga.gif />'
			}
	
			else if (ajax.readyState==4) {
				enviado.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("nom="+nom+"&des="+des)
	}
}

function contactoAccion(){
	var destinatario, nya, telefono, paises, estados, consulta, email, enviado;
	
	enviado = document.getElementById('enviado');
	destinatario = document.getElementById('destinatario').value;
	nya = document.getElementById('nya').value;
	telefono = document.getElementById('telefono').value;
	paises = document.getElementById('paises').value;
	estados = document.getElementById('estados').value;
	email = document.getElementById('email').value;
	consulta = document.getElementById('consulta').value;
	
	if ((destinatario == 0) || (nya == "") || (telefono == "") || (paises == 0) || (estados == 0) || (consulta == "") || (email == "")) {
		enviado.innerHTML = "<p class='rojo' align='center'>:: Falta completar datos ::</p>";
	}else{
		ajax=nuevoAjax();
		ajax.open("POST", "contenidos/contacto_accion.php",true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==1) {
				enviado.innerHTML = '<img src=img/precarga.gif />'
			}
	
			else if (ajax.readyState==4) {
				enviado.innerHTML = ajax.responseText
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("destinatario="+destinatario+"&nya="+nya+"&telefono="+telefono+"&paises="+paises+"&email="+email+"&estados="+estados+"&consulta="+consulta)
	}
}

function chkNumeros(){
  if( (event.keyCode>47 && event.keyCode<58) || (event.keyCode==13)){
  	if( event.keyCode>47 && event.keyCode<58){
  	return;
  	}
 }
 	event.keyCode=0;
}

//-----	SOLO SE INGRESAN NUMEROS Y EL PUNTO
function chkNumerosP(){
  if( (event.keyCode>47 && event.keyCode<58) || (event.keyCode==13) || (event.keyCode==46)){
  	if( (event.keyCode>47 && event.keyCode<58) || (event.keyCode==46)){
  	return;
  	}
 }
 	event.keyCode=0;
}

//-----	SOLO SE INGRESAN NUMEROS Y la barra "/"
function chkNumerosB(){
  if( (event.keyCode>47 && event.keyCode<58) || (event.keyCode==13) || (event.keyCode==47)){
  	if( (event.keyCode>47 && event.keyCode<58) || (event.keyCode==47)){
  	return;
  	}
 }
 	event.keyCode=0;
}

function chkProm(prom){
	var prom_ing;
	prom_ing = document.getElementById('prom').value;
	if (prom_ing < prom) {
		alert("El promedio debe ser igual o mayor a "+prom);
		document.getElementById('prom').focus();
	}
}


function getRadioButtonSelectedValue(ctrl)
{
	for(i=0;i<ctrl.length;i++){
		//alert(ctrl[i].checked);
		//alert(ctrl[i].value);
		if(ctrl[i].checked) return ctrl[i].value;
		}
		return"";
}


function Validar_fecha(Cadena){   
    var Fecha= new String(Cadena);   // Crea un string   
    var RealFecha= new Date();   // Para sacar la fecha de hoy   
    // Cadena Año   
    var Ano= new String(Fecha.substring(Fecha.lastIndexOf("/")+1,Fecha.length));
	var AnoBis= Ano % 4;
	var f = new Date();
	var AnoActual = f.getFullYear();
    // Cadena Mes   
    var Mes= new String(Fecha.substring(Fecha.indexOf("/")+1,Fecha.lastIndexOf("/")))   
    // Cadena D\u00ed a   
    var Dia= new String(Fecha.substring(0,Fecha.indexOf("/")))   
  
    // Valido el año   
    if (isNaN(Ano) || Ano.length<4 || parseFloat(Ano)<1900 || Ano>AnoActual){   
            alert('A\u00f1o inv\u00e1lido')   
        return false   
    }   
    // Valido el Mes   
    if (isNaN(Mes) || parseFloat(Mes)<1 || parseFloat(Mes)>12){   
        alert('Mes inv\u00e1lido')   
        return false   
    }   
    // Valido el Dia   
    if (isNaN(Dia) || parseInt(Dia, 10)<1 || parseInt(Dia, 10)>31){   
        alert('D\u00eda inv\u00e1lido')   
        return false   
    }   
    if (Mes==4 || Mes==6 || Mes==9 || Mes==11 || Mes==2) {   
        if (AnoBis!=0 && Mes==2 && Dia > 28 || Dia>30) {   
            alert('D\u00eda inv\u00e1lido')   
            return false   
        }
		if (AnoBis==0 && Mes==2 && Dia > 29 || Dia>30) {   
            alert('D\u00eda inv\u00e1lido')   
            return false   
        }   
   
    }   
}


function verify() {

var themessage = "Los siguientes campos, son requeridos para finalizar la inscripcin: ";

if (getRadioButtonSelectedValue(document.inscripcion.sexo)=="") {
themessage = themessage + " Sexo";
}
if (document.inscripcion.nombre.value=="") {
themessage = themessage + " - Nombre";
}
if (document.inscripcion.apellido.value=="") {
themessage = themessage + " - Apellido";
}
if (document.inscripcion.ape_madre.value=="") {
themessage = themessage + " - Apellido de la Madre";
}
if (document.inscripcion.fecha_nac.value=="") {
themessage = themessage + " - Fecha de Nacimiento";
}
if (document.inscripcion.mail.value=="") {
themessage = themessage + " - Correo electronico";
}
if (document.inscripcion.nro_doc.value=="") {
themessage = themessage + " - Numero de Documento";
}
if (document.inscripcion.id_univ.value=="") {
themessage = themessage + " - Universidad";
}
if (document.inscripcion.prom.value=="") {
themessage = themessage + " - Promedio";
}
if (document.inscripcion.especialidades.value=="") {
themessage = themessage + " - Especialidad";
}
if (document.inscripcion.pais_id.value=="0") {
themessage = themessage + " - Pais";
}
if (document.inscripcion.prov.value=="0") {
themessage = themessage + " - Provincia";
}
if (document.inscripcion.calle.value=="") {
themessage = themessage + " - Calle";
}
if (document.inscripcion.numero.value=="") {
themessage = themessage + " - Numero";
}	
if (document.inscripcion.piso.value=="") {
themessage = themessage + " - Piso";
}	
if (document.inscripcion.dpto.value=="") {
themessage = themessage + " - Departamento";
}
if (document.inscripcion.cp.value=="") {
themessage = themessage + " - Codigo Postal";
}	
if (document.inscripcion.loc.value=="") {
themessage = themessage + " - Localidad";
}
if (document.inscripcion.area_tel.value=="") {
themessage = themessage + " - Codigo de Area de Telefono";
}
if (document.inscripcion.telefono.value=="") {
themessage = themessage + " - Telfono";
}	
if (document.inscripcion.area_cel.value=="") {
themessage = themessage + " - Codigo de Area de Celular";
}
if (document.inscripcion.tel_cel.value=="") {
themessage = themessage + " - Celular";
}	
if (document.inscripcion.agree.checked == false) {
themessage = "Debe Aceptar las condiciones de Inscrpcion";
}	
if (themessage == "Los siguientes campos, son requeridos para finalizar la inscripcin: ") {
document.inscripcion.submit();
}
else {
alert(themessage);
return false;
   }
}

function verify_ddi() {

var themessage = "Los siguientes campos, son requeridos para finalizar la inscripcin: ";

if (getRadioButtonSelectedValue(document.inscripcion.sexo)=="") {
themessage = themessage + " Sexo";
}
if (document.inscripcion.nombre.value=="") {
themessage = themessage + " - Nombre";
}
if (document.inscripcion.apellido.value=="") {
themessage = themessage + " - Apellido";
}
if (document.inscripcion.ape_madre.value=="") {
themessage = themessage + " - Apellido de la Madre";
}
if (document.inscripcion.fecha_nac.value=="") {
themessage = themessage + " - Fecha de Nacimiento";
}
if (document.inscripcion.mail.value=="") {
themessage = themessage + " - Correo electronico";
}
if (document.inscripcion.nro_doc.value=="") {
themessage = themessage + " - Numero de Documento";
}
if (document.inscripcion.carrera_id.value=="0") {
themessage = themessage + " - Profesión / Ocupación";
}
if (document.inscripcion.espe_id.value=="0") {
themessage = themessage + " - Especialidad";
}
if (document.inscripcion.calle.value=="") {
themessage = themessage + " - Calle";
}
if (document.inscripcion.numero.value=="") {
themessage = themessage + " - Numero";
}	
if (document.inscripcion.piso.value=="") {
themessage = themessage + " - Piso";
}	
if (document.inscripcion.dpto.value=="") {
themessage = themessage + " - Departamento";
}
if (document.inscripcion.cp.value=="") {
themessage = themessage + " - Codigo Postal";
}	
if (document.inscripcion.loc.value=="") {
themessage = themessage + " - Localidad";
}
if (document.inscripcion.pais_id.value=="0") {
themessage = themessage + " - Pais";
}
if (document.inscripcion.prov.value=="0") {
themessage = themessage + " - Provincia";
}
if (document.inscripcion.area_tel.value=="") {
themessage = themessage + " - Codigo de Area de Telefono";
}
if (document.inscripcion.telefono.value=="") {
themessage = themessage + " - Telfono";
}	
if (document.inscripcion.area_cel.value=="") {
themessage = themessage + " - Codigo de Area de Celular";
}
if (document.inscripcion.tel_cel.value=="") {
themessage = themessage + " - Celular";
}
if (document.inscripcion.arancel_id.value==0) {
themessage = themessage + " - Arancel";
}	
if (document.inscripcion.agree.checked == false) {
themessage = "Debe Aceptar las condiciones de Inscrpcion";
}	
if (themessage == "Los siguientes campos, son requeridos para finalizar la inscripcin: ") {
document.inscripcion.submit();
}
else {
alert(themessage);
return false;
   }
}

