jQuery(function(){
	jQuery('#text_option_write').click(function(){
		jQuery('#text_option_form').each(function(){
			var text_option_title = jQuery('#text_option_title').val();
			var text_option_text = jQuery(this).val()
			var text_option_check = text_option_title.match(/'|"/g);
			if (text_option_check) {alert('定型文タイトルに「 \' 」や「 " 」は使わないでください。');} else {
				text_option_text = text_option_text.replace(/\n/g,'\\n');
				jQuery(this).val("\t\t" + '\'<textarea title="' + text_option_title + '">' + text_option_text + '</textarea>\' +' + "\n");
			}
		});
	});
	jQuery('#text_option_clear').click(function(){
		jQuery('#text_option_text').val();
		jQuery('#text_option_form').val('Text Options');
	});
	jQuery('#text_option_sample').each(function(){
		jQuery(this).find('dt').css('cursor','pointer').click(function(){
			var sample_text = jQuery(this).next('dd').html();
			sample_text = sample_text.replace(/<br.*>?/g,"");
			jQuery('#text_option_form').val(sample_text);
		});
	});
});