$(document).ready(function(){

	//Slider
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		numeric: true
	});


	$('img[class=sfade]').hoverIntent({
		over: makeTall, 
		timeout: 200, 
		out: makeShort
	});
		

}); /*--jQuery--*/

	  // Abrir y cerrar capa con productos
	  $('#clickme').click(function() {
								   
		if ($('#productos').css("display") == 'none') {				   
      		
			$('#productos').slideDown('slow', function() {
        	// Animation complete.
			
     		});
			
		}else{
			
			$('#productos').slideUp('slow', function() {
        	// Animation complete.
			
     		});
		};
	  
    }); 
	
	//Ocultar email
	$(function() {
		$('a.email').each(function(){
			e = this.rel.replace('arroba','@'); //Remplaza el texto '(arroba)' por '@'.
			this.href = 'mailto:' + e;
			$(this).text(e);
		});
	});
	
	
	function makeTall(){   $(this).fadeTo("fast", 0.50); }
	function makeShort(){  $(this).fadeTo("fast", 1.00); }
	
	
	$("#buttonSubmit").click(function() {
	  // validate and process form here	  
	  $('.error').hide();
	  var name = $("input#nombre").val();
	  var email = $("input#email").val();
	  var mensaje = $("textarea#comentario").val();
		//alert(name);
		if ((name == "") || (name == "\u2026 su nombre")){
		$("span#nombre_error").show();
		$("input#nombre").focus();
		return false;
	    }
		//alert(name);
		if ((email == "") || (email == "\u2026 su email")) {
		$("span#telemail_error").show();
		$("input#email").focus();
		return false;
		}
		if (!ValidateEmail(email)) {
		$("span#telemail_error").show();
		$("input#email").focus();
		return false;
		}
		//alert(name);
		if ((mensaje == "") || (mensaje == "\u2026 su comentario")) {
		$("span#comentario_error").show();
		$("input#comentario").focus();
		return false;
		}
	 
  
	  var dataString = 'nombre='+ name + '&email=' + email + '&mensaje=' + mensaje ;
	  //alert (dataString);return false;
	  // ajax process
	  $.ajax({
	   type: "POST",
	   url: "/web/process.php",
	   data: dataString,
	   success: function() {
		 $('#formContacto').html("<div id='message'></div>");
		 $('#message').html("<h2>Formulario de contacto enviado!</h2>")
		 .append("<p>Pronto contactaremos con usted. Gracias.</p><br>")
		 .hide()
		 .fadeIn(1500, function() {
		   $('#message').append("<img id='checkmark' src='img/check.png' />");
		 });
	   }
	  }); 	
	});
	
