set theTime to 5
tell application id "com.figure53.QLab.5" to tell front workspace
set theCues to (selected as list)
set theGroupCueList to {}
repeat with eachCue in theCues
if the q type of eachCue is in {"video", "text"} then
set the opacity of eachCue to 0
set the selected to eachCue
delay 0.01
make type "Fade"
set theFadeCue to last item of (selected as list)
set the duration of theFadeCue to theTime
set the opacity of theFadeCue to 100
set the do opacity of theFadeCue to true
set the cue target of theFadeCue to eachCue
make type "group"
set theGroupCue to last item of (selected as list)
set the end of theGroupCueList to theGroupCue
move eachCue to end of theGroupCue
move theFadeCue to end of theGroupCue
end if
end repeat
make type "group"
set theGroupCue to last item of (selected as list)
repeat with eachGroup in theGroupCueList
move eachGroup to end of theGroupCue
end repeat
make type "Fade"
set theFadeCue to last item of (selected as list)
set the duration of theFadeCue to theTime
set the opacity of theFadeCue to 0
set the do opacity of theFadeCue to true
set the cue target of theFadeCue to theGroupCue
set the stop target when done of theFadeCue to true
end tell