function SceneminiIncomingCall(options) {
	this.options = options;
    
    this.IncomingCallView = null;

    this.CallMemberThumbnail = null;
    
    this.NameLabel = null;
    this.MassageLabel = null;

    this.CameraOnBtn	= null;
	this.CallStartBtn	= null;
    this.CallEndBtn		= null;
    
	this.call_tooltip = null;
	this.flag_shown_tooltip = false;
	this.TooltipTimer = null;
    
  	this.flag_visible_camera_btn = false;
  	this.flag_hidden_cam_btn = false;
}

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

SceneminiIncomingCall.prototype.handleShow = function () {
	alert("SceneminiIncomingCall.handleShow()");
	
	this.update();
	this.ShowKeyHelpbar();
	if(Flag_Hidden_State==false)
       $("#skype_popup_background").show();
}

SceneminiIncomingCall.prototype.handleHide = function () {
	alert("SceneminiIncomingCall.handleHide()");
	
	this.flag_conference_call = false;
	this.flag_hidden_cam_btn = false;
	if(Flag_Hidden_State==false)
       $("#skype_popup_background").hide();
}

SceneminiIncomingCall.prototype.handleFocus = function () {
	alert("SceneminiIncomingCall.handleFocus()");

	if(this.CameraOnBtn.GetFlagVisible() == true)
	{
		this.highlight(this.CameraOnBtn);
	}
	else
	{
		this.highlight(this.CallStartBtn);
	}
	this.ShowKeyHelpbar();
}

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

    this.highlight(null);
}

SceneminiIncomingCall.prototype.handleKeyDown = function (keyCode) {
	alert("SceneminiIncomingCall.handleKeyDown(" + keyCode + ")");
	
	switch (keyCode) {
		case $.sfKey.LEFT:
            this.processLeftKey();		
			break;		
		case $.sfKey.RIGHT:	
			this.processRightKey();
			break;

		case $.sfKey.ENTER:
            this.processEnterKey();
			break;
         case	ENUM_CALL_BLOCK_KEY_CODE.DUALVIEW:
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.FUNCTION_ISNT_AVAILABLE);
			break;     
        case $.sfKey.RETURN:
            this.processReturnKey();
            $.sfKey.block(event);
			break;

        case $.sfKey.EXIT:
        	ProcMgr.flag_show_exit_popup = true;
            this.processReturnKey();
            $.sfKey.block(event);
			break;

		case 147:  //infolink
		case 261:  //contents
		case 115:  //wiselink
            ProcMgr.processInfolinkKey();
			break;
	}
	if(Flag_Hidden_State==false)
	event.stopPropagation();
}

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

SceneminiIncomingCall.prototype.create = function(){
    alert("SceneminiIncomingCall.create()");
    
    this.IncomingCallView = new View("IncomingCall");
    //this.IncomingCallView.SetBgImage();

	this.CallMemberThumbnail = new CompBase(); 
	this.CallMemberThumbnail.CreateBG("incoming_call_thumbnail");
	this.CallMemberThumbnail.AddJPGImageLayer("incoming_call_thumbnail_avatar");

    this.NameLabel= new Label(null, "incoming_call_name");
    this.NameLabel.SetIsPlainText(true);
    
    this.MassageLabel= new Label(null, "incoming_call_message");

    var this_ = $.sfScene.get({id:"miniIncomingCall",scope:WIDGET.id});
    var clickCF =  function(obj){this_.processClickEvent(obj);};
    
    this.CameraOnBtn = new Button();
    this.CameraOnBtn.SetImageObjId("incoming_call_camera_on_btn");
    this.CameraOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_VIDEO_CALL_CAMERA_BTN_NORMAL);
    this.CameraOnBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_VIDEO_CALL_CAMERA_BTN_NORMALFOCUS);
    this.CameraOnBtn.SetOnClickCallbackFunc(clickCF);
    this.CameraOnBtn.setTextKPILog(IDWS_MOIP_VIDEO_CALL_KR_VOICE);
    this.CameraOnBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.highlight(obj);
    });

    this.CallStartBtn = new Button();
    this.CallStartBtn.SetImageObjId("incoming_call_start_btn");
    this.CallStartBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_START_BTN_NORMAL);
    this.CallStartBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_START_BTN_NORMALFOCUS);
    this.CallStartBtn.SetOnClickCallbackFunc(clickCF);
    this.CallStartBtn.setTextKPILog(IDWS_MOIP_VOICE_CALL_KR_VOICE);
    this.CallStartBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.highlight(obj);
    });

	this.CallEndBtn = new Button();
    this.CallEndBtn.SetImageObjId("incoming_call_end_btn");
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CALL_END_BTN_NORMAL);
    this.CallEndBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CALL_END_BTN_NORMALFOCUS);
    this.CallEndBtn.SetOnClickCallbackFunc(clickCF);
    this.CallEndBtn.setTextKPILog(TV_SID_DECLINE);
	this.CallEndBtn.SetOnMouseOverCallbackFunc(function(obj){
        this_.highlight(obj);
    });

	this.creatTooltip();    
}

