
function SceneGuidePage(options) {
	this.GuidePageView = null;

	this.Title = null;
	this.Msg = null;
	this.CancelBtn = null;
	this.ContinueBtn = null;
	this.OkBtn = null;

	this.NumOfBtn = 1;
	this.PageType = null;
	
	this.WebPageURL = "www.skype.com/myskypename";
}

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

SceneGuidePage.prototype.handleShow = function() {
	alert("SceneGuidePage.handleShow()");
	this.UpdatePage();
}

SceneGuidePage.prototype.handleHide = function() {
	alert("SceneGuidePage.handleHide()");
	this.highlight(null);
}

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

	var currentHighlight = this.GuidePageView.getCurrentHighlight();

	if (currentHighlight != null) {
		this.highlight(currentHighlight);
	} else if (this.NumOfBtn == 1) {
		this.highlight(this.OkBtn);
	} else {
		this.highlight(this.CancelBtn);
	}
	var this_ = sf.scene.get("GuidePage");
  	var returnCF =  function(){this_.processReturnKey();};
    WndMgr.SetReturnIconClickCallback(returnCF);
}

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

	var currentHighlight = this.GuidePageView.getCurrentHighlight();

	if (currentHighlight != null) {

		currentHighlight.blur();
	}
	WndMgr.SetReturnIconClickCallback(null);

}

SceneGuidePage.prototype.handleKeyDown = function(keyCode) {
	alert("SceneGuidePage.handleKeyDown(" + keyCode + ")");
	PluginAPIMgr.PlayAudio(keyCode);
	if (ProcMgr.checkWidgetHighlight() == false) {
		return;
	}
	switch (keyCode) {
		case sf.key.ENTER:
			this.processEnterKey();
			break;
	
		case sf.key.RETURN:
		case sf.key.EXIT:
			this.processReturnKey();
			sf.key.preventDefault();
			break;
	
		case sf.key.LEFT:
			this.processLeftKey();
			break;
		case sf.key.RIGHT:
			this.processRightKey();
			break;
	
		case sf.key.UP:
		case sf.key.DOWN:
		case 147:
		//infolink
		case 261:
		//contents
		case 115:
			//wiselink
			break;
	
		default:
			ProcMgr.processBlockKey(keyCode);
			break;
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneGuidePage.prototype.UpdatePage = function() {
	alert("SceneGuidePage.UpdatePage() " + this.PageType);

	switch(this.PageType) {
		case GUIDEPAGE_TYPE.SIGNIN_WITH_MSA:
			this.Title.SetText(TV_SID_USE_MY_MICROSOFT_ACCOUNT);
			this.Msg.SetText("<br><br>"+g_Data.CombinateStrings(TV_SID_USE_LINKED_MICROSOFT_ACCOUNT+"<br><br>"+TV_SID_MIX_DON_T_KNOW_SKYPE_NAME_NOT_TO_WORRY_MSG,this.WebPageURL));
			this.CancelBtn.visibleObj();
			this.OkBtn.hiddenObj();
			this.ContinueBtn.visibleObj();
			break;
		case GUIDEPAGE_TYPE.SIGNIN_WITH_EMAIL:
			this.Title.SetText(TV_SID_USE_MY_MICROSOFT_ACCOUNT);
			this.Msg.SetText("<br><br>"+g_Data.CombinateStrings(TV_SID_USE_LINKED_MICROSOFT_ACCOUNT+"<br><br>"+TV_SID_MIX_DON_T_KNOW_SKYPE_NAME_NOT_TO_WORRY_MSG,this.WebPageURL));
			this.CancelBtn.hiddenObj();
			this.OkBtn.visibleObj();
			this.ContinueBtn.hiddenObj();
			break;
		case GUIDEPAGE_TYPE.CREATE_NEW_ACCOUNT:
			this.Title.SetText(TV_SID_CREATE_A_NEW_ACCOUNT);
			this.Msg.SetText("<br><br>"+g_Data.CombinateStrings(TV_SID_MIX_GET_STARTED_NEW_MICROSOFT_ACCOUNT,this.WebPageURL));
			this.CancelBtn.visibleObj();
			this.OkBtn.hiddenObj();
			this.ContinueBtn.visibleObj();
			break;
		case GUIDEPAGE_TYPE.NEED_HELP:
			this.Title.SetText(TV_SID_NEED_HELP);
			this.Msg.SetText("<br><br>"+TV_SID_PROBLEMS_SIGNING_VISIT_SITE_MSG);
			this.CancelBtn.hiddenObj();
			this.OkBtn.visibleObj();
			this.ContinueBtn.hiddenObj();
			break;
	}
	if($("#guide_page_icon").length == 0){
		$("<img id = 'guide_page_icon'  src='"+g_Image.IMAGE_WARNING_ICON+"' hspace='10px' hspace='0px' align='center'>").prependTo("#guide_page_title");
	}
}
SceneGuidePage.prototype.setType = function(type) {
	alert("SceneGuidePage.setType()" + type);
	this.PageType = type;
	this.NumOfBtn = 1;
	switch(this.PageType) {
		case GUIDEPAGE_TYPE.	SIGNIN_WITH_MSA:
		case GUIDEPAGE_TYPE.	CREATE_NEW_ACCOUNT:
			this.NumOfBtn = 2;
			break;
	}
}
SceneGuidePage.prototype.create = function() {
	alert("SceneGuidePage.create()");

	var this_ = this;

	this.GuidePageView = new View("GuidePage");
	$("#guide_page_box").css("background-image",'url('+g_Image.IMAGE_CREATE_ACCOUNT_AGREEMENT_BG+')');

	this.Title = new TextLayer("guide_page_title");

	this.Msg = new TextLayer("guide_page_message");

	this.CancelBtn = new Button();
	this.CancelBtn.SetImageObjId("guide_page_cancel_btn", 30);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_NORMAL);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_NORMALFOCUS);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_DIM);
	this.CancelBtn.SetTextObjId("guide_page_cancel_text");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "guide_page_button_text_nor_style");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "guide_page_button_text_focus_style");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "guide_page_button_text_dim_style");
	this.CancelBtn.SetText(SID_CANCEL);
	this.CancelBtn.SetOnClickCallbackFunc(function(obj) {
		this_.processClickEvent(obj);
	});
	this.CancelBtn.ResizeButton("C");

	this.ContinueBtn = new Button();
	this.ContinueBtn.SetImageObjId("guide_page_continue_btn", 30);
	this.ContinueBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_NORMAL);
	this.ContinueBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_NORMALFOCUS);
	this.ContinueBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_DIM);
	this.ContinueBtn.SetTextObjId("guide_page_continue_text");
	this.ContinueBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "guide_page_button_text_nor_style");
	this.ContinueBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "guide_page_button_text_focus_style");
	this.ContinueBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "guide_page_button_text_dim_style");
	this.ContinueBtn.SetText(TV_SID_CONTINUE_VOICE_KR_CONTINUE);
	this.ContinueBtn.SetOnClickCallbackFunc(function(obj) {
		this_.processClickEvent(obj);
	});

	this.OkBtn = new Button();
	this.OkBtn.SetImageObjId("guide_page_ok_btn", 30);
	this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_NORMAL);
	this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_NORMALFOCUS);
	this.OkBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_GUIDEPAGE_BTN_DIM);
	this.OkBtn.SetTextObjId("guide_page_ok_text");
	this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "guide_page_button_text_nor_style");
	this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "guide_page_button_text_focus_style");
	this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "guide_page_button_text_dim_style");
	this.OkBtn.SetText(SID_OK);
	this.OkBtn.SetOnClickCallbackFunc(function(obj) {
		this_.processClickEvent(obj);
	});
	this.OkBtn.hiddenObj();

	this.CancelBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.ContinueBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.OkBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	/*

	 var CurLangID = ResMgr.GetCurLanguage();
	 if(CurLangID == ENUM_TV_LANGUAGE.JPN)
	 {
	 $("#GuidePage_ShootButtonText").css('font-size', "22px" );
	 }
	 else{
	 $("#GuidePage_ShootButtonText").css('font-size', "24px" );
	 }*/

}

