﻿var cs = {};
cs.flashplayer = {
    onPlay : function(flashPlayerId, videoInfo)
    {
        cs.flashplayer.loadNewFileDetails(flashPlayerId, videoInfo);
    },
    
    getMovie : function(movieName) {        
        return document[movieName];
    },
    
    onPause : function(flashPlayerId, videoInfo)
    {
               
    },
    
    onNext : function(flashPlayerId, videoInfo)
    {
        cs.flashplayer.loadNewFileDetails(flashPlayerId, videoInfo);    
    },
    
    onPrev : function(flashPlayerId, videoInfo)
    {      
        cs.flashplayer.loadNewFileDetails(flashPlayerId, videoInfo);
    },
    
    loadNewFileDetails : function(flashPlayerId, videoInfo)
    {         
        if(flashPlayerId && videoInfo)    {
            if(videoInfo.thumbnail) {
                jQuery('#' + flashPlayerId + ' .VideoFileThumbnail').attr('src', videoInfo.thumbnail);
            }
            if(videoInfo.caption) {
                jQuery('#' + flashPlayerId + ' .VideoFileTitle').text(videoInfo.caption);    
            }
            if(videoInfo.description) {
                jQuery('#' + flashPlayerId + ' .VideoFileDescription').text(videoInfo.description);
            }
        }     
        cs.flashplayer.applyCssPropertiesForCurrent(flashPlayerId, videoInfo.id);        
    },
    
    playFileInFlash : function(movieName, fileId)
    {
        var movie = cs.flashplayer.getMovie(movieName);
        if(movie)
        {
            movie._playById(fileId);
        }
    },
    
    applyCssPropertiesForCurrent : function(flashPlayerId, fileId)    {        
        //unselect previous file
        jQuery('#' + flashPlayerId + ' .current').removeClass('current');
        //add css class for current displayed file
        jQuery('#' + flashPlayerId + ' .n' + fileId).addClass('current'); 
        
    }     
}