

function SceneBlock(options) {
	
	this.options = options;
	
	this.Type			= null;
	this.TargetDisplay	= null;
	this.TargetIdentity = null;
			
	this.BlockView	= null;	
	this.BlockPopupView = null;
	this.BlockDim = null;
	//this.NameLabel	= null;
	this.BodyMsg	= null;
	this.CheckBox	= null;	
	
	this.OkBtn			= null;
	this.CancelBtn		= null;
	this.BlockBtn		= null;
	this.BlockRemoveBtn	= null;
	this.BlockCancelBtn	= null;
	
	//flag
	this.IsBlockRemove	= false;
	this.showState		= false;

}

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

}

SceneBlock.prototype.handleShow = function () {
	alert("SceneBlock.handleShow()");
	this.BlockDim.show();	
	this.ResetPopup();
	this.showState = true;
	
	WndMgr.startPopupHideTimer(30000);
}

SceneBlock.prototype.handleHide = function () {
	alert("SceneBlock.handleHide()");
	this.BlockDim.hide();
	this.showState = false;
	
	this.highlight(null);

	WndMgr.stopPopupHideTimer();
		
}

SceneBlock.prototype.handleFocus = function () {
	alert("SceneBlock.handleFocus()");
	
    var currentHighlight =  this.BlockView.getCurrentHighlight();

    if(currentHighlight == null)
    {
		if(this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK || 
			this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_BLOCK ||
			this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_BLOCK){
			
			this.highlight(this.BlockBtn);
		}
		else if(this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_UNBLOCK || 
			this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_UNBLOCK ||
			this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_UNBLOCK){
				
			this.highlight(this.OkBtn);
		}
        
    }
    else
    {
         this.highlight(currentHighlight);
    }
	
}

SceneBlock.prototype.handleBlur = function () {
	alert("SceneBlock.handleBlur()");

    var currentHighlight =  this.BlockView.getCurrentHighlight();

    if(currentHighlight)
    {
        currentHighlight.blur();
    }
}

SceneBlock.prototype.handleKeyDown = function (keyCode) {
	alert("SceneRemove.handleKeyDown(" + keyCode + ")");
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	
	switch (keyCode) {
		case sf.key.LEFT:
			WndMgr.resetPopupHideTimer();
			this.processLeftKey();
			break;
			
		case sf.key.RIGHT:
			WndMgr.resetPopupHideTimer();
			this.processRightKey();
			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;
	}
}

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

