function SceneSettingsCallForwarding(options) {
	this.options = options;
	this.sceneId = "SettingsCallForwarding";
	this.SettingsCallForwardingView = null;
	this.SettingsCallForwardingDim = null;
	this.SettingsCallForwardingBG = null;
	this.CallBtn = null;
	this.TimeBtn = null;
	this.CallForwardingLabel = null;
	this.TimeLabel = null;
	this.SecondsLabel = null;
	this.maxPhones = 3;
	this.CountryCodeBtn = [];
	this.PhoneNumberBox = [];
	///////////
	this.Init_CallForward = null;
	this.Init_Time = 10;

	this.BeforeBtn = null;

	this.Init_CallForwardStrings = null;

	this.Init_CountryCode = [];
	this.Init_PhoneNumbers = [];
	this.Curr_CountryCode = [];

	this.DefaultCountry = "";
	this.CountryCodeIndex = null;

	this.IsChangeTime = false;
	this.IsChangeCallForward = false;

	this.splitCharSpace = " ";
	this.splitCharComma = ",";
	this.IsEnable = null;
	this.IsEnableSaveBtn = true;

	this.flagPlusBtnEnable = false;

	this.ShownOnOffSubList = false;
	this.ShownCountryList = false;
	this.waitingCommit = false;

	this.isCheckEnable = false;

}

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

SceneSettingsCallForwarding.prototype.handleShow = function() {
	// this function will be called when the scene manager show this scene
	alert("SceneSettingsCallForwarding.handleShow()");
	this.SettingsCallForwardingDim.show();
	this.InitBase();
	this.InitCallForwarding();
	this.setSaveBtnEnable(false);
	WndMgr.startPopupHideTimer(60000);
}

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

	if(this.ShownOnOffSubList) {
		WndMgr.HideSettingsOnOffSubList();
	}
	if(this.ShownCountryList) {
		sf.scene.hide('CountryFlagList');
	}
	this.SettingsCallForwardingDim.hide();
	WndMgr.stopPopupHideTimer();
	this.highlight(null);
	
}

SceneSettingsCallForwarding.prototype.handleFocus = function() {
	// this function will be called when the scene manager focus this scene
	alert("SceneSettingsCallForwarding.handleFocus()");
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();
	if(currentHighlight != null)
		this.highlight(currentHighlight);
	else {
		this.highlight(this.CallBtn);
	}
	this.ShownOnOffSubList = false;
	this.ShownCountryList = false;

}

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

	if(currentHighlight != null) {
		currentHighlight.blur();
	}
	
/*	if(this.ShownOnOffSubList)
		this.setSaveBtnEnable(false);*/

}

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

SceneSettingsCallForwarding.prototype.processLeftKey = function() {
	alert("SceneSettingsCallForwarding.processLeftKey() ");
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();

	switch(currentHighlight) {
		case this.CallBtn:
			break;
		case this.TimeBtn:
			break;
		case this.CountryCodeBtn[0]:
			break;
		case this.CountryCodeBtn[1]:
			break;
		case this.CountryCodeBtn[2]:
			break;
		case this.PhoneNumberBox[0]:
			this.highlight(this.CountryCodeBtn[0]);
			break;
		case this.PhoneNumberBox[1]:
			this.highlight(this.CountryCodeBtn[1]);
			break;
		case this.PhoneNumberBox[2]:
			this.highlight(this.CountryCodeBtn[2]);
			break;
		case this.SaveBtn:
			if(this.IsEnable == true) {
				this.highlight(this.BeforeBtn);
			}else{
				this.highlight(this.CallBtn);
			}
			break;
		case this.CancelBtn:
			if(this.IsEnable == true) {
				this.highlight(this.BeforeBtn);
			}else
				this.highlight(this.CallBtn);
			break;
	}
}

SceneSettingsCallForwarding.prototype.processRightKey = function() {
	alert("SceneSettingsCallForwarding.processRightKey() ");
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.CallBtn:
			this.BeforeBtn = currentHighlight;
			if(this.IsEnableSaveBtn == true)
				this.highlight(this.SaveBtn);
			else
				this.highlight(this.CancelBtn);
			break;
		case this.TimeBtn:
			this.BeforeBtn = currentHighlight;
			this.highlight(this.CancelBtn);
			break;
		case this.CountryCodeBtn[0]:
			this.highlight(this.PhoneNumberBox[0]);
			break;
		case this.CountryCodeBtn[1]:
			this.highlight(this.PhoneNumberBox[1]);
			break;
		case this.CountryCodeBtn[2]:
			this.highlight(this.PhoneNumberBox[2]);
			break;
		case this.PhoneNumberBox[0]:
			this.BeforeBtn = currentHighlight;
			if(this.IsEnableSaveBtn == true)
				this.highlight(this.SaveBtn);
			else
				this.highlight(this.CancelBtn);
			break;
		case this.PhoneNumberBox[1]:
			this.BeforeBtn = currentHighlight;
			if(this.IsEnableSaveBtn == true)
				this.highlight(this.SaveBtn);
			else
				this.highlight(this.CancelBtn);
			break;
		case this.PhoneNumberBox[2]:
			this.BeforeBtn = currentHighlight;
			if(this.IsEnableSaveBtn == true)
				this.highlight(this.SaveBtn);
			else
				this.highlight(this.CancelBtn);
			break;
		case this.SaveBtn:
			break;
		case this.CancelBtn:
			break;
	}

}

