 /*
    Description: 	PHP Ajax Feedback Form
    Author: 		InsideLab
    Version: 		1.0
*/

/*	--------------------------------------------------
	:: Feedback Form
	-------------------------------------------------- */
	
	jQuery.noConflict()(function($){
	    $(document).ready(function(){
	        $('#newsletter input').tooltipster({
                trigger: 'custom',
                onlyOne: true,
                position: 'right'
            });
		});
	});
	
	jQuery.noConflict()(function($){
	    $(document).ready(function(){
            $("#newsletter").validate({	
      			rules:{
					firstname:{
					    required:true
				    },
					lastname:{
					    required:true
				    },
					useremail:{
						required:true,
						email:true
					},
				},
				messages: {
			        firstname:{
						required: 'Please enter your First Name',
					},
					lastname:{
						required: 'Please enter your Last Name',
					},
					useremail:{
						required: 'Please enter your Email Address',
						email: 'Please enter a valid Email Address'
					},
		        },	
				errorPlacement: function (error, element) {
                    $(element).tooltipster('update', $(error).text());
                    $(element).tooltipster('show');
                },
                success: function (label, element) {
                    $(element).tooltipster('hide');
                },
				submitHandler:function(form) {
				    jQuery(form).ajaxSubmit({
					    target:'#newsletter-message',
                        beforeSubmit:function(){ 
                            $('#loader').show();
                        },
			            success:function(){ 
				            $('#loader').hide();
					        $("#newsletter-message").fadeIn(500);
							$("#newsletter").each(function(){
                                this.reset();
                            });
                        },
				    });
			    }
	        });
        });
	});