<!--
/* Coded by Ing. Ulises Morales Ramirez */
-->

<?php
session_start();
?>
<!DOCTYPE html>
<html>


<head>


    <title>Mi Huella por la Paz - Yucatán</title>

    <!-- Favicon -->
    <link rel="shortcut icon" href="favicon.ico?v2">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0">
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Lato"/>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
          integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css"
          integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="ownStyle.css" media="screen"/>


</head>

<body onload="document.getElementById('tname').focus();">

<!--div class="text-center" style="z-index: -1"><img src="images/header.png" width="800px"></div-->
<div class="ripple-background">
    <div class="circle xxlarge shade1"></div>
    <div class="circle xlarge shade2"></div>
    <div class="circle large shade3"></div>
    <div class="circle mediun shade4"></div>
    <div class="circle small shade5"></div>
</div>


<div class="container col-md-12" style="margin-top: 10%">

    <div class="d-flex justify-content-center  col-md-12 col-sm-12 col-xs-12">
        <div class="user_card">
            <div class="d-flex justify-content-center">
                <div class="brand_logo_container">
                    <img src="images/logo_geo.png" class=" visible-md brand_logo " alt="Logo">
                </div>
                <div class="brand_logo_container1">
                    <img src="images/g980.png" class=" hidden visible-xs visible-sm brand_logo1 " alt="Logo">
                </div>
                <div class="brand_logo_container2">
                    <img src="images/g1010.png" class="visible-md brand_logo1 " alt="Logo">
                </div>
            </div>
            <div class=" justify-content-center container form_container">
				<form action="insertar.php" method="post">
					<input type="hidden" name="escuela" value="<?= $_SESSION["escuela"] ?>">
					<input type="hidden" name="idioma" value="<?= $_POST['idioma']; ?>">
					<div class="input-group mb-3">
						<div class="input-group-append">
							<span class="input-group-text"><i class="fas fa-user"></i></span>
						</div>
						<input id="tname" type="text" name="nombre" class="form-control input_user" value="" placeholder="<?php
						if ($_POST['idioma']=='Maya')
						{
							echo "Tuláakal a k'aaba'";
						}
						else{
							echo "Nombre de pila";
						}
						?>" required>
					</div>
					<div class="input-group mb-3">
						<div class="input-group-append">
							<span class="input-group-text"><i class="fas fa-sort-numeric-up"></i></span>
						</div>
						<input type="number" pattern="\d*" min="1" max="99" name="edad" class="form-control input_user" value="" placeholder="<?php
						if ($_POST['idioma']=='Maya')
						{
							echo "Ja'ab";
						}
						else{
							echo "Edad ";
						}
						?>" required>
					</div>
					<div class="mt-4">
						<div class=" text-center links" style="color: white;">
                            <b>
                            <?php
                            if ($_POST['idioma']=='Maya')
                            {
                                echo "<h1><b>¿Ti' teeche' ba'ax le jets' óolalo'?</b></h1>";
                            }
                            else{
                                echo "<h1><b>¿CÓMO CONTRIBUYES CON LA PAZ?</b></h1>";
                            }
                            ?>

						</div>
					</div>

					<div class="form-group" style="color: white;">
						<textarea required class="form-control" rows="6" cols="50" name="comentario" style="resize: none" maxlength="200" onKeyDown="valida_longitud()" onKeyUp="valida_longitud()"></textarea>
						<?php
						if ($_POST['idioma']=='Maya')
						{
							echo "Cantidad u caracteres: ";
						}
						else{
							echo "Cantidad de caracteres: ";
						}
						?>
                        <input type="text" value="0" name=caracteres size=4 style="background: transparent; border: none; color: white" disabled>
					</div>

					<div class="d-flex justify-content-center mt-3 login_container">
						<div class="col-md-6">
						<button type="button"  onclick="return testNumeric(this.form);" class="btn login_btn"><?php
								if ($_POST['idioma']=='Maya')
								{
									echo "Túuxt a meyaj";
								}
								else{
									echo "Enviar";
								}
								?></button></div>
					</div>
				</form>
			</div>



		</div>
	</div>


    <div class="text-center" style="margin:40px;">
        <img class="img-fluid img-responsive" src="images/Logo-Horizontal-V2-blanco.png" width="300"><br>

        <div class="text-center" style="margin:40px;">
            <img class="img-fluid img-responsive" src="images/g122.png" width="300">
        </div>

    </div>
        
</div>

<script>
    contenido_textarea = ""
    num_caracteres_permitidos = 200

    function valida_longitud(){
        num_caracteres = document.forms[0].comentario.value.length

        if (num_caracteres > num_caracteres_permitidos){
            document.forms[0].comentario.value = contenido_textarea
        }else{
            contenido_textarea = document.forms[0].comentario.value
        }

        if (num_caracteres >= num_caracteres_permitidos){
            document.forms[0].caracteres.style.color="#ff0000";
        }else{
            document.forms[0].caracteres.style.color="#ffffff";
        }

        cuenta()
    }
    function cuenta(){
        document.forms[0].caracteres.value=document.forms[0].comentario.value.length;
    }

	function testNumeric(Form){

		if(Form.nombre.value == ""){ 
			alert("¡El nombre no puede estar vacío!"); 
			Form.nombre.focus();
			return false;
		}else{
			if(Form.edad.value == ""){ 
				alert("¡La edad no puede estar vacía y solo puede contener números!"); 
				Form.edad.focus();
				return false;
			}else{
				if(!/^\d+$/.test(Form.edad.value)) { 
					alert("¡La edad solo puede contener números!"); 
					Form.edad.focus();
					return false; 
				}else{
					if(Form.edad.value <= 0 || Form.edad.value >= 100 ) { 
						alert("¡La edad debe estar entre 1 y 99 años!"); 
						Form.edad.focus();
						return false; 
					}else{
						if(Form.comentario.value == ""){ 
							alert("Por favor contesta la pregunta..."); 
							Form.comentario.focus();
							return false; 
						}else{
							Form.submit();
						}
					}
				}
			}
		}
	}
	    
</script>




</body>
</html>
