function mostrar(info){
	if(controlarInputs(seccion)){
		switch(info){
			case 'Carreras':
				if(document.getElementById("Cursos").style.display!="inline"){
					document.getElementById("Carreras").style.display="inline";							
				}
			break;
			case 'Cursos':
				if(document.getElementById("Carreras").style.display!="inline"){	
					document.getElementById("Cursos").style.display="inline";
				}				
			break;		
			case 'Todo':
				document.getElementById("Todo").style.display="inline";		
			break;
		}
		document.getElementById("call2actionProgramasCursos").style.display="inline";	
	}
}

function controlarInputs(seccion){
	errorNombre = false;
	errorMail = false;
	errorInteres = false;
	
	nombre = document.getElementById("nombre").value;
	email = document.getElementById("email").value;
	if((nombre == "")||(nombre == "Tu nombre")){
		document.getElementById("nombre").className='formFieldError';
		document.getElementById("reqnombre").style.display="inline";
		errorNombre = true;
	}else{
		document.getElementById("nombre").className='formField';
		document.getElementById("reqnombre").style.display="none";
		errorNombre = false;
	
	}	
	
	if((email == "")||(email == "Tu e-mail")){
		document.getElementById("email").className='formFieldError';	
		document.getElementById("reqemail").style.display="inline";
		errorMail = true;		
	}
	else{
	//Si no es vacio controla que sea tipo email a@b.com
		if (isEMailAddr(email)==false) {
			document.getElementById("email").className='formFieldError';	
			document.getElementById("reqemail").style.display="inline";
			errorMail = true;	
		}else{
			document.getElementById("email").className='formField';	
			document.getElementById("reqemail").style.display="none";
			errorMail = false;			
		}			
	}

	if(seccion == "home"){
		interes = document.getElementById("Interes").value;
		if(interes=="--"){
			document.getElementById("Interes").className='formFieldError';	
			document.getElementById("reqinteres").style.display="inline";
			errorInteres = true;		
		}else{
			document.getElementById("Interes").className='formField';	
			document.getElementById("reqinteres").style.display="none";
			errorInteres = false;		
		}
		
		if ((!errorMail) && (!errorNombre) && (!errorInteres)){
			return true;
		}else{
			return false;
		}
	}else{
		if ((!errorMail) && (!errorNombre)){
			return true;
		}else{
			return false;
		}		
	}
}

function ocultar(seccion){
	contarSeleccion(seccion);
	document.getElementById(seccion).style.display="none";
	document.getElementById("call2actionProgramasCursos").style.display="none";
}

function contarSeleccion(seccion){
	txt = "";
	a = 0;
	Message = "";
	switch(seccion){
		case 'Carreras':
			boxes = document.call2actionform.Carreras.length;
			
			for (i = 0; i < boxes; i++) {
				if (document.call2actionform.Carreras[i].checked) {
					txt = txt + document.call2actionform.Carreras[i].value + ", ";
					a = a + 1;
				}
			}
			
			if (txt == "") {
				Message = "0 carreras";
				document.getElementById("CarrerasSeleccionadas").value = "";
				document.getElementById("Carrerascont").innerHTML = "";
			}
			else {
				Message = txt;
				document.getElementById("Carrerascont").innerHTML = "Has seleccionado "+a+" carrera/s.<br>";
				document.getElementById("CarrerasSeleccionadas").value = txt;
			}			
		break;
		case 'Cursos':
			boxes = document.call2actionform.Cursos.length;

			for (i = 0; i < boxes; i++) {
				if (document.call2actionform.Cursos[i].checked) {
					txt = txt + document.call2actionform.Cursos[i].value + ", ";
					a = a + 1;
				}
			}
			
			if (txt == "") {
				Message = "0 cursos";
				document.getElementById("CursosSeleccionados").value = "";	
				document.getElementById("Cursoscont").innerHTML = "";			
			}
			else {
				Message = txt;
				document.getElementById("Cursoscont").innerHTML = "Has seleccionado "+a+" curso/s.<br>";
				document.getElementById("CursosSeleccionados").value = txt;
			}		
		break;
		case 'Todo':
			boxesCursos = document.call2actionform.Cursos.length;
			boxesProgramas = document.call2actionform.Programas.length;			
			txtProgramas = "";
			txtCursos = "";
			
			for (i = 0; i < boxesCursos; i++) {
				if (document.call2actionform.Cursos[i].checked) {
					txtCursos = txtCursos + document.call2actionform.Cursos[i].value + ", ";
					a = a + 1;
				}
			}
			
			if (txtCursos == "") {
				document.getElementById("CursosSeleccionados").value = "";	
				document.getElementById("Cursoscont").innerHTML = "";			
			}
			else {
				document.getElementById("Cursoscont").innerHTML = "Has seleccionado "+a+" curso/s.<br>";
				document.getElementById("CursosSeleccionados").value = txtCursos;
			}
			
			for (i = 0; i < boxesProgramas; i++) {
				if (document.call2actionform.Programas[i].checked) {
					txtProgramas = txtProgramas + document.call2actionform.Programas[i].value + ", ";
					a = a + 1;
				}
			}
			
			if (txtProgramas == "") {
				document.getElementById("ProgramasSeleccionados").value = "";
				document.getElementById("Programascont").innerHTML = "";
			}
			else {
				document.getElementById("Programascont").innerHTML = "Has seleccionado "+a+" programa/s.<br>";
				document.getElementById("ProgramasSeleccionados").value = txtProgramas;
			}				
			
			
			
		break;		
	}

	//alert(Message);
}
function enviarfrm(){
	document.call2actionform.action = '/Espanol/Formularios/formulario.php';
	document.call2actionform.submit();
}
function enviarfrm2(seccion){
	if(controlarInputs(seccion)){
		document.call2actionform.action = '/Espanol/Formularios/formulario.php';
		document.call2actionform.submit();
	}
}
function isEMailAddr(elem) {

	var str = elem;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (!str.match(re)) {
		return false;
	} else {
		return true;
	}
}