
var ConfirmPopupIndex ={ 

		
/////Change Picture///// 
		DELETE_PICTURE		: 1,	
        
		START_CALL_AFTER_END_CALL	: 2,

//// face Recog		
		FACE_RE_REGISTRATION	: 3,
		FACE_DELETE	: 4,

 };
 //2013 add by minseok
 var NormalCoor = {
 	TOP : 266,
 	LEFT : 342,
 	WIDTH : 596,
 	HEIGHT : 188,
 	BTN_YES_TOP : 108,
 	BTN_YES_LEFT : 134,
 	BTN_NO_TOP : 108,
 	BTN_NO_LEFT : 302
 	
 }
 var WideCoor = {
 	TOP : 266,
 	LEFT : 301,
 	WIDTH : 677,
 	HEIGHT : 188,
 	BTN_YES_TOP : 114,
 	BTN_YES_LEFT : 178,
 	BTN_NO_TOP : 114,
 	BTN_NO_LEFT : 346
 	
 }
function SceneConfirmPopup(options) {
	this.options = options;
    
    this.PopupType = 0;
    this.YesCallbackFn = null;
    this.NoCallbackFn = null;
    
    this.ConfirmPopupView=null;
	this.ConfirmPopupDim=null;
    
    this.PopupWideMsg = null;
    this.PopupMsg = null;
    this.YesBtn = null;
    this.NoBtn = null;
   

}

SceneConfirmPopup.prototype.initialize = function () {
	alert("SceneConfirmPopup.initialize()");
    
   this.create();
}

SceneConfirmPopup.prototype.handleShow = function () {
	alert("SceneConfirmPopup.handleShow()");
	this.ConfirmPopupDim.show();
    this.highlight(this.YesBtn);
    this.update();
    
    WndMgr.startPopupHideTimer(60000);
    
}

SceneConfirmPopup.prototype.handleHide = function () {
	alert("SceneConfirmPopup.handleHide()");
	// this function will be called when the scene manager hide this scene  
	this.ConfirmPopupDim.hide();
	
    WndMgr.stopPopupHideTimer();
    this.highlight(null);
}

SceneConfirmPopup.prototype.handleFocus = function () {
	alert("SceneConfirmPopup.handleFocus()");
	// this function will be called when the scene manager focus this scene
	var currentHighlight = this.ConfirmPopupView.getCurrentHighlight();
	if(currentHighlight != null)
		this.highlight(currentHighlight);
	else
		this.highlight(this.YesCallbackFn);
}

SceneConfirmPopup.prototype.handleBlur = function () {
	alert("SceneConfirmPopup.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
	var currentHighlight = this.ConfirmPopupView.getCurrentHighlight();
	if(currentHighlight != null) {
		currentHighlight.blur();
	}
}

SceneConfirmPopup.prototype.handleKeyDown = function (keyCode) {
	alert("SceneConfirmPopup.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:
		WndMgr.resetPopupHideTimer();
        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;
	}
}

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

SceneConfirmPopup.prototype.create = function(){
    alert("SceneConfirmPopup.create()");
    this.ConfirmPopupView = new View("ConfirmPopup");
    this.ConfirmPopupBG = new View("ConfirmPopupBG");
	this.ConfirmPopupBG.CreatePopupBG(1, "ConfirmPopup_popup_BG");
	this.ConfirmPopupDim = new DimBg("ConfirmPopupDim", "ConfirmPopupBG");    
    
    this.PopupMsg = new Label(null,"confirm_popup_message");
    this.PopupMsg.SetTextStyle("confirm_popup_message_style");
    this.PopupMsg.SetText(IDWS_MOIP_SKYPE_SIGNIN);
    
    this.PopupWideMsg = new Label(null,"confirm_popup_wide_message");
    this.PopupWideMsg.SetTextStyle("confirm_popup_wide_message_style");
    this.PopupWideMsg.SetText(IDWS_MOIP_SKYPE_SIGNIN);
    
    var this_ = sf.scene.get("ConfirmPopup");
    var clickCF =  function(obj){this_.processClickEvent(obj);};

    this.YesBtn = new Button();
    this.YesBtn.SetImageObjId("confirm_popup_yes_btn",20);
    this.YesBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.YesBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
    this.YesBtn.SetTextObjId("confirm_popup_yes_btn_text");
    this.YesBtn.SetText(SID_YES);
    this.YesBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.YesBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.YesBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.YesBtn.SetOnClickCallbackFunc(clickCF);
	
    this.NoBtn = new Button();
    this.NoBtn.SetImageObjId("confirm_popup_no_btn",20);
    this.NoBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.NoBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);		
    this.NoBtn.SetTextObjId("confirm_popup_no_btn_text");
    this.NoBtn.SetText(SID_NO);
    this.NoBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.NoBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.NoBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.NoBtn.SetOnClickCallbackFunc(clickCF);
	this.YesBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.NoBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
}
SceneConfirmPopup.prototype.processMouseOver = function(obj) {
	var currentHighlight = this.ConfirmPopupView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
}
SceneConfirmPopup.prototype.highlight=function(obj)
{
	alert("SceneConfirmPopup.highlight() ");
    this.ConfirmPopupView.setCurrenHighlight(obj);
}


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

