var MAX_LAST_LOGIN_ID = 5;

function SceneLastLoginIdList(options) {

	this.options			= options;	
	this.list				= null;
	this.list_top			= null;
	this.list_bottom			= null;
	this.lastLoginIdArray	= new Array(MAX_LAST_LOGIN_ID);
	
	this.showstate			= false;
	
	this.callerScene = "";
	
	this.HelpBar			= null;	
}

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

SceneLastLoginIdList.prototype.handleShow = function () {
	alert("SceneLastLoginIdList.handleShow()");
    this.ResetData();
	this.list.Show();
	this.showstate = true;
	
	// this.HelpBar.visibleObj();	
}

SceneLastLoginIdList.prototype.handleHide = function () {
	alert("SceneLastLoginIdList.handleHide()");
	this.ResetBG();
	if(this.list){
		
		this.list.Hide();	
		this.showstate = false;
	}
	
	// this.HelpBar.hiddenObj();	
}

SceneLastLoginIdList.prototype.handleFocus = function () {
	alert("SceneLastLoginIdList.handleFocus()");
	
	this.list.Flag_Focus = true;
	if(this.list.GetMaxNumOfData() > 0){
		this.list.SetCurrentItem(0);
	}
	else{
		alert("No Previous Login ID");
	}
	
}

SceneLastLoginIdList.prototype.handleBlur = function () {
	alert("SceneLastLoginIdList.handleBlur()");
}

SceneLastLoginIdList.prototype.handleKeyDown = function (keyCode) {
	
	alert("SceneLastLoginIdList.handleKeyDown(" + keyCode + ")");
	PluginAPIMgr.PlayAudio(keyCode);
	if(ProcMgr.checkWidgetHighlight()==false){
		return;
	}
	this.list.KeyProcess(keyCode);	

}

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

SceneLastLoginIdList.prototype.create = function(){
    alert("SceneLastLoginIdList.create() ");
    
    this.list_left = "LoginIdList_Top";
    this.list_right = "LoginIdList_Bottom";

	this.list = new List();
	this.list.CreateBG("LoginIdList", true);
	this.list.SetBGImage(g_Image.IMAGE_LOGIN_LAST_LOGIN_ID_LIST_BG);	
	this.list.SetNumOfVisibleItem(5);
	this.list.SetStartDataIndex(0);
	this.list.SetItemBgImage(ITEM_STATE.NORMAL," ");
	this.list.SetItemBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_LOGIN_LAST_LOGIN_ID_ITEM_HIGHLIGHT_BG);
	this.list.SetItemDefualtTextStyle(ITEM_STATE.NORMAL,"cLoginIdList_Text_Normal");
	this.list.SetItemDefualtTextStyle(ITEM_STATE.HIGHLIGHT,"cLoginIdList_Text_Highlight");
	this.list.SetDataType(ITEM_DATA_TYPE.TEXT_ONLY);
	this.list.SetEventOnReturnFunc(this.ProcessKeyReturn);
	this.list.SetEventOnExitFunc(this.ProcessKeyReturn);
	this.list.SetItemPressedEventCallback(this.ProcessKeyEnter);

	//Set Click Event
	this.list.SetOnClickCallbackFunc(0,this.onClickEventFunc1);
	this.list.SetOnClickCallbackFunc(1,this.onClickEventFunc2);
	this.list.SetOnClickCallbackFunc(2,this.onClickEventFunc3);
	this.list.SetOnClickCallbackFunc(3,this.onClickEventFunc4);
	this.list.SetOnClickCallbackFunc(4,this.onClickEventFunc5);	
	this.list.SetOnMouseOverCallbackFunc(0,this.onMouseOverEventFunc1);
	this.list.SetOnMouseOverCallbackFunc(1,this.onMouseOverEventFunc2);
	this.list.SetOnMouseOverCallbackFunc(2,this.onMouseOverEventFunc3);
	this.list.SetOnMouseOverCallbackFunc(3,this.onMouseOverEventFunc4);
	this.list.SetOnMouseOverCallbackFunc(4,this.onMouseOverEventFunc5);	
	this.list.SetClickEventAvailable(WndMgr.MouseClickEnable);	
	
	// this.HelpBar = new HelpBar(HelpBarIndex.SIGNIN_LAST_ID_LIST, "LastLoginIdList");
		
}