SceneminiIncomingCall.prototype.highlight=function(obj)
{
    this.IncomingCallView.setCurrenHighlight(obj);

    if(obj)
    {
    	this.showTooltip(obj);
    }
}
SceneminiIncomingCall.prototype.ShowKeyHelpbar = function(){
	if(WIDGET.mouse==true){
		helpBarHandler.hideHelpIcon('red',"");
		helpBarHandler.hideHelpIcon('green',"");
		helpBarHandler.hideHelpIcon('yellow',"");
		helpBarHandler.hideHelpIcon('blue',TV_SID_CHANGE_VIEW);
		helpBarHandler.hideHelpIcon('tools',sfLang.SID_TOOLS);
		helpBarHandler.showHelpIcon('return',SID_RETURN);
		helpBarHandler.setHelpIconClickEvent('help_return',function(){
                $.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).processExitKey();
        });
	}else{
		$("#HomeHelp").sfKeyHelp({
			'return' : SID_RETURN
		});
	}	
}
SceneminiIncomingCall.prototype.update = function()
{	
	alert('SceneminiIncomingCall.update');
	//check if conference call or not !!!
	var callee_display = PluginAPIMgr.GetCallMemberDisplayName();
	var callee_name = PluginAPIMgr.GetCallMemberID();

	this.CallMemberThumbnail.SetImageLayer(1,PluginAPIMgr.GetContactAvataImage(callee_name));
			
	this.NameLabel.SetText(callee_display);
	
	if(PluginAPIMgr.IsConference() == 1)
	{
		this.flag_conference_call = true;
		this.MassageLabel.SetText(TV_INIVITED_JOIN_CONFERENCE_CALL);
	}
	else
	{
		this.flag_conference_call = false;
		this.MassageLabel.SetText(TV_CALLING_PROGRESS);
	}
	
	this.SetBtn();

}

SceneminiIncomingCall.prototype.processLeftKey=function()
{
    alert("SceneminiIncomingCall.processLeftKey() ");
    
    var currentHighlight =  this.IncomingCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
		case this.CallEndBtn:
			this.highlight(this.CallStartBtn);
			break;
			
		case this.CallStartBtn:
			if(this.CameraOnBtn.GetFlagVisible() == true)
			{
				this.highlight(this.CameraOnBtn);
			}			
			break;
	}
}

SceneminiIncomingCall.prototype.processRightKey=function()
{

    alert("SceneminiIncomingCall.processLeftKey() ");
    
    var currentHighlight =  this.IncomingCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
		case this.CameraOnBtn:	
			this.highlight(this.CallStartBtn);
			break;
			
		case this.CallStartBtn:        
			this.highlight(this.CallEndBtn);
			break;
	}

}

