function verify(url, text){ if (text=='') text='Are you sure you want to delete this comment?'; if (confirm(text)){ document.location = url; } return void(0); } // setup everything when document is ready jQuery(document).ready(function($) { $("#idiotspeak_post").css("display","none"); $("#idiotspeak_post_toggle").click(function(){ $("#idiotspeak_post").slideToggle("fast"); $("#idiotspeak_post #comment").focus(); $("#idiotspeak_post #author").focus(); }); $('#idiotspeakform').ajaxForm({ // target identifies the element(s) to update with the server response target: '#idiotspeakcomments', // handler function for success event success: function(responseText, statusText) { $('#idiotspeakresponse').html(''+'Well, thats what YOU say...'+''); $('#submit_idiotspeak_post').attr('value', 'Submit'); $("#idiotspeak_post").hide("fast"); $("#idiotspeak_post #author").attr('value', ''); $("#idiotspeak_post #comment").attr('value', ''); } , // handler function for errors error: function(request) { // parse the response for WordPress error if (request.responseText.search(/WordPress › Error<\/title>/) != -1) { var data = request.responseText.match(/<p>(.*)<\/p>/); $('#idiotspeakresponse').html('<span class="idiotspeak-error">'+ data[1] +'</span>'); } else { $('#idiotspeakresponse').html('<span class="idiotspeak-error">An error occurred, please notify the administrator.</span>'); } $('#submit_idiotspeak_post').attr('value', 'Submit'); $("#idiotspeak_post #author").attr('value', ''); $("#idiotspeak_post #comment").attr('value', ''); } , beforeSubmit: function(formData, jqForm, options) { // clear response div $('#idiotspeakresponse').empty(); for (var i=0; i < formData.length; i++) { if (!formData[i].value) { $('#idiotspeakresponse').html('<span class="idiotspeak-error">'+'Please fill in the required fields.'+'</span'); return false; } } $('#submit_idiotspeak_post').attr('value', 'Please wait'); } }); $('.nav #img_left').click(function(){ var page= $('#idiotspeakcomments #page_left'); var idiotspeakform = $('#idiotspeakform'); $('#idiotspeakcomments').load(idiotspeakform[0].action+'?refresh=' + page[0].value ); }); $('.nav #img_right').click(function(){ var page= $('#idiotspeakcomments #page_right'); var idiotspeakform = $('#idiotspeakform'); $('#idiotspeakcomments').load(idiotspeakform[0].action+'?refresh=' + page[0].value ); }); });