
function SceneCreateAccountStep4(options) {
	this.options = options;
	
	this.MainView=null;
	
	//2013 add by minseok 
	this.Nevi_icon1 = null;
	this.Nevi_icon2 = null;
	this.Nevi_icon3 = null;
	this.Nevi_icon4 = null;
	
	
	this.AgreemenBg = null;
	this.TitleLabel = null;
	
	this.AcceptPage = null;
	this.ReadPage = null;
	
	this.MsgTopLabelBg = null;
	this.MsgTopLabel = null;
	this.Msg1Label = null;
	this.Msg2Label = null;
	//this.EulaBtn = null;
	this.TosBtn = null;
	this.PsBtn = null;
	
	this.PreviousBtn = null;
	this.DisagreeBtn = null;
	this.AcceptBtn= null;
	
	this.ReadTitleLabel = null;
	this.ReadContentsLabel = null;
	
	this.DefaultHelpBar =null;
	
	this.isReadMode = false;
	this.ReadContents = null;
	this.ContentsAnchor = null;
	
	this.ScrollBg=null;
	this.ScrollTop=null;
	this.ScrollCenter=null;
	this.ScrollUnder=null;
	
	this.TopArrow = null;
	this.BottomArrow = null;
	
	this.KeyDown = false;
}

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

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

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

