Pagination functions!
removed old pagination fund.
indentation fixes, added catching trailingslashits, catch for when permalinks are turned off