SceneSettingsCallForwarding.prototype.processDownKey = function() {
	alert("SceneSettingsCallForwarding.processDownKey() ");
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();
	switch(currentHighlight) {
		case this.CallBtn:
			if(this.IsEnable == true)
				this.highlight(this.PhoneNumberBox[0]);
			break;
		case this.TimeBtn:
			break;
		case this.CountryCodeBtn[0]:
			this.highlight(this.CountryCodeBtn[1]);
			break;
		case this.CountryCodeBtn[1]:
			this.highlight(this.CountryCodeBtn[2]);
			break;
		case this.CountryCodeBtn[2]:
			this.highlight(this.TimeBtn);
			break;
		case this.PhoneNumberBox[0]:
			this.highlight(this.PhoneNumberBox[1]);
			break;
		case this.PhoneNumberBox[1]:
			this.highlight(this.PhoneNumberBox[2]);
			break;
		case this.PhoneNumberBox[2]:
			this.highlight(this.TimeBtn);
			break;
		case this.SaveBtn:
			this.highlight(this.CancelBtn);
			break;
		case this.CancelBtn:
			break;
	}
}

SceneSettingsCallForwarding.prototype.processUpKey = function() {
	alert("SceneSettingsCallForwarding.processUpKey() ");
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();

	switch(currentHighlight) {
		case this.CallBtn:
			break;
		case this.TimeBtn:
			this.highlight(this.PhoneNumberBox[2]);
			break;
		case this.CountryCodeBtn[0]:
			this.highlight(this.CallBtn);
			break;
		case this.CountryCodeBtn[1]:
			this.highlight(this.CountryCodeBtn[0]);
			break;
		case this.CountryCodeBtn[2]:
			this.highlight(this.CountryCodeBtn[1]);
			break;
		case this.PhoneNumberBox[0]:
			this.highlight(this.CallBtn);
			break;
		case this.PhoneNumberBox[1]:
			this.highlight(this.PhoneNumberBox[0]);
			break;
		case this.PhoneNumberBox[2]:
			this.highlight(this.PhoneNumberBox[1]);
			break;
		case this.SaveBtn:
		//	this.highlight(this.CallBtn);
			break;
		case this.CancelBtn:
			if(this.IsEnableSaveBtn)
				this.highlight(this.SaveBtn);
			/*
			else
							this.highlight(this.CallBtn);*/
			
			break;
	}
}

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

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

SceneSettingsCallForwarding.prototype.processReturnKey = function() {
	alert("SceneSettingsCallForwarding.processReturnKey() ");
	StateMgr.Stop_SettingsCallForwarding_State(true);
}

SceneSettingsCallForwarding.prototype.processEnterKey = function() {
	alert("SceneSettingsCallForwarding.processEnterKey() ");
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();
	var scene = sf.scene.get("SettingsCallForwarding");
	switch(currentHighlight) {
		case this.CallBtn:
			this.ShownOnOffSubList = true;
			WndMgr.StartSettingsOnOffSubList(this.CallBtn, this.sceneId, this.SettingsCallForwardingView, this.SublistCallBack/*callback*/, this.CallBtn.GetText());
			
			break;
		case this.TimeBtn:
			/*
			if(this.IsEnableSaveBtn)
							this.highlight(this.SaveBtn);
						else
							this.highlight(this.CancelBtn);*/
			
			break;
		case this.CountryCodeBtn[0]:
			this.showCountryList(0);
			break;
		case this.CountryCodeBtn[1]:
			this.showCountryList(1);
			break;
		case this.CountryCodeBtn[2]:
			this.showCountryList(2);
			break;
		case this.PhoneNumberBox[0]:
			break;
		case this.PhoneNumberBox[1]:
			break;
		case this.PhoneNumberBox[2]:
			break;
		case this.SaveBtn:
			this.SaveCallForwardingData();
			break;
		case this.CancelBtn:
			this.processReturnKey();
			break;
	}
}
SceneSettingsCallForwarding.prototype.ChangeHelpbar = function(type,str) {
	var dataInfo="";
	if(str){
		dataInfo = str;
	}else{
		switch(type){
			case 0:
				dataInfo = {
					'return' : SID_RETURN
				};
				break;
			case 1:
				dataInfo = {
			'ff' : SID_NUMBER,
			'play' : SID_DELETE, //not support
			'return' : SID_RETURN
		};
				break;
			case 2:
				dataInfo = {
					'ff' : SID_NUMBER,
					'stop' : "+",
			'return' : SID_RETURN
		};
				break;
			case 3:
				dataInfo = {
			'ff' : SID_NUMBER,
			'return' : SID_RETURN
		};
				break;
		}
	}
	if(dataInfo.length!=0)
		this.SettingsCallForwardingBG.SetHelpbarContentsOfPopupBG(dataInfo);
}
/*
SceneSettingsCallForwarding.prototype.checkHelpbarForInputBox = function(){
	alert("SceneSettingsCallForwarding.checkHelpbarForInputBox()");
	var obj = this.SettingsCallForwardingView.getCurrentHighlight();
	if( !(obj==this.PhoneNumberBox[0]|| obj==this.PhoneNumberBox[1]|| obj==this.PhoneNumberBox[2]))
		return ;
		
	var posOfCaret = obj.GetPosOfCaret();
	if(posOfCaret==0){		//no string '+' : show, delete : hide
		this.ChangeHelpbar(2);
	}else{						//exist string -> '+' : hide, delete : show						
		this.ChangeHelpbar(1);
	}
}*/


