$(document).ready(function() {
	
	//MENUS SUPERIORES
	$(function() {
	var d=300;
	$('#navigation a').each(function(){
	$(this).stop().animate({
	'marginTop':'-80px'
	},d+=150);
	});

	$('#navigation > li').hover(
	function () {
	$('a',$(this)).stop().animate({
	'marginTop':'-2px'
	},200);
	},
	function () {
	$('a',$(this)).stop().animate({
	'marginTop':'-80px'
	},200);
	}
	);
	});

	
	//FAQ
	$('.faq_titulo').click(function(){
		$('.faq_respuesta').slideUp('fast');
		$(this).next('p').slideDown('fast');
	});

	
	//SLIDE PRESENTACION
	$("#myController").jFlow({
			controller: ".jFlowControl", // must be class, use . sign
			slideWrapper : "#jFlowSlider", // must be id, use # sign
			slides: "#mySlides",  // the div where all your sliding divs are nested in
			selectedWrapper: "jFlowSelected",  // just pure text, no sign
			duration: 700,
			easing: "swing",
			width: "960px",  // this is the width for the content-slider
			height: "230px",  // this is the height for the content-slider// time in miliseconds to transition one slide
			prev: ".jFlowPrev", // must be class, use . sign
			next: ".jFlowNext", // must be class, use . sign
			auto: true	
    });


	//CLICK EN LA CLAUSULA DE CONFIDENCIALIDAD
	$("#confidencialidad").click(function(){
			//registro_modal
			$("#clausula_confidencialidad").modal(
				
				{
				onClose: function (dialog) {
				dialog.data.fadeOut('slow', function () {
					dialog.container.hide('slow', function () {
						dialog.overlay.slideUp('fast', function () {
							$.modal.close();
							});
						});
					});
				},
				onOpen: function (dialog) {
				dialog.overlay.fadeIn('fast', function () {
					dialog.container.slideDown('slow', function () {
						dialog.data.fadeIn('fast');
						});
					});
				}}
			);
			//FIN Registro_modal
	});
	

	//FORMULARIO DE TPV
	//VALIDAR CAMPOS
		$('#formulario_tpv').submit(function(event) {
			var alerta=0;
			var alerta_t="";
			//alert('hola');

			//PARA ARTICULOS
			if ($("#nombre").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta el NOMBRE\n";
			}
			if ($("#apellidos").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Faltan los APELLIDOS\n";
			}
			if ($("#nif").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta el NIF\n";
			}
			if ($("#domicilio").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta el DOMICILIO\n";
			}
			if ($("#poblacion").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta la POBLACION\n";
			}

			if ($("#codigo_postal").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta el CÓDIGO POSTAL\n";
			}	else	{
				if (isNaN($("#codigo_postal").val()))	{
					alerta=1;
					alerta_t=alerta_t+"Sólo números en el CÓDIGO POSTAL\n";
				}
			}



			if ($("#provincia").val()=="00")	{
				alerta=1;
				alerta_t=alerta_t+"Falta la PROVINCIA\n";
			}
			if ($("#telefono").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta el TELÉFONO\n";
			}	else	{
				if (isNaN($("#telefono").val()))	{
					alerta=1;
					alerta_t=alerta_t+"Sólo números en el TELÉFONO\n";
				}
			}

			if ($("#mail").val()=="")	{
				alerta=1;
				alerta_t=alerta_t+"Falta el EMAIL\n";
			}

			if ($("#marketing").val()=="0")	{
				alerta=1;
				alerta_t=alerta_t+"Indica cómo nos conociste, por favor\n";
			}
			
			//if ($("#usuario").val().length < 6 || $("#usuario").val().length > 8)	{
			//	alerta=1;
			//	alerta_t=alerta_t+"El nombre de USUARIO debe contener entre 6 y ocho caracteres\n";
			//}

			//if ($("#password").val().length < 6 || $("#password").val().length > 8)	{
			//	alerta=1;
			//	alerta_t=alerta_t+"El PASSWORD debe contener entre 6 y ocho caracteres\n";
			//}	else	{
			//	if ($("#password").val() != $("#re_password").val())	{
			//			alerta=1;
			//			alerta_t=alerta_t+"Los PASSWORDS no coinciden\n";
			//	}
			//}

			if ($("#acepto").is(':checked'))	{
			}	else	{
				alerta=1;
				alerta_t=alerta_t+"Acepta la CLÁUSULA DE CONSENTIMIENTO \n";
			}
			
			
			if (alerta==1){
				alert(alerta_t);
				event.preventDefault();
			}
			

			
			
		});  


	///VALIDACION DE CAMPOS DEL FORMULARIO TPV
	///VALIDACION DE CAMPOS DEL FORMULARIO TPV
	
	//FORMULARIO DE REGISTRO CURSOS
	$("#formulario_registro").validate({
		debug: true,
		
      rules: { 
			//usuario: { required: true, minlength: 6, maxlength: 8 },
			//password: { required: true, minlength: 6, maxlength: 8 },
			email: { required: true, email: true},
			nombre: { required: true },
			apellidos: { required: true },
			direccion: { required: true },
			codigo_postal: { required: true, digits: true},
			poblacion: { required: true },
			telefono: { required: true, digits: true, minlength: 9 },
			provincia:	{min: 1},
			marketing:	{ required: true },
			acepto: "required",
			nif: { required: true },
			//re_password: {equalTo: "#password"}
 
      },
	  messages:	{
			//usuario: {required: "Introduzca usuario", minlength: "Entre 6 y 8 caracteres", maxlength: "Entre 6 y 8 caracteres"},
			//re_password: "Contraseñas no coinciden",
			//password:	{required: "Introduzca contraseña", minlength: "Entre 6 y 8 caracteres", maxlength: "Entre 6 y 8 caracteres"},
			email:	{required: "Introduzca e-mail", email: "E-mail no válido"},
			nombre: "Introduzca su nombre",
			apellidos: "Introduzca sus apellidos",
			direccion: "Introduzca su domicilio",
			codigo_postal: {required: "Introduzca su codigo postal", digits: "Sólo números, por favor" },
			poblacion: "Introduzca su poblacion",
			marketing: "Indíquenos cómo nos conoció",
			provincia:	{min: "Por favor introduzca su provincia"},
			acepto: "Acepte los términos de la cláusula",
			nif: "Por favor, introduzca su nif",
			telefono: {  digits: "Sólo números", required: "Introduzca teléfono", minlength: "Teléfono no válido"}
			
	},
		submitHandler: function() {
			$('#formulario_registro').hide();
			$('#precarga').fadeIn(200, function () {
			$.ajax({
				type: 'POST',
				url: 'paginas/registro.php',
				data: $('#formulario_registro').serialize() + '&action=send',
				cache:false,
				dataType: 'html',
				async:false,
				// Mostramos un mensaje con la respuesta de PHP
				success: function(data) {
					$('#registro').fadeTo('slow', 0.3, function() {
						$('#registro').html(data);
						$('#registro').fadeTo('fast', 1);
					});

					 
					}
				});
			});
		}
		
   }); 
	///VALIDACION DE CAMPOS DEL FORMULARIO DE REGISTRO
	// VALIDACION DE CAMPOS DEL FORMULARIO DE REGISTRO


	

	///VALIDACION DE CAMPOS DEL FORMULARIO DE CONTACTO
	// VALIDACION DE CAMPOS DEL FORMULARIO DE CONTACTO

	$("#formulario_contacto").validate({
	debug: true,
		
      rules: { 
			
			email: { required: true, email: true},
			nombre: { required: true },
			marketing:	{ required: true },
			poblacion: { required: true }
      },
	  messages:	{
			email:	{required: "Introduzca e-mail", email: "E-mail no válido"},
			nombre: "Introduzca su nombre",
			poblacion: "Introduzca su poblacion",
			marketing: "Indíquenos cómo nos conoció",
			telefono: {  digits: "Sólo números", minlength: "Teléfono no válido"}		
	},
		submitHandler: function() {
			$('#formulario_contacto').hide();
			$('#precarga').fadeIn(200, function () {
			$.ajax({
				type: 'POST',
				url: 'paginas/contacto.php',
				data: $('#formulario_contacto').serialize() + '&action=send',
				cache:false,
				dataType: 'html',
				async:false,
				// Mostramos un mensaje con la respuesta de PHP
				success: function(data) {
					$('#contacto').fadeTo('slow', 0.3, function() {
						$('#contacto').html(data);
						$('#contacto').fadeTo('fast', 1);
					});

					 
					}
				});
			});
		}
		
   }); 
	///VALIDACION DE CAMPOS DEL FORMULARIO DE CONTACTO
	// VALIDACION DE CAMPOS DEL FORMULARIO DE CONTACTO

	


	///VALIDACION DE CAMPOS DEL FORMULARIO DE DESEMBPLEADOS
	// VALIDACION DE CAMPOS DEL FORMULARIO DE DESEMBPLEADOS

	$("#formulario_desempleados").validate({
	debug: true,
		
      rules: { 
			
			email: { required: true, email: true},
			nombre: { required: true },
			marketing:	{ required: true },
			poblacion: { required: true }
      },
	  messages:	{
			email:	{required: "Introduzca e-mail", email: "E-mail no válido"},
			nombre: "Introduzca su nombre",
			poblacion: "Introduzca su poblacion",
			marketing: "Indíquenos cómo nos conoció",
			telefono: {  digits: "Sólo números", minlength: "Teléfono no válido"}		
	},
		submitHandler: function() {
			$('#formulario_desempleados').hide();
			$('#precarga').fadeIn(200, function () {
			$.ajax({
				type: 'POST',
				url: 'paginas/contacto_desempleados.php',
				data: $('#formulario_desempleados').serialize() + '&action=send',
				cache:false,
				dataType: 'html',
				async:false,
				// Mostramos un mensaje con la respuesta de PHP
				success: function(data) {
					$('#desempleados').fadeTo('slow', 0.3, function() {
						$('#desempleados').html(data);
						$('#desempleados').fadeTo('fast', 1);
					});

					 
					}
				});
			});
		}
		
   }); 
	///VALIDACION DE CAMPOS DEL FORMULARIO DE DESEMBPLEADOS
	// VALIDACION DE CAMPOS DEL FORMULARIO DE DESEMBPLEADOS













 });