SceneConfirmPopup.prototype.processEnterKey = function(){
    alert("SceneConfirmPopup.processEnterKey() ");
    
    var currentHighlight =  this.ConfirmPopupView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.YesBtn:
           WndMgr.NextConfirmPopup(); 
            break;
            
        case this.NoBtn:
           WndMgr.StopConfirmPopup(); 
            break;
    }
}

SceneConfirmPopup.prototype.processReturnKey = function(){
    alert("SceneConfirmPopup.processReturnKey() ");
    
    WndMgr.StopConfirmPopup();
}

SceneConfirmPopup.prototype.yseCallBack = function()
{
	alert("SceneConfirmPopup.yseCallBack() ");
	if(this.YesCallbackFn)
	{
		this.YesCallbackFn();
	}
}

SceneConfirmPopup.prototype.noCallBack = function()
{
	alert("SceneConfirmPopup.noCallBack() ");
	if(this.NoCallbackFn)
	{
		this.NoCallbackFn();
	}
}

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

SceneConfirmPopup.prototype.initPopup = function(typeIndex)
{
    this.PopupType =  typeIndex;
}

SceneConfirmPopup.prototype.update = function()
{
    alert("SceneConfirmPopup.update() ");
    this.changeView(this.PopupType)
    this.updatePopupMsg();
    this.updateYesCallbakcFn();
    this.updateNoCallbakcFn();
}
SceneConfirmPopup.prototype.changeView = function(typeIndex){
	switch(typeIndex)
    {
        case ConfirmPopupIndex.FACE_DELETE : 
        
        alert("Change wide view");
            this.ConfirmPopupView.ChangeClass(WideCoor.TOP, WideCoor.LEFT, WideCoor.WIDTH, WideCoor.HEIGHT);
    		this.ConfirmPopupBG.ChangePopupBGSize("ConfirmPopup_popup_BG_wide");
    		this.YesBtn.SetLeft(WideCoor.BTN_YES_LEFT);
    		this.YesBtn.SetTop(WideCoor.BTN_YES_TOP);
        	this.NoBtn.SetLeft(WideCoor.BTN_NO_LEFT);
        	this.NoBtn.SetTop(WideCoor.BTN_NO_TOP);
        	this.PopupWideMsg.visibleObj();
        	this.PopupMsg.hiddenObj();
        	this.PopupWideMsg.SetText(TV_SID_SURE_TO_DELETE_FACE_FROM_THIS_ACCOUNT);
            break;	
       case ConfirmPopupIndex.DELETE_PICTURE:
            this.ConfirmPopupView.ChangeClass(NormalCoor.TOP, NormalCoor.LEFT, NormalCoor.WIDTH, NormalCoor.HEIGHT);
			this.ConfirmPopupBG.ChangePopupBGSize("ConfirmPopup_popup_BG");
			this.YesBtn.SetLeft(NormalCoor.BTN_YES_LEFT);
			this.YesBtn.SetTop(NormalCoor.BTN_YES_TOP);
			this.NoBtn.SetLeft(NormalCoor.BTN_NO_LEFT);
			this.NoBtn.SetTop(NormalCoor.BTN_NO_TOP);
			this.PopupWideMsg.hiddenObj();
			this.PopupMsg.visibleObj();
        	break;
        default:
        	this.ConfirmPopupView.ChangeClass(NormalCoor.TOP, NormalCoor.LEFT, NormalCoor.WIDTH, NormalCoor.HEIGHT);
    		this.ConfirmPopupBG.ChangePopupBGSize("ConfirmPopup_popup_BG");
    		this.YesBtn.SetLeft(NormalCoor.BTN_YES_LEFT);
    		this.YesBtn.SetTop(NormalCoor.BTN_YES_TOP);
        	this.NoBtn.SetLeft(NormalCoor.BTN_NO_LEFT);
        	this.NoBtn.SetTop(NormalCoor.BTN_NO_TOP);
        	this.PopupWideMsg.hiddenObj();
        	this.PopupMsg.visibleObj();
        	break;
     }
}
SceneConfirmPopup.prototype.updatePopupMsg = function()
{
    alert("SceneConfirmPopup.updatePopupMsg() ");
    
    switch(this.PopupType)
    {

        case ConfirmPopupIndex.DELETE_PICTURE : 
            this.PopupMsg.SetText(IDWS_MOIP_DELETE_SELECTED_PICTURE);
            break;		
            
			
	    case ConfirmPopupIndex.START_CALL_AFTER_END_CALL :
			this.PopupMsg.SetText(TV_SID_START_NEW_CALL_CURRENT_CALL_WILL_END_MSG);
			break;
			
	    case ConfirmPopupIndex.FACE_RE_REGISTRATION :
			this.PopupMsg.SetText(TV_ALREADY_FACE_REGISTERED_ACCOUNT_MSG);
			break;
			
	    case ConfirmPopupIndex.FACE_DELETE:
			this.PopupMsg.SetText(TV_SID_SURE_TO_DELETE_FACE_FROM_THIS_ACCOUNT);
			break;
					
    }
}

