	$(function() {
			   
				/* @reload captcha
				------------------------------------------- */			   
				function reloadCaptcha(){
					$("#captcha").attr("src","contact/php/captcha.php?r=" + Math.random());
				}
				
				$('.captcode').click(function(e){
					e.preventDefault();
					reloadCaptcha();
				});				
			   
				$( "#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: 1000
								},		
								senderemail: {
										required: true,
										email: true
								},
								sendernumber: {
										required: true,
										minlength: 1
								},	
								senderaddress: {
										required: true,
										minlength: 1
								},								
								sendercompany: {
										required: true,
										minlength: 1
								},
								sendermessage: {
										required: true,
										minlength: 1
								},
								securitycode:{
										required:true
								}
						},
						
					
						messages:{
								sendername: {
										required: 'Enter your username',
										minlength: 'username is required'
								},				
								senderemail: {
										required: 'Enter password',
										email: 'Enter a VALID password'
								},
								sendernumber: {
										required: 'Enter your Phone number',
										minlength: 'Enter a VALID Phone number'
								},	
								senderaddress: {
										required: 'Enter your address',
										minlength: 'address is required'
								},														
								sendercompany: {
										required: 'Enter your company',
										minlength: 'Company is required'
								},
								sendermessage: {
										required: 'Oops you forgot your request',
										minlength: 'Request is required'
								},																
								securitycode:{
										required: 'Please enter security code'
								}
						},

						/* @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(){ 
											$('.form-footer').addClass('progress');
									},
									error:function(){
											$('.form-footer').removeClass('progress');
									},
									 success:function(){
											$('.form-footer').removeClass('progress');
											$('.alert-success').show().delay(15000).fadeOut();
											$('.field').removeClass("state-error, state-success");
											if( $('.alert-error').length == 0){
												$('#smart-form').resetForm();
												reloadCaptcha();
											}
									 }
							  });
						}
						// end submitHandler:
				});		
		
	});				
    