Script to down/up an inteface if ping gateway fails

Im looking for a script that will get the current default gateway installed(its dynamic), ping it, and if it doesnt ping after 5 tries, make an interface go down, then back up after a small delay?

Use netwatch:
http://www.mikrotik.com/testdocs/ros/2.9/tools/netwatch.php