$.fn.formValidation = function(){
	 // $('form.validated').submit(function () {
	$(this).each(function(index) {		
		 $(this).submit(function () {
	  	var valid = true;
	  	var email_regex = new RegExp("^[\w!#$%&'*+/=?`{|}~^-]+(?:\.[\w~#$%&'*+/=?`{|}~^-]+)*@(?:[A-Z0-9-]]+\.)+[A-Z]{2,6}$", "i");

		$("input._required", this).each(function (i, input) {
		  // Before validating this input element, ensure the error state is
		  // cleared from its ancestor <li> element.
		  $(input).closest('li').removeClass('error');

		  // Ensure string inputs are not empty
		  if(input.value === '') {
		    valid = false;
		    $(input).closest('li').addClass('error');
		  } 
			else {
		    if(input.name === 'email') {
		      if(input.value.match(/^.+@.+/)) {
		        valid = valid && true;
		      }
		      else {
		        valid = false;
		        $(input).closest('li').addClass('error');
		      }
		    }
		    else if(input.name === 'phone-number') {
		      if(input.value.replace(/\D/, '').length >= 10) {
		        valid = valid && true;
		      }
		      else {
		        valid = false;
		        $(input).closest('li').addClass('error');
		      }
		    }
		  }
		});
	   if(!valid) {
	     window.scrollTo(0, 0);
	     $("p.error-msg").slideDown('fast');
	     $('li.error').errorTip();

	   }
	   return valid;
	 });
	});
};
