/* 
 * comment form ajax
 */


$(document).ready(function(){

	 // prepare the form when the DOM is ready
    var options = {
        target:			'#output',   // target element(s) to be updated with server response
		beforeSubmit:	showRequest,  // pre-submit callback
        success:		showResponse,  // post-submit callback
		dataType:		'json'        // 'xml', 'script', or 'json' (expected server response type)

        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        
        //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:   3000
    };

    // bind form using 'ajaxForm'
    $('#sylwadau').ajaxForm(options);
	
});

// pre-submit callback
function showRequest(formData, jqForm, options)
{
	// show loading graphic
	// send data
	$('#sylwadau').hide('slow');
	
    return true;
}

// post-submit callback
function showResponse(responseText, statusText)
{
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property

	if(responseText.status == 'fail')
		{
			$('#sylwadau').show();
		}

	$('#idTab2').append(responseText.message); 
}
