jQuery(document).ready(
	function(){
		var options = { 
        
		//target:        parseData, //'.tx_resform_pi1_error_msg',
        beforeSubmit:  showRequest,
        success:       showResponse,
		error: errorResponse,
		url:  '/theme/yellowpoint/includes/form.php',
		dataType: 'json'
		//timeout: 30000
		}; 
		jQuery('#contact_form').submit(function() { 
			jQuery(this).ajaxSubmit(options);
			return false; 
		});
		
		
		function showRequest(formData, jqForm, options) { 
		    var queryString = jQuery.param(formData); 
		    return true; 
		} 
		 
		function errorResponse(){

			alert('Wystapił problem z połączeniem. Spróbuj ponownie za jakiś czas. Jeżeli problem się powtórzy, skontaktuj się z administratorem.');
			return false;
		}
		 
		function showResponse(data) { 
			jQuery('#message').empty();
			jQuery('#message').removeClass();
			if(data.message != '_'){
				jQuery('#message').addClass("success");
				jQuery('#message').text(data.message);
				jQuery('#contact_form').clearForm();
			}
			
			if(data.error != '_'){
				jQuery('#message').addClass("error");
				jQuery('#message').text(data.error);
			
			}
			var rand_no = Math.random();
			rand_no = rand_no * 100;
			jQuery("#image_captcha").attr('src', '/theme/yellowpoint/image.php?' + rand_no);				
		}

		jQuery("#refreshimg").click(
		function(){
			var rand_no = Math.random();
			rand_no = rand_no * 100;
			jQuery("#image_captcha").attr('src', '/theme/yellowpoint/image.php?' + rand_no);
			return false;
		});		
	}

)	

