function SceneChangePassword(options) {
	this.options = options;

	this.ChangePasswordView = null;
	this.ChangePasswordDim = null;
	this.ChangePasswordBG = null;

	this.MsgLabel = null;

	this.CurrentPWDLabel = null;
	this.CurrentPWDInputBox = null;

	this.NewPWDLabel = null;
	this.NewPWDInputBox = null;

	this.RepeatPWDLabel = null;
	this.RepeatPWDInputBox = null;

	this.OkBtn = null;
	this.CancelBtn = null;

	this.flagPWD = true;
	this.initText = "";
	this.maxStringLenght = 50;
	this.callerObj = null;

	this.flagCurrentPWDInit = false;
	this.flagNewPWDInit = false;
	this.flagRepeatPWDInit = false;

	this.reserveHighlight = null;

	this.IsReturnOnly = false;
	this.InitFlag = true;

}

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

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

	this.ChangePasswordDim.show();
	if(this.InitFlag == true) {
		this.initChangePassword();
	}
	//this.ChangeHelpbar();
	WndMgr.startPopupHideTimer(60000);
}

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

	this.ChangePasswordDim.hide();
	this.highlight(null);
	WndMgr.stopPopupHideTimer();
}

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

	WndMgr.restartPopupHideTimer();

	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();
	if(currentHighlight == null && this.reserveHighlight == null) {
		this.IsReturnOnly = true;
		this.highlight(this.CurrentPWDInputBox);
	} else {
		if(this.reserveHighlight != null) {
			this.highlight(this.reserveHighlight);
			this.reserveHighlight = null;
		} else {
			this.highlight(currentHighlight);
		}
	}
}

