function Reload(){
    this.status = "start";
    this.start = function(){
        if (this.status == "stop"){
            this.status = "start";
            this.reload = window.setTimeout(function(){window.location.reload();},this.time);
            if (window.console){
                console.log("Reload Status:"+this.status);
                
            };
        };
    };
    this.stop = function(){
        if (this.status == "start"){
            this.status = "stop";
            clearTimeout(this.reload);
            if (window.console){
                console.log("Reload Status:"+this.status);
            };
        };
    };
    this._constructor = function(inicia,time){
        this.time = time * 1000;
        if ( inicia ){
            this.status = "stop";
            this.start();
        }else{
            this.status = "start";
            this.stop();
        };
    };
    this._constructor.apply(this,arguments);
};

function stateListener(obj){
    var currentState = obj.newstate; 
    var previousState = obj.oldstate; 
    if(currentState=="PLAYING"||currentState =="PAUSED"||currentState=="BUFFERING"){
        oReload.stop();
    }else{
        oReload.start();
    };
};
function playerReady(thePlayer){
    var playerVideo;
    try{
        playerVideo = document.getElementById('player');
        playerVideo.addModelListener("STATE","stateListener");
    }catch(e){}
    
    try{
        playerVideo = document.getElementById('player_AE');
        playerVideo.addModelListener("STATE","stateListener");
    }catch(e){}
    
    
    
};
