Altered majority of file to work with jQuery/AJAX and Facebook SDK.