SceneChangePassword.prototype.handleBlur = function() {
	alert("SceneChangePassword.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene

	var obj = this.ChangePasswordView.getCurrentHighlight();
	if(obj)
		obj.blur();
}

SceneChangePassword.prototype.handleKeyDown = function(keyCode) {
	alert("SceneChangePassword.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	switch (keyCode) {
		case sf.key.LEFT:
			WndMgr.resetPopupHideTimer();
			this.processLeftKey();
			break;
		case sf.key.RIGHT:
			WndMgr.resetPopupHideTimer();
			this.processRightKey();
			break;
		case sf.key.UP:
			WndMgr.resetPopupHideTimer();
			this.processUpKey();
			break;
		case sf.key.DOWN:
			WndMgr.resetPopupHideTimer();
			this.processDownKey();
			break;

		case sf.key.ENTER:
			this.processEnterKey();
			break;

		case sf.key.RETURN:
		case sf.key.EXIT:
			this.processReturnKey();
			sf.key.preventDefault();
			break;

		case 147:
		//infolink
		case 261:
		//contents
		case 115:
			//wiselink
			ProcMgr.processInfolinkKey();
			break;
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneChangePassword.prototype.create = function() {
	alert("SceneChangePassword.create()");
	this.ChangePasswordView = new View("ChangePassword");

	this.ChangePasswordBG = new View("ChangePasswordBG");
	this.ChangePasswordBG.CreatePopupBG(0, "ChangePassword_popup_BG");
	this.ChangePasswordBG.SetTitleTextofPopupBG(IDWS_MOIP_CHANGE_PASS);
	this.ChangePasswordDim = new DimBg("ChangePasswordDim", "ChangePasswordBG");

	this.CurrentPWDLabel = new Label(null, "change_password_current_password_text");
	this.CurrentPWDLabel.SetTextStyle("change_password_text_style");
	this.CurrentPWDLabel.SetText(IDWS_MOIP_ENTER_CURRENT_PASS);

	this.NewPWDLabel = new Label(null, "change_password_new_password_text");
	this.NewPWDLabel.SetTextStyle("change_password_text_style");
	this.NewPWDLabel.SetText(IDWS_MOIP_ENTER_NEW_PASS);

	this.RepeatPWDLabel = new Label(null, "change_password_repeat_password_text");
	this.RepeatPWDLabel.SetTextStyle("change_password_text_style");
	this.RepeatPWDLabel.SetText(IDWS_MOIP_ENTER_RE_NEW_PASS);

	var CurLangID = ResMgr.GetCurLanguage();

	/*
	 if(CurLangID == ENUM_TV_LANGUAGE.TAM) {
	 $("#change_password_current_password_text").css('top', "73px" );
	 $("#change_password_current_password_input_box").css('top', "89px" );

	 $("#change_password_new_password_text").css('top', "140px" );
	 $("#change_password_new_password_input_box").css('top', "156px" );		//-12

	 $("#change_password_repeat_password_text").css('top', "207px" );
	 $("#change_password_repeat_password_input_box").css('top', "242px" ); //+5

	 }*/

	var this_ = sf.scene.get("ChangePassword");
	var clickCF = function(obj) {
		this_.processClickEvent(obj);
	};

	this.CurrentPWDInputBox = new Button();
	this.CurrentPWDInputBox.SetImageObjId("change_password_current_password_input_box", 29);
	this.CurrentPWDInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CHANGE_PASSWORD_INPUTBOX_NORMAL);
	this.CurrentPWDInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CHANGE_PASSWORD_INPUTBOX_NORMALFOCUS);
	this.CurrentPWDInputBox.SetTextObjId("change_password_current_password_input_box_text", true);
	this.CurrentPWDInputBox.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
	this.CurrentPWDInputBox.SetMaxStringLength(20);
	this.CurrentPWDInputBox.SetMinStringLength(6);
	this.CurrentPWDInputBox.SetIsPlainText(true);
	this.CurrentPWDInputBox.SetOnTextChangeFunc(function() {
		this_.checkOkBtnEnable();
	});
	/*
	if(CurLangID == ENUM_TV_LANGUAGE.HEB) {
			this.CurrentPWDInputBox.SetHelpText(IDWS_MOIP_PRESS_ENTER, "change_password_input_btn_help_large_style");
		} else {
			this.CurrentPWDInputBox.SetHelpText(IDWS_MOIP_PRESS_ENTER, "change_password_input_btn_help_style");
		}*/
	

	this.CurrentPWDInputBox.SetTextEditorInfo(IDWS_MOIP_CHANGE_PASS, IDWS_MOIP_ENTER_CURRENT_PASS);
	this.CurrentPWDInputBox.SetOnClickCallbackFunc(clickCF);

	this.NewPWDInputBox = new Button();
	this.NewPWDInputBox.SetImageObjId("change_password_new_password_input_box", 29);
	this.NewPWDInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CHANGE_PASSWORD_INPUTBOX_NORMAL);
	this.NewPWDInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CHANGE_PASSWORD_INPUTBOX_NORMALFOCUS);
	this.NewPWDInputBox.SetTextObjId("change_password_new_password_input_box_text", true);
	this.NewPWDInputBox.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
	this.NewPWDInputBox.SetMaxStringLength(20);
	this.NewPWDInputBox.SetMinStringLength(6);
	this.NewPWDInputBox.SetIsPlainText(true);
	this.NewPWDInputBox.SetOnTextChangeFunc(function() {
		this_.checkOkBtnEnable();
	});
	// if(CurLangID == ENUM_TV_LANGUAGE.HEB) {
		// this.NewPWDInputBox.SetHelpText(IDWS_MOIP_PRESS_ENTER, "change_password_input_btn_help_large_style");
	// } else {
		// this.NewPWDInputBox.SetHelpText(IDWS_MOIP_PRESS_ENTER, "change_password_input_btn_help_style");
	// }

	this.NewPWDInputBox.SetTextEditorInfo(IDWS_MOIP_CHANGE_PASS, IDWS_MOIP_ENTER_NEW_PASS);
	this.NewPWDInputBox.SetOnClickCallbackFunc(clickCF);

	this.RepeatPWDInputBox = new Button();
	this.RepeatPWDInputBox.SetImageObjId("change_password_repeat_password_input_box", 29);
	this.RepeatPWDInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CHANGE_PASSWORD_INPUTBOX_NORMAL);
	this.RepeatPWDInputBox.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CHANGE_PASSWORD_INPUTBOX_NORMALFOCUS);
	this.RepeatPWDInputBox.SetTextObjId("change_password_repeat_password_input_box_text", true);
	this.RepeatPWDInputBox.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
	this.RepeatPWDInputBox.SetMaxStringLength(20);
	this.RepeatPWDInputBox.SetMinStringLength(6);
	this.RepeatPWDInputBox.SetIsPlainText(true);
	this.RepeatPWDInputBox.SetOnTextChangeFunc(function() {
		this_.checkOkBtnEnable();
	});
	/*
	if(CurLangID == ENUM_TV_LANGUAGE.HEB) {
			this.RepeatPWDInputBox.SetHelpText(IDWS_MOIP_PRESS_ENTER, "change_password_input_btn_help_large_style");
		} else {
			this.RepeatPWDInputBox.SetHelpText(IDWS_MOIP_PRESS_ENTER, "change_password_input_btn_help_style");
		}*/
	

	this.RepeatPWDInputBox.SetTextEditorInfo(IDWS_MOIP_CHANGE_PASS, IDWS_MOIP_ENTER_RE_NEW_PASS);
	this.RepeatPWDInputBox.SetOnClickCallbackFunc(clickCF);

	this.OkBtn = new Button();
	this.OkBtn.SetImageObjId("change_password_ok_btn", 20);
	this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CHANGE_PASSWORD_BTN_NORMAL);
	this.OkBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CHANGE_PASSWORD_BTN_NORMALFOCUS);
	this.OkBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CHANGE_PASSWORD_BTN_DIM);
	this.OkBtn.SetTextObjId("change_password_ok_btn_text");

	this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.OkBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.OkBtn.SetText(SID_OK_KR_YES);
	this.OkBtn.SetOnClickCallbackFunc(clickCF);

	this.CancelBtn = new Button();
	this.CancelBtn.SetImageObjId("change_password_cancel_btn", 20);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_CHANGE_PASSWORD_BTN_NORMAL);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_CHANGE_PASSWORD_BTN_NORMALFOCUS);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_CHANGE_PASSWORD_BTN_DIM);
	this.CancelBtn.SetTextObjId("change_password_cancel_btn_text");

	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.CancelBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.CancelBtn.SetText(SID_CANCEL);
	this.CancelBtn.SetOnClickCallbackFunc(clickCF);
	this.CurrentPWDInputBox.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.NewPWDInputBox.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.RepeatPWDInputBox.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.OkBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.CancelBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
}

