function SceneLiveContactSwitch(options) {

	this.options	= options;
	
    this.LiveContactSwitchView	= null;	 
	this.LiveContactSwitchDim 	= null;  
    this.Title 					= null;
	this.list					= null;
	this.GIFLayer				= null;
		
	//flags
	this.IsCreatedObj	= false;
	this.IsShownObj		= false;
	this.SetFocus		= false;
	
	//timer
    this.CloseTimer = false;
}

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

SceneLiveContactSwitch.prototype.handleShow = function () {
	alert("SceneLiveContactSwitch.handleShow()");

	this.LiveContactSwitchDim.show();
	this.ShowLoading();
	
	setTimeout("ShowObj()", 300);	

	ShowObj = function(){
	
		This_ = sf.scene.get("LiveContactSwitch");
	
		if(This_.IsCreatedObj == false){					
			This_.createObj();
		}						

		This_.list.Initialize();        
		This_.list.Show();
			
		This_.HideLoading();
		This_.IsShownObj = true;
		
		//check focus
		if(This_.SetFocus){

			This_.list.highlight();			
		}
		
	}	
	
	this.startTimer();
}

SceneLiveContactSwitch.prototype.handleHide = function () {
	alert("SceneLiveContactSwitch.handleHide()");
	
	this.LiveContactSwitchDim.hide();

	this.list.Hide();
	
	this.IsShownObj	= false;

    if (this.CloseTimer == true)
    {
        this.stopTimer();
    }

}

SceneLiveContactSwitch.prototype.handleFocus = function () {
	alert("SceneLiveContactSwitch.handleFocus()");
    
	//set focus when popup was shown...
	if(this.IsShownObj){

		this.list.highlight();
	}
		
	this.SetFocus = true;
}

SceneLiveContactSwitch.prototype.handleBlur = function () {
	alert("SceneLiveContactSwitch.handleBlur()");
	
	this.list.blur();

	this.SetFocus = false;
}

SceneLiveContactSwitch.prototype.handleKeyDown = function (keyCode) {	
	alert("SceneLiveContactSwitch.handleKeyDown(" + keyCode + ")");	
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	if(keyCode ==  sf.key.LEFT || keyCode ==  sf.key.RIGHT || keyCode ==  sf.key.UP || keyCode ==  sf.key.DOWN)
	{
		this.resetTimer();
	}
	
	this.list.KeyProcess(keyCode);
}

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

SceneLiveContactSwitch.prototype.create = function(){
    alert("SceneLiveContactSwitch.create() ");

    this.LiveContactSwitchView = new View("LiveContactSwitch");
    this.LiveContactSwitchView.SetBgImage(WndMgr.Bg_LiveContactList.src);
    
	this.LiveContactSwitchDim = new DimBg("LiveContactSwitchDim", "LiveContactSwitch"); 
	
	this.GIFLayer = new JPGImageLayer("Loading_gif");
	this.GIFLayer.SetImage(WndMgr.Bg_LoadingGIF.src);
	    
}


SceneLiveContactSwitch.prototype.createObj = function(){

	alert("SceneLiveContactSwitch.createObj() ");
	
	this.list = new pContactList();
	this.list.Create();

    this.Title = new Label(null,"LiveContactSwitch_title");    
    this.Title.SetText(TV_SID_CONTACK_LIST);
 
    this.HelpBar = new HelpBar(HelpBarIndex.LIVE_CALL_CONTACT, "LiveContactSwitch");
    
    
	var this_ = sf.scene.get('LiveContactSwitch');
    this.HelpBar.SetOnClickCallbackFunc(1, function(){this_.processReturnKey();});
        
    this.LiveContactSwitchView.registHelpBar( this.HelpBar);
    	
	this.IsCreatedObj	= true;
		
}

SceneLiveContactSwitch.prototype.ProgressCallDuration = function(strTime){

	if(this.IsShownObj){
		this.list.ProgressCallDuration(strTime);
	}	
}

SceneLiveContactSwitch.prototype.ShowLoading = function(){
	
	$("#"+ this.GIFLayer.Obj).css('display', 'block');
}

SceneLiveContactSwitch.prototype.HideLoading = function(){
	
	$("#"+ this.GIFLayer.Obj).css('display', 'none');
}

SceneLiveContactSwitch.prototype.Activation = function(){	
}

SceneLiveContactSwitch.prototype.Deactivation = function(){
}

SceneLiveContactSwitch.prototype.processReturnKey = function(){
	
	this.list.ProcessReturnKey();
}


SceneLiveContactSwitch.prototype.startTimer = function()
{
    alert("SceneLiveContactSwitch.startTimer() ");
	
	this.CloseTimer = true;
	PluginAPIMgr.StartOSDTimer("60000" , function() { sf.scene.get('LiveContactSwitch').popupTimerCallback();}, ENUM_TIMER_TYPE.POPUP_WND);
}

SceneLiveContactSwitch.prototype.resetTimer = function()
{
    alert("SceneLiveContactSwitch.resetTimer() ");

	if(this.CloseTimer == true)
	{
		PluginAPIMgr.RestartOSDTimer("60000" ,ENUM_TIMER_TYPE.POPUP_WND);
	}
}

SceneLiveContactSwitch.prototype.stopTimer = function()
{
    alert("SceneLiveContactSwitch.stopTimer() ");
	
	this.CloseTimer = false;
	PluginAPIMgr.StopOSDTimer(ENUM_TIMER_TYPE.POPUP_WND);
}

SceneLiveContactSwitch.prototype.popupTimerCallback = function()
{
	alert("SceneLiveContactSwitch.popupTimerCallback() ");
   if(this.CloseTimer==false)
   {
   	return;
   }
   this.CloseTimer = false;
   
   this.processReturnKey();
}

