
function ChatHistoryList() {

	this.ListPropNum = 6;
				
	MainList.call(this);
}

ChatHistoryList.prototype = new MainList(); 

ChatHistoryList.prototype.Costomizing = function(){

	this.ElimentName = "chat";
	this.ItemClass = ChatHistoryItem;
	this.FuncPopupClass = ChatHistoryFuncButtons;
	this.NoItemString = TV_SID_EMPTY_LIST_OF_CONVERSATIONS_MSG;
	this.PossibleToUpdatePageWithIdentity = false;
	this.SceneName = "ListMainProfile";			
}

//costomize...
ChatHistoryList.prototype.GetNumberOfDatas = function(){
	
	return PluginAPIMgr.GetNumberOfChatList();
}

ChatHistoryList.prototype.UpdatePage = function(){

	alert("ChatHistoryList.UpdatePage"); 

	var startIndexOfPage = (this.CurPage - 1) * MaxNumOfMainItem;
	
	var strChatList = PluginAPIMgr.GetChatList(startIndexOfPage);
		
	//alert("String = " + strChatList );

	var ChatNameArray			= new Array(MaxNumOfMainItem);
	var TypeArray				= new Array(MaxNumOfMainItem);
	var ParticipantsArray 		= new Array(MaxNumOfMainItem);
	var FriendlyNameArray 		= new Array(MaxNumOfMainItem);
	var TimeArray 				= new Array(MaxNumOfMainItem);
	var NewChatNumArray 		= new Array(MaxNumOfMainItem);
			
	var NumOfItemInThisPage = 0;						
							
	if(strChatList)
	{				
		var STX = String.fromCharCode(2);
		var ETX = String.fromCharCode(3);
		var splitter = ETX + STX;
	
		var Result = strChatList.split(splitter);	
		NumOfItemInThisPage = parseInt(Result.length / (this.ListPropNum));

		var TokenNum = 0;
		
		for (var i=0; i < NumOfItemInThisPage ; i++) {
					
			TokenNum = i*(this.ListPropNum);						
			
			ChatNameArray[i] 		= Result[TokenNum];			
			TypeArray[i] 			= Result[TokenNum+1];			
			ParticipantsArray[i] 	= Result[TokenNum+2];						
			FriendlyNameArray[i]	= Result[TokenNum+3];						
			TimeArray[i] 			= Result[TokenNum+4];						
			NewChatNumArray[i] 		= Result[TokenNum+5];					
			
//			alert("ChatNameArray[" + i +"] = " 		+ ChatNameArray[i] );	
//			alert("TypeArray[" + i +"] = " 			+ TypeArray[i] );				
//			alert("ParticipantsArray[" + i +"] = " 	+ ParticipantsArray[i] );
//			alert("FriendlyNameArray[" + i +"] = " 	+ FriendlyNameArray[i] );
//			alert("TimeArray[" + i +"] = " 			+ TimeArray[i] );
//			alert("NewChatNumArray[" + i +"] = " 	+ NewChatNumArray[i] );
									
		}
	}
		
	var tempData = new Array(MaxNumOfMainItem);
			
	for (var j=0; j < NumOfItemInThisPage; j++) {
	
		//alert("tempData[" + j +"] create");
		tempData[j] = new ChatHistoryData();		
		tempData[j].SetData(ChatNameArray[j],TypeArray[j],ParticipantsArray[j],FriendlyNameArray[j],TimeArray[j],NewChatNumArray[j]);
					
		this.ItemArray[j].SetItem(tempData[j]);
				
	}
	
	this.NumOfVisibleItem = NumOfItemInThisPage;
	
	for(var k = NumOfItemInThisPage; k < MaxNumOfMainItem ; k++) {
		
		//alert("ItemArray[" + k +"] not include data!!");
		if(this.ItemArray[k]){
						
			this.ItemArray[k].SetFlagForExistData(false);
		}		
	}

	this.ShowItem();
	
	this.ResetPageUI();		
}

ChatHistoryList.prototype.GetCurChatName = function(){
	
	return this.ItemArray[this.CurrentItemIndex].GetChatName();
}

ChatHistoryList.prototype.GetCurParticipantName = function(){
	
	return this.ItemArray[this.CurrentItemIndex].GetParticipantName()
}

ChatHistoryList.prototype.GetCurIsMultiChat = function(){
	
	return this.ItemArray[this.CurrentItemIndex].GetIsMultiChat()
}
