$(document).ready(function(){
	feedback_form();
});

function feedback_form()
{
	$('.feedback').click(function(){
		var options = {
			type:		'POST',
			url:		presets.siteURL() + 'contact/feedback_form',
			dataType:	'json',
			success:	function(json){
				modalbox_t(json.view);
				close_modalbox();
				feedback();
			}
		};
		$.ajax(options);		
	});
}

function feedback()
{
	var options = {
		type:			'POST',
		success:		post_submit_feedback,
		url:			presets.siteURL() + 'contact/send_feedback',
		dataType:		'json'
	};
	
	$('#feedback_form').submit(function(){
	    $(this).ajaxSubmit(options); 
	    return false;
	});
}

function post_submit_feedback(json)
{
	if(!json.errors){
		jMessage(json.message, json.message_title, function(result){
			if(result) modalbox_destroy();
		});		
	}else{
		jError(json.message, json.message_title);
	}
}