SceneCreateAccountStep4.prototype.handleFocus = function () {
	alert("SceneCreateAccountStep4.handleFocus()");
	// this function will be called when the scene manager focus this scene

    this.highlight(this.TosBtn);
    
    var this_ = sf.scene.get("CreateAccountStep4");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

SceneCreateAccountStep4.prototype.handleBlur = function () {
	alert("SceneCreateAccountStep4.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
    var currentHighlight =  this.MainView.getCurrentHighlight();
    currentHighlight.blur();

	WndMgr.SetReturnIconClickCallback(null);
}

SceneCreateAccountStep4.prototype.handleKeyDown = function (keyCode) {
	alert("SceneCreateAccountStep4.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:
            this.processLeftRightKey(keyCode);
			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.RETURN:
            this.processReturnKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
        
       case sf.key.EXIT:
            this.processExitKey();
            //2013 modify by minseok
            sf.key.preventDefault();
            //sf.key.block(event);
			break;
            
       case 147:  //infolink
       case 261:  //contents
       case 115:  //wiselink
            ProcMgr.processInfolinkKey(); 
			break;
		
		default:
            ProcMgr.processBlockKey(keyCode);
            break;
	}
}

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

SceneCreateAccountStep4.prototype.create = function(){
    alert("SceneCreateAccountStep4.create()");
    this.MainView = new View("CreateAccountStep4");
    // this.MainView.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_BG);
	
	
	//2013 add by minseok
	this.Nevi_icon1 = new Label("create_account_step4_nevi1",null);
	this.Nevi_icon1.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_NEVI_NORMAL);
	this.Nevi_icon2 = new Label("create_account_step4_nevi2",null);
	this.Nevi_icon2.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_NEVI_NORMAL);
	this.Nevi_icon3 = new Label("create_account_step4_nevi3",null);
	this.Nevi_icon3.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_NEVI_NORMAL);
	this.Nevi_icon4 = new Label("create_account_step4_nevi4",null);
	this.Nevi_icon4.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_NEVI_HIGHLIGHT);
	
	
	this.AcceptPage = new View("create_account_step4_agreement_accept_page");
	
	this.ReadPage = new View("create_account_step4_agreement_read_page");
	this.ReadPage.hiddenObj();

    this.TitleLabel = new Label(null,"create_account_step4_title");
    this.TitleLabel.SetTextStyle("create_account_title_style");
    this.TitleLabel.SetText(TV_SID_CREATE_AN_ACCOUNT);  
	
	this.AgreemenBg= new Label("create_account_step4_agreement_bg", null);
    this.AgreemenBg.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_BG); 

	//2013 add by minseok
	this.MsgTopLabelBg = new Label("create_account_step4_agreement_message_top",null);
	this.MsgTopLabelBg.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_MSG_TOP_BG);
    
    this.MsgTopLabel = new Label(null,"create_account_step4_agreement_message_top_text");
    this.MsgTopLabel.SetTextStyle("create_account_step4_agreement_message_top_style");
    this.MsgTopLabel.SetText(IDWS_MOIP_LICENSE_AGREEMENT);   
	
	this.Msg1Label = new Label(null,"create_account_step4_agreement_message1");
    this.Msg1Label.SetTextStyle("create_account_step4_agreement_message_style");
    this.Msg1Label.SetText(TV_NO_EMERGENCY_CALLS); 
    
	this.Msg2Label = new Label(null,"create_account_step4_agreement_message2");
    this.Msg2Label.SetTextStyle("create_account_step4_agreement_message_style");
    this.Msg2Label.SetText(TV_SKYPE_NOT_ORDINARY_AND_EMERGENCY_MSG); 
    
    this.Msg3Label = new Label(null,"create_account_step4_agreement_message3");
    this.Msg3Label.SetTextStyle("create_account_step4_agreement_message_style");
    this.Msg3Label.SetText(TV_ACCEPT_SKYPE_TERMS_OF_USE_MSG); 
    
	
	
	var this_ = sf.scene.get("CreateAccountStep4");
	var clickCF =  function(obj){this_.processClickEvent(obj);};
	var overCF =  function(obj){this_.processMouseOverEvent(obj);};
	
	this.TosBtn= new Button();
    this.TosBtn.SetImageObjId("create_account_step4_agreement_tos_btn", 30);
    this.TosBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_BTN_NORMAL);
    this.TosBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_BTN_NORMALFOCUS);
    this.TosBtn.SetTextObjId("create_account_step4_agreement_tos_btn_text");
    this.TosBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"create_account_btn_normal_style");
    this.TosBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"create_account_btn_select_style");
    this.TosBtn.SetText(TV_SID_VIEW_TERMS_KR_CAPITAL);
    this.TosBtn.SetOnClickCallbackFunc(clickCF);
    this.TosBtn.SetOnMouseOverCallbackFunc(overCF);
	
	this.PsBtn= new Button();
    this.PsBtn.SetImageObjId("create_account_step4_agreement_ps_btn", 30);
    this.PsBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_BTN_NORMAL);
    this.PsBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_BTN_NORMALFOCUS);
    this.PsBtn.SetTextObjId("create_account_step4_agreement_ps_btn_text");
    this.PsBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"create_account_btn_normal_style");
    this.PsBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"create_account_btn_select_style");
	this.PsBtn.SetText(TV_VIEW_PRIVACY_STATEMENT);
	this.PsBtn.SetOnClickCallbackFunc(clickCF);
	this.PsBtn.SetOnMouseOverCallbackFunc(overCF);
    
    this.PreviousBtn= new Button();
    this.PreviousBtn.SetImageObjId("create_account_step4_previous_btn", 30);
    this.PreviousBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CREATE_ACCOUNT_PREVIOUS_BTN_NORMAL);
    this.PreviousBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CREATE_ACCOUNT_PREVIOUS_BTN_NORMALFOCUS);
    this.PreviousBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CREATE_ACCOUNT_NEXT_BTN_DIM);
    this.PreviousBtn.SetTextObjId("create_account_step4_previous_btn_text");
    this.PreviousBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"create_account_btn_normal_style");
	this.PreviousBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"create_account_btn_select_style");
    this.PreviousBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"create_account_btn_dim_style");
    this.PreviousBtn.SetText(SID_BACK_KR_PREV);
    this.PreviousBtn.SetOnClickCallbackFunc(clickCF);
    this.PreviousBtn.SetOnMouseOverCallbackFunc(overCF);
	
	//2013 add by minseok
	this.DisagreeBtn= new Button();
	this.DisagreeBtn.SetImageObjId("create_account_step4_disagree_btn", 30);
    this.DisagreeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CREATE_ACCOUNT_PREVIOUS_BTN_NORMAL);
    this.DisagreeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CREATE_ACCOUNT_PREVIOUS_BTN_NORMALFOCUS);
    this.DisagreeBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CREATE_ACCOUNT_NEXT_BTN_DIM);
    this.DisagreeBtn.SetTextObjId("create_account_step4_disagree_btn_text");
    this.DisagreeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"create_account_btn_normal_style");
	this.DisagreeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"create_account_btn_select_style");
    this.DisagreeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"create_account_btn_dim_style");
    this.DisagreeBtn.SetText(SID_DISAGREE);
    this.DisagreeBtn.SetOnClickCallbackFunc(clickCF);
    this.DisagreeBtn.SetOnMouseOverCallbackFunc(overCF);
	
	
	
	
	this.AcceptBtn= new Button();
    this.AcceptBtn.SetImageObjId("create_account_step4_accept_btn", 30);
    this.AcceptBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CREATE_ACCOUNT_NEXT_BTN_NORMAL);
    this.AcceptBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CREATE_ACCOUNT_NEXT_BTN_NORMALFOCUS);
    this.AcceptBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CREATE_ACCOUNT_NEXT_BTN_DIM);
    this.AcceptBtn.SetTextObjId("create_account_step4_accept_btn_text");
    this.AcceptBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE,"create_account_btn_normal_style");
	this.AcceptBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE,"create_account_btn_select_style");
    this.AcceptBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE,"create_account_btn_dim_style");
    this.AcceptBtn.SetText(SID_AGREE);
    this.AcceptBtn.SetOnClickCallbackFunc(clickCF);
    this.AcceptBtn.SetOnMouseOverCallbackFunc(overCF);
	
	this.ReadTitleLabel = new Label(null,"create_account_step4_agreement_read_title");
    this.ReadTitleLabel.SetTextStyle("create_account_step4_agreement_message_top_style");
	
	this.ReadContentsLabel = new Label(null,"create_account_step4_agreement_read_contents");
	
	this.ScrollBg= new Label("create_account_step4_agreement_scroll_bg", null);
    this.ScrollBg.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_SCROLL_BG);
    
    this.ScrollTop= new Label("create_account_step4_agreement_scroll_top", null);
    this.ScrollTop.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_SCROLL_TOP);
    
    this.ScrollUnder= new Label("create_account_step4_agreement_scroll_middle", null);
    this.ScrollUnder.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_SCROLL_MIDDLE);
    
    this.ScrollCenter= new Label("create_account_step4_agreement_scroll_bottom", null);
    this.ScrollCenter.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_SCROLL_BOTTOM);
    
    this.TopArrow= new Label("create_account_step4_agreement_top_arrow", null);
    this.TopArrow.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_ALLOW_TOP_NOR);
    this.TopArrow.SetOnClickCallbackFunc(clickCF);
    this.TopArrow.SetOnMouseOutOverImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_ALLOW_TOP_NOR, g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_ALLOW_TOP_OVER);

    this.BottomArrow= new Label("create_account_step4_agreement_bottom_arrow", null);
    this.BottomArrow.SetBgImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_ALLOW_BOTTOM_NOR);
    this.BottomArrow.SetOnClickCallbackFunc(clickCF);
    this.BottomArrow.SetOnMouseOutOverImage(g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_ALLOW_BOTTOM_NOR, g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_ALLOW_BOTTOM_OVER);	    
    
    // this.hiddenScrollBar();
}

