// scripts-about.js for EES

// ASK A QUESTION

var aaq_succ = function( r, obj ) {
	// Success
	if( !r['error'] ) {
		$( 'table.form' ).fadeOut(666);
		$( 'div.result' ).html( r['msg'] );
	}
	// Failure
	else {
		// Show error message
		alert( r['msg'] );
	}
	$( 'table.form' ).fadeOut(666)
}
var aaq_fail = function( r, obj ){
	alert( 'Не удалось выполнить ваш запрос' )
}
function aaq( url ) {
	var name = document.getElementById( 'comm_name' ).value;
	var contact = document.getElementById( 'comm_res' ).value;
	var comment = document.getElementById( 'comm_ctext' ).value;
	if( !jQuery.trim(name) )		return	alert( 'Укажите, пожалуйста, как к Вам обращаться.' );
	if( !jQuery.trim(contact) )	return	alert( 'Укажите свой контактный e-mail и/или телефон для связи' );
	if( !jQuery.trim(comment) )	return 	alert( 'Ваши вопросы/комментарии?' );
	sendXHR( url,	'name=' + encodeURIComponent( name ) +
					'&contact=' + encodeURIComponent( contact ) +
					'&comment=' + encodeURIComponent( comment ), aaq_succ, aaq_fail, {} );
}

// *****************************************************************************
// ON READY
// *****************************************************************************

$( document ).ready( function() {
	$( '#comm_btn_send' ).click( function() { aaq( '/about/ask' ) } )
} );
