$(function() {
    
	$('#email').alphanumeric({allow:"@_."});
	$('#tel1, #tel2').numeric({allow:"-()"});
	
	
});

SubmittingForm=function() {
			alert("The form has been validated.");
		}

		$(document).ready(function() {
			
			//Abrir AboutUs//
			/*FancyBox*/
						$("a[rel=info]").fancybox({
							'padding' 			:	0,
							'autoDimensions' 	:	true,
							'width'				: '75%',
							'height'			: '75%',
							'autoScale'     	: true,
							'transitionIn'		: 'none',
							'transitionOut'		: 'none',
							'type'				: 'iframe'
						});
				
				
			//FancyBoxEnd

			$("#contacto").click(function(e){
				
				e.preventDefault();			
				$('#hiddenclicker').trigger('click');
			
				return false;
			});
			$("#sendinfo").validate({
				/*submitHandler:function(form) {
					SubmittingForm();
				},*/
				rules: {
					name_u: "required",		// simple rule, converted to {required:true}
					email: {
						required: true
					},
					tel1: {
						required: true
					},
					corp: {
						required: true
					},
					comment: {
						required: true
					}
				},
				messages: {
					name_u: "Este campo es importante.",
					email: "Proporcione correo v&aacute;lido.",
					corp: "Proporcione nombre.",
					tel1: "Proporcione telefono v&aacute;lido.",
					comment: "Tiene alguna pregunta."
					
				},
				submitHandler: function(form) {
					var loading="<strong>Enviando...</strong><br /><div id=\"loading\"></div>";
			  		$('#leftp #works div.sendwait').html(loading).fadeIn();
					$.ajax({
						type: "POST",
						url: "correo.php",
						data: $("#sendinfo").serialize(),
						success: function(datos){							
						   $('#leftp #works div.sendwait').html("<strong>Envio Correcto.</strong><br /><strong>Responderemos a la m&aacute;s pronta brevedad.</strong><br /><a href=\"#\" id=\"cerrarsend\">Cerrar</a>");
						   //alert("Correo enviado.\nEn breve nos comunicaremos contigo.");
						   $('#sendinfo').each(function(){
							  this.reset();
							});
						}
					});
					
				   //alert($("#sendinfo").serialize());
				 }
			});
			$("#hiddenclicker").fancybox({
				'scrolling'		: 'no',
				'titleShow'		: false,
				'padding'		: 0,
				'margin'		:0,
				'onClosed'		: function() {
					//$("#login_error").hide();
				}
			});
		});
		$('#leftp #works div.sendwait a#cerrarsend').live('click', function(e){
			e.preventDefault();
			$(this).html("").parent().fadeOut();
		});
		jQuery.validator.addMethod(
			"selectNone",
			function(value, element) {
				if (element.value == "none")
				{
					return false;
				}
				else return true;
			},
			"Please select an option."
		);

