refactored for better ordering of statements, including setting FB data
before calling smarty init
made $APP_ID publicly accessible for "if (isFbSet)" logic
added logic to check if FB cfg data is available for use