SceneSettingsCallForwarding.prototype.processMouseOver = function(obj) {
	//add : smartcontrol highlight issue(130926)
	if(PluginAPIMgr.FlagSmartControlNumber()==1){
		return;
	}
	var currentHighlight = this.SettingsCallForwardingView.getCurrentHighlight();
	if(currentHighlight != obj) {
		this.highlight(obj);
	}
	WndMgr.resetPopupHideTimer();
}
SceneSettingsCallForwarding.prototype.highlight = function(obj) {
	alert("SceneSettingsCallForwarding.highlight() ");
	this.SettingsCallForwardingView.setCurrenHighlight(obj);
	switch(obj) {
		case this.PhoneNumberBox[0]:
		case this.PhoneNumberBox[1]:
		case this.PhoneNumberBox[2]:
		//	this.checkHelpbarForInputBox();
			break;
		case this.TimeBtn:
			this.ChangeHelpbar(1);
			break;
		default:
			this.ChangeHelpbar(0);
			break;
	}
}

SceneSettingsCallForwarding.prototype.IsValidNumbers = function() {
	//return true;
	if(this.IsEnable) {
		for(var i = 0; i < 3; i++) {
			var phoneNumber = this.PhoneNumberBox[i].GetText();
			if((phoneNumber != null) && (phoneNumber.length > 0)) {
				var totalNumber = this.addPrefix(this.Curr_CountryCode[i], phoneNumber);
				alert("totalNumber : " + totalNumber);
				var normalized_phone_number = PluginAPIMgr.NormalizeIdentity(totalNumber);

				if(normalized_phone_number.length <= 0) {
					return false;
				} else {
					var isEmergencyCall = PluginAPIMgr.IsEmergencyCall(normalized_phone_number);
					if(isEmergencyCall == 1) {
						return false;
					}
				}
			}
		}
		return true;
	} else {
		return true;
	}
}

