//-----Mostrar y ocultar las secciones de la portada----
function mostrarBloque_we()
{
	if ($("div#texto_entrada").is(":hidden"))
	{				
		 $('div#secciones_portada').hide();
		 $('div#texto_entrada').fadeIn(1000);
	}
	else
	{
		$("div#texto_entrada").hide();
		$('div#secciones_portada').fadeIn(1000);
	}
}
//------------------------------------------------------

//Función para mostrar/ocultar divs--------------
function muestra(nombrediv,nombretit) {
        if(document.getElementById(nombrediv).style.display == '') {
                document.getElementById(nombrediv).style.display = 'none';				
				document.getElementById(nombretit).style.color = '#646464';
				document.getElementById(nombretit).style.textDecoration = 'none';				
        } else {
                document.getElementById(nombrediv).style.display = '';
				document.getElementById(nombretit).style.color = '#5d7d4c';							
        }
    }
//-----------------------------------------------

//Función para mostrar/ocultar divs en las FAQS--------------
function faqshow(nombrediv,nombretit) {
        if(document.getElementById(nombrediv).style.display == '') {
                document.getElementById(nombrediv).style.display = 'none';				
				document.getElementById(nombretit).style.color = '#74862c';
				//document.getElementById(nombretit).style.textDecoration = 'none';				
        } else {
                document.getElementById(nombrediv).style.display = '';
				document.getElementById(nombretit).style.color = '#93ab34';							
        }
    }
//-----------------------------------------------

//Mostar elementos pasando la id
function mostrarporid(elemento) {
        if(document.getElementById(elemento).style.display == 'none') {
                document.getElementById(elemento).style.display = '';				
        } 
}

//Ocultar elementos pasando la id
function ocultarporid(elemento) {
        if(document.getElementById(elemento).style.display == '') {
                document.getElementById(elemento).style.display = 'none';
        } 
}

//Mostrar y ocultar elementos por id
function empujar(bloque) {
        if(document.getElementById(bloque).style.display == '') {
                document.getElementById(bloque).style.display = 'none';				
        } else {
                document.getElementById(bloque).style.display = '';
        }		 
}

//--------Cambiar texto-----------
function masmenos(texto)
{
		if(document.getElementById(texto).innerHTML == "[+]") {
                document.getElementById(texto).innerHTML = "[-]";
        } else {
                document.getElementById(texto).innerHTML = "[+]";
        }		
}

function subrayar(elemento) {
        if(document.getElementById(elemento).style.textDecoration == 'underline') {
                document.getElementById(elemento).style.textDecoration = 'none';				
        } else {
                document.getElementById(elemento).style.textDecoration = 'underline';
        }		 
}
//----------------------------------

//Borrar campos de formularios
function borrarvalorcampos(campo1,campo2)
{
	if(document.forms[0].elements[campo1].value != ""){		
		document.forms[0].elements[campo1].value = "";				
	}
	if(document.forms[0].elements[campo2].value != ""){		
		document.forms[0].elements[campo2].value = "";				
	}
}

//Aceptar condiciones
function aceptar_con()
{	
	if (!document.forms["condiciones"].elements["acepto"].checked) {//Elemento type=checkbox
	//if (!condiciones.acepto.checked) {//Elemento type=checkbox
		alert("Debe aceptar las condiciones");return false; 
	}
	else{
		document.forms["condiciones"].submit(); 
		//document.formulario.submit();
	}
}

//*******CARGA IMAGENES********//
numImagenes = 0;
function cargar_imagen()
{
	numImagenes++;
	if (numImagenes == 1)
	{
    	document.getElementById('portfolio').style.display = '';
	}
}
//*****************************//