SceneCreateAccountStep4.prototype.goToAcceptPage = function(){
	alert("SceneCreateAccountStep4.goToAcceptPage() ");
	this.isReadMode = false;
	
	//To fix DMS01140789
	this.ReadTitleLabel.SetText(" ");
	
	this.hiddenScrollBar();
	$("div#signup_agreement_read_contents p:first").html("");
	this.AcceptPage.visibleObj();
	this.ReadPage.hiddenObj();
}

SceneCreateAccountStep4.prototype.goToReadPage = function(index){
	alert("SceneCreateAccountStep4.goToReadPage() ");
	
	ProcMgr.showLicensePopup(index);
}



SceneCreateAccountStep4.prototype.highlight=function(obj)
{
	alert("SceneCreateAccountStep4.highlight()");
	
    this.MainView.setCurrenHighlight(obj);
}


SceneCreateAccountStep4.prototype.processLeftRightKey = function(keyCode){
    alert("SceneCreateAccountStep4.processLeftRightKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();
    
    switch(currentHighlight)
    {
        case this.PreviousBtn:
        	if(keyCode==sf.key.RIGHT){
               this.highlight(this.DisagreeBtn);
              }
            break;
        case this.DisagreeBtn:
        	if(keyCode==sf.key.RIGHT){
        		this.highlight(this.AcceptBtn);
        	}else if(keyCode==sf.key.LEFT){
        		this.highlight(this.PreviousBtn);
        	}
        	break;
        case this.AcceptBtn:
        	if(keyCode==sf.key.LEFT){
            	this.highlight(this.DisagreeBtn);
            }
        break;
    }
    
}

SceneCreateAccountStep4.prototype.processUpKey = function(){
    alert("SceneCreateAccountStep4.processUpKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();

    
    switch(currentHighlight)
    {
		
		case this.PsBtn:
            this.highlight(this.TosBtn);
        break;
		
        case this.PreviousBtn:
        case this.DisagreeBtn:    
        case this.AcceptBtn:
            this.highlight(this.PsBtn);
        break;		
    }    
}

SceneCreateAccountStep4.prototype.processDownKey = function(){
    alert("SceneCreateAccountStep4.processDownKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();

    
    switch(currentHighlight)
    {
            
        case this.TosBtn:
            this.highlight(this.PsBtn);
        break;
		
		case this.PsBtn:
            this.highlight(this.AcceptBtn);
        break;
		
    }    
}


SceneCreateAccountStep4.prototype.processEnterKey = function(){
    alert("SceneCreateAccountStep4.processEnterKey() ");
    
    var currentHighlight =  this.MainView.getCurrentHighlight();

     switch(currentHighlight)
    {
        case this.TosBtn:
         	ProcMgr.ShowLicensePopup(2);
        	
        break;
		
		case this.PsBtn:
			ProcMgr.ShowLicensePopup(3);
            
        break;
		
        case this.PreviousBtn:
            this.processReturnKey();
        break;
        case this.DisagreeBtn:
            this.processReturnKey();
        break;
        case this.AcceptBtn:
           ProcMgr.CreateAccount();
        break;					
    }
}

SceneCreateAccountStep4.prototype.processReturnKey = function(){
    alert("SceneCreateAccountStep4.processReturnKey() ");
    if(this.isReadMode == true)
	{
		this.goToAcceptPage();
	}
	else
	{
		var currentHighlight =  this.MainView.getCurrentHighlight();
		if(currentHighlight==this.PreviousBtn){
			WndMgr.BackStepCreateAccount();
		}else{
			StateMgr.Start_Welcome_State();
		}
		
	}   
}

SceneCreateAccountStep4.prototype.processExitKey = function(){
    alert("SceneCreateAccountStep4.processExitKey() ");
   
   ProcMgr.ExitWithSignIn();
}


///////// Processing Click evnet  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////


SceneCreateAccountStep4.prototype.processClickEvent = function(obj){
	alert("SceneCreateAccountStep4.processClickEvent() ");
	
	if(obj == this.TopArrow)
	{
		this.scrollUp();
		return;
	}
	else if(obj == this.BottomArrow)
	{
		this.scrollDown();
		return;
	}
	
	
	this.processEnterKey();
}
SceneCreateAccountStep4.prototype.processMouseOverEvent = function(obj){
	if(obj == this.TopArrow)
	{
		return;
	}
	else if(obj == this.BottomArrow)
	{
		return;
	}
	var currentHighlight =  this.MainView.getCurrentHighlight();
    if(currentHighlight != obj)
    {
    	this.highlight(obj);
    }
}
