function chequear(valor,nombreForm){
	//var form = document.getElementById(nombreForm);
	
	var input = document.getElementById(nombreForm);
	
	if(input.checked) input.checked = false;
	else input.checked = true;
	
	/*
	for (var i = 0; i < form.tema.length; i++) {
		if(form.tema[i].value == valor){
			if(form.tema[i].checked) form.tema[i].checked = false;
			else form.tema[i].checked = true;
		}
	
	}
	*/
}

function Mostrar(id){
		var respuesta = document.getElementById(id);
		
		if(respuesta.style.display == '' || respuesta.style.display == 'none'){
			respuesta.style.display = 'block';
		}else{
			respuesta.style.display = 'none';
		}
		
	}
	
	
/****** FUNCIONES DEL FORMULARIO DE REGISTRACION ******/

function validarCampo(input,min,max) {
	if ((input.value == '') || (input.value.length < min) || (input.value.length > max)) {
		input.style.background = 'url(imagenes/login_input_error.png) top left no-repeat';


		// input.style.border = '#FF0000';
	} else {
		input.style.background = 'url(imagenes/login_input.png) top left no-repeat';
	}
}


function validarEmail(emailInput){
	
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var emailField = emailInput.value;
     
   if(reg.test(emailField) == false) {
        emailInput.style.background = 'url(imagenes/login_input_error.png) top left no-repeat';
   }    else{
        emailInput.style.background = 'url(imagenes/login_input.png) top left no-repeat';

   }

	
}

function validarPassword(input,labelField,min,max) {

	var campoLabel = document.getElementById(labelField);

	if((input.value == '') || (input.value.length < min) || (input.value.length > max)) {
		
		//input.style.color = '#fc7e7e';
                input.style.background = 'url(imagenes/login_input_error.png) top left no-repeat';

                campoLabel.innerHTML = "Debe poseer un mínimo de 6 caracteres";
		//contraseniaLeyenda.innerHTML="Debe poseer un mínimo de 6 caracteres";
		/*campoLabel.style.background = '#ecb3b3';
		campoLabel.style.borderWidth = '2px';
		campoLabel.style.borderColor = '#ff0000';
		campoLabel.style.color = '#000000';
		*/
	}else{

		input.style.color = '#2f685b';

		var soloNumerica = true;
		if (isNaN(input.value)) {
			soloNumerica = false;
		}

		var re = /^[a-zA-Z]+$/;
		var soloLetras = re.test(input.value);

		if (soloNumerica || soloLetras) {
		
			if (input.value.length <= 8){
				campoLabel.innerHTML="Débil.";
				/*campoLabel.style.background = '#ecb3b3';
				campoLabel.style.borderWidth = '2px';
				campoLabel.style.borderColor = '#ff0000';*/
                                input.style.background = 'url(imagenes/login_input.png) top left no-repeat';
				campoLabel.style.color = '#fc7e7e';
			}
			
			if (input.value.length >= 9) {
				campoLabel.innerHTML="Medianamente fuerte.";
				/*campoLabel.style.background = '#fdef9f';
				campoLabel.style.borderWidth = '2px';
				campoLabel.style.borderColor = '#fad612';*/
                                input.style.background = 'url(imagenes/login_input.png) top left no-repeat';
				campoLabel.style.color = '#ffb134';
			}
			
		}else{
			if(input.value.length <= 8) {
				campoLabel.innerHTML="Fuerte.";
				/*campoLabel.style.background = '#9ae3f0';
				campoLabel.style.borderWidth = '2px';
				campoLabel.style.borderColor = '#00cef3';*/
                                input.style.background = 'url(imagenes/login_input.png) top left no-repeat';
				campoLabel.style.color = '#2f685b';
				
			}

			if(input.value.length >= 9) {
				campoLabel.innerHTML="Muy Fuerte.";
				/*campoLabel.style.background = '#bafbbf';
				campoLabel.style.borderWidth = '2px';
				campoLabel.style.borderColor = '#00cef3';*/
                                input.style.background = 'url(imagenes/login_input.png) top left no-repeat';
				campoLabel.style.color = '#2f685b';
				
			}
		}
	}
}
			
function validarSegundoPass(inputOriginal, inputComparativo, errorId){
	
	var password = document.getElementById(inputOriginal);
	var password2 = document.getElementById(inputComparativo);
	var errorMsj = document.getElementById(errorId);
	
	if(password.value != password2.value){
		errorMsj.innerHTML = 'Las contraseñas no coinciden';
                input.style.background = 'url(imagenes/login_input_error.png) top left no-repeat';
	}else{
		errorMsj.innerHTML = '';
                input.style.background = 'url(imagenes/login_input.png) top left no-repeat';
	}
	
}

//Limpiar Campos
$("input[name=search]").focus(function () { 
      
	  var actual = $(this).val();
	  if(actual != ''){
		  $(this).val('');
	  }
	   
});
$("input[name=comentario]").focus(function () { 
      
	  var actual = $(this).val();
	  if(actual != ''){
		  $(this).val('');
	  }
	   
});

$(document).ready(function(){
	
	$(".scroll").click(function(event){
		
		event.preventDefault();
		
		var r = $(this).attr('href');
		var distancia = $('#pieColIzq').offset().top;
		
		$('html,body').animate({scrollTop: distancia}, 2000, "swing");
		
		return false;
	});
	
});
