function SceneSkypeOutCallWithDial(options) {
	this.options = options;
    
    this.SkypeOutCallWithDialView =null;
    
    this.CallDurationTextLabel =null;
    this.CallDurationTimeLabel =null;

    this.YourNameLabel=null;
    this.MyNameLabel=null;
    
    this.YourPhoneNumberLabel=null;
    this.MyCreditLabel=null;

    this.YourThumbnailLabel=null;
    this.MyThumbnailLabel=null;
    
    this.Number1Btn=null;
    this.Number2Btn=null;
    this.Number3Btn=null;
    this.Number4Btn=null;
    this.Number5Btn=null;
    this.Number6Btn=null;
    this.Number7Btn=null;
    this.Number8Btn=null;
    this.Number9Btn=null;
    this.Number0Btn=null;
    this.StarBtn=null;
    this.SharpBtn=null;
    
    this.NumBtnList = new Array(12);
    this.SelectTimer = null;
    
    this.HoldIconLabel = null;

    this.HelpBar=null;
}

SceneSkypeOutCallWithDial.prototype.initialize = function () {
	alert("SceneSkypeOutCallWithDial.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();
}

SceneSkypeOutCallWithDial.prototype.handleShow = function () {
	alert("SceneSkypeOutCallWithDial.handleShow()");
	// this function will be called when the scene manager show this scene 
    this.update();
   
}

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

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

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

SceneSkypeOutCallWithDial.prototype.handleKeyDown = function (keyCode) {
	alert("SceneSkypeOutCallWithDial.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:
            this.processLeftKey();
			break;
		case sf.key.RIGHT:
           this.processRightKey();
			break;
		case sf.key.UP:
            this.processUpKey();
			break;
		case sf.key.DOWN:
            this.processDownKey();
			break;

		case sf.key.ENTER:
            this.processEnterKey();
			break;
			
		case sf.key.YELLOW:
		case sf.key.GREEN:
		case sf.key.RED:
		case sf.key.BLUE:

            break;
            
        case sf.key.VOL_DOWN:
        case sf.key.PANEL_VOL_DOWN:
		case sf.key.VOL_UP:
        case sf.key.PANEL_VOL_UP:
             this.processVolumeKey();
			break;
       
        case sf.key.N1:
        case sf.key.N2:
        case sf.key.N3:
        case sf.key.N4:
        case sf.key.N5:
        case sf.key.N6:
        case sf.key.N7:
        case sf.key.N8:
        case sf.key.N9:
        case 35:
		case 650: 
        case sf.key.N0:
        case 259:
            ProcMgr.SendDTMF(keyCode);
            break;  
            
        case sf.key.RETURN:
           this.processReturnKey();
            sf.key.block(event);
            break;
            
         case sf.key.EXIT:
            this.processExitKey();
            sf.key.block(event);
			break;
            
        case 147:  //infolink
        case 261:  //contents
        case 115:  //wiselink
            ProcMgr.processInfolinkKey();
			break;
            
        default:
            ProcMgr.processBlockKey(keyCode);
            break;  
        
	}
}

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

SceneSkypeOutCallWithDial.prototype.create = function(){
    alert("SceneSkypeOutCallWithDial.create() ");
    this.SkypeOutCallWithDialView = new View("SkypeOutCallWithDial");
    this.SkypeOutCallWithDialView.SetBgImage(g_Image.IMAGE_VOICE_CALL_BG);
    
    this.CallDurationTextLabel = new Label(null,"skype_out_call_with_dial_duration_text");
    this.CallDurationTextLabel.SetTextStyle("skype_out_call_with_dial_duration_text_style");
    this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION);

    this.CallDurationTimeLabel = new Label(null,"skype_out_call_with_dial_duration_time");
    this.CallDurationTimeLabel.SetTextStyle("skype_out_call_with_dial_duration_time_style");
    this.CallDurationTimeLabel.SetText("00:00:00");

    this.YourNameLabel = new Label(null,"skype_out_call_with_dial_your_name");
    this.YourNameLabel.SetTextStyle("skype_out_call_with_dial_member_name_style");

    this.MyNameLabel = new Label(null,"skype_out_call_with_dial_my_name");
    this.MyNameLabel.SetTextStyle("skype_out_call_with_dial_member_name_style");
   
    this.YourPhoneNumberLabel = new Label(null,"skype_out_call_with_dial_your_phone_number");
    this.YourPhoneNumberLabel.SetTextStyle("skype_out_call_with_dial_member_name_style");

    this.MyCreditLabel = new Label(null,"skype_out_call_with_dial_my_credit");
    this.MyCreditLabel.SetTextStyle("skype_out_call_with_dial_member_name_style");

    this.YourThumbnailLabel= new Label("skype_out_call_with_dial_your_thumbnail", null);
    this.YourThumbnailLabel.SetBgImage(g_Image.IMAGE_VOICE_CALL_THUMBNAIL);
    this.YourThumbnailLabel.AppendFgImage("skype_out_call_with_dial_your_thumbnail_avata","3px","3px","143px","140px");
    this.YourThumbnailLabel.SetFgImage(g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_PSTN);

    this.MyThumbnailLabel= new Label("skype_out_call_with_dial_my_thumbnail", null);
    this.MyThumbnailLabel.SetBgImage(g_Image.IMAGE_VOICE_CALL_THUMBNAIL);
    this.MyThumbnailLabel.AppendFgImage("skype_out_call_with_dial_my_thumbnail_avata","3px","3px","143px","140px");
    this.MyThumbnailLabel.SetFgImage(g_Image.IMAGE_LIST_MAIN_VIEW_DEFAULT_AVATA);
    
/////Dial pad /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    
    this.Number1Btn = new Button();
    this.Number1Btn.SetImageObjId("skype_out_call_with_dial_number_1_btn");
    this.Number1Btn.SetTextObjId("skype_out_call_with_dial_number_1_btn_text");
    this.Number1Btn.SetText("1");

    this.Number2Btn = new Button();
    this.Number2Btn.SetImageObjId("skype_out_call_with_dial_number_2_btn");
    this.Number2Btn.SetTextObjId("skype_out_call_with_dial_number_2_btn_text");
    this.Number2Btn.SetText("2");

    this.Number3Btn = new Button();
    this.Number3Btn.SetImageObjId("skype_out_call_with_dial_number_3_btn");
    this.Number3Btn.SetTextObjId("skype_out_call_with_dial_number_3_btn_text");
    this.Number3Btn.SetText("3");

    this.Number4Btn = new Button();
    this.Number4Btn.SetImageObjId("skype_out_call_with_dial_number_4_btn");
    this.Number4Btn.SetTextObjId("skype_out_call_with_dial_number_4_btn_text");
    this.Number4Btn.SetText("4");

    this.Number5Btn = new Button();
    this.Number5Btn.SetImageObjId("skype_out_call_with_dial_number_5_btn");
    this.Number5Btn.SetTextObjId("skype_out_call_with_dial_number_5_btn_text");
    this.Number5Btn.SetText("5");

    this.Number6Btn = new Button();
    this.Number6Btn.SetImageObjId("skype_out_call_with_dial_number_6_btn");
    this.Number6Btn.SetTextObjId("skype_out_call_with_dial_number_6_btn_text");
    this.Number6Btn.SetText("6");

    this.Number7Btn = new Button();
    this.Number7Btn.SetImageObjId("skype_out_call_with_dial_number_7_btn");
    this.Number7Btn.SetTextObjId("skype_out_call_with_dial_number_7_btn_text");
    this.Number7Btn.SetText("7");

    this.Number8Btn = new Button();
    this.Number8Btn.SetImageObjId("skype_out_call_with_dial_number_8_btn");
    this.Number8Btn.SetTextObjId("skype_out_call_with_dial_number_8_btn_text");
    this.Number8Btn.SetText("8");

    this.Number9Btn = new Button();
    this.Number9Btn.SetImageObjId("skype_out_call_with_dial_number_9_btn");
    this.Number9Btn.SetTextObjId("skype_out_call_with_dial_number_9_btn_text");
    this.Number9Btn.SetText("9");

    this.StarBtn = new Button();
    this.StarBtn.SetImageObjId("skype_out_call_with_dial_star_btn");	
    this.StarBtn.SetTextObjId("skype_out_call_with_dial_star_btn_text");
    this.StarBtn.SetText("*");

    this.Number0Btn = new Button();
    this.Number0Btn.SetImageObjId("skype_out_call_with_dial_number_0_btn");
    this.Number0Btn.SetTextObjId("skype_out_call_with_dial_number_0_btn_text");
    this.Number0Btn.SetText("0");

    this.SharpBtn = new Button();
    this.SharpBtn.SetImageObjId("skype_out_call_with_dial_sharp_btn");
    this.SharpBtn.SetTextObjId("skype_out_call_with_dial_sharp_btn_text");
    this.SharpBtn.SetText("#");
    
    var this_ = sf.scene.get("SkypeOutCallWithDial");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
    
    var a=0;
     for(a=0; a<this.NumBtnList.length; a++)
     {
         this.NumBtnList[a]=new Object();
     }
     
     this.NumBtnList[0].obj =  this.Number1Btn;
     this.NumBtnList[1].obj =  this.Number2Btn;
     this.NumBtnList[2].obj =  this.Number3Btn;
     this.NumBtnList[3].obj =  this.Number4Btn;
     this.NumBtnList[4].obj =  this.Number5Btn;
     this.NumBtnList[5].obj =  this.Number6Btn;
     this.NumBtnList[6].obj =  this.Number7Btn;
     this.NumBtnList[7].obj =  this.Number8Btn;
     this.NumBtnList[8].obj =  this.Number9Btn;
     this.NumBtnList[9].obj =  this.StarBtn;
     this.NumBtnList[10].obj =  this.Number0Btn;
     this.NumBtnList[11].obj =  this.SharpBtn;
    
     for(a=0; a<this.NumBtnList.length; a++)
     {
         this.NumBtnList[a].obj.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_LIST_MAIN_CALL_NUMBER_KEY_BTN_NORMAL);
         this.NumBtnList[a].obj.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_MAIN_CALL_NUMBER_KEY_BTN_NORMALFOCUS);
         this.NumBtnList[a].obj.SetBgImage(BtnImgIndex.BTN_SELECTED_IMG, g_Image.IMAGE_LIST_MAIN_CALL_NUMBER_KEY_BTN_SELECTED);
         this.NumBtnList[a].obj.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"skype_out_call_with_dial_number_btn_text_style");
		 this.NumBtnList[a].obj.SetOnClickCallbackFunc(clickCF);
     }
	 
     this.NumBtnList[0].DTMFKey =  sf.key.N1;
     this.NumBtnList[1].DTMFKey =  sf.key.N2;
     this.NumBtnList[2].DTMFKey =  sf.key.N3;
     this.NumBtnList[3].DTMFKey =  sf.key.N4;
     this.NumBtnList[4].DTMFKey =  sf.key.N5;
     this.NumBtnList[5].DTMFKey =  sf.key.N6;
     this.NumBtnList[6].DTMFKey =  sf.key.N7;
     this.NumBtnList[7].DTMFKey =  sf.key.N8;
     this.NumBtnList[8].DTMFKey =  sf.key.N9;
	 if(ProcMgr.isTTXMIX == false)
	 {
	 	this.NumBtnList[9].DTMFKey =  35;
	 }
     else
	 {
	 	this.NumBtnList[9].DTMFKey =  650;
	 }
	 
     this.NumBtnList[10].DTMFKey =  sf.key.N0;
     this.NumBtnList[11].DTMFKey =  259;
     
    this.HoldIconLabel= new Label("skype_out_call_with_dial_hold_icon", null);
    this.HoldIconLabel.SetBgImage(g_Image.IMAGE_VIDEO_CALL_HOLD_ICON);
    
    this.HelpBar = new HelpBar(HelpBarIndex.SKYPE_OUT_CALL_DIAL, "SkypeOutCallWithDial");
    this.HelpBar.SetOnClickCallbackFunc(2, function(){this_.processReturnKey();});
    
   	this.SkypeOutCallWithDialView.registHelpBar( this.HelpBar);
}

