
var MaxNumOfBlockItem = 3;
var BlockListPropNum = 2;

function BlockList() {
    ScrollList.call(this);

}

BlockList.prototype = new ScrollList(); 

BlockList.prototype.Create = function() {

    alert("BlockList.Create");
		
	//Set List 
	this.CreateBG("blockList");  
    this.ElimentName = "blockList";	
	this.SetNumOfVisibleItem(MaxNumOfBlockItem);
	this.SetItemClass(BlockItem);	
	
	this.CreateScrBar("blockListScrollBar");
	this.ResetData();
	
	this.SetScrBarPosition(184,0,4);
	this.SetScrollBarImage(g_Image.IMAGE_POPUP_INNERBOX_SCROLLBAR_TOP, g_Image.IMAGE_POPUP_INNERBOX_SCROLLBAR_CENTER, g_Image.IMAGE_POPUP_INNERBOX_SCROLLBAR_BOTTOM);
		
	this.SetScrBGImage(g_Image.IMAGE_POPUP_INNERBOX_SCROLLBAR_BG_TOP, g_Image.IMAGE_POPUP_INNERBOX_SCROLLBAR_BG_CENTER, g_Image.IMAGE_POPUP_INNERBOX_SCROLLBAR_BG_BOTTOM);
	
	
	var OriginalScene = sf.scene.get("SettingsBlockedContacts");
		
	this.SetEventOnReturnFunc(function(){OriginalScene.processReturnKey();});
	this.SetItemPressedEventCallback(this.pressEnterKey);
	
	
	this.SetOnClickCallbackFunc(0,function(){OriginalScene.ProcessClick(0);});
	this.SetOnClickCallbackFunc(1,function(){OriginalScene.ProcessClick(1);});
	this.SetOnClickCallbackFunc(2,function(){OriginalScene.ProcessClick(2);});
	
	this.SetOnMouseOverCallbackFunc(0,function(){OriginalScene.processMouseOver(0);});
	this.SetOnMouseOverCallbackFunc(1,function(){OriginalScene.processMouseOver(1);});
	this.SetOnMouseOverCallbackFunc(2,function(){OriginalScene.processMouseOver(2);});
	
	this.SetClickEventAvailable(WndMgr.MouseClickEnable);	
	
	this.ShowItem();	
	
}

BlockList.prototype.GetCurSkypeName = function(){

	return this.ItemArray[this.CurrentItemIndex].GetUnblockName();
	
}
BlockList.prototype.ResetData2 = function(){
	
	/*
	if(this.MaxNumOfData > 0){
			this.DeleteDataAll();
		}*/
	
	
					var tempData = new Array(3);			
		//Set Data 									
		for (var i=0; i <3 ; i++) {
							
/*
			alert("SkypeName[" + i +"] = " + SkypeName );	
			alert("DisplayName[" + i +"] = " + DisplayName );		
*/						
			tempData[i] = ["111","222"];
				
			this.AddData(tempData[i]);	
						
		}
				
		//Set Page Info
		this.TotalPage = parseInt(this.MaxNumOfData / this.MaxNumOfItem);
		if((this.MaxNumOfData % this.MaxNumOfItem) > 0) {
			this.TotalPage++;
		}	
				
//	else {
//		
//		this.TotalPage = 0;
//		this.CurPage = 0;
//	}

	//this.PrintListInfo();
	
}
//Set Total~,Max~ Info..... not cur~ Info
BlockList.prototype.ResetData = function(){
	
	if(this.MaxNumOfData > 0){
		this.DeleteDataAll();
	}
	
	var strBlockList = PluginAPIMgr.GetBlockList();
	alert("strBlockList = " + strBlockList );	
							
	if(strBlockList) {
		var STX = String.fromCharCode(2);
		var ETX = String.fromCharCode(3);
		var splitter = ETX + STX;
	
		var Result = strBlockList.split(splitter);	
		
		var totalNumOfBlock = parseInt(Result.length / BlockListPropNum);
		alert("totalNumOfBlock = " + totalNumOfBlock );	
					
		var TokenNum = 0;

		var SkypeName;
		var DisplayName;
				
		var tempData = new Array(totalNumOfBlock);					
							
		//Set Data 									
		for (var i=0; i < totalNumOfBlock ; i++) {
			TokenNum = i*BlockListPropNum;						
			SkypeName = Result[TokenNum];	
			DisplayName = Result[TokenNum+1];
							
/*
			alert("SkypeName[" + i +"] = " + SkypeName );	
			alert("DisplayName[" + i +"] = " + DisplayName );		
*/						
			if(SkypeName == DisplayName){
				DisplayName = null;
			}		
			tempData[i] = [SkypeName,DisplayName];
				
			this.AddData(tempData[i]);	
						
		}
				
		//Set Page Info
		this.TotalPage = parseInt(this.MaxNumOfData / this.MaxNumOfItem);
		if((this.MaxNumOfData % this.MaxNumOfItem) > 0) {
			this.TotalPage++;
		}	
				
	}
//	else {
//		
//		this.TotalPage = 0;
//		this.CurPage = 0;
//	}

	//this.PrintListInfo();
	
}

BlockList.prototype.IsExistBlockedUser = function(blockString){
		
	for (var i=0; i<this.MaxNumOfData; i++) {
		
		if(this.DataArray[i][0] == blockString){
			return true;
		}
	}
	return false;

}