SceneLastLoginIdList.prototype.setCallerScene = function(caller){
	this.callerScene = caller;	
	alert("SceneLastLoginIdList.setCallerScene() "+ this.callerScene);
}

SceneLastLoginIdList.prototype.ProcessKeyReturn = function(){

	var scene = sf.scene.get("LastLoginIdList");
	sf.scene.focus(scene.callerScene);
	sf.scene.hide('LastLoginIdList');

}

SceneLastLoginIdList.prototype.ProcessKeyEnter = function(){
	
	var scene = sf.scene.get("LastLoginIdList");	
	var Index = scene.list.GetCurrentItem();
	
	alert("ProcessKeyEnter >>  Index = " + Index );
	
    sf.scene.get(scene.callerScene).SetSkypeNameFromLoginIdList(scene.lastLoginIdArray[Index]);	
	sf.scene.hide('LastLoginIdList');
	
}

SceneLastLoginIdList.prototype.ShowState = function(){

	return this.showstate;

}

SceneLastLoginIdList.prototype.ResetData = function(){

	this.list.DeleteDataAll();
	this.list.SetStartDataIndex(0);

	
	var tempData = new Array(MAX_LAST_LOGIN_ID); 
	var LoginId;
	
	for (var i=0; i < MAX_LAST_LOGIN_ID; i++) {
			
		LoginId = PluginAPIMgr.GetLastLoginID(i);
		
		if(LoginId){
			
			tempData[i] = [ LoginId ,null ];			
			this.list.AddData(tempData[i]);
			this.lastLoginIdArray[i] = LoginId;	
		
		}
		else{
			break;
		}
	}
		
	this.list.ShowItem();	

}
//2013 add by minseok
SceneLastLoginIdList.prototype.ResetBG = function(){
	alert("SceneLastLoginIdList.ResetBG()");
	var div_center = this.list.GetElimentName();
	var div_bottom = this.list.GetElimentBottomName();
	
	$("#"+div_center).css('height',4);
	$("#"+div_bottom).css('top',345);
	
}

SceneLastLoginIdList.prototype.ProcessCallback = function(Index){

	alert("SceneLastLoginIdList.ProcessCallback >> " + Index );
	
    sf.scene.get(this.callerScene).SetSkypeNameFromLoginIdList(this.lastLoginIdArray[Index]);	
	sf.scene.hide('LastLoginIdList');
}
SceneLastLoginIdList.prototype.ProcessMouseOverCallback = function(Index){

	alert("SceneLastLoginIdList.ProcessMouseOverCallback >> " + Index );
	this.list.SetCurrentItem(Index);
    // sf.scene.get(this.callerScene).SetSkypeNameFromLoginIdList(this.lastLoginIdArray[Index]);	
	// sf.scene.hide('LastLoginIdList');
}

SceneLastLoginIdList.prototype.onClickEventFunc1 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessCallback(0);
}

SceneLastLoginIdList.prototype.onClickEventFunc2 = function(){

	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessCallback(1);
}

SceneLastLoginIdList.prototype.onClickEventFunc3 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessCallback(2);
}

SceneLastLoginIdList.prototype.onClickEventFunc4 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessCallback(3);
}

SceneLastLoginIdList.prototype.onClickEventFunc5 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessCallback(4);
}
SceneLastLoginIdList.prototype.onMouseOverEventFunc1 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessMouseOverCallback(0);
}

SceneLastLoginIdList.prototype.onMouseOverEventFunc2 = function(){

	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessMouseOverCallback(1);
}

SceneLastLoginIdList.prototype.onMouseOverEventFunc3 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessMouseOverCallback(2);
}

SceneLastLoginIdList.prototype.onMouseOverEventFunc4 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessMouseOverCallback(3);
}

SceneLastLoginIdList.prototype.onMouseOverEventFunc5 = function(){
	
	var This_ = sf.scene.get("LastLoginIdList");	
	This_.ProcessMouseOverCallback(4);
}