SceneSkypeOutCallWithDial.prototype.update = function()
{
    var call_member_display_name =  PluginAPIMgr.GetCallMemberDisplayName();
    var call_member_id = PluginAPIMgr.GetCallMemberID() ;
    if(call_member_display_name == call_member_id)
    {
        this.YourNameLabel.SetText("");
        
    }
    else
    {
        this.YourNameLabel.SetText(call_member_display_name);
    }
    
    this.YourPhoneNumberLabel.SetText(call_member_id);
    this.YourThumbnailLabel.SetFgImage(g_Image.IMAGE_VOICE_CALL_DEFAULT_AVATA_PSTN);
    
    this.MyNameLabel.SetText(PluginAPIMgr.GetMyDisplayName() );
    this.MyCreditLabel.SetText(PluginAPIMgr.GetMyCredit());
    this.MyThumbnailLabel.SetFgImage(PluginAPIMgr.GetMyAvataImageForCall());
    
      if(g_Data.GetCallLocalHold() == true)
     {
        this.LocalHold();
     }
     else if(g_Data.GetCallRemoteHold() == true)
     {
        this.RemoteHold();
     }
     else
     {
        this.Resume();
     }
     
     this.updateCallDuration(g_Data.GetCallDuration());
}

 SceneSkypeOutCallWithDial.prototype.updateCallDuration = function(time)
{
     this.CallDurationTimeLabel.SetText(time);
}

 SceneSkypeOutCallWithDial.prototype.updateCredit = function()
{
     this.MyCreditLabel.SetText(PluginAPIMgr.GetMyCredit());
}

