Update jp.php

added a sortPostsBy function which is called by javascript.
added a sendExpirationEmail() which sends an email if the post is expiring.