The player variable needs to be declared first, before code can make use of it.
Each event, such as onclick, or onmouseover, or onmouseout, is seen by the browser as a different section of code. Variables declared in one section aren't known about by the others, which results in some duplication.
This duplication can be removed, but means moving away from the inline events. While we are still with inline events it's something that just needs to be lived with.