SceneSettingsCallForwarding.prototype.addPrefix = function(countrycode, input_phone_number) {
	if(input_phone_number == null || input_phone_number.length == 0)
		return "";
	if(input_phone_number.indexOf("+") == 0) {
		return input_phone_number;
	} else if(input_phone_number.indexOf("00") == 0) {
		return input_phone_number;
	} else if(input_phone_number.indexOf("011") == 0) {
		return input_phone_number;
	} else {
		var prefix = PluginAPIMgr.GetISOCountryPrefix(countrycode);
		if(prefix != "0") {
			return "+" + prefix + input_phone_number;
		} else {
			return input_phone_number;
		}
	}
}
SceneSettingsCallForwarding.prototype.MakeForwardingNumbers = function() {
	var timeLimits = ["0", "60", "120", "180"];
	var recordIndex = 0;
	var NumberList = "";
	var divider = "";

	for(var i = 0; i < 3; i++) {
		var localNumber = this.PhoneNumberBox[i].GetText();
		var countrycode = this.Curr_CountryCode[i];
		var number = this.addPrefix(countrycode, localNumber);

		alert("index : " + i);
		alert("Local number: " + localNumber);
		alert("code: " + countrycode);
		alert("Number: " + number);

		if(localNumber.length !== 0) {
			if(recordIndex > 0)
				divider = this.splitCharSpace;
			NumberList = NumberList + divider + timeLimits[recordIndex] + this.splitCharComma + timeLimits[recordIndex + 1] + this.splitCharComma + number;
			recordIndex++;
		}
	}
	alert("SceneSettingsCallForwarding.MakeForwardingNumbers()" + NumberList);
	return NumberList;
}
SceneSettingsCallForwarding.prototype.SaveSuccess = function() {
	alert("SceneSettingsCallForwarding.SaveSuccess");
	if(this.waitingCommit == false) {
		StateMgr.Stop_SettingsCallForwarding_State(true);
		this.Init_CallForwardStrings = this.CallForwardStrings;
		this.Init_CallForward = this.CallBtn.GetText();
		this.Init_Time = this.TimeBtn.GetText();
	}
}
SceneSettingsCallForwarding.prototype.SaveCallForwardingData = function() {
	alert("SceneSettingsCallForwarding.SaveCallForwardingData");
	if(this.isCheckEnable == true || this.IsSkypeOutEnable() == true) {
		this.isCheckEnable = false;

		if(this.IsValidNumbers() == true) {
			//if(this.CallBtn.GetText() == SID_ON) {

				if(this.IsChangeCallForward) {
				//	alert("KJY : callforwarding state saved");
					PluginAPIMgr.SetCallForward(this.CallBtn.GetText());
				}
				if(this.CallBtn.GetText() == SID_ON){
					if(this.IsChangeTime) {
					//	alert("KJY : time saved");
						PluginAPIMgr.SetCallForwardTimer(this.TimeBtn.GetText());
					}
				}else{
					if(PluginAPIMgr.GetVoicemailForward() != SID_ON) {
						PluginAPIMgr.SetCallForwardTimer(g_Data.DATA_DEFAULT_CALL_FORWARDING_TIME);
					}
				}
				if(this.IsChangePhoneNumbers() || this.IsChangeCountryCode()) {
					//invalid
				//	alert("KJY : time IsChangePhoneNumbers");
					this.waitingCommit = true;
					this.CallForwardStrings = this.MakeForwardingNumbers();
					PluginAPIMgr.SetCallForwardNumbers(this.CallForwardStrings);
				}
				WndMgr.SetCurrentPopupSceneId(this.sceneId);
				WndMgr.HideSettingsCallForwarding();
				if(this.waitingCommit == true) {
					WndMgr.StartLoading(LoadingTypeIndex.WAIT);
				} else {
					WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_OK);
				}

			//} else {
				/*
				if(this.IsChangeCallForward) {
								//	alert("KJY : callforwarding off state saved");
									PluginAPIMgr.SetCallForward(this.CallBtn.GetText());
									
									WndMgr.SetCurrentPopupSceneId(this.sceneId);
									WndMgr.HideSettingsCallForwarding();
									WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_OK);
								}
								
								if(this.IsChangePhoneNumbers() || this.IsChangeCountryCode()) {
									//invalid
								//	alert("KJY : time IsChangePhoneNumbers");
									this.waitingCommit = true;
									this.CallForwardStrings = this.MakeForwardingNumbers();
									PluginAPIMgr.SetCallForwardNumbers(this.CallForwardStrings);
								}*/
				
			//}
		} else {
			//alert("KJY : callforwarding OPTIONS_WRONG_NUMBER");
			WndMgr.SetCurrentPopupSceneId(this.sceneId);
			WndMgr.HideSettingsCallForwarding();
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_WRONG_NUMBER);
			/*return;*/
		}
	} else {
		//alert("KJY : callforwardingOPTIONS_SKYPEOUT_DISABLED");
		WndMgr.SetCurrentPopupSceneId(this.sceneId);
		WndMgr.HideSettingsCallForwarding();
		WndMgr.StartOneBottonPopup(OneBtnPopupIndex.OPTIONS_SKYPEOUT_DISABLED);
	}

}
SceneSettingsCallForwarding.prototype.IsSkypeOutEnable = function() {
	this.isCheckEnable = true;
	if(PluginAPIMgr.GetAccountCapability(ENUM_CONTACT_CAPABILITY.CAPABILITY_SKYPEOUT) !== "1")
		return true;
	else
		return false;
}
SceneSettingsCallForwarding.prototype.SublistCallBack = function(result) {
	alert("SceneSettingsCallForwarding.SublistCallBack");
	var this_ = sf.scene.get("SettingsCallForwarding");

	if(this_.Init_CallForward != result) {
		this_.IsChangeCallForward = true;
	} else {
		this_.IsChangeCallForward = false;
	}
	if(result === SID_OFF) {
		this_.disable();
		this.IsEnable = false;
	} else {
		this_.enable();
		this.IsEnable = true;
	}
	this_.IsChange("ONOFF");
}
SceneSettingsCallForwarding.prototype.IsChangeCountryCode = function() {
	for(var i = 0; i < 3; i++) {
		if(this.Init_CountryCode[i] != this.Curr_CountryCode[i])
			return true;
	}
	return false;
}
SceneSettingsCallForwarding.prototype.IsChangePhoneNumbers = function() {
	for(var i = 0; i < 3; i++) {
		if(this.Init_PhoneNumbers[i] != this.PhoneNumberBox[i].GetText())
			return true;
	}
	return false;
}
SceneSettingsCallForwarding.prototype.IsChange = function(caller) {
	alert("SceneSettingsCallForwarding.IsChange() " + caller);
	switch(caller) {
		case "ONOFF":
			if(this.IsChangeCallForward) {
				this.setSaveBtnEnable(true);
			} else if(this.IsChangeCallForward == false && (this.IsChangeCountryCode() || this.IsChangePhoneNumbers() || this.IsChangeTime)) {
				this.setSaveBtnEnable(true);
			} else {
				this.setSaveBtnEnable(false);
			}
			break;
		case "COUNTRYCODE":
			var changed = this.IsChangeCountryCode();
			if(changed) {
				this.setSaveBtnEnable(true);
			} else if(changed == false && (this.IsChangeCallForward || this.IsChangePhoneNumbers() || this.IsChangeTime)) {
				this.setSaveBtnEnable(true);
			} else {
				this.setSaveBtnEnable(false);
			}
			break;
		case "NUMBERS":
			var changed = this.IsChangePhoneNumbers();
			if(changed) {
				this.setSaveBtnEnable(true);
			} else if(changed == false && (this.IsChangeCallForward || this.IsChangeCountryCode() || this.IsChangeTime)) {
				this.setSaveBtnEnable(true);
			} else {
				this.setSaveBtnEnable(false);
			}
			break;
		case "TIME":
			if(this.Init_Time != this.TimeBtn.GetText()) {
				this.setSaveBtnEnable(true);
				this.IsChangeTime = true;
			} else if((this.Init_Time == this.TimeBtn.GetText()) && (this.IsChangeCallForward || this.IsChangeCountryCode() || this.IsChangePhoneNumbers())) {
				this.setSaveBtnEnable(true);
				this.IsChangeTime = true;
			} else {
				this.setSaveBtnEnable(false);
				this.IsChangeTime = false;
			}
			break;
	}
	// phonenumber box 3 ea
}
SceneSettingsCallForwarding.prototype.setSaveBtnEnable = function(flag_enable) {
	alert("SceneSettingsCallForwarding.setSaveBtnEnable() : ");

	if(flag_enable == true) {
		this.SaveBtn.SetFlagDim(false);
		this.IsEnableSaveBtn = true;
	} else if(flag_enable == false) {
		this.SaveBtn.SetFlagDim(true);
		this.IsEnableSaveBtn = false;
	}
}