SceneSkypeOutCallWithDial.prototype.toggleMicVolumeBtnEnable=function()
{
    alert("SceneSkypeOutCallWithDial.toggleMicVolumeBtnEnable() ");
    
    var camera_state = PluginAPIMgr.GetCameraState();
    
    if(camera_state == ENUM_CAM_STATE.CAM_STATE_DISCONNECTED || camera_state == ENUM_CAM_STATE.CAM_STATE_CONNECTING)
    {
        alert("SceneSkypeOutCallWithDial.toggleMicVolumeBtnEnable() Dim : true ->  camera_state : "+ camera_state );
    }
    else
    {
        alert("SceneSkypeOutCallWithDial.toggleMicVolumeBtnEnable() Dim :  false ");
        if(PluginAPIMgr.IsInCall()==1)
		{
			PluginAPIMgr.StartRecord();
		} 
    }    
}


SceneSkypeOutCallWithDial.prototype.highlight=function(obj)
{
    this.SkypeOutCallWithDialView.setCurrenHighlight(obj);
}

SceneSkypeOutCallWithDial.prototype.processDownKey = function(){
    alert("SceneSkypeOutCallWithDial.processDownKey() ");
    var currentHighlight =  this.SkypeOutCallWithDialView.getCurrentHighlight();
    
    var a=0;
    for(a=0; a<this.NumBtnList.length; a++)
     {
         if(this.NumBtnList[a].obj==currentHighlight)
         {
            if(a+3 >= this.NumBtnList.length)
            {
                this.highlight(this.NumBtnList[a%3].obj);
            }
            else
            {   
                this.highlight(this.NumBtnList[a+3].obj);
            }
         }
     }
}

