
var MaxNumOfCountryItem = 6;

function CountryList() {
								
    ScrollList.call(this);
}

CountryList.prototype = new ScrollList(); 

CountryList.prototype.Create = function() {

    alert("CountryList.Create");

	//Set List 
	//2013 modify by minseok
	this.CreateBG("CFlagList","divide");	//List.CreateBG    
	this.SetNumOfVisibleItem(MaxNumOfCountryItem);	//List.SetNumOfVisibleItem
	this.SetItemClass(CountryItem);				//List.SetItemClass
	this.CreateScrBar("CFlagListScrollBar");
	//no circulation
	// this.SetCirculation(false);
	
	// this.SetScrBarImage(g_Image.IMAGE_SIGNUP_COUNTRY_LIST_SCROLLBAR_BG,
		// g_Image.IMAGE_BLOCK_SCROLLBAR_TOP,
		// g_Image.IMAGE_BLOCK_SCROLLBAR_CENTER,
		// g_Image.IMAGE_BLOCK_SCROLLBAR_BOTTOM);	
		
	this.InitData();		
	
	this.SetScrBarPosition(284,0,4);
	this.SetScrollBarImage(g_Image.IMAGE_BLOCK_SCROLLBAR_TOP,
		g_Image.IMAGE_BLOCK_SCROLLBAR_CENTER,
		g_Image.IMAGE_BLOCK_SCROLLBAR_BOTTOM);	
	this.SetScrBGImage(g_Image.IMAGE_SIGNUP_COUNTRY_LIST_SCROLLBAR_BG_TOP,
		g_Image.IMAGE_SIGNUP_COUNTRY_LIST_SCROLLBAR_BG_CENTER,
		g_Image.IMAGE_SIGNUP_COUNTRY_LIST_SCROLLBAR_BG_BOTTOM);
	// this.ResetScrollBar();
			

	var Scene = sf.scene.get('CountryFlagList');
	var This_ = Scene.FlagList;

	//Imae Lable
	this.UpArrow = new CompBase(); 
	this.UpArrow.CreateBG("CFlagListUpArrow");
	this.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	this.UpArrow.SetOnClickCallbackFunc(function(){
		Scene.EnterList();
		This_.Previous();});	
	this.UpArrow.SetOnMouseOverCallbackFunc(function(){This_.onMouseOverFunc(ARROW_TYPE.UP_SEL);});
	this.UpArrow.SetOnMouseOutCallbackFunc(function(){This_.onMouseOutFunc(ARROW_TYPE.UP_NOR);});			

	this.DownArrow = new CompBase(); 
	this.DownArrow.CreateBG("CFlagListDownArrow");
	this.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	this.DownArrow.SetOnClickCallbackFunc(function(){
		Scene.EnterList();
		This_.Next();});	
	this.DownArrow.SetOnMouseOverCallbackFunc(function(){This_.onMouseOverFunc(ARROW_TYPE.DOWN_SEL);});
	this.DownArrow.SetOnMouseOutCallbackFunc(function(){This_.onMouseOutFunc(ARROW_TYPE.DOWN_NOR);});	


	//hide arrows
	this.onMouseOutFunc();
	
}

/*

CountryList.prototype.GetCurSkypeName = function(){

	return this.ItemArray[this.CurrentItemIndex].GetSkypeName();
	
}

*/

CountryList.prototype.InitData = function(){

	alert("CountryList.InitData ");	
	
	var NumOfCountryList = g_Data.GetNumOfCountry();
	var tempData = new Array(NumOfCountryList);  
			
	for (var i=0; i < NumOfCountryList; i++) {
						
		tempData[i] = new CountryData();
		tempData[i].SetData(g_Data.DATA_COUNTRY_NAME_ARRAY[i],g_Data.DATA_COUNTRY_PREFIX_ARRAY[i],g_Data.DATA_COUNTRY_CODE_ARRAY[i]);		
		this.AddData(tempData[i]);					
	}		

	this.SetOnClickCallbackFunc(0,this.onClickEventFunc1);
	this.SetOnClickCallbackFunc(1,this.onClickEventFunc2);
	this.SetOnClickCallbackFunc(2,this.onClickEventFunc3);
	this.SetOnClickCallbackFunc(3,this.onClickEventFunc4);
	this.SetOnClickCallbackFunc(4,this.onClickEventFunc5);
	this.SetOnClickCallbackFunc(5,this.onClickEventFunc6);
	this.SetOnMouseOverCallbackFunc(0,this.onMouseOverEventFunc1);
	this.SetOnMouseOverCallbackFunc(1,this.onMouseOverEventFunc2);
	this.SetOnMouseOverCallbackFunc(2,this.onMouseOverEventFunc3);
	this.SetOnMouseOverCallbackFunc(3,this.onMouseOverEventFunc4);
	this.SetOnMouseOverCallbackFunc(4,this.onMouseOverEventFunc5);
	this.SetOnMouseOverCallbackFunc(5,this.onMouseOverEventFunc6);
	this.SetClickEventAvailable(WndMgr.MouseClickEnable);
			
	for(var i=0;i<6;i++){
		// this.SetOnMouseOverCallbackFunc(i,this.onMouseOverFunc);
		this.SetOnMouseOutCallbackFunc(i,this.onMouseOutFunc);
	}		
	
	this.ShowItem();
	// this.SetScrBarPosition(210,0,5);
	

}

