/** APARIENCIA DEL HTML **/
function muestraElemento(idElemento) {
	var elemento = document.getElementById(idElemento);
	elemento.style.display = 'inline';
}
function ocultaElemento(idElemento) {
	var elemento = document.getElementById(idElemento);
	elemento.style.display = 'none';
}
/** FIN APARIENCIA DEL HMTL **/


function carrerasOfrecidas_muestraEmpresas(idCarrera) {
	var nombreElementoTR = 'tr_lista_empresas_id_carrera_'+idCarrera;
	//var nombreElementoDIV = 'accion_lista_perfiles_idempresa_'+idEmpresa;
	var elementoTR = document.getElementById(nombreElementoTR);
	//var elementoDIV = document.getElementById(nombreElementoDIV);
	if (!elementoTR.style.display || elementoTR.style.display=='none') {
		try {
			elementoTR.style.display='table-row';
		} catch(e) {
			elementoTR.style.display = 'block';
		}
		//elementoDIV.innerHTML = "ocultar";
	}
	else
	{
		elementoTR.style.display = 'none';
		//elementoDIV.innerHTML = "mostrar";
	}
}

function chequeaMaximoOpcionesMarcadasEnObjetoCheckbox(objeto, numeroObjeto)
{
	var opcionesObjeto = eval('document.formperfil.'+objeto.name);
	var cantidadOpcionesHabilitadas = 0;
	for (var i=0; i<opcionesObjeto.length; i++)
	{
		if (opcionesObjeto[i].checked)
			cantidadOpcionesHabilitadas++;
	}
	if (cantidadOpcionesHabilitadas>3)
	{
		objeto.checked = false;
		alert('No puede seleccionar más de 3 alternativas. Si desea seleccionar '+
			'esta alternativa, deseleccione una de las marcadas anteriormente y vuelva a intentarlo');
	}
}



function isRadioSeleccionado(objetoRadio) {
		for (var jl=0; jl<objetoRadio.length; jl++)
			if (objetoRadio[jl].checked)
				return true;
		return false;
	}
	function isLargoAdecuado(valor, largoMinimo, largoMaximo) {
		if (isEmpty(valor)) return false;
		if (valor.length<largoMinimo) return false;
		if (valor.length>largoMaximo) return false;
		return true;
	}
	function isListaSeleccionada(valor) {
		if (!valor) return false;
		if (isEmpty(valor)) return false;
		if (valor==-1) return false;
		if (valor=='-1') return false;
		return true;
	}

// s es vacio
function isEmpty(s) {   
	return ((s == null) || (s.length == 0))
}






function chequeaFormularioContactoPublico()
{
	var formulario = document.formcontacto;
	var error = false;
	
	if (!isLargoAdecuado(formulario.campoNombre.value, 2, 100)) {
		//muestraElemento("ERRORcampoNombre");
		alert("Ingrese Nombre");
		error = true;
		formulario.campoNombre.focus();
	}
	//else
		//ocultaElemento("ERRORcampoNombre");

	/*if (!isLargoAdecuado(formulario.campoApellidos.value, 2, 100)) {
		muestraElemento("ERRORcampoApellidos");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoApellidos");
	*/

	if (!isLargoAdecuado(formulario.campoMail.value, 2, 100)) {
		//muestraElemento("ERRORcampoMail");
		alert("Ingrese Mail");
		error = true;
	}
	//else
	//	ocultaElemento("ERRORcampoMail");

	if (!isLargoAdecuado(formulario.campoComentario.value, 2, 500)) {
		//muestraElemento("ERRORcampoComentario");
		alert("Ingrese Mensaje");
		error = true;
	}
	//else
	//	ocultaElemento("ERRORcampoComentario");

	return !error;
}


function chequeaFormularioEmpresa()
{
	var formulario = document.formempresa;
	var error = false;
	
	if (!isRut(formulario.campoRut.value)) {
		muestraElemento("ERRORcampoRut");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoRut");
	
	if (!isLargoAdecuado(formulario.campoNombre.value, 2, 100)) {
		muestraElemento("ERRORcampoNombre");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoNombre");
	
	/*
	if (!isLargoAdecuado(formulario.campoRubro.value, 2, 100)) {
		muestraElemento("ERRORcampoRubro");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoRubro");
	*/
	
	/*
	if (!isLargoAdecuado(formulario.campoNombreUsuario.value, 2, 100)) {
		muestraElemento("ERRORcampoNombreUsuario");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoNombreUsuario");
	*/
	
	if (!isLargoAdecuado(formulario.campoClaveUsuario.value, 2, 100)) {
		muestraElemento("ERRORcampoClaveUsuario");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoClaveUsuario");
	
	/*
	if (!isLargoAdecuado(formulario.campoDireccionCasaMatriz.value, 2, 100)) {
		muestraElemento("ERRORcampoDireccionCasaMatriz");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoDireccionCasaMatriz");
	
	if (!isListaSeleccionada(formulario.campoIdRegion.value)) {
		muestraElemento("ERRORcampoIdRegion");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoIdRegion");
	*/
	
	/*
	if (!isLargoAdecuado(formulario.campoTelefono.value, 2, 100)) {
		muestraElemento("ERRORcampoTelefono");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoTelefono");
	
	if (!isLargoAdecuado(formulario.campoMail.value, 2, 100)) {
		muestraElemento("ERRORcampoMail");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoMail");

	if (!isLargoAdecuado(formulario.campoUrl.value, 2, 200)) {
		muestraElemento("ERRORcampoUrl");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoUrl");
	
	if (!isNumber(formulario.campoCantidadEmpleados.value)) {
		muestraElemento("ERRORcampoCantidadEmpleados");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoCantidadEmpleados");

	if (!isListaSeleccionada(formulario.campoIdTipoEmpresa.value)) {
		muestraElemento("ERRORcampoIdTipoEmpresa");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoIdTipoEmpresa");

	if (!isNumber(formulario.campoCantidadSucursales.value)) {
		muestraElemento("ERRORcampoCantidadSucursales");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoCantidadSucursales");

	if (!isLargoAdecuado(formulario.campoGlosa.value, 2, 400)) {
		muestraElemento("ERRORcampoGlosa");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoGlosa");

	if (!isLargoAdecuado(formulario.campoMision.value, 2, 400)) {
		muestraElemento("ERRORcampoMision");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoMision");
	
	if (!isLargoAdecuado(formulario.campoGerenteOPresidente.value, 2, 100)) {
		muestraElemento("ERRORcampoGerenteOPresidente");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoGerenteOPresidente");
	
	if (!isLargoAdecuado(formulario.campoGerenteRRHH.value, 2, 100)) {
		muestraElemento("ERRORcampoGerenteRRHH");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoGerenteRRHH");
	
	if (!isLargoAdecuado(formulario.campoCualidadesPostulante.value, 2, 400)) {
		muestraElemento("ERRORcampoCualidadesPostulante");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoCualidadesPostulante");
	
	if (!isLargoAdecuado(formulario.campoPreguntaPostulacion.value, 2, 400)) {
		muestraElemento("ERRORcampoPreguntaPostulacion");
		error = true;
	}
	else
		ocultaElemento("ERRORcampoPreguntaPostulacion");
	*/
		

	return !error;
}
	