SceneminiIncomingCall.prototype.processEnterKey=function()
{
    alert("SceneminiIncomingCall.processEnterKey() ");
    
    var currentHighlight =  this.IncomingCallView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
		case this.CameraOnBtn:
			PluginAPIMgr.StopPreview();
			PluginAPIMgr.AnswerWithVideo();
			break;
			
		case this.CallStartBtn:
			PluginAPIMgr.StopPreview();
			PluginAPIMgr.AnswerWithVoice();
			break;
			
		case this.CallEndBtn:
			if(PluginAPIMgr.IsConference() == 1)
			{
				ProcMgr.DeclineIncomingConferenceCall();
			}
			else
			{
				ProcMgr.DeclineIncomingCall();
			}
			break;
	}
}

SceneminiIncomingCall.prototype.processReturnKey=function()
{
    alert("SceneminiIncomingCall.processReturnKey() ");
    	
	if(PluginAPIMgr.IsConference() == 1)
	{
		ProcMgr.DeclineIncomingConferenceCall();
	}
	else
	{
		ProcMgr.DeclineIncomingCall();
	}
}

SceneminiIncomingCall.prototype.SetBtn = function(){
	alert("SceneminiIncomingCall.SetBtn() ");
	
	this.flag_visible_camera_btn = true;
	
	if(this.flag_conference_call == 1)
	{
		this.flag_visible_camera_btn = false;
	}
	else
	{
		var camera_state = PluginAPIMgr.GetCameraState();
		if(camera_state == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || camera_state == ENUM_CAM_STATE.CAM_STATE_CONNECTING)
		{
			this.flag_visible_camera_btn = false;
		}
	}

	if(this.flag_visible_camera_btn == false)
	{
		alert(" camera btn hidden ");
		
		this.CameraOnBtn.hiddenObj();
		
		$('#incoming_call_start_btn').css('left','85px');
		$('#incoming_call_end_btn').css('left','156px');

		//this.CallStartBtn.setTextKPILog(TV_VCMD_ANSWER);
	    //this.CallEndBtn.setTextKPILog(TV_SID_DECLINE);		
		
	}
	else{
		alert(" camera btn visible ");
		
		if(TVCOMM_SERVICE_MODE == TVCHAT_MODE_HIDDEN)
		{
			this.flag_hidden_cam_btn = true;
			this.CameraOnBtn.hiddenObj();
		}
		else
		{	
			this.CameraOnBtn.visibleObj();
		}
		
		$('#incoming_call_camera_on_btn').css('left','55px');
		$('#incoming_call_start_btn').css('left','128px');
		$('#incoming_call_end_btn').css('left','201px');
		
		//this.CameraOnBtn.setTextKPILog(IDWS_MOIP_VIDEO_CALL_KR_VOICE);
		//this.CallStartBtn.setTextKPILog(IDWS_MOIP_VOICE_CALL_KR_VOICE);
	    //this.CallEndBtn.setTextKPILog(TV_SID_DECLINE);
	}

}

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

}
SceneminiIncomingCall.prototype.creatTooltip = function()
{	
	this.call_tooltip = new CompBase(); 
	this.call_tooltip.CreateBG("incoming_call_tooltip_bg");
	this.call_tooltip.AddImageLayer("incoming_call_tooltip_left_corner");
	this.call_tooltip.AddImageLayer("incoming_call_tooltip_left_px");
	this.call_tooltip.AddImageLayer("incoming_call_tooltip_center");
	this.call_tooltip.AddImageLayer("incoming_call_tooltip_right_px");
	this.call_tooltip.AddImageLayer("incoming_call_tooltip_right_corner");
	this.call_tooltip.AddTextLayer("incoming_call_tooltip_text");
	
	this.call_tooltip.SetImageLayer(1,g_Image.IMAGE_TOOLTIP_LEFT);
	this.call_tooltip.SetImageLayer(2,g_Image.IMAGE_TOOLTIP_PX);
	this.call_tooltip.SetImageLayer(3,g_Image.IMAGE_TOOLTIP_CENTER);
	this.call_tooltip.SetImageLayer(4,g_Image.IMAGE_TOOLTIP_PX);
	this.call_tooltip.SetImageLayer(5,g_Image.IMAGE_TOOLTIP_RIGHT);	
	
	this.flag_shown_tooltip = false;
}