SceneSettingsCallForwarding.prototype.showCountryList = function(Btnidx) {
	alert("SceneProfilePhoneNumberSet.showCountryList() btnIdx :" + Btnidx);

	var this_ = sf.scene.get("SettingsCallForwarding");
	var Index = g_Data.GetCountryIndexWithCode(this.Curr_CountryCode[Btnidx]);
	this.CountryCodeIndex = Btnidx;
	sf.scene.get("CountryFlagList").Init(FLAG_LIST_TYPE.LIST_MAIN_CALL, "SettingsCallForwarding", this_.SetCountryList, null);
	sf.scene.get("CountryFlagList").SetCurIndex(Index);
	sf.scene.show('CountryFlagList');

	setTimeout("CloseTimerCF()", 0);
	CloseTimerCF = function() {
		sf.scene.focus('CountryFlagList');
	}
	this.ShownCountryList = true;
}

SceneSettingsCallForwarding.prototype.SetCountryList = function() {
	alert("SceneSettingsCallForwarding.SetCountryList() ");
	var this_ = sf.scene.get("SettingsCallForwarding");
	var Scene = sf.scene.get("CountryFlagList");
	var FlagImage = Scene.GetCountryFlag();
	var CountryCode = Scene.GetCountryCode();
	//var Prefix = Scene.GetPrefix();

	this_.SetCountryData(this_.CountryCodeIndex, CountryCode, FlagImage);
}

SceneSettingsCallForwarding.prototype.SetCountryData = function(idx, code, flagImage) {
	this.Curr_CountryCode[idx] = code;
	//Set UI
	this.CountryCodeBtn[idx].SetFgImage(flagImage);
	this.IsChange("COUNTRYCODE");
}

SceneSettingsCallForwarding.prototype.enable = function() {
	alert("SceneSettingsCallForwarding.enable");
	if(this.IsEnable == true)
		return;
	for(var i = 0; i < this.maxPhones; i++) {
		this.CountryCodeBtn[i].SetFlagDim(false);
		this.PhoneNumberBox[i].SetFlagDim(false);
		$("#" + this.CountryCodeBtn[i].GetObjId()).css("opacity", "1.0");
		$("#" + this.PhoneNumberBox[i].GetObjId()).css("opacity", "1.0");
		$("#" + this.TimeBtn.GetObjId()).css("opacity", "1.0");
	}
	this.TimeBtn.SetFlagDim(false);
	this.IsEnable = true;
}

SceneSettingsCallForwarding.prototype.disable = function() {
	alert("SceneSettingsCallForwarding.disable");
	if(this.IsEnable == false)
		return;
	for(var i = 0; i < this.maxPhones; i++) {
		this.CountryCodeBtn[i].SetFlagDim(true);
		this.PhoneNumberBox[i].SetFlagDim(true);
		$("#" + this.CountryCodeBtn[i].GetObjId()).css("opacity", "0.6");
		$("#" + this.PhoneNumberBox[i].GetObjId()).css("opacity", "0.6");
		$("#" + this.TimeBtn.GetObjId()).css("opacity", "0.6");
		this.PhoneNumberBox[i].SetText("");
	}
	this.TimeBtn.SetFlagDim(true);
	this.IsEnable = false;
}

