Assuming you can find your moved post again... what you want to do seems entirely possible, though it would probably result in a longer script than you were intending. Mostly because as gm9 said, probably the only way to detect your pet type is to check the spell name on up to 30 maintained spell icons.
If you're up for it, I can write generally what you'd have to accomplish.
You'll need some text elements holding the maintained icon's spell names. (Repeat 30x)
Code:
<Text Name="Icon01Name" Visible="false" DynamicData="/GameData.Maintained.Spell_1.Name" />
You'll need some UI script to check the icon text for your pet buff name.(Repeat 30x)
Code:
MATCH=Parent.DynamicDataPage.Icon01Name.LocalText==SearchName
Found=MATCH ? true : Found
Some hidden Page or Button elements with OnShow/OnActivate handler scripts to do your different commands. (One element pet pet type)
Code:
<Page Name="FirePetPage" Visible="false" OnShow="Visible=false do_some_commands" />
Then you'll need some code to do your branching once you have checked all of the icons for each of the pet names.
Code:
Parent.FirePetPage.Visible=FIREPETFOUND
Parent.EarthPetPage.Visible=EARTHPETFOUND
Only one of the booleans should be true(think switch/case block), so only one page should be made visible causing its OnShow event to be triggered. Hide an element after making it visible so you can use it a second time.
That's generally how I would make it... though there are certainly some parts I left out aside from repeating things 30x.