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

	this.OnlineStatusView = null;
	this.OnlineStatusDim = null;
	this.OnlineStatusBG = null;

	this.OnlineBtn = null;
	this.AwayBtn = null;
	this.DoNotDisturbBtn = null;
	this.InvisibleBtn = null;
	this.OfflineBtn = null;

	this.InitStatus = null;
	this.CancelBtn = null;
	this.BeforeStatus = null;
	
	this.flagInit = false;


}

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

SceneOnlineStatus.prototype.handleShow = function() {
	alert("SceneOnlineStatus.handleShow()");
	// this function will be called when the scene manager show this scene
	this.OnlineStatusDim.show();
	
	this.initOnlineStatus();
	WndMgr.startPopupHideTimer(60000);
}
SceneOnlineStatus.prototype.handleFocus = function() {
	alert("SceneOnlineStatus.handleFocus()");
	// this function will be called when the scene manager focus this scene
	var  obj = this.OnlineStatusView.getCurrentHighlight();
	if(obj != null)
	{
		this.highlight(obj);
	}   
}

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

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

SceneOnlineStatus.prototype.handleKeyDown = function(keyCode) {
	alert("SceneOnlineStatus.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:
			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;
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////

SceneOnlineStatus.prototype.create = function() {
	alert("SceneOnlineStatus.create()");
	this.OnlineStatusView = new View("OnlineStatus");
	this.OnlineStatusBG = new View("OnlineStatusBG");
	this.OnlineStatusBG.CreatePopupBG(0, "OnlineStatus_popup_BG");
	this.OnlineStatusBG.SetTitleTextofPopupBG(IDWS_MOIP_SETTING_ONLINE_STATUS);
	this.OnlineStatusDim = new DimBg("OnlineStatusDim", "OnlineStatusBG");

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

	this.OnlineBtn = new Button();
	this.OnlineBtn.SetImageObjId("online_status_online_btn", 30);
	this.OnlineBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
	this.OnlineBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_SELECTION_HIGH);
	this.OnlineBtn.SetTextObjId("online_status_online_btn_text");
	this.OnlineBtn.SetText(IDWS_MOIP_SETTING_ONLINE);
	this.OnlineBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "online_status_btn_small_style_nor");
	this.OnlineBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "online_status_btn_small_style_focus");
	this.OnlineBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "online_status_btn_small_style_dim");
	this.OnlineBtn.SetIconObjId("online_status_online_btn_icon");
	this.OnlineBtn.SetBgIcon(0, g_Image.IMAGE_LIST_MAIN_PROFILE_ONLINE_STATUS_ICON);
	this.OnlineBtn.SetChkObjId("online_status_online_btn_chk");
	this.OnlineBtn.SetBgCheckBox(g_Image.IMAGE_ONLINE_STATUS_BTN_CHK);

	this.OnlineBtn.SetOnClickCallbackFunc(clickCF);

	this.AwayBtn = new Button();
	this.AwayBtn.SetImageObjId("online_status_away_btn", 30);
	this.AwayBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
	this.AwayBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_SELECTION_HIGH);
	this.AwayBtn.SetTextObjId("online_status_away_btn_text");
	this.AwayBtn.SetText(IDWS_MOIP_SETTING_AWAY);
	this.AwayBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "online_status_btn_small_style_nor");
	this.AwayBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "online_status_btn_small_style_focus");
	this.AwayBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "online_status_btn_small_style_dim");
	this.AwayBtn.SetIconObjId("online_status_away_btn_icon");
	this.AwayBtn.SetBgIcon(0, g_Image.IMAGE_LIST_MAIN_PROFILE_AWAY_ICON);
	this.AwayBtn.SetChkObjId("online_status_away_btn_chk");
	this.AwayBtn.SetBgCheckBox(g_Image.IMAGE_ONLINE_STATUS_BTN_CHK);

	this.AwayBtn.SetOnClickCallbackFunc(clickCF);

	this.DoNotDisturbBtn = new Button();
	this.DoNotDisturbBtn.SetImageObjId("online_status_do_not_disturb_btn", 30);
	this.DoNotDisturbBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
	this.DoNotDisturbBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_SELECTION_HIGH);
	this.DoNotDisturbBtn.SetTextObjId("online_status_do_not_disturb_btn_text");
	this.DoNotDisturbBtn.SetText(IDWS_MOIP_SETTING_DO_NOT_DISTURB);
	this.DoNotDisturbBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "online_status_btn_small_style_nor");
	this.DoNotDisturbBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "online_status_btn_small_style_focus");
	this.DoNotDisturbBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "online_status_btn_small_style_dim");
	this.DoNotDisturbBtn.SetIconObjId("online_status_do_not_disturb_btn_icon");
	this.DoNotDisturbBtn.SetBgIcon(0, g_Image.IMAGE_LIST_MAIN_PROFILE_DONOTDISTURB_ICON);
	this.DoNotDisturbBtn.SetChkObjId("online_status_do_not_disturb_btn_chk");
	this.DoNotDisturbBtn.SetBgCheckBox(g_Image.IMAGE_ONLINE_STATUS_BTN_CHK);
	this.DoNotDisturbBtn.SetOnClickCallbackFunc(clickCF);

	this.InvisibleBtn = new Button();
	this.InvisibleBtn.SetImageObjId("online_status_invisible_btn", 30);
	this.InvisibleBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
	this.InvisibleBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_SELECTION_HIGH);
	this.InvisibleBtn.SetTextObjId("online_status_invisible_btn_text");
	this.InvisibleBtn.SetText(IDWS_MOIP_SETTING_INVISIBLE);
	this.InvisibleBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "online_status_btn_small_style_nor");
	this.InvisibleBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "online_status_btn_small_style_focus");
	this.InvisibleBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "online_status_btn_small_style_dim");
	this.InvisibleBtn.SetIconObjId("online_status_invisible_btn_icon");
	this.InvisibleBtn.SetBgIcon(0, g_Image.IMAGE_LIST_MAIN_PROFILE_INVISIBLE_ICON);
	this.InvisibleBtn.SetChkObjId("online_status_invisible_btn_chk");
	this.InvisibleBtn.SetBgCheckBox(g_Image.IMAGE_ONLINE_STATUS_BTN_CHK);
	this.InvisibleBtn.SetOnClickCallbackFunc(clickCF);

	this.OfflineBtn = new Button();
	this.OfflineBtn.SetImageObjId("online_status_offline_btn", 30);
	this.OfflineBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, null);
	this.OfflineBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_LIST_SELECTION_HIGH);
	this.OfflineBtn.SetTextObjId("online_status_offline_btn_text");
	this.OfflineBtn.SetText(TV_SID_OFFLINE);
	this.OfflineBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "online_status_btn_small_style_nor");
	this.OfflineBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "online_status_btn_small_style_focus");
	this.OfflineBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "online_status_btn_small_style_dim");
	this.OfflineBtn.SetIconObjId("online_status_offline_btn_icon");
	this.OfflineBtn.SetBgIcon(0, g_Image.IMAGE_LIST_MAIN_PROFILE_SIGNOUT_ICON);
	this.OfflineBtn.SetChkObjId("online_status_offline_btn_chk");
	this.OfflineBtn.SetBgCheckBox(g_Image.IMAGE_ONLINE_STATUS_BTN_CHK);

	this.OfflineBtn.SetOnClickCallbackFunc(clickCF);

	this.CancelBtn = new Button();
	this.CancelBtn.SetImageObjId("online_status_cancel_btn", 20);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.CancelBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);

	this.CancelBtn.SetTextObjId("online_status_cancel_btn_text");
	this.CancelBtn.SetText(SID_CANCEL);
	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.SetOnClickCallbackFunc(clickCF);
	
	this.OnlineBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.AwayBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.DoNotDisturbBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.InvisibleBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.OfflineBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
	this.CancelBtn.SetOnMouseOverCallbackFunc(function(obj){
			this_.processMouseOver(obj);
		});
