/**
 *
 */
jQuery(document).ready(function(){

jQuery("#loading_contacto").css("display","none");
jQuery("#response_contacto").css("display","none");
//jQuery('#contacto input, #contacto textarea').css("background-image:","assets/templates/dynaware/images/fields.jpg");

//jQuery('#contacto input#Enviar, #contacto input#Borrar').css("background-color","white");
//jQuery('#contacto input#Enviar, #contacto input#Borrar').css("border-color","gray");

jQuery('#contacto input, #contacto textarea').click(function(){
	//jQuery(this).css("background-color:","#F2F2F2");
	//jQuery(this).css("border-color","blue");
	//jQuery('#contacto input#Enviar, #contacto input#Borrar, #radios input').css("background","none");
	//jQuery('#contacto input#Enviar, #contacto input#Borrar').css("border-color","gray");
});

jQuery('#contacto input, #contacto textarea').blur(function(){
	//jQuery(this).css("background","none");
	//jQuery(this).css("border-color","gray");
	//jQuery('#contacto input#Enviar, #contacto input#Borrar, #radios input').css("background","none");
	//jQuery('#contacto input#Enviar, #contacto input#Borrar').css("border-color","gray");
});

jQuery("#formContacto").validate({
        rules: {
        	nombre: {
				required: true,
				minlength: 3,
				maxlength: 50
			},
			apellidos: {
				required: true,
				minlength: 3,
				maxlength: 50
			},
        	
        	telefono: {
				required: true,
				minlength: 3,
				maxlength: 50
			},
		email: {
			required: true,
			email: true,
			minlength: 3,
			maxlength: 50
		},
		mensaje: {
			required: true,
			minlength: 5,
			maxlength: 1000
		}
        },
	messages: {
		nombre: "Introduce tu nombre por favor",
		apellidos: "Introduce tus apellidos por favor",
		telefono: "Introduce tu telefono por favor",
		email: "Introduce un email válido por favor",
		mensaje: "Introduce un mensaje por favor ( 5 - 1000 caracteres)"
	},
	submitHandler: function() {
		jQuery("#formContacto").ajaxSubmit({
			beforeSubmit:  showRequest,  // pre-submit callback 
			success:       showResponse  // post-submit callback
		});
	
	},
	highlight: function(element, errorClass) {
	    //jQuery(element).addClass('error');
	},
	unhighlight: function(element, errorClass){
	  //jQuery(element).removeClass('error');
	}
    });

	function showRequest(formData, jqForm, options) { 
		//jQuery(":input#Borrar").attr("disabled", true);
		//jQuery(":input#Enviar").attr("disabled",true);
		jQuery("#loading_contacto").show("slow");
	} 

	// post-submit callback 
	function showResponse(responseText, statusText)  { 
		jQuery("#loading_contacto").hide("slow");
		jQuery("#response_contacto").show("slow").append(responseText).fadeTo(3000, 1).fadeOut(2000);
		//jQuery(":input#Enviar").removeAttr("disabled");
		//jQuery(":input#Borrar").removeAttr("disabled");
		//alert("Gracias por su InscripciÃ³n");
		//jQuery('#gracias').show();
		jQuery('form')[1].reset();
	}
});

