// prepare the form when the DOM is ready 
$(document).ready(function() { 
    
   // Ajax form post
	$('#pinyinForm').ajaxForm({ beforeSubmit: showThrobber, success: postSearch, dataType: 'json'});
	
	$('#txtPinyin').focus(function() { this.select();});
    
    $('#showHtmlLink').click(function() { $('#htmlOutput').show('slow'); $('#showHtmlLink').hide();});
    
}); 

function showThrobber(){
	$('#pinyinOutput').hide();
	$('#dictThrobber').show();
}


function postSearch(data) {

	$('#pinyinOutput').html(data.text);
	$('#htmlOutput').html('<h2>HTML encoding</h2>' + data.html);
	$('#dictThrobber').hide();
	$('#pinyinOutput').show();

}