/*
if(ResMgr.GetCurLanguage() == ENUM_TV_LANGUAGE.GRE) {
	} else {
	}*/

}

SceneOnlineStatus.prototype.initOnlineStatus = function() {
	this.OnlineBtn.hiddenChkBox();
	this.DoNotDisturbBtn.hiddenChkBox();
	this.OfflineBtn.hiddenChkBox();
	this.InvisibleBtn.hiddenChkBox();
	this.AwayBtn.hiddenChkBox();
	
	var profile_ = sf.scene.get("ListMainProfile");
	
	this.Init_OnlineStatusEnum = profile_.GetOnlineStatus();
	
	
	alert("SceneOnlineStatus.initOnlineStatus() ");
	this.BeforeStatus = null;
	if(this.Init_OnlineStatusEnum == ENUM_ACCOUNT_AVAILABILITY.ONLINE) {
		this.BeforeStatus = this.OnlineBtn;
	} else if(this.Init_OnlineStatusEnum == ENUM_ACCOUNT_AVAILABILITY.AWAY) {
		this.BeforeStatus = this.AwayBtn;
	} else if(this.Init_OnlineStatusEnum == ENUM_ACCOUNT_AVAILABILITY.DO_NOT_DISTURB) {
		this.BeforeStatus = this.DoNotDisturbBtn;
	} else if(this.Init_OnlineStatusEnum == ENUM_ACCOUNT_AVAILABILITY.INVISIBLE) {
		this.BeforeStatus = this.InvisibleBtn;
	} else if(this.Init_OnlineStatusEnum == ENUM_ACCOUNT_AVAILABILITY.OFFLINE) {
		this.BeforeStatus = this.OfflineBtn;
	} else {
		this.BeforeStatus = this.OfflineBtn;
	}
	
	this.BeforeStatus.visibleChkBox();
	this.highlight(this.BeforeStatus);
	this.flagInit = true;
}
SceneOnlineStatus.prototype.processMouseOver = function(obj) {
	var currentHighlight = this.OnlineStatusView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
	WndMgr.resetPopupHideTimer();
}
SceneOnlineStatus.prototype.highlight = function(obj) {
	this.OnlineStatusView.setCurrenHighlight(obj);
}

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

	var currentHighlight = this.OnlineStatusView.getCurrentHighlight();

	switch(currentHighlight) {

		case this.AwayBtn:
			this.highlight(this.OnlineBtn);
			break;

		case this.DoNotDisturbBtn:
			this.highlight(this.AwayBtn);
			break;

		case this.InvisibleBtn:
			this.highlight(this.DoNotDisturbBtn);
			break;

		case this.OfflineBtn:
			this.highlight(this.InvisibleBtn);
			break;
		case this.CancelBtn:
			this.highlight(this.OfflineBtn);
			break;
	}
}

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

	var currentHighlight = this.OnlineStatusView.getCurrentHighlight();

	switch(currentHighlight) {
		case this.OnlineBtn:
			this.highlight(this.AwayBtn);
			break;

		case this.AwayBtn:
			this.highlight(this.DoNotDisturbBtn);
			break;

		case this.DoNotDisturbBtn:
			this.highlight(this.InvisibleBtn);
			break;

		case this.InvisibleBtn:
			this.highlight(this.OfflineBtn);
			break;

		case this.OfflineBtn:
			this.highlight(this.CancelBtn);
			break;

	}
}

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

	var currentHighlight = this.OnlineStatusView.getCurrentHighlight();
	if(this.BeforeStatus==currentHighlight){
		alert("not changed")
		StateMgr.Stop_Online_Status_State(true);
	}
	var profile_ = sf.scene.get("ListMainProfile");
	
	switch(currentHighlight) {
		case this.OnlineBtn:
			this.Init_OnlineStatusEnum= ENUM_ACCOUNT_AVAILABILITY.ONLINE;
			break;
		case this.AwayBtn:
			this.Init_OnlineStatusEnum= ENUM_ACCOUNT_AVAILABILITY.AWAY;
			break;
		case this.DoNotDisturbBtn:
			this.Init_OnlineStatusEnum= ENUM_ACCOUNT_AVAILABILITY.DO_NOT_DISTURB;
			break;
		case this.InvisibleBtn:
			this.Init_OnlineStatusEnum= ENUM_ACCOUNT_AVAILABILITY.INVISIBLE;
			break;
		case this.OfflineBtn:
			this.Init_OnlineStatusEnum= ENUM_ACCOUNT_AVAILABILITY.OFFLINE;
			break;
		case this.CancelBtn:
			StateMgr.Stop_Online_Status_State(true);
			break;
		
	}
	if(currentHighlight!=this.CancelBtn){
		profile_.SetOnlineStatus(this.Init_OnlineStatusEnum);
		ProcMgr.SetOnlineStatus(this.Init_OnlineStatusEnum);
	//	sf.scene.get("ListMain").updateOnlineStatus();
		this.flagInit=false;
	}
}

SceneOnlineStatus.prototype.processReturnKey = function() {
	alert("SceneOnlineStatus.processReturnKey() ");
	StateMgr.Stop_Online_Status_State(true);

}

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

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

	this.processEnterKey();
}