

function SceneVideoAllowPopup(options) {
	this.options = options;
    
    this.VideoAllowPopupView=null;
	this.VideoAllowPopupDim=null;
    
    this.PopupMsg = null;
    this.YesBtn = null;
    this.NoBtn = null;
   
    this.VideoAllowPopupTimer = false;

}

SceneVideoAllowPopup.prototype.initialize = function () {
	alert("SceneVideoAllowPopup.initialize()");
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here 
	// scene HTML and CSS will be loaded before this function is called
    
   this.create();
}

SceneVideoAllowPopup.prototype.handleShow = function () {
	alert("SceneVideoAllowPopup.handleShow()");
	// this function will be called when the scene manager show this scene 
	this.VideoAllowPopupDim.show();
	
	this.update();
    this.highlight(this.YesBtn);

    this.startTimer();
    
}

SceneVideoAllowPopup.prototype.handleHide = function () {
	alert("SceneVideoAllowPopup.handleHide()");
	// this function will be called when the scene manager hide this scene  

	this.VideoAllowPopupDim.hide();
	
	if(this.VideoAllowPopupTimer== true)
	{
		this.stopTimer();
	}
}

SceneVideoAllowPopup.prototype.handleFocus = function () {
	alert("SceneVideoAllowPopup.handleFocus()");
	// this function will be called when the scene manager focus this scene

}

SceneVideoAllowPopup.prototype.handleBlur = function () {
	alert("SceneVideoAllowPopup.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
}

SceneVideoAllowPopup.prototype.handleKeyDown = function (keyCode) {
	alert("SceneVideoAllowPopup.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	switch (keyCode) {
		case sf.key.LEFT:
		case sf.key.RIGHT:
		this.resetTimer();
        this.processLeftRightKey();
			break;
		case sf.key.UP:

			break;
		case sf.key.DOWN:

			break;

		case sf.key.ENTER:
             this.processEnterKey();
			break;
            
        case sf.key.RETURN:
        case sf.key.EXIT:
            this.processReturnKey();            
            sf.key.preventDefault();
			break;
            
         case 147:  //infolink
         case 261:  //contents
         case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneVideoAllowPopup.prototype.create = function(){
    alert("SceneVideoAllowPopup.create()");
    this.VideoAllowPopupView = new View("VideoAllowPopup");
    this.VideoAllowPopupView.SetBgImage(WndMgr.Bg_Popup.src); 
	 
	this.VideoAllowPopupDim = new DimBg("VideoAllowPopupDim", "VideoAllowPopup");   
    
    this.PopupMsg = new Label(null,"video_allow_popup_message");
    this.PopupMsg.SetTextStyle("video_allow_popup_message_style");
    this.PopupMsg.SetIsPlainText(true);
    
    var this_ = sf.scene.get("VideoAllowPopup");
    var clickCF =  function(obj){this_.processClickEvent(obj);};

    this.YesBtn = new Button();
    this.YesBtn.SetImageObjId("video_allow_popup_yes_btn");
    this.YesBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_LOADING_BTN_NORMAL);
    this.YesBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LOADING_BTN_NORMALFOCUS);	
    this.YesBtn.SetTextObjId("video_allow_popup_yes_btn_text");
    this.YesBtn.SetText(SID_ALLOW);
    this.YesBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"common_btn_text_f19_normal_style");
	this.YesBtn.SetOnClickCallbackFunc(clickCF);
    
    this.NoBtn = new Button();
    this.NoBtn.SetImageObjId("video_allow_popup_no_btn");
    this.NoBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_LOADING_BTN_NORMAL);
    this.NoBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LOADING_BTN_NORMALFOCUS);	
    this.NoBtn.SetTextObjId("video_allow_popup_no_btn_text");
    this.NoBtn.SetText(IDWS_MOIP_NOT_ALLOW);
    this.NoBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"common_btn_text_f19_normal_style");
	this.NoBtn.SetOnClickCallbackFunc(clickCF);
}

SceneVideoAllowPopup.prototype.update=function()
{
	this.PopupMsg.SetText(g_Data.CombinateStrings(SID_MIX_IS_CALLING_VIA_VIDEO,PluginAPIMgr.GetCallMemberID())); 
}

SceneVideoAllowPopup.prototype.highlight=function(obj)
{
    this.VideoAllowPopupView.setCurrenHighlight(obj);

}

SceneVideoAllowPopup.prototype.startTimer = function()
{
    alert("SceneVideoAllowPopup.startTimer() ");
	
	this.VideoAllowPopupTimer = true;
	PluginAPIMgr.StartOSDTimer("30000" , function() { sf.scene.get('VideoAllowPopup').popupTimerCallback();}, ENUM_TIMER_TYPE.POPUP_WND);
}

SceneVideoAllowPopup.prototype.resetTimer = function()
{
    alert("SceneVideoAllowPopup.resetTimer() ");
	
	if(this.VideoAllowPopupTimer == true)
	{
		PluginAPIMgr.RestartOSDTimer("30000" ,ENUM_TIMER_TYPE.POPUP_WND);
	}
}

SceneVideoAllowPopup.prototype.stopTimer = function()
{
    alert("SceneVideoAllowPopup.stopTimer() ");

	this.VideoAllowPopupTimer = false;
	PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.POPUP_WND); 
}

SceneVideoAllowPopup.prototype.popupTimerCallback = function()
{
    alert("SceneVideoAllowPopup.popupTimerCallback() ");
	
	if (this.VideoAllowPopupTimer == false)
	{
		return;
	}
	this.VideoAllowPopupTimer = false;	
		
   StateMgr.Stop_Video_Allow_State(true);
}

SceneVideoAllowPopup.prototype.processLeftRightKey = function(){
    alert("SceneVideoAllowPopup.processLeftRightKey() ");
    
    var currentHighlight =  this.VideoAllowPopupView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.YesBtn:
           this.highlight(this.NoBtn);
            break;
            
        case this.NoBtn:
           this.highlight(this.YesBtn);
            break;
    }
}

SceneVideoAllowPopup.prototype.processEnterKey = function(){
    alert("SceneVideoAllowPopup.processEnterKey() ");
    
    var currentHighlight =  this.VideoAllowPopupView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.YesBtn:
			StateMgr.Stop_Video_Allow_State(true);
		   	ProcMgr.SetStartReceiveVideo();

            break;
            
        case this.NoBtn:

		   	StateMgr.Stop_Video_Allow_State(true);
            break;
    }
}

SceneVideoAllowPopup.prototype.processReturnKey = function(){
    alert("SceneVideoAllowPopup.processReturnKey() ");
	
   	StateMgr.Stop_Video_Allow_State(true);
}

SceneVideoAllowPopup.prototype.processClickEvent = function(obj){
	alert("SceneVideoAllowPopup.processClickEvent() ");
	
	var currentHighlight =  this.VideoAllowPopupView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
	
	this.processEnterKey();
}

