var myControl = $get('<%= ClickMe.ClientID %>');
if(myControl.styles.backgroundColor == 'red')
myControl.styles.backgroundColor = 'blue'
myControl.styles.backgroundColor = 'red'
I have used this technique in MasterPages, UserControls, and WebParts (including those hosted in SharePoint), and it works like a charm.