SceneSkypeOutCallWithDial.prototype.processUpKey = function(){
    alert("SceneSkypeOutCallWithDial.processUpKey() ");
    
    var currentHighlight =  this.SkypeOutCallWithDialView.getCurrentHighlight();
    
    var a=0;
    for(a=0; a<this.NumBtnList.length; a++)
     {
         if(this.NumBtnList[a].obj==currentHighlight)
         {
            if(a-3 < 0)
            {
               this.highlight(this.NumBtnList[(this.NumBtnList.length) - (3-a)].obj);
            }
            else
            {   
                this.highlight(this.NumBtnList[a-3].obj);
            }
         }
     }
}

SceneSkypeOutCallWithDial.prototype.processLeftKey = function(){
    alert("SceneSkypeOutCallWithDial.processLeftKey() ");
    
    var currentHighlight =  this.SkypeOutCallWithDialView.getCurrentHighlight();
    
    var a=0;
    for(a=0; a<this.NumBtnList.length; a++)
     {
         if(this.NumBtnList[a].obj==currentHighlight)
         {
            if(a%3 ==0)
            {
                this.highlight(this.NumBtnList[a+2].obj);
            }
            else
            {   
                this.highlight(this.NumBtnList[a-1].obj);
            }
         }
     }
    
}

SceneSkypeOutCallWithDial.prototype.processRightKey = function(){
    alert("SceneSkypeOutCallWithDial.processRightKey() ");
    
    var currentHighlight =  this.SkypeOutCallWithDialView.getCurrentHighlight();

    var a=0;
    for(a=0; a<this.NumBtnList.length; a++)
     {
         if(this.NumBtnList[a].obj==currentHighlight)
         {
            if(a%3 ==2)
            {
                this.highlight(this.NumBtnList[a-2].obj);
            }
            else
            {   
                this.highlight(this.NumBtnList[a+1].obj);
            }
         }
     }
}