SceneBlock.prototype.create = function(){
    alert("SceneRemove.create()");
	
    this.BlockView = new View("Block");
    this.BlockPopupView = new View("BlockBg");
    this.BlockPopupView.CreatePopupBG(1,"BlockBg");
	this.BlockDim = new DimBg("BlockDim", "Block");  
    this.BodyMsg 	= new Label(null,"BlockMassage");
    this.BodyMsg.SetIsPlainText(true);	

	var This_ = sf.scene.get('Block');

    this.OkBtn = new ButtonBase();
    this.OkBtn.Create("Block_OkButton",BUTTON_BASE_TYPE.BG_TEXT, 20);
    this.OkBtn.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.OkBtn.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
	this.OkBtn.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"Block_Button_Normal_Text_style");
	//this.OkBtn.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cButton_Text_Highlight_Style");		
    this.OkBtn.SetText(SID_YES);
 	this.OkBtn.SetOnClickCallbackFunc(this.ClickOkBtn);    
 

	this.CancelBtn = new ButtonBase();
    this.CancelBtn.Create("Block_CancelButton",BUTTON_BASE_TYPE.BG_TEXT, 20);
    this.CancelBtn.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.CancelBtn.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
	this.CancelBtn.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"Block_Button_Normal_Text_style");
	//this.CancelBtn.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cButton_Text_Highlight_Style");	
    this.CancelBtn.SetText(SID_NO);
    this.CancelBtn.SetOnClickCallbackFunc(this.ClickCancelBtn);

    this.BlockBtn = new ButtonBase();
    this.BlockBtn.Create("Block_BlockButton",BUTTON_BASE_TYPE.BG_TEXT, 20);
    this.BlockBtn.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.BlockBtn.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
	this.BlockBtn.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"Block_Button_Normal_Text_style");
	//this.BlockBtn.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cButton_Text_Highlight_Style");	
    this.BlockBtn.SetText(IDWS_MOIP_SKYPE_BLOCK);
    this.BlockBtn.SetOnClickCallbackFunc(this.ClickBlockBtn);
   
	this.BlockRemoveBtn = new ButtonBase();
    this.BlockRemoveBtn.Create("Block_BlockRemoveButton",BUTTON_BASE_TYPE.BG_TEXT, 20);
    this.BlockRemoveBtn.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.BlockRemoveBtn.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
	this.BlockRemoveBtn.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"Block_Button_Long_Text_style");
	this.BlockRemoveBtn.SetText(TV_SID_BLOCK_N_REMOVE);
 	this.BlockRemoveBtn.SetOnClickCallbackFunc(this.ClickBlockRemoveBtn);
 		
	this.BlockCancelBtn = new ButtonBase();
    this.BlockCancelBtn.Create("Block_BlockCancelButton",BUTTON_BASE_TYPE.BG_TEXT, 20);
    this.BlockCancelBtn.SetBgImage(BUTTON_BASE_STATE.NORMAL, g_Image.IMAGE_POPUP_BTN_NORMAL);
    this.BlockCancelBtn.SetBgImage(BUTTON_BASE_STATE.HIGHLIGHT, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);	
	this.BlockCancelBtn.SetTextStyle(BUTTON_BASE_STATE.NORMAL,"Block_Button_Normal_Text_style");
	//this.BlockCancelBtn.SetTextStyle(BUTTON_BASE_STATE.HIGHLIGHT,"cButton_Text_Highlight_Style");	
    this.BlockCancelBtn.SetText(SID_CANCEL);
 	this.BlockCancelBtn.SetOnClickCallbackFunc(this.ClickCancelBtn);
 	
	this.OkBtn.SetOnMouseOverCallbackFunc(function(obj) {This_.processMouseOver(obj);});
	this.CancelBtn.SetOnMouseOverCallbackFunc(function(obj) {This_.processMouseOver(obj);});
	this.BlockBtn.SetOnMouseOverCallbackFunc(function(obj) {This_.processMouseOver(obj);});
	this.BlockRemoveBtn.SetOnMouseOverCallbackFunc(function(obj) {This_.processMouseOver(obj);});
	this.BlockCancelBtn.SetOnMouseOverCallbackFunc(function(obj) {This_.processMouseOver(obj);});
  	
}

SceneBlock.prototype.highlight=function(obj)
{
	alert("SceneBlock.highlight()");
	
    this.BlockView.setCurrenHighlight(obj);
	
}

SceneBlock.prototype.Init = function(Type_,Identity,Display){
    alert("SceneBlock.Init() ");


	this.Type			= Type_;
	this.TargetDisplay	= Display;
	this.TargetIdentity = Identity;
}


SceneBlock.prototype.ResetPopup = function(){
	alert("SceneBlock.ResetPopup() ");

	var finalName; 

	if(this.TargetDisplay.length > 15){
		
		finalName = this.TargetDisplay.slice(0,14) + '...';
	}
	else{
		finalName = this.TargetDisplay;
	}

	//this.NameLabel.SetText(this.TargetDisplay);

	var BodyText;

	if(this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK || 
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_BLOCK ||
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_BLOCK){

		BodyText = g_Data.CombinateStrings(TV_SID_MIX_ADD_TO_YOUR_BLOCKED_LIST,finalName);

		this.OkBtn.Hide();
		this.CancelBtn.Hide();
		this.BlockBtn.Show();
		this.BlockRemoveBtn.Show();
		this.BlockCancelBtn.Show();		
		
			
	}
	else if(this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_UNBLOCK || 
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_UNBLOCK ||
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_UNBLOCK){
		
		BodyText = g_Data.CombinateStrings(TV_SID_MIX_REMOVE_FROM_YOUR_BLOCKED_LIST,finalName);
		
		this.BlockBtn.Hide();
		this.BlockRemoveBtn.Hide();
		this.BlockCancelBtn.Hide();	
		this.OkBtn.Show();
		this.CancelBtn.Show();
	}
	
	this.BodyMsg.SetText(BodyText);
}