//*********VALIDACION DE FORMULARIOS***********
function validacion(formulario) {

	var er_nombre = /^([a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/			//letras, '.' y '-' o vacio
	var er_comentarios = /^([a-z]|[A-Z]|á|é|í|ó|ú|ñ|ü|\s|\.|-)+$/			//letras, '.' y '-' o vacio

	//direccion de correo electronico
	var er_email = /^(.+\@.+\..+)$/
	var x	 	
      	
	//comprueba campo de nombre
	if(!er_nombre.test(formulario.nombre.value)) { 
		alert('Debe de introducir una Persona de Contacto válida');
		formulario.nombre.focus();
		return false
	}
	
	//comprueba campo de email
	if(!er_email.test(formulario.email.value)) { 
		alert('Debe introducir un E-mail válido');
		formulario.email.focus();
		return false
	}
	
	//comprueba campo de comentarios
	if (formulario.comentarios.value == "") {
		alert('Debe introducir algún Comentario');
		formulario.comentarios.focus();
		return false
	}
	
	//comprueba el checkbox de Aceptar las concidciones
	//if (!document.forms[0].elements["acepto"].checked) {//Elemento type=checkbox
	if (!formulario.acepto.checked) {//Elemento type=checkbox
		alert("Debe aceptar las condiciones");
		return false;	
   }

	//Si los campos introducidos son correctos...
	//document.forms[0].submit();
	document.formulario.submit();
	return false			//cambiar por return true para ejecutar la accion del formulario
}

//************************************************

/** VERIFICAR FORMULARIO DE CONTACTO **/
function verif(theform){
   missinginfo = "";
   
   if (document.contacto.nombre.value == "") {
     missinginfo += "\n     -  Persona de contacto";
   }
   if (document.contacto.email.value == "") {
     missinginfo += "\n     -  E-mail";
   }
   if (document.contacto.mensaje.value == "") {
     missinginfo += "\n     -  Observaciones";
   } 
   if (missinginfo != "") {
     missinginfo ="Faltan los siguientes campos por rellenar:\n" + missinginfo;
     alert(missinginfo);
     return false;
   }   
   
   else {
     if (document.all || document.getElementById) {
       for (i = 0; i < theform.length; i++) {
         var tempobj = theform.elements[i];
         if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
           tempobj.disabled = true;
       }
       return true;
     }
     else {
       return false;
     }
   }
 }
/**************************************/


//************SCROLL AL INICIO DE LA PÁGINA (jquery)**************//
function scrollUp(){
	$('html, body').animate({scrollTop:0}, 850); //Back to top
}
//*****************************************************************//


//*********VALIDACION DEL FORMULARIO DEL ENVIO DE LA HISTORIA***********
function validacion_historia(formulario) {

	var er_nombre = /^([a-z]|[A-Z]|á|é|í|ó|ú|Á|É|Í|Ó|Ú|ñ|ü|\s|\.|-)+$/			//letras, '.' y '-' o vacio
	var er_historia = /^([a-z]|[A-Z]|á|é|í|ó|ú|Á|É|Í|Ó|Ú|,|;|"|'|(|)|@|´|`|&|^|¨|ä|ë|1|2|3|4|5|6|7|8|9|0|ñ|ü|\s|\.|-)+$/			//letras, '.' y '-' o vacio

	//direccion de correo electronico
	var er_email = /^(.+\@.+\..+)$/
	var x	 	
      	
	//comprueba campo de nombre
	if(!er_nombre.test(formulario.nombre.value)) { 
		alert('Debe de introducir un Nombre válido');
		formulario.nombre.focus();
		return false
	}
	
	//comprueba campo de apellidos
	if(!er_nombre.test(formulario.apellidos.value)) { 
		alert('Debe de introducir sus apellidos');
		formulario.apellidos.focus();
		return false
	}
	
	//comprueba campo de email
	if(!er_email.test(formulario.email.value)) { 
		alert('Debe introducir un E-mail válido');
		formulario.email.focus();
		return false
	}
	
	//comprueba campo de ciudad
	if(!er_nombre.test(formulario.ciudad.value)) { 
		alert('Debe introducir su Ciudad');
		formulario.ciudad.focus();
		return false
	}
	
	//comprueba campo de pais
	if(!er_nombre.test(formulario.pais.value)) { 
		alert('Debe introducir su País');
		formulario.pais.focus();
		return false
	}	
	
	//comprueba campo de historia
	if (formulario.historia.value == "") {
		alert('Debe introducir su historia');
		formulario.historia.focus();
		return false
	}
	
	//comprueba el checkbox de Aceptar las concidciones
	//if (!document.forms[0].elements["acepto"].checked) {//Elemento type=checkbox
	if (!formulario.acepto.checked) {//Elemento type=checkbox
		alert("Debe aceptar las condiciones");
		return false;	
   }

	//Si los campos introducidos son correctos...
	//document.forms[0].submit();
	document.formulario.submit();
	return false			//cambiar por return true para ejecutar la accion del formulario
}

//**********************************************************************