function save(item, id) {
    jQuery.get('/ajax_requests/save.php?item'+item+'&id='+id, function(data){jQuery.prompt(data);});
}

function mail() {
    jQuery.get('/ajax_requests/mail.php', function(data){jQuery.prompt(data);});
}

function contact(user) {
    jQuery.get('/ajax_requests/contact.php?user='+user, function(data){jQuery.prompt(data);});
}

function replyToComment(id) {
    jQuery('#replyFor').show();
    jQuery('#replyFor').html('<h3>Reply to comment:</h3>'+jQuery('#c'+id+' > p').html()+'<input type="hidden" name="parent" value="'+id+'"/>');
    jQuery('#replyCancel').html('<a href="javascript:;" onclick="doNotReply(\'c'+id+'\');" class="red">cancel</a>');
    jQuery('#replySubmit').html('Add reply to comment');
    jQuery('#commentForm textarea').focus();
}

function doNotReply(id) {
    jQuery.scrollTo('#'+id, 400);
    jQuery('#replyFor').fadeOut('fast', function(){jQuery('#replyFor').html('');jQuery('#replyCancel').html('');jQuery('#replySubmit').html('Add this comment');});
}

function deleteMessages() {
    var n = jQuery('#messages_form input:checked').length;
    if (n) {
        sbmt('#messages_form', 'Deleting '+n+' message(s). Are you sure?');
    }
}

function addComment() {
    var n = jQuery.trim(jQuery('#commentForm > textarea').val());
    if (n) {
        sbmt('#commentForm', '');
    }
}

function decomposeBoxes() {
    jQuery('#boxes > div').each(function() {
        if (jQuery('#col1').height() <= jQuery('#col2').height()) {
            jQuery('#col1').append(jQuery(this).clone());
        } else {
            jQuery('#col2').append(jQuery(this).clone());
        }
    });
    jQuery('#boxes').remove();
    if (!jQuery('#col2').height()) {
        jQuery('#col1').width('100%');
    }
}

function removeError(i) {
    jQuery(i).removeClass('error');
    jQuery(i).siblings('div').hide();
}

function sbmt(i, c) {
    if (c) {
        if (confirm(c)) {
            jQuery(i).submit();
        }
    } else {
        jQuery(i).submit();
    }
}

function cLink(c, b, l) {
    jQuery.get('/ajax_requests/confirm.php?l='+encodeURIComponent(l)+'&b='+encodeURIComponent(b)+'&c='+c, function(data){jQuery.prompt(data);});
}

jQuery(function() {
    if (jQuery('#tabs > ul')){jQuery('#tabs > ul').tabs();}
    if (jQuery('#boxes')){decomposeBoxes();}
})

addthis_pub  = 'agencywiz';