SceneSettingsCallForwarding.prototype.InitBase = function() {
	alert("SceneSettingsCallForwarding.InitBase");
	this.Init_CallForward = PluginAPIMgr.GetCallForward();
	this.Init_CallForwardStrings = PluginAPIMgr.GetCallForwardNumbers();

	alert("Packet :" + this.Init_CallForwardStrings);

	this.DefaultCountry = PluginAPIMgr.GetMyCountryCode();

	var offset = 2;

	for(var i = 0; i < this.maxPhones; i++) {
		this.Init_CountryCode[i] = this.DefaultCountry;
		this.Init_PhoneNumbers[i] = "";
		this.Curr_CountryCode[i] = this.DefaultCountry;
	}

	if(this.Init_CallForwardStrings) {
		var set = this.Init_CallForwardStrings.split(this.splitCharSpace);
		alert("forwarding number : " + set.length);
		for(var i = 0; i < set.length; i++) {
			alert("Index: " + i);
			var item = set[i].split(this.splitCharComma);
			alert("item.length: " + item.length);

			alert("item: " + item);
			alert("item[offset]: " + item[offset]);
			if(!item || item[offset] === undefined) {
				continue;
			}
			this.Init_CountryCode[i] = PluginAPIMgr.FindCountryCodeByNumber(item[offset]);
			this.Init_PhoneNumbers[i] = PluginAPIMgr.GetLocalNumber(item[offset]);
			this.Curr_CountryCode[i] = this.Init_CountryCode[i];
			if(this.Init_CountryCode[i].length == 0) {
				this.Init_CountryCode[i] = this.DefaultCountry;
				this.Curr_CountryCode[i] = this.DefaultCountry;
			}

		}
	}

}
SceneSettingsCallForwarding.prototype.InitCallForwarding = function() {
	alert("SceneSettingsCallForwarding.InitCallForwarding");

	this.CallBtn.SetText(this.Init_CallForward);
	var forwardingtime = PluginAPIMgr.GetCallForwardTimer();
	if(forwardingtime)
		this.Init_Time = forwardingtime;
	else
		this.Init_Time = 10;
	this.TimeBtn.SetText(this.Init_Time);
	for(var i = 0; i < this.maxPhones; i++) {
		this.CountryCodeBtn[i].SetFgImage(g_Image.base_flag_image_path + this.Init_CountryCode[i].toUpperCase() + ".png");
		this.PhoneNumberBox[i].SetText(this.Init_PhoneNumbers[i]);
	}
	if(this.Init_CallForward == SID_OFF) {
		this.disable();
		this.IsEnable = false;
	} else {
		this.enable();
		this.IsEnable = true;
	}
	this.IsChangeTime = false;
	this.IsChangeCallForward = false;
	this.IsEnableSaveBtn = false;

}
SceneSettingsCallForwarding.prototype.create = function() {
	alert("SceneSettingsCallForwarding.create()");
	this.SettingsCallForwardingView = new View("SettingsCallForwarding");
	this.SettingsCallForwardingBG = new View("SettingsCallForwardingBG");
	this.SettingsCallForwardingBG.CreatePopupBG(0, "SettingsCallForwarding_popup_BG");
	this.SettingsCallForwardingBG.CreateInnerBox("SettingsCallForwarding_popup_innerbox");
	this.SettingsCallForwardingBG.SetTitleTextofPopupBG(IDWS_MOIP_SKYPE_CALL_FORWARDING);
	this.SettingsCallForwardingDim = new DimBg("SettingsCallForwardingDim", "SettingsCallForwardingBG");

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

	this.CallForwardingLabel = new Label(null, "settingscallforwarding_call_forwarding_label");
	this.CallForwardingLabel.SetTextStyle("settingscallforwarding_label_style");
	//this.CallForwardingLabel.SetReverseDisable(true);
	if(ResMgr.isReverseLanguage()) {
		this.CallForwardingLabel.SetText(IDWS_MOIP_SKYPE_CALL_FORWARDING);
	} else {
		this.CallForwardingLabel.SetText(IDWS_MOIP_SKYPE_CALL_FORWARDING + " :");
	}

	this.TimeLabel = new Label(null, "settingscallforwarding_time_label");
	this.TimeLabel.SetTextStyle("settingscallforwarding_label_style");
	//this.TimeLabel.SetReverseDisable(true);
	if(ResMgr.isReverseLanguage()) {
		this.TimeLabel.SetText(TV_SID_FORWARDING_TIME_SETTING);
	} else {
		this.TimeLabel.SetText(TV_SID_FORWARDING_TIME_SETTING + " :");
	}
    if(this.TimeLabel.text_layer.GetTextMinHeight()>30){
        $("#settingscallforwarding_time_label").css("top","395px");
    }else{
        $("#settingscallforwarding_time_label").css("top","411px");
    }
	this.SecondsLabel = new Label(null, "settingscallforwarding_seconds_label");
	this.SecondsLabel.SetTextStyle("settingscallforwarding_label_style");
	this.SecondsLabel.SetText(COM_TV_IDWS_MOIP_SECONDS);

	var CurLangID = ResMgr.GetCurLanguage();


	this.SkypeCreditLabel = new Label(null, "settingscallforwarding_skype_credit_label");
	this.SkypeCreditLabel.SetTextStyle("settingscallforwarding_label_style");
	this.SkypeCreditLabel.SetText(IDWS_MOIP_NEED_TO_PURCHASE);

	this.CallBtn = new Button();
	this.CallBtn.SetImageObjId("settingscallforwarding_call_btn", 15);
	this.CallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_BASIC_BUTTON_NORMAL);
	this.CallBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_BASIC_BUTTON_FOCUS);
	this.CallBtn.SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_BASIC_BUTTON_DIM);
	this.CallBtn.SetTextObjId("settingscallforwarding_call_btn_txt");
	this.CallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.CallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.CallBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.CallBtn.SetIconObjId("settingscallforwarding_call_btn_arrow");
	this.CallBtn.SetBgIcon(0, g_Image.IMAGE_POPUP_BTN_ARROW_DOWN);
	this.CallBtn.SetOnClickCallbackFunc(clickCF);
	

	this.TimeBtn = new NumberInputBox();
	this.TimeBtn.SetButtonObjId("settingscallforwarding_time_input_box", 30);
	this.TimeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_TEXT_INPUT_NORMAL);
	this.TimeBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_TEXT_INPUT_FOCUS);
	this.TimeBtn.SetButtonTextObjId("settingscallforwarding_time_input_text");
	this.TimeBtn.SetInputBoxObjId("settingscallforwarding_time_input_text_editor");
	this.TimeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
	this.TimeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "image_text_box_focus_style");
	this.TimeBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "image_text_box_dim_style");

	this.TimeBtn.setPrevEventOnLeftFunc(function() {
		scene.processLeftKey();
		WndMgr.resetPopupHideTimer();
	});
	this.TimeBtn.setPrevEventOnRightFunc(function() {
		scene.processRightKey();
		WndMgr.resetPopupHideTimer();
	});
	this.TimeBtn.setPrevEventOnDownFunc(function() {
		scene.processDownKey();
		WndMgr.resetPopupHideTimer();
	});
	this.TimeBtn.setPrevEventOnUpFunc(function() {
		scene.processUpKey();
		WndMgr.resetPopupHideTimer();
	});
	this.TimeBtn.setEnterFunc(function() {
		scene.processEnterKey();
		WndMgr.resetPopupHideTimer();
	});
	this.TimeBtn.setPrevEventOnReturnFunc(function() {
		scene.processReturnKey();
	});
	this.TimeBtn.setPrevEventOnExitFunc(function() {
		scene.processReturnKey();
	});
	this.TimeBtn.setAnyKeyFunc(function(keyCode) {
		scene.IsChange("TIME");
		WndMgr.resetPopupHideTimer();
	});
	this.TimeBtn.setMaxLength(3);
	this.TimeBtn.setFlagPhoneNumber(false);
	this.TimeBtn.SetHelpbarChangeEnable("SettingsCallForwarding");
	this.TimeBtn.SetOnClickCallbackFunc(clickCF);

	this.CountryCodeBtn = new Array(this.maxPhones);
	this.PhoneNumberBox = new Array(this.maxPhones);
	this.Curr_CountryCode = new Array(this.maxPhones);
	this.Init_CountryCode = new Array(this.maxPhones);
	this.Init_PhoneNumbers = new Array(this.maxPhones);

	var country_code = "settingscallforwarding_country_code_";
	var phone_number = "settingscallforwarding_phone_number_";
	for(var i = 0; i < this.maxPhones; i++) {
		this.CountryCodeBtn[i] = new Button();
		this.CountryCodeBtn[i].SetImageObjId(country_code + "btn" + i, 15);
		this.CountryCodeBtn[i].SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_BASIC_BUTTON_NORMAL);
		this.CountryCodeBtn[i].SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_BASIC_BUTTON_FOCUS);
		this.CountryCodeBtn[i].SetBgImage(BtnImgIndex.BTN_DIM_IMG, g_Image.IMAGE_BASIC_BUTTON_DIM);
		this.CountryCodeBtn[i].AppendFgImage(country_code + "icon" + i);
		this.CountryCodeBtn[i].SetIconObjId(country_code + "btn_arrow_" + i);
		this.CountryCodeBtn[i].SetBgIcon(BtnIconIndex.BTN_NORMAL_ICON, g_Image.IMAGE_POPUP_BTN_ARROW_DOWN);
		this.CountryCodeBtn[i].SetOnClickCallbackFunc(clickCF);
		this.CountryCodeBtn[i].SetOnMouseOverCallbackFunc(function(obj) {
			this_.processMouseOver(obj);
		});

		this.PhoneNumberBox[i] = new NumberInputBox();
		this.PhoneNumberBox[i].SetButtonObjId(phone_number + "input_box" + i, 30);
		this.PhoneNumberBox[i].SetButtonTextObjId(phone_number + "input_text" + i);
		this.PhoneNumberBox[i].SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_TEXT_INPUT_NORMAL);
		this.PhoneNumberBox[i].SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_TEXT_INPUT_FOCUS);

		this.PhoneNumberBox[i].SetInputBoxObjId(phone_number + "input_text_editor" + i);
		this.PhoneNumberBox[i].SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "image_text_box_normal_style");
		this.PhoneNumberBox[i].SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "image_text_box_focus_style");
		this.PhoneNumberBox[i].SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "image_text_box_dim_style");
		if(CurLangID == ENUM_TV_LANGUAGE.KOR) {
			$("#" + phone_number + "phone_number" + i).css("font-size", "22px");
		}
		this.PhoneNumberBox[i].setPrevEventOnLeftFunc(function() {
			scene.processLeftKey();
			WndMgr.resetPopupHideTimer();
		});
		this.PhoneNumberBox[i].setPrevEventOnRightFunc(function() {
			scene.processRightKey();
			WndMgr.resetPopupHideTimer();
		});
		this.PhoneNumberBox[i].setPrevEventOnDownFunc(function() {
			scene.processDownKey();
			WndMgr.resetPopupHideTimer();
		});
		this.PhoneNumberBox[i].setPrevEventOnUpFunc(function() {
			scene.processUpKey();
			WndMgr.resetPopupHideTimer();
		});
		this.PhoneNumberBox[i].setEnterFunc(function() {
			WndMgr.resetPopupHideTimer();
			scene.processEnterKey();
		});
		this.PhoneNumberBox[i].setPrevEventOnReturnFunc(function() {
			scene.processReturnKey();
		});
		this.PhoneNumberBox[i].setPrevEventOnExitFunc(function() {
			scene.processReturnKey();
		});
		this.PhoneNumberBox[i].setAnyKeyFunc(function(keyCode) {
			scene.IsChange("NUMBERS");
			WndMgr.resetPopupHideTimer();
		});
		this.PhoneNumberBox[i].setMaxLength(30);
		this.PhoneNumberBox[i].SetReverseDisable(true);
		this.PhoneNumberBox[i].SetHelpbarChangeEnable("SettingsCallForwarding");
		this.PhoneNumberBox[i].SetOnClickCallbackFunc(clickCF);
		this.PhoneNumberBox[i].SetOnMouseOverCallbackFunc(function(obj) {
			this_.processMouseOver(obj);
		});
	}
	this.SaveBtn = new Button();
	this.SaveBtn.SetImageObjId("settingscallforwarding_save_btn", 20);
	this.SaveBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_IMG, g_Image.IMAGE_POPUP_BTN_NORMAL);
	this.SaveBtn.SetBgImage(BtnImgIndex.BTN_NORMAL_FOCUS_IMG, g_Image.IMAGE_POPUP_BTN_NORMALFOCUS);
	this.SaveBtn.SetTextObjId("settingscallforwarding_save_btn_text");
	this.SaveBtn.SetText(SID_SAVE);
	this.SaveBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_NORMAL_STYLE, "popup_btn_text_normal_style");
	this.SaveBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_FOCUS_STYLE, "popup_btn_text_focus_style");
	this.SaveBtn.SetTextStyle(BtnTextStyleIndex.BTN_TEXT_DIM_STYLE, "popup_btn_text_dimmed_style");
	this.SaveBtn.SetOnClickCallbackFunc(clickCF);

	this.CancelBtn = new Button();
	this.CancelBtn.SetImageObjId("settingscallforwarding_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("settingscallforwarding_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.CallBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.TimeBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.SaveBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	this.CancelBtn.SetOnMouseOverCallbackFunc(function(obj) {
		this_.processMouseOver(obj);
	});
	if(ResMgr.isReverseLanguage()==true){
	    var timeVal = $("#settingscallforwarding_time_label").css("left");
	    var inputVal = $("#settingscallforwarding_time_input_box").css("left");
	    var secVal = $("#settingscallforwarding_seconds_label").css("left");
	    $("#settingscallforwarding_time_label").css("left","auto");
        $("#settingscallforwarding_time_input_box").css("left","auto");
        $("#settingscallforwarding_seconds_label").css("left","auto");
        $("#settingscallforwarding_time_label").css("right",timeVal);
        $("#settingscallforwarding_time_input_box").css("right",inputVal);
        $("#settingscallforwarding_seconds_label").css("right",secVal);
	}
	
	
}
