loadScript =
  (obj)->
    $.ajax(
      url:"http://www.youtube.com/iframe_api/"
      dataType:"script"
      success:
        (data)->
          window.onYouTubeIframeAPIReady =
            ->
              target = obj.target
              id = obj.id
              width = obj.width
              height = obj.height
              loadPlayer(target,id,width,height)
      error:
        (xhr, status, thrown)->
          loadScript()
    )
loadPlayer =
  (target,id,width,height)->
    if !window.ytPlayer
      window.ytPlayer = new YT.Player(target,
        width: width
        height: height
        videoId: id
        playerVars:
          hl:'ja_JP'
          fs:1
          hd:1
          rel:0
          showinfo:0
          autohide:1
          theme:'light'
      )
    else
      ytPlayer.loadVideoById(id)
movie =
  target:$('#player').attr('id')
  id:$('#player').attr('data-movieid')
  width:260
  height:146
loadScript(movie)