$(document).ready(function(){$('#content-main > p.create a').live('click',function(event){event.preventDefault();$('#content-main > p.create').siblings('form').each(function(){$(this).slideUp('fast',function(){$(this).remove();});});$.get('/blog/scripts/api/create/',function(json){$(json.html).css('display','none').insertBefore('#content-main > p.create').slideDown(function(){$('textarea.tinymce').trigger('mytinymce');});},'json');});$('#content-main > form > p.button > a').live('click',function(event){event.preventDefault();$('#content-main > form').slideUp(function(){$(this).remove();});});$('#content-main > form').live('submit',function(event){event.preventDefault();$.post('/blog/scripts/api/create/',$(this).serialize(),function(json){if(json.response=='success'){$('#content-main > form').slideUp(function(){$(this).remove();if(postId=$(this).find('#postId').val()){$('#post-'+postId).fadeOut('slow').css('visibility','hidden').replaceWith($(json.html).css('display','none').fadeIn('slow'));}
else{$(json.html).css('display','none').insertAfter('#content-main > p.create').slideDown();}});}
else{$('#content-main > form').replaceWith(json.html);$('textarea.tinymce').trigger('mytinymce');}},'json');});$('#content-main div.post dl dd ul.actions li.delete a').live('click',function(event){event.preventDefault();postDiv=$(this).parents('div.post');title=postDiv.find('h3:first').text();if(confirm('Would you like to delete the article "'+title+'"?')){url=$(this).attr('href').replace('/blog/','/blog/scripts/api/admin/');$.get(url,function(status){if(status=='success'){postDiv.slideUp(function(){$(this).remove();});}
else{alert('There was an error deleting this post.');}});}});});