SceneSkypeOutCallWithDial.prototype.processEnterKey = function(){
    alert("SceneSkypeOutCallWithDial.processEnterKey() ");
    var currentHighlight =  this.SkypeOutCallWithDialView.getCurrentHighlight();
    
    var a=0;
    for(a=0; a<this.NumBtnList.length; a++)
     {
      
         if(this.NumBtnList[a].obj==currentHighlight)
         {
            this.NumBtnList[a].obj.select();
            if(this.SelectTimer)
            {
                this.SelectTimer =null;
            }

             ProcMgr.SendDTMF(this.NumBtnList[a].DTMFKey);
             this.SelectTimer=setTimeout("timerCF()", 300);
         }
     }
     
     timerCF = function() { sf.scene.get("SkypeOutCallWithDial").selectTimerCallback();}
     
}

SceneSkypeOutCallWithDial.prototype.processReturnKey = function(){
    alert("SceneSkypeOutCallWithDial.processReturnKey() ");
   WndMgr.ToggleSkypeOutCallMode();
}


SceneSkypeOutCallWithDial.prototype.processExitKey = function(){
    alert("SceneSkypeOutCall.processExitKey() ");

   StateMgr.Start_Exit_State(false);
}

SceneSkypeOutCallWithDial.prototype.processVolumeKey=function()
{
    alert("SceneSkypeOutCallWithDial.processVolumeKey() ");
    StateMgr.Start_Volume_Speaker_State();
}

SceneSkypeOutCallWithDial.prototype.selectTimerCallback= function()
{
     alert("SceneSkypeOutCallWithDial.selectTimerCallback() ");
      var currentHighlight =  this.SkypeOutCallWithDialView.getCurrentHighlight();
     
     for(a=0; a<this.NumBtnList.length; a++)
     {     
         if(this.NumBtnList[a].obj==currentHighlight)
         {
            this.NumBtnList[a].obj.highlight();
         }
         else
         {
            this.NumBtnList[a].obj.blur();
         }
     }    
}

SceneSkypeOutCallWithDial.prototype.LocalHold=function()
{
    alert("SceneSkypeOutCallWithDial.LocalHold() ");   
    this.HoldIconLabel.visibleObj();
    this.CallDurationTextLabel.SetText(IDWS_MOIP_CALL_ON_HOLD);    
}

SceneSkypeOutCallWithDial.prototype.RemoteHold=function()
{
    alert("SceneSkypeOutCallWithDial.RemoteHold() ");  
    this.HoldIconLabel.visibleObj();
    this.CallDurationTextLabel.SetText(TV_SID_YOU_ARE_ON_HOLD); 
}

SceneSkypeOutCallWithDial.prototype.Resume=function()
{
    alert("SceneSkypeOutCallWithDial.Resume() ");  
    this.HoldIconLabel.hiddenObj();
    this.CallDurationTextLabel.SetText(IDWS_MOIP_SKYPE_CALL_DURATION); 
}

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