Update index.php

Overhaul, better ajax-integration and overall a better code.