/******** Funciones para validar el formulario de contacto **********************************/
/*******************************************************************************************/

function validarEmail(valor){

	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor));
	
}

function validarContacto(){
	var texto;
	texto="";
	
	if (document.formulario.nombre.value==""){
		texto+=" - Debe introducir su nombre.\n";
	}
	
	if (document.formulario.email.value==""){
		texto+=" - Debe introducir su email.\n";
	}
	
	if (document.formulario.email.value!=""){
		if(!validarEmail(document.formulario.email.value)){
			texto+=" - Formato de email incorrecto.\n";
		}
	}
	
	if (document.formulario.comentarios.value==""){
		texto+=" - Indique el motivo de su consulta.\n";
	}
	
	if (texto!=""){
		alert("Se han encontrado los siguientes problemas:\n\n" + texto);
	}else{
		//enviar
		document.formulario.submit();
	}
}	

function validarContactoIng(){
	var texto;
	texto="";
	
	if (document.formulario.nombre.value==""){
		texto+=" - Name and Surname.\n";
	}
	
	if (document.formulario.email.value==""){
		texto+=" - Email.\n";
	}
	
	if (document.formulario.email.value!=""){
		if(!validarEmail(document.formulario.email.value)){
			texto+=" - Invalid email format.\n";
		}
	}
	
	if (document.formulario.comentarios.value==""){
		texto+=" - Comments.\n";
	}
	
	if (texto!=""){
		alert("The following fields are must to:\n\n" + texto);
	}else{
		//enviar
		document.formulario.submit();
	}
}	

//**************************** fin de las funciones para validar formularios *****************************//
//*********************************************************************************************************//

//**************** Funciones para manejar los menus desplegables *****************************************//
//*******************************************************************************************************//

function ampliarTema(capa){
	if (document.getElementById("capaServicios" + capa).style.display == 'block'){
		document.getElementById("capaServicios" + capa).style.display = 'none';
	}else{
		document.getElementById("capaServicios" + capa).style.display = 'block';
	}
}

function ampliaNoticia(id, cadena) {
	http.open("GET", "getServicios.asp?numNoticia="+ id + "&titulo=" + cadena, true);    
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}

//********************************************************************************************************//
//********************************************************************************************************//