SceneminiIncomingCall.prototype.showTooltip = function(cur_button)
{
	alert('SceneminiConferenceCall.showTooltip');	
	var center_pos;
	var text_width_st;
	var tooltip_text;
	//check left position
	if(this.flag_visible_camera_btn == true)
	{
		if(cur_button == this.CameraOnBtn)
		{
			tooltip_text = IDWS_MOIP_VIDEO_CALL_KR_VOICE;	
			center_pos = 90;
		}
		else if(cur_button == this.CallStartBtn)
		{
			tooltip_text = IDWS_MOIP_VOICE_CALL_KR_VOICE;
			center_pos = 163;
		}
		else if(cur_button == this.CallEndBtn)
		{
			tooltip_text = TV_SID_DECLINE;		
			center_pos = 236;
		}
	}
	//Btn_total_num == 2
	else 
	{
		if(cur_button == this.CallStartBtn)
		{
			if(this.flag_conference_call == true)
			{
				tooltip_text = TV_VCMD_ANSWER;
			}
			else
			{
				tooltip_text = IDWS_MOIP_VOICE_CALL_KR_VOICE;
			}
			center_pos = 120;
		}
		else if(cur_button == this.CallEndBtn)
		{
			tooltip_text = TV_SID_DECLINE;
			center_pos = 191;
		}
	}
	
	$('#incoming_call_tooltip_text_checker').html(tooltip_text);
	var text_width = parseInt($("#incoming_call_tooltip_text_checker").css('width').replace(/[^-\d\.]/g, ''));
	alert('text_width='+text_width);
		
	var text_width_half = parseInt(text_width/2);
			
	//setting bg position
	var bg_width = (40+text_width) +'px';
	var bg_left = (center_pos-text_width_half-20) + 'px';
	$('#incoming_call_tooltip_bg').css('left',bg_left);	
	$('#incoming_call_tooltip_bg').css('width',bg_width);
	
	
	//setting left px position
	var left_px_width_pos = (text_width_half-10)+'px';
	$('#incoming_call_tooltip_left_px').css('width',left_px_width_pos);
	
	//setting center position
	var center_left_pos = (text_width_half+10)+'px';	
	$('#incoming_call_tooltip_center').css('left',center_left_pos);
	
	//setting right px position
	var right_px_left_pos = (text_width_half+30)+'px';
	$('#incoming_call_tooltip_right_px').css('left',right_px_left_pos);
	$('#incoming_call_tooltip_right_px').css('width',left_px_width_pos);
		
	//setting right corner position	
	var right_corner_left_pos = (text_width+20)+'px';
	if(text_width%2 > 0)
	{
		right_corner_left_pos = (text_width+19)+'px';
	}
	
	$('#incoming_call_tooltip_right_corner').css('left',right_corner_left_pos);
	
	//setting right corner position
	var text_width_pos = text_width+'px';
	$('#incoming_call_tooltip_text').css('width',text_width_pos);
	
	if(this.flag_shown_tooltip == false)
	{
		this.call_tooltip.Show();
		this.flag_shown_tooltip = true;
	}

	this.call_tooltip.SetTextLayer(6,tooltip_text);

	//start & reset tooltip timer
	this.StartTimerTooltip();
}

SceneminiIncomingCall.prototype.StartTimerTooltip = function()
{
	if(this.TooltipTimer)
	{
		clearTimeout(this.TooltipTimer);
	}
    
	this.TooltipTimer = setTimeout("incomingHideToolTipCB()", 6000);
	
	incomingHideToolTipCB = function(){
		var this_ = $.sfScene.get({id:'miniIncomingCall',scope:WIDGET.id});
		this_.call_tooltip.Hide();
		this_.flag_shown_tooltip = false;
    }	
}

SceneminiIncomingCall.prototype.RecoveryCamBtn = function()
{
	if(this.flag_hidden_cam_btn == true)
	{
		this.flag_hidden_cam_btn.visibleObj();
	}
}