SceneChangePassword.prototype.setInitFlag = function(init_flag) {
	this.InitFlag = init_flag;
}

SceneChangePassword.prototype.initChangePassword = function() {
	alert("SceneChangePassword.initChangePassword() ");

	this.CurrentPWDInputBox.SetText("");
	this.NewPWDInputBox.SetText("");
	this.RepeatPWDInputBox.SetText("");

	this.highlight(null);
	this.reserveHighlight = null;

	this.InitFlag = false;

	this.checkOkBtnEnable();
}
SceneChangePassword.prototype.processMouseOver = function(obj) {
	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
	WndMgr.resetPopupHideTimer();
}
SceneChangePassword.prototype.highlight = function(obj) {
	this.ChangePasswordView.setCurrenHighlight(obj);
}


SceneChangePassword.prototype.processUpKey = function() {
	alert("SceneChangePassword.processUpKey() ");

	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.NewPWDInputBox:
			this.highlight(this.CurrentPWDInputBox);
			break;
		case this.RepeatPWDInputBox:
			this.highlight(this.NewPWDInputBox);
			break;
		case this.OkBtn:
			this.highlight(this.RepeatPWDInputBox);
			break;
		case this.CancelBtn:
			this.highlight(this.RepeatPWDInputBox);
			break;

	}
}

