/**
 * @author EvgeniyV
 */
 
AppEvents = {};
 
AppEvents.onLoad = function() {
	Logger.write("[on load]", "AppEvents");
    widgetAPI = new Common.API.Widget();
    widgetAPI.sendReadyEvent();
    pluginAPI = new Common.API.Plugin();    
    window.onShow = onShowEventHandler;    
    Network.init();         
}

AppEvents.onUnLoad = function () {
	Logger.write("[on unload]", "AppEvents");
    tvKey = new Common.API.TVKeyValue();
    pluginAPI.unregistKey(tvKey.KEY_SOURCE);
    if  (ScenePlayer.isPlaying == true)
    {
        ScenePlayer.stop();
    }
}

AppEvents.Exit = function(){
	$("#loadingObject").sfLoading("show");
    widgetAPI.blockNavigation(event);
    if  (ScenePlayer.isPlaying == true)
    {
        ScenePlayer.stop();
    }
    widgetAPI.sendExitEvent();
}

onShowEventHandler = function(){
    Logger.write("onShowEventHandler()", "AppEvents");
    
    var nnaviPlugin = document.getElementById('pluginObjectNNavi');
    nnaviPlugin.SetBannerState(2);
    tvKey = new Common.API.TVKeyValue();
    
	pluginAPI.registKey(tvKey.KEY_SOURCE);
    // For volume OSD
    /*pluginAPI.unregistKey(tvKey.KEY_VOL_UP);
    pluginAPI.unregistKey(tvKey.KEY_VOL_DOWN);*/
    pluginAPI.unregistKey(tvKey.KEY_MUTE);
    
    pluginAPI.unregistKey(tvKey.KEY_MENU);
    pluginAPI.unregistKey(tvKey.KEY_INFOLINK);
    pluginAPI.unregistKey(tvKey.KEY_CONTENT); 
}