var player = false;

function playerReady(p) {
    player = window.document[p.id];

    addListeners();
}

function addListeners() {
    if (player) {
        player.addModelListener("STATE", "stateListener");
    } else {
        setTimeout("addListeners()", 100);
    }
}

function stateListener(obj) {
    currentState = obj.newstate;
    previousState = obj.oldstate;
    
    if (currentState == "COMPLETED" && Shadowbox) {
		Shadowbox.close()
    }
}