SceneGuidePage.prototype.processMouseOver = function(obj) {
	var currentHighlight = this.GuidePageView.getCurrentHighlight();
	if (currentHighlight != obj) {
		this.highlight(obj);
	}
}
SceneGuidePage.prototype.highlight = function(obj) {

	this.GuidePageView.setCurrenHighlight(obj);
}

SceneGuidePage.prototype.processMouseOver = function(obj) {
	var currentHighlight = this.GuidePageView.getCurrentHighlight();
	if (currentHighlight != obj) {
		this.highlight(obj);
	}
}

SceneGuidePage.prototype.processReturnKey = function() {
	alert("SceneGuidePage.processReturnKey() ");
	if(StateMgr.GetCurrentState()=="FaceRecogSignin"){
		WndMgr.HideGuidePageFaceRecogSignin(); 
	}else if (this.PageType == GUIDEPAGE_TYPE.SIGNIN_WITH_EMAIL)
		StateMgr.Start_Signin_State();
	else {
		StateMgr.Start_Welcome_State();
	}
}

SceneGuidePage.prototype.processLeftKey = function() {
	if (this.NumOfBtn == 1)
		return;
	alert("SceneGuidePage.processLeftKey() ");
	this.highlight(this.CancelBtn);
}
SceneGuidePage.prototype.processRightKey = function() {

	if (this.NumOfBtn == 1)
		return;
	alert("SceneGuidePage.processRightKey() ");
	this.highlight(this.ContinueBtn);
}

SceneGuidePage.prototype.processEnterKey = function() {
	alert("SceneGuidePage.processEnterKey() ");

	var currentHighlight = this.GuidePageView.getCurrentHighlight();

	switch(currentHighlight) {

		case this.OkBtn:
			if(StateMgr.GetCurrentState()=="FaceRecogSignin"){
				WndMgr.HideGuidePageFaceRecogSignin(); 
			}else if (this.PageType == GUIDEPAGE_TYPE.NEED_HELP) {
				StateMgr.Start_Welcome_State();
			} else {
				StateMgr.Start_Signin_State();
			}
			break;

		case this.CancelBtn:
			StateMgr.Start_Welcome_State();
			break;

		case this.ContinueBtn:
			StateMgr.Start_Signin_State();
			break;
	}
}
SceneGuidePage.prototype.processClickEvent = function(obj) {
	alert("SceneGuidePage.processClickEvent() ");
	var currentHighlight = this.GuidePageView.getCurrentHighlight();
	if (currentHighlight != obj) {
		this.highlight(obj);
	}
	this.processEnterKey();
}