$(document).ready(function() { 

   	    var options_com = { 

       // target:        '#status',   // target element(s) to be updated with server response 

        beforeSubmit:showRequest_com,  // pre-submit callback 

        success:showResponse_com,  // post-submit callback 

 

        // other available options: 

        url:'http://biznesguide.ru/main/add_com'         // override for form's 'action' attribute 

        //type:post        // 'get' or 'post', override for form's 'method' attribute 

        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 

        //clearForm: true        // clear all form fields after successful submit 

        //resetForm: true        // reset the form after successful submit 

 

        // $.ajax options can be used here too, for example: 

       // timeout:   3

    };

	

	// bind to the form's submit event 

    $('#myForm').submit(function() { 

        // inside event callbacks 'this' is the DOM element so we first 

        // wrap it in a jQuery object and then invoke ajaxSubmit 

        $(this).ajaxSubmit(options_com); 

 

        // !!! Important !!! 

        // always return false to prevent standard browser submit and page navigation 

        return false; 

		}); 

	});

// pre-submit callback 

	function showRequest_com(formData, jqForm, options_com) { 

	  

		$('#status').html("<img src='http://biznesguide.ru/img/loading.gif' width='16' height='16'><br><p>Ваши данные обрабатываются...</p>");

		$('#error').html('');

		return true; 

	}

// post-submit callback 

	function showResponse_com(responseText, statusText)  { 

		var data = eval('(' + responseText + ')');
		
		$('#captcha').attr('src','http://biznesguide.ru/main/captcha/'+Math.round(Math.random(0)*1000));

		if (data.status == "OK") {

			$('#status').html('Ваш комментарий успешно добавлен!');
			$('#error').html('');			
			$('#com').append(data.text);
			//$('#myForm').clearForm();
			$('.comments').html(data.comments);
			$('input[name=keystring]').attr('value','');
			$('textarea[name=text]').attr('value','');

		}

		else {

			$('#status').html('<u>Пожалуйста, проверьте введенные данные!</u>');

			$('#error').html(data.error);
			$('input[name=keystring]').attr('value','');

		}

	} 