SceneBlock.prototype.processEnterKey = function(){
    alert("SceneBlock.processEnterKey() ");
	
	var currentHighlight =  this.BlockView.getCurrentHighlight();

	if(this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_BLOCK || 
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_BLOCK ||
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_BLOCK){

		if (currentHighlight == this.BlockBtn) {
			
			this.highlight(null);
			ProcMgr.BlockContact(this.TargetIdentity,false,this.Type);			
		}
		else if(currentHighlight == this.BlockRemoveBtn){
			
			this.highlight(null);
			ProcMgr.BlockContact(this.TargetIdentity,true,this.Type);
		}		
		else{
			this.processReturnKey();
		}		
			
	}
	else if(this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CONTACT_UNBLOCK || 
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.HISTORY_UNBLOCK ||
		this.Type == MAIN_LIST_POPUP_FUNCTION_TYPE.CHAT_UNBLOCK){
		
		if (currentHighlight == this.OkBtn) {
			
			this.highlight(null);			
			ProcMgr.UnblockContact(this.TargetIdentity,this.Type);
		}
		else{
			
			this.processReturnKey();
		}		

	}

}
	
	

SceneBlock.prototype.processReturnKey = function(){
    alert("SceneBlock.processReturnKey() ");

	this.highlight(null);
	
	StateMgr.Stop_Block_State(true);	

	/*
	var Scene = sf.scene.get(WndMgr.GetMainSubSceneID());	
		Scene.Activation();*/
	

}

SceneBlock.prototype.processLeftKey = function(){
    alert("SceneRemove.processLEFTKey() ");

    var currentHighlight =  this.BlockView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.OkBtn:
            this.highlight(this.CancelBtn);
            break;
            
        case this.CancelBtn:
            this.highlight(this.OkBtn);
            break;

        case this.BlockBtn:
            this.highlight(this.BlockCancelBtn);
            break;
            
        case this.BlockRemoveBtn:
            this.highlight(this.BlockBtn);
            break;

        case this.BlockCancelBtn:
            this.highlight(this.BlockRemoveBtn);
            break;
								
    }
    
}


SceneBlock.prototype.processRightKey = function(){
    alert("SceneRemove.processLEFTKey() ");

    var currentHighlight =  this.BlockView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.OkBtn:
            this.highlight(this.CancelBtn);
            break;
            
        case this.CancelBtn:
            this.highlight(this.OkBtn);
            break;
			
        case this.BlockBtn:
            this.highlight(this.BlockRemoveBtn);
            break;
            
        case this.BlockRemoveBtn:
            this.highlight(this.BlockCancelBtn);
            break;

        case this.BlockCancelBtn:
            this.highlight(this.BlockBtn);
            break;			
    }    
}

SceneBlock.prototype.GetShowState = function() {
	return this.showState;	
}


SceneBlock.prototype.processMouseOver = function(obj) {
    alert("SceneBlock.processMouseOver() " + obj);

	var currentHighlight = this.BlockView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
}

SceneBlock.prototype.ClickOkBtn = function(){
	alert("SceneBlock.ClickOkBtn");	

	var This_ = sf.scene.get('Block');
	
	This_.highlight(null);			
	ProcMgr.UnblockContact(This_.TargetIdentity,This_.Type);
	
}

SceneBlock.prototype.ClickCancelBtn = function(){
	alert("SceneBlock.ClickCancelBtn");	

	var This_ = sf.scene.get('Block');
	
	This_.processReturnKey();
	
}

SceneBlock.prototype.ClickBlockBtn = function(){
	alert("SceneBlock.ClickBlockBtn");	

	var This_ = sf.scene.get('Block');
	
	This_.highlight(null);
	ProcMgr.BlockContact(This_.TargetIdentity,false,This_.Type);
}


SceneBlock.prototype.ClickBlockRemoveBtn = function(){
	alert("SceneBlock.ClickBlockRemoveBtn");	

	var This_ = sf.scene.get('Block');
	
	This_.highlight(null);
	ProcMgr.BlockContact(This_.TargetIdentity,true,This_.Type);
}


