/* scroll to top */ jQuery(document).ready(function(){ // hide #back-top first jQuery("#back-top").hide(); // fade in #back-top jQuery(function () { jQuery(window).scroll(function () { if (jQuery(this).scrollTop() > 500) { jQuery('#back-top').fadeIn(); } else { jQuery('#back-top').fadeOut(); } }); // scroll body to 0px on click jQuery('#back-top a').click(function () { jQuery('body,html').animate({ scrollTop: 0 }, 800); return false; }); }); }); /* * Scroll */ $(function () { $('a[href*=#]:not([href=#])').click(function () { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html,body').animate({ scrollTop: (target.offset().top - 5) }, 850); return false; } } }); }); // Validation $(function() { // Setup form validation on the #register-form element $("#register-form").validate({ // Specify the validation rules rules: { firstname: "required", message: "required", email: { required: true, email: true }, password: { required: true, minlength: 5 }, agree: "required" }, // Specify the validation error messages messages: { firstname: "Please enter your first name", message: "Please enter your message", password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, email: "Please enter a valid email address", agree: "Please accept our policy" }, submitHandler: function(form) { form.submit(); } }); }); // nav $(document).ready(function() { $('#nav').onePageNav(); });