Gateway Failover Scripts Required

Hi,

I have 2 ADSL, each from different ISP, with Different Static IP’s & different DNS for each.

i want Public 2 gateway to go be enabled with masquerding set for Public2, when my Public1 is down and Public1 will enabled when its back.

I know to check the gateway from Netwatch but what is the script/ how to enable Gateway & Masquerding on Public2 simultaneously and then when Public1 is up it should disable Gateway & Masquerding on Public2 and enable Gateway & Masquerding on Public1 back.

Pls help me.

Regards
Sanjay