CountryList.prototype.SetStyle = function(type){

	alert("CountryList.SetStyle(" + type  +")");	
	
	var HighlightImg;

	if(type == FLAG_LIST_TYPE.LIST_MAIN_CALL){	
		this.SetScrBarStyle('CFlagListScrollBar_ListMainCall');
		HighlightImg = g_Image.IMAGE_LIST_MAIN_CALL_COUNTR_FLAG_LIST_ITEM_HIGHLIGHT_BG;	
		
		this.UpArrow.SetStyle(0,'CFlagListUpArrow_ListMainCall');
		this.DownArrow.SetStyle(0,'CFlagListDownArrow_ListMainCall');
	}
	else {
		this.SetScrBarStyle('CFlagListScrollBar_AddPhoneNumber');
		HighlightImg = g_Image.IMAGE_LIST_MAIN_CALL_COUNTR_FLAG_LIST_ITEM_HIGHLIGHT_BG;
		
		this.UpArrow.SetStyle(0,'CFlagListUpArrow_AddPhoneNumber');
		this.DownArrow.SetStyle(0,'CFlagListDownArrow_AddPhoneNumber');
		
	}
	
	for (var i=0; i< MaxNumOfCountryItem ; i++) {
		
		this.ItemArray[i].SetContainerStyle(type);
		this.ItemArray[i].SetBgImage(ITEM_STATE.HIGHLIGHT,HighlightImg);
	}
	
}

CountryList.prototype.onClickEventFunc1 = function()
{
	var OriginalScene = sf.scene.get("CountryFlagList");	
	OriginalScene.ProcessClick(0);	
}

CountryList.prototype.onClickEventFunc2 = function()
{
	var OriginalScene = sf.scene.get("CountryFlagList");	
	OriginalScene.ProcessClick(1);	
}

CountryList.prototype.onClickEventFunc3 = function()
{
	var OriginalScene = sf.scene.get("CountryFlagList");	
	OriginalScene.ProcessClick(2);	
}

CountryList.prototype.onClickEventFunc4 = function()
{
	var OriginalScene = sf.scene.get("CountryFlagList");	
	OriginalScene.ProcessClick(3);	
}

CountryList.prototype.onClickEventFunc5 = function()
{
	var OriginalScene = sf.scene.get("CountryFlagList");	
	OriginalScene.ProcessClick(4);	
}
CountryList.prototype.onClickEventFunc6 = function()
{
	var OriginalScene = sf.scene.get("CountryFlagList");	
	OriginalScene.ProcessClick(5);	
}
CountryList.prototype.onMouseOverEventFunc1 = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	OriginalScene.processMouseOver(0);
}
CountryList.prototype.onMouseOverEventFunc2 = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	OriginalScene.processMouseOver(1);
}
CountryList.prototype.onMouseOverEventFunc3 = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	OriginalScene.processMouseOver(2);
}
CountryList.prototype.onMouseOverEventFunc4 = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	OriginalScene.processMouseOver(3);
}
CountryList.prototype.onMouseOverEventFunc5 = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	OriginalScene.processMouseOver(4);
}
CountryList.prototype.onMouseOverEventFunc6 = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	OriginalScene.processMouseOver(5);
}
/*arrow over callback func*/
CountryList.prototype.onMouseOverFunc = function(type){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
	This_.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
	This_.UpArrow.Show();
	This_.DownArrow.Show();
	if(type){
		//if arrow over
		This_.ChangeArrow(type);
	}
}
CountryList.prototype.onMouseOutFunc = function(){
	var OriginalScene = sf.scene.get("CountryFlagList");	
	var This_ = OriginalScene.FlagList;
	This_.UpArrow.SetBGImage(" ");
	This_.DownArrow.SetBGImage(" ");
}

CountryList.prototype.ChangeArrow = function(Type)
{
	alert("CountryList.ChangeArrow");

	switch(Type)
	{
		case ARROW_TYPE.UP_NOR:
			this.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_NOR);
			break;
		case ARROW_TYPE.UP_SEL:
			this.UpArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_UP_SEL);
			break;
		case ARROW_TYPE.DOWN_NOR:
			this.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_NOR);
			break;
		case ARROW_TYPE.DOWN_SEL:
			this.DownArrow.SetBGImage(g_Image.IMAGE_LIST_MAIN_ARROW_DOWN_SEL);
			break;		
	}
}
