         frisbee.animate {left: percentOfWidth(-25), bottom: percentOfHeight(-25)}, 1250, 'easeInOutQuad', ->
                 cb()
 
-    if oldFrisbee.hasClass('frisbeeContent')
+    if oldFrisbee.length is 0
+        animateFrisbee()
+    else if oldFrisbee.hasClass('frisbeeContent')
         oldFrisbee.fadeOut animateFrisbee
     else
         oldFrisbee.animate left: -300, 1000, 'easeInOutQuad', animateFrisbee

        , 200

$ ->
    startAnimation()
        
    # TODO: Handle denials, in the case of denial, just fail
    
handleData = (data) ->
    {type, content} = data

    switch type
        when "url"
            a = $("<iframe src='#{content}'></iframe>")
            a.css width: percentOfWidth(100) - 100, height: percentOfHeight(100) - 100
        when "youtube"
            time = if data.time then data.time else ""
            a = $("<iframe src='http://www.youtube.com/embed/#{content}?autoplay=1\#t=#{time}' frameborder='0' autoplay=true allowfullscreen></iframe>")
            a.css width: percentOfWidth(100) - 100, height: percentOfHeight(100) - 100

        when "image"
            $("body").append $("<img src='#{content}'></img>")
        when "spotify"
            document.location = "spotify:track:#{content}"
        else
            alert("Unknown")
            return
    a.hide()
    a.appendTo('.content')
    a.fadeIn('slow')

socket.on 'frisbee', (data) ->
    console.log data

    throwFrisbee ->
        handleData data


throwFrisbee = window.throwFrisbee = (cb) ->
