﻿var player = null;
function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id);
		addListeners();
}

function addListeners() {
	if (player) { 
		player.addModelListener("STATE", "stateListener");
	} else {
		setTimeout("addListeners()",100);
	}
}

var counter = 0;
function stateListener(obj) 
{ 
//IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
    
    if (counter == 0 && obj.newstate=="PLAYING") 
    {
	    req = new XMLHttpRequest();
	    req.open("GET", LoggingURL);
	    req.send("logthis");
	    counter++;
    }
}

var LoggingURL = "";
function createPlayer(logurl, movie, image, height, width) 
{
    LoggingURL = logurl;
	var flashvars = {};
	flashvars.file = movie;
    flashvars.image =image;
	flashvars.backcolor ="#000000";
	flashvars.frontcolor ="#ffffff";
	flashvars.abouttext ="Videoavspiller for Vox";
	flashvars.aboutlink ="#";
	flashvars.allowscriptaccess = "always";
    //flashvars.skin = "swf/modieus.swf";
	var params = {};
    params.allowfullscreen = "true";
	var attributes = {};
	attributes.id = "player1";
	attributes.name = "player1";
	swfobject.embedSWF("/videovox/player.swf", "videoplayer", width, height, "9.0.115", false, flashvars, params, attributes);
}