///////////////////////////////////////////////////////PLAYER FUNCTIONS//////////////////////////////////////////////	

// some variables to save
var currentPosition;
var currentState; 

// these functions are caught by the JavascriptView object of the player.
function getUpdate(typ,pr1,pr2) {

       if(typ == "state"){ currentState = pr1; }
       if(typ == "time"){ 

            currentPosition = pr1;
            //var time_remain = pr2;
            
            if(currentPosition == currentDuration && currentState == 2){ 

                if(currentType == "preroll"){ clearTimeout(timer); timer = setTimeout("load_video(current,\"video\");",5000); }
                else{ clearTimeout(timer); timer = setTimeout("manage_video(current+1);",5000); }

                } 
            }

        var id = document.getElementById(typ);
        id.innerHTML = typ+ ": "+Math.round(pr1);
        pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
};

// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("mpl").loadFile(obj); };
function getItemData(idx) {
        var obj = thisMovie("mpl").itemData(idx);
        var nodes = "";
        for(var i in obj) { 
                nodes += "<li>"+i+": "+obj[i]+"</li>"; 
        }
        document.getElementById("data").innerHTML = nodes;
};

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
    if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[movieName];
        } else {
                return document[movieName];
        }
};
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