SceneChangePassword.prototype.processDownKey = function() {
	alert("SceneChangePassword.processDownKey() ");

	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();

	switch(currentHighlight) {
		case this.CurrentPWDInputBox:
			this.highlight(this.NewPWDInputBox);
			break;

		case this.NewPWDInputBox:
			this.highlight(this.RepeatPWDInputBox);
			break;

		case this.RepeatPWDInputBox:
			if(this.OkBtn.GetFlagDim() == true) {
				this.highlight(this.CancelBtn);
			} else {
				this.highlight(this.OkBtn);
			}
			break;
	}
}
SceneChangePassword.prototype.processRightKey = function() {
	alert("SceneChangePassword.processRightKey() ");
	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.OkBtn:
			this.highlight(this.CancelBtn);
			break;
	}
}
SceneChangePassword.prototype.processLeftKey = function() {
	alert("SceneChangePassword.processLeftKey() ");

	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.CancelBtn:
			if(this.OkBtn.GetFlagDim() != true)
				this.highlight(this.OkBtn);
			break;
	}
}
SceneChangePassword.prototype.processEnterKey = function() {
	alert("SceneChangePassword.processEnterKey() ");

	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();

	switch(currentHighlight) {
		case this.CurrentPWDInputBox:
		case this.NewPWDInputBox:
		case this.RepeatPWDInputBox:
			WndMgr.holdPopupHideTimer ();
			currentHighlight.SetImeTextEndFunc(function(){WndMgr.restartPopupHideTimer();});
			WndMgr.StartTextEditor(currentHighlight, "ChangePassword", this.ChangePasswordDim);
			break;
		case this.OkBtn:
			var old_pwd = this.CurrentPWDInputBox.GetText();
			var new_pwd = this.NewPWDInputBox.GetText();
			var re_pwd = this.RepeatPWDInputBox.GetText();
			if(old_pwd.length > 0 && new_pwd.length > 0 && re_pwd.length > 0) {
				ProcMgr.ChangePassword(old_pwd, new_pwd, re_pwd);
			}
			break;
		case this.CancelBtn:
			this.processReturnKey();
			break;
	}
}

SceneChangePassword.prototype.checkOkBtnEnable = function() {
	if(this.InitFlag == true) {
		return;
	}
	alert("SceneChangePassword.checkOkBtnEnable() ");

	var old_pwd = this.CurrentPWDInputBox.GetText();
	var new_pwd = this.NewPWDInputBox.GetText();
	var re_pwd = this.RepeatPWDInputBox.GetText();

	if((old_pwd.length > 0) && (new_pwd.length > 0) && (re_pwd.length > 0)) {
		this.OkBtn.SetFlagDim(false);
	} else {
		this.OkBtn.SetFlagDim(true);
	}
}

SceneChangePassword.prototype.processReturnKey = function() {
	alert("SceneChangePassword.processReturnKey() ");
	StateMgr.Stop_Change_Password_State(true);
}

SceneChangePassword.prototype.InputOldPWDAgain = function() {
	alert("SceneSignup.InputOldPWDAgain() ");

	this.reserveHighlight = this.CurrentPWDInputBox;
	this.CurrentPWDInputBox.SetText("");
}

SceneChangePassword.prototype.InputNewPWDAgain = function() {
	alert("SceneSignup.InputNewPWDAgain() ");

	this.reserveHighlight = this.NewPWDInputBox;
	this.NewPWDInputBox.SetText("");
	this.RepeatPWDInputBox.SetText("");
}

SceneChangePassword.prototype.processClickEvent = function(obj) {
	alert("SceneChangePassword.processClickEvent() ");

	var currentHighlight = this.ChangePasswordView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
	this.processEnterKey();
}

SceneChangePassword.prototype.ChangeHelpbar = function(type) {
	if(this.IsReturnOnly == true && type == 1) {
		var dataInfo = {
			/*'enter' : SID_INPUT,*/
			'return' : SID_RETURN
		};
		this.ChangePasswordBG.SetHelpbarContentsOfPopupBG(dataInfo);
		this.IsReturnOnly = false;
	} else if(this.IsReturnOnly == false && type == 0) {
		var dataInfo = {
			'return' : SID_RETURN
		};
		this.ChangePasswordBG.SetHelpbarContentsOfPopupBG(dataInfo);
		this.IsReturnOnly = true;
	}
}