text: 	$(function() {
  
  			/* open modal 
  			----------------------------------------------------------- */
  			$('.smartforms-modal-trigger').on('click', function(event){
  				event.preventDefault();
  				$('.smartforms-modal').addClass('smartforms-modal-visible');
  				$('body').addClass('smartforms-modal-scroll');
  			});
  			
  			/* close modal
  			------------------------------------------------------------ */
  			$('.smartforms-modal').on('click', function(event){
  				if( $(event.target).is('.smartforms-modal-close') || $(event.target).is('.smartforms-modal')) {
  					event.preventDefault();
  					$(this).removeClass('smartforms-modal-visible');
  					$('body').removeClass('smartforms-modal-scroll');
  				}
  			});
  			
  			/* close modal when clicking the esc keyboard button
  			------------------------------------------------------------ */	
  			$(document).keyup(function(event){
  				if(event.which=='27'){
  					$('.smartforms-modal').removeClass('smartforms-modal-visible');
  					$('body').removeClass('smartforms-modal-scroll');
  				}
  			});
  
  				function reloadCaptcha(){ $("#captchax").attr("src","php/captcha/captcha.php?r=" + Math.random()); }
  				$('.captcode').click(function(e){
  					e.preventDefault();
  					reloadCaptcha();
  				});
  				
  				function swapButton(){
  					var txtswap = $(".smartforms-modal-footer button[type='submit']");
  					if (txtswap.text() == txtswap.data("btntext-sending")) {
  						txtswap.text(txtswap.data("btntext-original"));
  					} else {
  						txtswap.data("btntext-original", txtswap.text());
  						txtswap.text(txtswap.data("btntext-sending"));
  					}
  				}
  			   
  				$( "#smart-form" ).validate({
  				
  						/* @validation states + elements 
  						------------------------------------------- */
  						errorClass: "state-error",
  						validClass: "state-success",
  						errorElement: "em",
  						onkeyup: false,
  						onclick: false,
  						
  						/* @validation rules 
  						------------------------------------------ */
  						rules: {
  								sendername: {
  										required: true,
  										minlength: 2
  								},		
  								emailaddress: {
  										required: true,
  										email: true
  								},
  								sendersubject: {
  										required: true,
  										minlength: 4
  								},								
  								sendermessage: {
  										required: true,
  										minlength: 10
  								},
  								captcha:{
  									required:true,
  									remote:'php/captcha/process.php'
  								}
  						},
  						messages:{
  								sendername: {
  										required: 'Enter your name',
  										minlength: 'Name must be at least 2 characters'
  								},				
  								emailaddress: {
  										required: 'Enter your email address',
  										email: 'Enter a VALID email address'
  								},
  								sendersubject: {
  										required: 'Subject is important',
  										minlength: 'Subject must be at least 4 characters'
  								},														
  								sendermessage: {
  										required: 'Oops you forgot your message',
  										minlength: 'Message must be at least 10 characters'
  								},															
  								captcha:{
  										required: 'You must enter the captcha code',
  										remote:'Captcha code is incorrect'
  								}
  						},
  
  						/* @validation highlighting + error placement  
  						---------------------------------------------------- */
  						highlight: function(element, errorClass, validClass) {
  								$(element).closest('.field').addClass(errorClass).removeClass(validClass);
  						},
  						unhighlight: function(element, errorClass, validClass) {
  								$(element).closest('.field').removeClass(errorClass).addClass(validClass);
  						},
  						errorPlacement: function(error, element) {
  						   if (element.is(":radio") || element.is(":checkbox")) {
  									element.closest('.option-group').after(error);
  						   } else {
  									error.insertAfter(element.parent());
  						   }
  						},
  						
  						/* @ajax form submition 
  						---------------------------------------------------- */						
  						submitHandler:function(form) {
  							$(form).ajaxSubmit({
  								    target:'.result',			   
  									beforeSubmit:function(){ 
  											swapButton();
  											$('.smartforms-modal-footer').addClass('progress');
  									},
  									error:function(){
  											swapButton();
  											$('.smartforms-modal-footer').removeClass('progress');
  									},
  									 success:function(){
  										 	swapButton();
  											$('.smartforms-modal-footer').removeClass('progress');
  											$('.alert-success').show().delay(7000).fadeOut();
  											$('.field').removeClass("state-error, state-success");
  											if( $('.alert-error').length == 0){
  												$('#smart-form').resetForm();
  												reloadCaptcha();
  												setTimeout(function () {
  													$('.smartforms-modal').removeClass('smartforms-modal-visible');
  													$('body').removeClass('smartforms-modal-scroll');
  												}, 7500);
  											}
  									 }
  							  });
  						}
  						
  				});		
  		
  	});				
      