SceneConfirmPopup.prototype.updateYesCallbakcFn = function()
{
    alert("SceneConfirmPopup.updateYesCallbakcFn() ");
	switch(this.PopupType)
	{
		

        case ConfirmPopupIndex.DELETE_PICTURE :
    
	        this.YesCallbackFn = function(){
				
				var Index = sf.scene.get('ChangePicture').GetDeletePhotoIndex();
				PluginAPIMgr.DeleteSnapShot(Index);				
				WndMgr.StartChangePictureStep();
									
			};
	        break;				
            
            
	    case ConfirmPopupIndex.FACE_RE_REGISTRATION :
			this.YesCallbackFn = function(){ProcMgr.ProcessReRegisterFace();};
			break;
			
	    case ConfirmPopupIndex.FACE_DELETE:
	        this.YesCallbackFn = function(){
	        	ProcMgr.ProcessDeleteFace();				
			};
			break;
		
    }
}

SceneConfirmPopup.prototype.updateNoCallbakcFn = function()
{
    alert("SceneConfirmPopup.updateNoCallbakcFn() ");
	switch(this.PopupType)
	{
			
			
        case ConfirmPopupIndex.DELETE_PICTURE :
    
	        this.NoCallbackFn = function(){				
				WndMgr.StartChangePictureStep();
			};
	        break;							
        
            
	    case ConfirmPopupIndex.FACE_RE_REGISTRATION :
	        this.NoCallbackFn = function(){				
				WndMgr.BackStepAccountManager();
			};
			
			break;
		
	    case ConfirmPopupIndex.FACE_DELETE:
	        this.NoCallbackFn = function(){
	        	WndMgr.ShowSettingsFaceRecognition();				
				// WndMgr.BackStepAccountManager();
			};
			
			break;
    }
}

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

