function SceneSNSObject() {
}

function Layer(element_id){
    
    this.Obj		= element_id;
	
    this.Style		= "";
	
	this.type		= null;
}

Layer.prototype.SetObj = function(element_id)
{
    this.Obj = element_id;    
}

Layer.prototype.GetObjId = function(){
	return this.Obj;	
}

Layer.prototype.SetStyle = function(cStyle)
{	
	
	//alert("##mini##Layer.SetStyle()");
	
    if(this.Style.length>0)
    {
        $("#"+this.Obj).removeClass(this.Style);
    }
    
	
    $("#"+this.Obj).addClass(cStyle);
    this.Style = cStyle;
}

Layer.prototype.GetStyle = function()
{	
    return this.Style
}


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

/**
 * @author Samsung
 */

function TextLayer(id){
    
    this.textObj = id;
    this.currentStyle = "";
	
		

	Layer.call(this,id);	
	
	this.isTextInTable =  false;	

	this.isMarqueeEnable = false;
	this.maxMarqueeWidth =0;
	
	this.marqueeEnableStyle = "";
	this.marqueeDisableStyle ="";
	
	this.flagReverseDisable=false;
	
	this.curr_text_length =0;
	
	this.isPlainText = false;
	
}

TextLayer.prototype = new Layer(); 

TextLayer.prototype.GetObjectId = function()
{
	return this.textObj;
}

TextLayer.prototype.SetText = function(string)
{
	//alert("##mini##SetText");
	if(string != null)
	{
		this.curr_text_length = string.length;
	}
	else
	{
		this.curr_text_length = 0;
	}
			
	if(this.isMarqueeEnable ==true)
	{
		if(this.currentStyle.length>0 && this.isTextInTable==false )
		{
			//alert("##mini##removeClass");
			$("#"+this.textObj).removeClass(this.currentStyle);
		}		
	}
	
	if(this.isTextInTable==false)    
	{
		if(this.isPlainText == false)
		{
			$("#"+this.textObj).html(string);
		}
		else
		{
			//alert("##mini##setPlainText");
			$("#"+this.textObj).text(string);
		}
		
	}
	else
	{
		if(this.isPlainText == false)
		{
			$("div#"+this.textObj+" td:first").html(string);
		}
		else
		{
			//alert("##mini##setPlainText");
			$("div#"+this.textObj+" td:first").text(string);
		}
		
	}
	
	if(this.isMarqueeEnable ==true)
	{
		if(this.isTextInTable==false)  
		{
			var curr_w = $("#"+this.textObj).css('width');
			//alert("##mini##TextLayer curr width1 : "+ curr_w);
			
			var len= curr_w.indexOf("px");
			var curr_w_int = parseInt(curr_w.substring(0,len));
			//alert("##mini##TextLayer curr width2: "+ curr_w_int);
			
			if(this.maxMarqueeWidth < curr_w_int)
			{
			//	alert("##mini##start marquee");
				$("#"+this.textObj).addClass(this.marqueeEnableStyle);
				this.currentStyle = this.marqueeEnableStyle;
			}
			else
			{
				//alert("##mini##stop marquee");
				$("#"+this.textObj).addClass(this.marqueeDisableStyle);
				this.currentStyle = this.marqueeDisableStyle;
			}
			
			if(ResMgr.isReverseLanguage() && this.flagReverseDisable==false)
			{
				$("#"+this.textObj).css("direction","rtl");
			}
		}
	}
 	else
 	{
		if(ResMgr.isReverseLanguage() && this.flagReverseDisable==false)
	    {
	    	if(this.isTextInTable==false)   
	    	{
	    		$("#"+this.textObj).css("direction","rtl");
	    	}
	    	else
	    	{
	    		$("div#"+this.textObj+" td:first").css("direction","rtl");
	    	}	    	
	    }	
 	}
	

}

TextLayer.prototype.SetTextStyle = function(style)
{
	//alert("##mini##SetTextStyle");	
	
	if(this.isTextInTable==false)
	{
		 if(this.currentStyle.length>0)
	    {
	        $("#"+this.textObj).removeClass(this.currentStyle);
	    }
	    
	    $("#"+this.textObj).addClass(style);  
	    
	}
	else
	{
		if(this.currentStyle.length>0)
	    {
	        $("div#"+this.textObj+" td:first").removeClass(this.currentStyle);
	    }
	    
	    $("div#"+this.textObj+" td:first").addClass(style);
	    
	}
	
	
	    	
	this.currentStyle=style;
}

TextLayer.prototype.visibleObj=function()
{
    //alert("##mini##TextLayer.prototype.visibleObj()");

    $("#"+this.textObj).css("visibility","visible");
}

TextLayer.prototype.hiddenObj=function(){
    //alert("##mini##TextLayer.prototype.hiddenObj()");
   $("#"+this.textObj).css("visibility","hidden");
}

TextLayer.prototype.SetIsTextInTable = function(flagInTable)
{
    this.isTextInTable = flagInTable ;   
}

TextLayer.prototype.SetMarqueeEnable = function(maxWidth, enableStyle, disableStyle)
{
	this.isMarqueeEnable = true;
	
	this.maxMarqueeWidth = maxWidth;
	this.marqueeEnableStyle = enableStyle;
	this.marqueeDisableStyle =disableStyle;
	
}


TextLayer.prototype.CheckTextLength = function(CheckerEID,CheckerText)
{
	//alert("##mini##CheckTextLength");

	$("#"+CheckerEID).removeClass('cItem_Name_checker');	  // only widht
	$("#"+CheckerEID).html(CheckerText); 
 	
 	var curr_w = $("#"+CheckerEID).css('width');
	//alert("##mini##CheckTextLength curr width1 : "+ curr_w);
	
	var len= curr_w.indexOf("px");
	var curr_w_int = parseInt(curr_w.substring(0,len));
	//alert("##mini##CheckTextLength curr width2: "+ curr_w_int);

	$("#"+CheckerEID).addClass('cItem_Name_checker');

	return curr_w_int;
}

TextLayer.prototype.SetReverseDisable = function(flag)
{
	var back_flag = this.flagReverseDisable;
	this.flagReverseDisable=flag;
	
	if(this.flagReverseDisable==true && ResMgr.isReverseLanguage() && this.flagReverseDisable!=back_flag)
	{
		if(this.curr_text_length>0)
		{
	    	if(this.isTextInTable==false)   
	    	{ 
	    		$("#"+this.textObj).css("direction","ltr");
	    	}
	    	else
	    	{
	    		$("div#"+this.textObj+" td:first").css("direction","ltr");
	    	}
		}
	}
}

TextLayer.prototype.SetIsPlainText= function(flagPlainText)
{
    this.isPlainText = flagPlainText ;   
}



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

/**
 * @author Samsung
 */


function ImageLayer(id){
   
	this.imageObj = id; 
	this.fgImageObj = null;
	this.fgImageVSpace ="";
	this.fgImageHSpace ="";
	this.fgImagewidth ="";
	this.fgImageHeight ="";
	this.fgImageSrc ="";
	
	this.fgImageFlag = false;
	
	Layer.call(this,id);			
}

ImageLayer.prototype = new Layer();

ImageLayer.prototype.GetObjectId = function()
{
	return this.imageObj;
}

ImageLayer.prototype.SetBgImage = function(bgImage)
{
	if(this.bgimage !=bgImage)
    $("#"+this.imageObj).css("background-image", 'url('+bgImage+')');
    this.bgimage = bgImage;
}

ImageLayer.prototype.SetImage = function(bgImage)
{
	if (bgImage) {	
    	$("#"+this.imageObj).css("background-image", 'url('+bgImage+')');
	}
}

ImageLayer.prototype.SetColor = function(color)
{
	if (color) {	
		$("#" + this.imageObj).css("background-color", color);
	}
}


ImageLayer.prototype.AppendFgImage = function(img_id, h_space, v_space, w, h, img_src)
{
    this.fgImageObj = img_id;
	
	this.fgImageHSpace = h_space;
	this.fgImageVSpace = v_space;
	this.fgImagewidth = w;
	this.fgImageHeight =h;
}

ImageLayer.prototype.SetFgImage = function(img_src){

	if(img_src.length > 0)
	{
		if(this.fgImageFlag == false)
		{
			var HtmlStr = "<img id='"+this.fgImageObj+"' hspace='"+this.fgImageHSpace+"' vspace='"+this.fgImageVSpace+"' width='"+this.fgImagewidth+"' height='"+this.fgImageHeight+"' />";
			$(HtmlStr).appendTo("#"+this.imageObj);
			
			this.fgImageFlag=true;
		}
		
		this.fgImageSrc = img_src;
	   	$("#"+this.fgImageObj).attr("src",img_src);		
	}
	else
	{
		if(this.fgImageFlag == true)
		{
			$("#"+this.fgImageObj).remove();
			this.fgImageFlag=false;
		}
	}

 }
 
ImageLayer.prototype.ChangeFgImageRect = function(h_space, v_space, w, h, img_src)
{    
	if(this.fgImageFlag == true)
	{
		$("#"+this.fgImageObj).remove();
		
		this.fgImageHSpace = h_space;
		this.fgImageVSpace = v_space;
		this.fgImagewidth = w;
		this.fgImageHeight =h;
		
		var HtmlStr = "<img id='"+this.fgImageObj+"' hspace='"+this.fgImageHSpace+"' vspace='"+this.fgImageVSpace+"' width='"+this.fgImagewidth+"' height='"+this.fgImageHeight+"' />";
		$(HtmlStr).appendTo("#"+this.imageObj);
		
		$("#"+this.fgImageObj).attr("src",this.fgImageSrc);
	}
}
 
ImageLayer.prototype.visibleObj=function()
{
   // alert("##mini##ImageLayer.prototype.visibleObj()");
    $("#"+this.imageObj).css("visibility","visible");
}

ImageLayer.prototype.hiddenObj=function(){
   //alert("##mini##ImageLayer.prototype.hiddenObj()");
   $("#"+this.imageObj).css("visibility","hidden");
}

ImageLayer.prototype.visibleFgObj=function()
{
    //alert("##mini##ImageLayer.prototype.visibleFgObj()");
    if(this.fgImageObj)
    {
        $("#"+this.fgImageObj).css("visibility","visible");
    }
}

ImageLayer.prototype.hiddenFgObj=function(){
   // alert("##mini##ImageLayer.prototype.hiddenFgObj()");
	if (this.fgImageObj) {
        $("#"+this.fgImageObj).css("visibility","hidden");
    }
}

ImageLayer.prototype.SetOnMouseOverCallbackFunc = function(func){
	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
	if(this.imageObj != null)
	{
		alert("##mini##ImageLayer.SetOnMouseOverCallbackFunc() set on image_layer");
		
		this.onMouseOverCallbackFunc = func;
		this.EnableOnMouseOver();			
	}
	
}

ImageLayer.prototype.SetOnMouseOutCallbackFunc = function(func){
	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
	if(this.imageObj != null)
	{
		alert("##mini##ImageLayer.SetOnMouseOutCallbackFunc() set on image_layer");
		
		this.onMouseOutCallbackFunc = func;
		this.EnableOnMouseOut();			
	}
}

ImageLayer.prototype.EnableOnMouseOver = function(){
	var object = this.imageObj;
	var this_ = this;
	$("#"+object).bind("mouseenter",function(){
		this_.onMouseOverCallbackFunc(this_);
	});
//	document.getElementById(object).onmouseover = function(){this_.onMouseOverCallbackFunc(this_);};
}

ImageLayer.prototype.DisableOnMouseOver = function(){
	var object = this.imageObj;
	$("#"+object).unbind("mouseenter");
	//document.getElementById(object).onmouseover = null;
}

ImageLayer.prototype.EnableOnMouseOut = function(){
	var object = this.imageObj;
	var this_ = this;
	$("#"+object).bind("mouseleave",function(){
		this_.onMouseOutCallbackFunc(this_);
	});
	//document.getElementById(object).onmouseout = function(){this_.onMouseOutCallbackFunc(this_);};
}

ImageLayer.prototype.DisableOnMouseOut = function(){
	var object = this.imageObj;
	$("#"+object).unbind("mouseleave");
//	document.getElementById(object).onmouseout = null;
}


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



function JPGImageLayer(id){
	
	Layer.call(this,id);		
}

JPGImageLayer.prototype = new Layer(); 

JPGImageLayer.prototype.SetImage = function(img_src){

	//alert("##mini##JPGImageLayer.SetImage(" + img_src + ")" );
	$("#" +this.Obj).attr("src", img_src);
       
}

/*

ImageLayer.prototype.AppendFgImage = function(img_id, h_space, v_space, w, h, img_src)
{

    this.fgImageObj = img_id;
    
    $("<img/>", {id: this.fgImageObj}).appendTo("#"+this.imageObj);
    
    $("#" +this.fgImageObj).attr("hspace",  h_space);
    $("#" +this.fgImageObj).attr("vspace",  v_space);
    $("#" +this.fgImageObj).attr("width:",  w);
    $("#" +this.fgImageObj).attr("height",  h);
    //attr:{hspace:h_space, vspace:v_space, width:w, height:h}
}
*/


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



function CompBase () {
   
	this.Showstate  = false;
	
	this.BGLayerIndex	= -1;			
   
	this.BGLayerObj	= null;
   
	this.BGLayerObj_left = null;
	this.BGLayerObj_right = null;
	this.BGLayerObj_center = null;
	this.BGLayer_left = null;
	this.BGLayer_right = null;
	this.BGLayer_center = null;
   
    this.LayerArray = [];
    
    this.clickCallbackFunc			= null;
    this.onMouseOverCallbackFunc	= null;
    this.onMouseOutCallbackFunc		= null;
    
    //availity...
    this.flag_ClickEvent		= false;
    this.flag_MouseMoveEvent	= false;    
    //prevent duplication
    this.flag_ClickinProgress	= false; 
    this.flag_MouseOverProgress	= false;
    this.flag_MouseOutProgress	= false;
    this.flag_EnableRightClick	= false;

	this.Container_layer =null;
	this.image_divide = false;
}

CompBase.prototype.GetShowState = function() {
		 
	 //alert("##mini##CompBase.GetShowState = " + this.ShowState);	 
     return this.Showstate; 

}


CompBase.prototype.GetLastLayerIndex = function() {
	  
	return this.LayerArray.length - 1;

} 

CompBase.prototype.InsertLayer = function(Layer) {
	
    this.LayerArray.push(Layer);    

} 

   
CompBase.prototype.AddTextLayer = function(eID) {

    //alert("##mini##CompBase.AddTextLayer(" + tID + ")");
    var textLayer = new TextLayer(eID);

    this.InsertLayer(textLayer); 
    
}

CompBase.prototype.AddImageLayer = function(eID,divide) {

	if(divide){
		this.CreateBG(eID,divide);
		this.image_divide = true;
	}else{
    var imageLayer = new ImageLayer(eID);
    this.InsertLayer(imageLayer); 
	}
    
} 

CompBase.prototype.AddJPGImageLayer = function(eID) {

    var imageLayer = new JPGImageLayer(eID);
    this.InsertLayer(imageLayer); 
    
} 



CompBase.prototype.CreateBG = function(eID, divide_option) {

   // alert("##mini##CompBase.CreateBG(" + divide_option + ")");
    if(eID == null) {
        alert("##mini##CCompBase.CreateBG()  >>>   Param is null !!  ");
        return false;
    }
    
    if(divide_option){
   		this.divide_num = divide_option;
		var temp_html = $("#"+eID).html();
		temp_html += "<div id=" + eID + "_t></div><div id=" + eID + "_m></div><div id=" + eID + "_b></div>";
		$("#"+eID).html(temp_html);

		this.BGLayerObj_left = eID + "_t";
		this.BGLayerObj_right = eID + "_b";
		this.BGLayerObj = eID;
		this.BGLayerObj_center = eID + "_m";

		this.BGLayer_center = new ImageLayer(eID + "_m");
		this.BGLayer_left = new ImageLayer(eID + "_t");
		this.BGLayer_right = new ImageLayer(eID + "_b");
		this.BGLayerIndex = this.LayerArray.length;
		
		var imageLayer = new ImageLayer(eID);
		this.InsertLayer(imageLayer);

		this.SetStyle();
    } else {
    var imageLayer = new ImageLayer(eID);
    
	this.BGLayerIndex = this.LayerArray.length;
	this.BGLayerObj = eID;
	
    this.InsertLayer(imageLayer);
	
	//this.Showstate  = false;
  }
}

CompBase.prototype.GetObjId=function(){
	return this.BGLayerObj;
}

CompBase.prototype.SetBGImage = function(ImageUrl) {

   // alert("##mini##CompBase.SetBGImage()");

	if(this.image_divide){
		if(ImageUrl != null) {
			var result = ImageUrl.indexOf('_m');
			var Url;
			if(result != -1) {
				Url = ImageUrl.substring(0, result);

			//	alert("##mini##Url : " + Url);
			}
			this.BGLayer_left.SetImage(Url + '_t.png');
			this.BGLayer_center.SetImage(Url + '_m.png');
			this.BGLayer_right.SetImage(Url + '_b.png');
		}
	}else{
	this.LayerArray[this.BGLayerIndex].SetImage(ImageUrl);
}
}


CompBase.prototype.Update = function() {

    //
    
} 

CompBase.prototype.SetTextLayer = function(ArrayIndex,Text) {

    if(ArrayIndex == null || Text == null) {
        alert("##mini##[CompBase.SetTextLayer()] Param is null !!");
        return false;
    }
    	
    this.LayerArray[ArrayIndex].SetText(Text);
        
} 

CompBase.prototype.SetImageLayer = function(ArrayIndex,ImageUrl) {

    if(ArrayIndex == null || ImageUrl == null) {
        alert("##mini##[CompBase.SetImageLayer()] Param is null !!");
        return false;
    }
	
	if(this.image_divide)
		this.SetBGImage(ImageUrl);
	else
    this.LayerArray[ArrayIndex].SetImage(ImageUrl);
    
    
} 

CompBase.prototype.SetStyle = function(ArrayIndex,style) {

	alert("##mini##CompBase.SetStyle ()" );
	if(this.divide_num > 0) {
		var OrginWidth = $("#" + this.BGLayerObj).css('width');
		var OrginHeight = $("#" + this.BGLayerObj).css('height');

		var WidthLen = OrginWidth.indexOf("px");
		var HeightLen = OrginHeight.indexOf("px");

		var w_int = parseInt(OrginWidth.substring(0, WidthLen));
		var h_int = parseInt(OrginHeight.substring(0, HeightLen));

		$("#" +this.BGLayerObj_left).addClass("cListItemWithTreeObject");
		$("#" +this.BGLayerObj_left).css('top', '0');
		$("#" +this.BGLayerObj_left).css('width', w_int);
		$("#" +this.BGLayerObj_left).css('height', this.divide_num);

		$("#" +this.BGLayerObj_center).addClass("cListItemWithTreeObject");
		$("#" +this.BGLayerObj_center).css('top', this.divide_num);
		$("#" +this.BGLayerObj_center).css('width', w_int);
		$("#" +this.BGLayerObj_center).css('height', h_int-(this.divide_num*2));

		$("#" +this.BGLayerObj_right).addClass("cListItemWithTreeObject");
		$("#" +this.BGLayerObj_right).css('top', h_int-this.divide_num);
		$("#" +this.BGLayerObj_right).css('width', w_int);
		$("#" +this.BGLayerObj_right).css('height', this.divide_num);

		this.BGLayerObj_left = this.BGLayerObj + "_t";
		this.BGLayerObj_right = this.BGLayerObj + "_b";
		this.BGLayerObj_center = this.BGLayerObj + "_m";

	} 
	else {
    	this.LayerArray[ArrayIndex].SetStyle(style);
	}
}

CompBase.prototype.Show = function() {
	
	this.Showstate = true;
	
	if(this.flag_ClickEvent == true)
	{
		this.SetClickEvent();	
	}

	if(this.flag_MouseMoveEvent == true)
	{
		this.SetMouseOverEvent();		
		this.SetMouseOutEvent();	
	}	
		
	if(this.Container_layer)
		$("#" + this.Container_layer).css('display', 'block');
	else
	$("#"+ this.LayerArray[this.BGLayerIndex].Obj).css('display', 'block');	
}

CompBase.prototype.Hide = function() {
	
	this.Showstate = false;	
	if(this.flag_ClickEvent == true)
	{
		this.ResetClickEvent();	
	}

	if(this.flag_MouseMoveEvent == true)
	{
		this.ResetMouseOverEvent();		
		this.ResetMouseOutEvent();	
	}		
			
	if(this.Container_layer)
		$("#" + this.Container_layer).css('display', 'none');
	else
	$("#"+ this.LayerArray[this.BGLayerIndex].Obj).css('display', 'none');
}

CompBase.prototype.GetBGLayer = function() {
	
	return this.LayerArray[this.BGLayerIndex];
}

//Public
CompBase.prototype.SetOnClickCallbackFunc = function(func) {

	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}
	
	if(func != null)
	{
		alert("##mini##CompBase.SetOnClickCallbackFunc()");		
		this.clickCallbackFunc = func;
		this.SetClickEvent();
		this.flag_ClickEvent = true;
	}
	
}

CompBase.prototype.ResetOnClickCallbackFunc = function() {

	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}

	alert("##mini##CompBase.ResetOnClickCallbackFunc()");	
	this.clickCallbackFunc = null;
	this.ResetClickEvent();
	this.flag_ClickEvent = false;
}

CompBase.prototype.SetOnMouseOverCallbackFunc = function(func)
{
	if(WndMgr.MouseOverEnable == false)
	{
		return;	
	}	

	if(func != null)
	{
		alert("##mini##CompBase.SetOnMouseOverCallbackFunc()");		
		this.onMouseOverCallbackFunc = func;
		this.SetMouseOverEvent();
		this.flag_MouseMoveEvent = true;
	}
}

CompBase.prototype.SetOnMouseOutCallbackFunc = function(func)
{
	if(WndMgr.MouseOverEnable == false)
	{
		return;	
	}
		
	if(func != null)
	{
		alert("##mini##CompBase.SetOnMouseOutCallbackFunc()");		
		this.onMouseOutCallbackFunc = func;
		this.SetMouseOutEvent();
		this.flag_MouseMoveEvent = true;
	}
}

CompBase.prototype.ResetOnMouseOverCallbackFunc = function()
{
	if(WndMgr.MouseOverEnable == false)
	{
		return;	
	}

	alert("##mini##CompBase.ResetOnMouseOverCallbackFunc()");	
	this.onMouseOverCallbackFunc = null;
	this.ResetMouseOverEvent();
	this.flag_MouseMoveEvent = false;
	
}

CompBase.prototype.ResetOnMouseOutCallbackFunc = function()
{
	if(WndMgr.MouseOverEnable == false)
	{
		return;	
	}

	alert("##mini##CompBase.ResetOnMouseOutCallbackFunc()");	
	this.onMouseOutCallbackFunc = null;
	this.ReetMouseOutEvent();
	this.flag_MouseMoveEvent = false;	
	
}

//Private
CompBase.prototype.SetClickEvent = function() {

	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}

	if(this.flag_ClickinProgress == false)
	{
		alert("##mini##CompBase.SetClickEvent()");
		document.getElementById(this.BGLayerObj).onclick = this.clickCallbackFunc;
		$("#"+this.BGLayerObj).css({'cursor' : 'pointer'});
		this.flag_ClickinProgress = true;
	}
	else{
		alert("##mini##CompBase.SetClickEvent()  ===> flag_ClickEvent is true");
	}
}

CompBase.prototype.ResetClickEvent = function() {

	if(WndMgr.MouseClickEnable==false)
	{
		return;	
	}

	if(this.flag_ClickinProgress == true)
	{
		alert("##mini##CompBase.ResetClickEvent()");
		document.getElementById(this.BGLayerObj).onclick = null;
		$("#"+this.BGLayerObj).css({'cursor' : ''});
		this.flag_ClickinProgress = false;
	}
} 

//mouse move...
CompBase.prototype.SetMouseOverEvent = function() {

	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
    var this_ = this;
	if(this.flag_MouseOverProgress == false)
	{
		alert("##mini##CompBase.SetMouseOverEvent()");
		$("#"+this.BGLayerObj).bind("mouseenter",function(){
			this_.onMouseOverCallbackFunc(this_);
		});
		//document.getElementById(this.BGLayerObj).onmouseover = this.onMouseOverCallbackFunc;
		this.flag_MouseOverProgress = true;
	}
	else{
		alert("##mini##CompBase.SetMouseOverEvent()  ===> flag_MouseOverProgress is true");
	}

}

CompBase.prototype.ResetMouseOverEvent = function() {

	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
   var this_ = this;
	if(this.flag_MouseOverProgress == true)
	{
		alert("##mini##CompBase.ResetClickEvent()");
		$("#"+this.BGLayerObj).unbind("mouseenter");
		//document.getElementById(this.BGLayerObj).onmouseover = null;

		this.flag_MouseOverProgress = false;
	}
} 

CompBase.prototype.SetMouseOutEvent = function() {

	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
   var this_ = this;
	if(this.flag_MouseOutProgress == false)
	{
		alert("##mini##CompBase.SetMouseOutEvent()");
		$("#"+this.BGLayerObj).bind("mouseleave",function(){
			this_.onMouseOutCallbackFunc(this_);
		});
		//document.getElementById(this.BGLayerObj).onmouseout = this.onMouseOutCallbackFunc;
		this.flag_MouseOutProgress = true;
	}
	else{
		alert("##mini##CompBase.SetMouseOutEvent()  ===> flag_MouseOutProgress is true");
	}
}

CompBase.prototype.ResetMouseOutEvent = function() {

	if(WndMgr.MouseOverEnable==false)
	{
		return;	
	}
   var this_ = this;
	if(this.flag_MouseOutProgress == true)
	{
		alert("##mini##CompBase.ResetClickEvent()");
		$("#"+this.BGLayerObj).unbind("mouseleave");
		//document.getElementById(this.BGLayerObj).onmouseout = null;
		this.flag_MouseOutProgress = false;
	}
} 


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

var BUTTON_BASE_TYPE = { 
 
 	ONLY_BG		: 0,
 	BG_TEXT		: 1,
	BG_FG		: 2, 	
	BG_FG_TEXT	: 3,
}

var BUTTON_BASE_STATE = { 
 
 	NORMAL		: 0,
 	HIGHLIGHT	: 1,
	SELECT		: 2, 	
	DIM			: 3,
	MAX			: 4
}


function ButtonBase() {

    this.FgImgLayerIndex	= -1;		//Fg Image 
    this.TextLayerIndex		= -1;
    
	this.BgImgPath = new Array(BUTTON_BASE_STATE.MAX);
	this.FgImgPath = new Array(BUTTON_BASE_STATE.MAX);
	  
	this.TextStyle = new Array(BUTTON_BASE_STATE.MAX);
	this.BgImgStyle = new Array(BUTTON_BASE_STATE.MAX);
	this.FgImgStyle = new Array(BUTTON_BASE_STATE.MAX);
   
	this.buttonType = BUTTON_BASE_TYPE.ONLY_BG;
	this.state = BUTTON_BASE_STATE.NORMAL;
   	
	this.Id	= null;
	
	CompBase.call(this);
}


ButtonBase.prototype = new CompBase(); 

ButtonBase.prototype.Create = function(eID,nType){
	
    alert("##mini##ButtonBase.Create(" + eID + ")");
    if(eID == null) {
        alert("##mini##ButtonBase.Create()  >>>   Param is null !!  ");
        return false;
    }
    this.Id = eID;
	this.CreateBG(eID);	
	
	if(nType > 1) {
		this.CreateFG(eID + "Fg");	
	}
	if((nType % 2) > 0) {
		this.CreateText(eID + "Text");
	}
		
}

ButtonBase.prototype.CreateFG = function(eID){
	
    var imageLayer = new ImageLayer(eID);
    
	this.FgImgLayerIndex = this.LayerArray.length;
	
    this.InsertLayer(imageLayer);
	
}
ButtonBase.prototype.GetObjId = function(){
	return this.Id;
}
ButtonBase.prototype.CreateText = function(eID){
	
    var textLayer = new TextLayer(eID);
    
	this.TextLayerIndex = this.LayerArray.length;
	
    this.InsertLayer(textLayer);
	
}


ButtonBase.prototype.SetBgImage = function(stateIndex,ImagePath){
    	
    this.BgImgPath[stateIndex] = ImagePath;
    
    if(stateIndex == BUTTON_BASE_STATE.NORMAL)
    {
		this.LayerArray[this.BGLayerIndex].SetImage(ImagePath);
    }
}

ButtonBase.prototype.SetFgImage = function(stateIndex,ImagePath){
    	
    this.FgImgPath[stateIndex] = ImagePath;
    
    if(stateIndex == BUTTON_BASE_STATE.NORMAL)
    {
		this.LayerArray[this.FgImgLayerIndex].SetImage(ImagePath);
    }
}

ButtonBase.prototype.SetBgStyle = function(stateIndex,Style){
    
    this.BgImgStyle[stateIndex] = Style;
    
    if(stateIndex == BUTTON_BASE_STATE.NORMAL)
    {
		this.LayerArray[this.BGLayerIndex].SetStyle(Style);		
    }
}

ButtonBase.prototype.SetFgStyle = function(stateIndex,Style){
    
    this.FgImgStyle[stateIndex] = Style;
    
    if(stateIndex == BUTTON_BASE_STATE.NORMAL)
    {
		this.LayerArray[this.FgImgLayerIndex].SetStyle(Style);		
    }
}

ButtonBase.prototype.SetTextStyle = function(stateIndex,Style){
    
    this.TextStyle[stateIndex] = Style;
    
    if(stateIndex == BUTTON_BASE_STATE.NORMAL)
    {
		this.LayerArray[this.TextLayerIndex].SetStyle(Style);		
    }
}

ButtonBase.prototype.SetText = function(string){
	
	if(this.TextLayerIndex > 0)  
	{
		this.LayerArray[this.TextLayerIndex].SetText(string);
	}

}



ButtonBase.prototype.ChangeMode = function() {
	
	var curState = this.state;
	
	if(this.BgImgPath[curState]) {
		this.LayerArray[this.BGLayerIndex].SetImage(this.BgImgPath[curState]);		
	}
	
	if(this.FgImgPath[curState]){
		this.LayerArray[this.FgImgLayerIndex].SetImage(this.FgImgPath[curState]);	
	}
	
	if(this.TextStyle[curState]){
		this.LayerArray[this.TextLayerIndex].SetStyle(this.TextStyle[curState]);
	}

	if(this.BgImgStyle[curState]){
		this.LayerArray[this.BGLayerIndex].SetStyle(this.BgImgStyle[curState]);
	}
	
	if(this.FgImgStyle[curState]){
		this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FgImgStyle[curState]);
	}	
}

ButtonBase.prototype.Show = function() {
	
	this.Showstate = true;
	
	if(this.flag_ClickEvent == true)
	{
		if(this.state == BUTTON_BASE_STATE.NORMAL)
		{
			this.SetClickEvent();	
		}
	}	
	$("#"+ this.LayerArray[this.BGLayerIndex].Obj).css('display', 'block');	
}

ButtonBase.prototype.Hide = function() {
	
	this.Showstate = false;
	
	if(this.flag_ClickEvent == true)
	{
		this.ResetClickEvent();	
	}		
	$("#"+ this.LayerArray[this.BGLayerIndex].Obj).css('display', 'none');
}

ButtonBase.prototype.highlight = function(){

    this.state    = BUTTON_BASE_STATE.HIGHLIGHT;
	this.ChangeMode();

	if(this.flag_ClickEvent == true)
	{
		this.SetClickEvent();	
	}	
}

ButtonBase.prototype.blur = function(){

    this.state    = BUTTON_BASE_STATE.NORMAL;
	this.ChangeMode();
	
	if(this.flag_ClickEvent == true)
	{
		this.SetClickEvent();	
	}		
}

ButtonBase.prototype.select = function(){
    
    this.state    = BUTTON_BASE_STATE.SELECT;
	this.ChangeMode();
	
	if(this.flag_ClickEvent == true)
	{
		this.ResetClickEvent();	
	}	
}

ButtonBase.prototype.dim = function(){
    
    this.state    = BUTTON_BASE_STATE.DIM;
	this.ChangeMode();
	
	if(this.flag_ClickEvent == true)
	{
		this.ResetClickEvent();	
	}	
}

ButtonBase.prototype.SetID = function(nID){
    this.ID = nID;
}

ButtonBase.prototype.GetID = function(){
    return this.ID;
}

ButtonBase.prototype.GetState = function(){
    return this.state;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * @author donghee80.lee
 */

var SCROLLBAR_SHAPE_STYLE = { 
 
    HORIZONTAL		: 0,
	VERTICAL		: 1,
}

 
function ScrollBar() {

    this.FirstLayerIndex	= -1;
    this.SegmentLayerIndex	= -1;
	this.LastLayerIndex		= -1;
	
	this.ShapeStyle		= SCROLLBAR_SHAPE_STYLE.VERTICAL;
	
	this.TotalNum	= 0;
	this.CurrentNum	= 0;
	
	this.StartPosition	= 0;
	this.FirstLength	= 0;
	this.TotalLength	= 0;
	
	this.objId = null;
	
    CompBase.call(this);
}

ScrollBar.prototype = new CompBase(); 

ScrollBar.prototype.Create = function(eName) {
    
    alert("##mini##ScrollBar.Create()");
            
	this.objId = eName;
	this.CreateBG(eName)  
	
	var ElementStr;
		
    ElementStr = eName + "First";    
    this.FirstLayerIndex = this.LayerArray.length; 
    this.AddImageLayer(ElementStr);		

    ElementStr = eName + "Segment";
    this.SegmentLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr);    

    ElementStr = eName + "Last";
    this.LastLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr);    
	
}

ScrollBar.prototype.SetShapeStyle = function(nShapeStyle){

	this.ShapeStyle = nShapeStyle;
}


ScrollBar.prototype.SetPosition = function(totalNum,TotalLength_,StartPosition_,FirstLength_){
	
	this.TotalNum		= totalNum;	
	this.CurrentNum		= 1;
	this.TotalLength	= TotalLength_;
	this.StartPosition	= StartPosition_;
	this.FirstLength 	= FirstLength_;	   			   
}


ScrollBar.prototype.SetTotalNum = function(nTotalNum){
	
	this.TotalNum = nTotalNum;	    			   
}


ScrollBar.prototype.SetCurrentNum = function(nCurNum){
	
	this.CurrentNum	= nCurNum;	    			  
		
	//alert("##mini##ScrollBar.CurrentNum = " + nCurNum);	  
}


ScrollBar.prototype.SetStartPosition = function(nPos){
	
   this.StartPosition = nPos;		   

}

ScrollBar.prototype.SetFirstLength = function(nLength){
	
   this.FirstLength = nLength;		   

}


ScrollBar.prototype.SetTotalLength = function(nLength){
	
   this.TotalLength = nLength;		   

}

ScrollBar.prototype.ResetScrollBar = function(){
	
	alert("##mini##ScrollBar.ResetScrollBar()");
	
	if(this.TotalNum > 1)
	{
		//set block length
		var BlockLengh = parseInt(this.TotalLength/this.TotalNum);
		
		var RestLength;
		var adjustRest;
		var FirstPosition;
		var SegmentPositon;
		var SegmentLength;
		var LastPosition;
		
//BlockLengh = this.FirstLength * 2 + 2;		
		if(BlockLengh < this.FirstLength * 2 + 2){
			
			BlockLengh = this.FirstLength * 2 + 2;
			
			var MtotalLength = this.TotalLength - BlockLengh;
			var MblockLength = parseInt(MtotalLength/(this.TotalNum-1));
			
			RestLength = parseInt(MtotalLength % (this.TotalNum-1));
			adjustRest = parseInt(RestLength * this.CurrentNum / this.TotalNum);
			
			//first
			FirstPosition = this.StartPosition + MblockLength * (this.CurrentNum - 1);
			FirstPosition += adjustRest;
			
			//segment				
			SegmentPositon = FirstPosition + this.FirstLength;
			SegmentLength = 2;
			
			//last				
			LastPosition = FirstPosition + this.FirstLength + SegmentLength;				
			
		}
		else {

			RestLength = parseInt(this.TotalLength % this.TotalNum);
			adjustRest = parseInt(RestLength * this.CurrentNum / this.TotalNum);
			
			//first
			FirstPosition = this.StartPosition + BlockLengh * (this.CurrentNum - 1);
			FirstPosition += adjustRest;
			
			//segment				
			SegmentPositon = FirstPosition + this.FirstLength;
			SegmentLength = BlockLengh - this.FirstLength * 2;
			
			//last				
			LastPosition = FirstPosition + this.FirstLength + SegmentLength;			
		}

		alert("##mini##BlockLengh = " + BlockLengh);
		alert("##mini##adjustRest = " + adjustRest);
		alert("##mini##FirstPosition = " + FirstPosition); 
		alert("##mini##SegmentPositon = " + SegmentPositon); 
		alert("##mini##SegmentLength = " + SegmentLength); 
		alert("##mini##LastPosition = " + LastPosition); 

		if(this.ShapeStyle == SCROLLBAR_SHAPE_STYLE.VERTICAL){
			$("#"+this.LayerArray[this.FirstLayerIndex].Obj).css('top', FirstPosition + 'px');
			$("#"+this.LayerArray[this.SegmentLayerIndex].Obj).css('top', SegmentPositon + 'px');	
			$("#"+this.LayerArray[this.SegmentLayerIndex].Obj).css('height', SegmentLength + 'px');			
			$("#"+this.LayerArray[this.LastLayerIndex].Obj).css('top', LastPosition + 'px');			
		}
		else{
			$("#"+this.LayerArray[this.FirstLayerIndex].Obj).css('left', FirstPosition + 'px');
			$("#"+this.LayerArray[this.SegmentLayerIndex].Obj).css('left', SegmentPositon + 'px');	
			$("#"+this.LayerArray[this.SegmentLayerIndex].Obj).css('width', SegmentLength + 'px');
			$("#"+this.LayerArray[this.LastLayerIndex].Obj).css('left', LastPosition + 'px');			
		}	
	

		if(this.Showstate == false)
		{
			this.Show();
		}	
	}
	else{
		alert("##mini##ResetScrollBar is TotalNum <= 1 ");

		if(this.Showstate == true)
		{
			alert("##mini##111111ResetScrollBar Hide");
			this.Hide();
		}				
	}

}


ScrollBar.prototype.SetFirstImage = function(ImagePath){
	
   this.LayerArray[this.FirstLayerIndex].SetImage(ImagePath); 			   

}

ScrollBar.prototype.SetSegmentImage = function(ImagePath){
	
   this.LayerArray[this.SegmentLayerIndex].SetImage(ImagePath); 			   

}

ScrollBar.prototype.SetLastImage = function(ImagePath){
	
   this.LayerArray[this.LastLayerIndex].SetImage(ImagePath); 			   

}

ScrollBar.prototype.SetBGImage = function(first, segment, last) {
	alert("##mini##ScrollBar,SetBGImage : objId = " + this.objId);
	if(this.ShapeStyle == SCROLLBAR_SHAPE_STYLE.VERTICAL) {
		$("#" + this.objId).append("<div id='" + this.objId + "_first_bg'></div><div id='" + this.objId + "_segment_bg'></div><div id='" + this.objId + "_last_bg'></div>");	
		var width = $("#" + this.objId).css('width');
		var scroll_width = parseInt(width.substring(0, width.indexOf("px")))+1;
		$("#" + this.objId + "_first_bg").css('width', scroll_width+"px");
		$("#" + this.objId + "_segment_bg").css('width', scroll_width+"px");
		$("#" + this.objId + "_last_bg").css('width', scroll_width+"px");

		$("#" + this.objId + "_first_bg").css('height', this.FirstLength+"px");

		$("#" + this.objId + "_segment_bg").css('top', this.FirstLength+"px");
		$("#" + this.objId + "_segment_bg").css('height', this.TotalLength - (this.FirstLength * 2) +"px");

		$("#" + this.objId + "_last_bg").css('top', this.TotalLength - this.FirstLength +"px");
		$("#" + this.objId + "_last_bg").css('height', this.FirstLength+"px");
		
		$("#" + this.objId + "_first_bg").css("background-image", "url('" + first + "')");
		$("#" + this.objId + "_segment_bg").css('background-image', "url('" + segment + "')");
		$("#" + this.objId + "_last_bg").css('background-image', "url('" + last + "')");

	} else if(this.ShapeStyle == SCROLLBAR_SHAPE_STYLE.HORIZONTAL) {
		$("#" + this.objId + "_BG_First").css("background-image", "url('" + first + "')");
		$("#" + this.objId + "_BG_Segment").css('background-image', "url('" + segment + "')");
		$("#" + this.objId + "_BG_Last").css('background-image', "url('" + last + "')");
	}
	
}



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


var ITEM_DATA_TYPE = { 

 	CUSTOM				:	0,
    TEXT_ONLY			:   1,
    IMAGE_ONLY			:   2,
	IMAGE_TEXT			:	3
}


var ITEM_SIZE_STYLE = { 
 	
    FIXED_SIZE			:   0,			
    REMOVE_SIZE			:   1,			
}

var ITEM_STATE = { 
 	
    NORMAL			:   0,
    HIGHLIGHT		:   1,
    SELECT			:   2,
	MAX				:	3	

}

function ListItem() {


    this.ItemID		= -1; 
    
    this.State		= ITEM_STATE.NORMAL;  

	this.ItemDataType	= ITEM_DATA_TYPE.CUSTOM;
    this.ImageLayerIndex	= -1;
	this.FgImgLayerIndex = -1;
    this.TextLayerIndex		= -1;
	

	this.BGUrl = new Array(ITEM_STATE.MAX);
	this.BGStyle = new Array(ITEM_STATE.MAX);
    
	this.FGUrl = new Array(ITEM_STATE.MAX);
	this.FGStyle = new Array(ITEM_STATE.MAX);

	//ItemStyle
	this.TextStyle = new Array(ITEM_STATE.MAX);
	this.ImageStyle = new Array(ITEM_STATE.MAX);
	this.FgImgStyle = new Array(ITEM_STATE.MAX);

	this.InputData	= null;

	this.ExistData	= false;

    CompBase.call(this);
}


ListItem.prototype = new CompBase(); 

ListItem.prototype.Create = function(eName, divide) {
    
    alert("##mini##ListItem.Create()");
            
    this.CreateBG(eName, divide);
	if(divide)
		this.divide_num = divide;
	var ElementStr;
	
	if(this.ItemDataType & ITEM_DATA_TYPE.TEXT_ONLY)
	{		
	    ElementStr = eName + "Text";    
	    this.TextLayerIndex = this.LayerArray.length; 
	    this.AddTextLayer(ElementStr);		
		alert("##mini##AddTextLayer(" + ElementStr + ")");
	}
	if(this.ItemDataType & ITEM_DATA_TYPE.IMAGE_ONLY)
	{
		alert("##mini##ListItem.Create()");
	    ElementStr = eName + "Image";
	    this.ImageLayerIndex = this.LayerArray.length;    
	    this.AddImageLayer(ElementStr);    
		alert("##mini##AddImageLayer(" + ElementStr + ")");		
	}
	if(this.ItemDataType & ITEM_DATA_TYPE.FG_ONLY) {
		alert("##mini##ListItem.Create()_FG_ONLY");
		ElementStr = eName + "Icon";
		this.FgImgLayerIndex = this.LayerArray.length;
		this.AddImageLayer(ElementStr);
		alert("##mini##AddImageLayer(" + ElementStr + ")");
	}
	this.Showstate  = false;			
}



ListItem.prototype.SetItemID = function(nID) {
	//alert("##mini##ListItem.SetItemID()");
    this.ItemID = nID;
}

ListItem.prototype.GetItemID = function() {

    return this.ItemID;
}


ListItem.prototype.SetFlagForExistData = function(flag) {

    this.ExistData = flag;
}

ListItem.prototype.GetFlagForExistData = function() {

    return this.ExistData;
}

ListItem.prototype.GetData = function(){
	return this.InputData;
}

ListItem.prototype.GetDataText = function() {

  
	if(this.ItemDataType & ITEM_DATA_TYPE.TEXT_ONLY)
	{
		return this.InputData[0];
	}		
}

ListItem.prototype.GetDataImage = function() {

	if(this.ItemDataType & ITEM_DATA_TYPE.IMAGE_ONLY)
	{
		return this.InputData[1];
	}
	
}


ListItem.prototype.SetDivideBgImage = function(BgUrl) {
	alert("##mini##bgImage : " + BgUrl);
	if(BgUrl != null) {
		var result = BgUrl.indexOf('_m');
		var Url;
		if(result != -1) {
			Url = BgUrl.substring(0, result);

			alert("##mini##Url : " + Url);
		}
		this.BGLayer_center.SetImage(Url + "_m.png");
		this.BGLayer_left.SetImage(Url + "_t.png");
		this.BGLayer_right.SetImage(Url + "_b.png");
	}
}

ListItem.prototype.SetBgImage = function(ItemStateIndex, BgUrl){
     
	if (BgUrl) {
		this.BGUrl[ItemStateIndex] = BgUrl;
		
		if(ItemStateIndex == ITEM_STATE.NORMAL) {	
			if(this.divide_num) {
				this.SetDivideBgImage(BgUrl);
			} else {
			this.LayerArray[this.BGLayerIndex].SetImage(BgUrl);	
		}		
		}		
	}
}

ListItem.prototype.SetFgImage = function(ItemStateIndex, FgUrl) {
		
	this.FGUrl[ItemStateIndex] = FgUrl;

	if(ItemStateIndex == ITEM_STATE.NORMAL) {
		this.LayerArray[this.FgImgLayerIndex].SetImage(FgUrl);
	}

}

ListItem.prototype.SetBgStyle = function(ItemStateIndex, BgStyle){
    	
	this.BGStyle[ItemStateIndex] = BgStyle;
	
	if(ItemStateIndex == ITEM_STATE.NORMAL) {	
		this.LayerArray[this.BGLayerIndex].SetStyle(BgStyle);	
	}
    
}

ListItem.prototype.SetTextStyle = function(ItemStateIndex, Style){
    	
	this.TextStyle[ItemStateIndex] = Style;

	if(ItemStateIndex == ITEM_STATE.NORMAL) {	
		this.LayerArray[this.TextLayerIndex].SetStyle(Style);	
	}
    
}

ListItem.prototype.SetImageStyle = function(ItemStateIndex, Style){
    	
	this.ImageStyle[ItemStateIndex] = Style;

	if(ItemStateIndex == ITEM_STATE.NORMAL) {	
		this.LayerArray[this.ImageLayerIndex].SetStyle(Style);	
	}
    
}

ListItem.prototype.SetFgStyle = function(ItemStateIndex, Style) {

	this.FGStyle[ItemStateIndex] = Style;

	if(ItemStateIndex == ITEM_STATE.NORMAL) {
		this.LayerArray[this.FgImgLayerIndex].SetStyle(Style);
	}
}

ListItem.prototype.SetDataType = function(nDataType){
    	
	this.ItemDataType = nDataType;
    
}

ListItem.prototype.GetState = function() {

    return this.State;
    
}

ListItem.prototype.Normal = function() {
	
	alert("##mini##ListItem.Normal()" );
    this.State = ITEM_STATE.NORMAL;
	this.ChangeBG();
	this.ChangeItem();
}

ListItem.prototype.Highlight = function() {
	
	this.State = ITEM_STATE.HIGHLIGHT;
	this.ChangeBG();
	this.ChangeItem();
}

ListItem.prototype.Select = function() {
    
	this.State = ITEM_STATE.SELECT;
	this.ChangeBG();
	this.ChangeItem();
}


ListItem.prototype.ChangeBG = function() {

    alert("##mini##ListItem.ChangeBG()" );
	
    switch(this.State) {
		
		case ITEM_STATE.NORMAL:
			if(this.BGStyle[ITEM_STATE.NORMAL])
			{				
				this.LayerArray[this.BGLayerIndex].SetStyle(this.BGStyle[ITEM_STATE.NORMAL]);
			}			
			if(this.BGUrl[ITEM_STATE.NORMAL])
			{
				if(this.divide_num) {
				    alert("##mini##ListItem.ChangeBG(NORMAL) : this.divide_num = "+ this.divide_num);
					this.SetDivideBgImage(this.BGUrl[ITEM_STATE.NORMAL]);
				} else {
				this.LayerArray[this.BGLayerIndex].SetImage(this.BGUrl[ITEM_STATE.NORMAL]);
			}			 
			}			 

			if(this.FGStyle[ITEM_STATE.NORMAL]) {
				this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FGStyle[ITEM_STATE.NORMAL]);
			}
			if(this.FGUrl[ITEM_STATE.NORMAL]) {
				this.LayerArray[this.FgImgLayerIndex].SetImage(this.FGUrl[ITEM_STATE.NORMAL]);
			}
			break;
			
		case ITEM_STATE.HIGHLIGHT:
				
			if(this.BGStyle[ITEM_STATE.HIGHLIGHT]) {
				this.LayerArray[this.BGLayerIndex].SetStyle(this.BGStyle[ITEM_STATE.HIGHLIGHT]);
			}
			if(this.BGUrl[ITEM_STATE.HIGHLIGHT]) {
				if(this.divide_num) {
				    alert("##mini##ListItem.ChangeBG(HIGHLIGHT) : this.divide_num = "+ this.divide_num);
					this.SetDivideBgImage(this.BGUrl[ITEM_STATE.HIGHLIGHT]);
				} else {
					this.LayerArray[this.BGLayerIndex].SetImage(this.BGUrl[ITEM_STATE.HIGHLIGHT]);
				}
			}

			if(this.FGStyle[ITEM_STATE.HIGHLIGHT]) {
				this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FGStyle[ITEM_STATE.HIGHLIGHT]);
			}
			if(this.FGUrl[ITEM_STATE.HIGHLIGHT]) {
				this.LayerArray[this.FgImgLayerIndex].SetImage(this.FGUrl[ITEM_STATE.HIGHLIGHT]);
			}

			break;		
			
		case ITEM_STATE.SELECT:
		
			if(this.BGStyle[ITEM_STATE.SELECT])
			{
				this.LayerArray[this.BGLayerIndex].SetStyle(this.BGStyle[ITEM_STATE.SELECT]);
			}
			if(this.BGUrl[ITEM_STATE.SELECT])
			{
				if(this.divide_num) {
				    alert("##mini##ListItem.ChangeBG(SELECT) : this.divide_num = "+ this.divide_num);
					this.SetDivideBgImage(this.BGUrl[ITEM_STATE.SELECT]);
				} else {
					this.LayerArray[this.BGLayerIndex].SetImage(this.BGUrl[ITEM_STATE.SELECT]);
				}
			}						
			if(this.FGStyle[ITEM_STATE.SELECT]) {
				this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FGStyle[ITEM_STATE.SELECT]);
			}
			if(this.FGUrl[ITEM_STATE.SELECT]) {
				this.LayerArray[this.FgImgLayerIndex].SetImage(this.FGUrl[ITEM_STATE.SELECT]);
			}
			break;			
	}	
}

ListItem.prototype.ChangeItem = function() {

    alert("##mini##ListItem.ChangeItem()" );
	
    switch(this.State) {
		
		case ITEM_STATE.NORMAL:
			if(this.TextStyle[ITEM_STATE.NORMAL])
			{
				this.LayerArray[this.TextLayerIndex].SetStyle(this.TextStyle[ITEM_STATE.NORMAL]);
			}
			if(this.ImageStyle[ITEM_STATE.NORMAL])
			{
				this.LayerArray[this.ImageLayerIndex].SetStyle(this.ImageStyle[ITEM_STATE.NORMAL]);
			}			
			if(this.FgImgStyle[ITEM_STATE.NORMAL]) {
				this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FgImgStyle[ITEM_STATE.NORMAL]);
			}
			break;
			
		case ITEM_STATE.HIGHLIGHT:
				
			if(this.TextStyle[ITEM_STATE.HIGHLIGHT])
			{
				this.LayerArray[this.TextLayerIndex].SetStyle(this.TextStyle[ITEM_STATE.HIGHLIGHT]);
			}
			if(this.ImageStyle[ITEM_STATE.HIGHLIGHT])
			{
				this.LayerArray[this.ImageLayerIndex].SetStyle(this.ImageStyle[ITEM_STATE.HIGHLIGHT]);
			}				
			if(this.FgImgStyle[ITEM_STATE.HIGHLIGHT]) {
				this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FgImgStyle[ITEM_STATE.HIGHLIGHT]);
			}
			break;		
			
		case ITEM_STATE.SELECT:
		
			if(this.TextStyle[ITEM_STATE.SELECT])
			{
				this.LayerArray[this.TextLayerIndex].SetStyle(this.TextStyle[ITEM_STATE.SELECT]);
			}
			if(this.ImageStyle[ITEM_STATE.SELECT])
			{
				this.LayerArray[this.ImageLayerIndex].SetStyle(this.ImageStyle[ITEM_STATE.SELECT]);
			}
			if(this.FgImgStyle[ITEM_STATE.SELECT]) {
				this.LayerArray[this.FgImgLayerIndex].SetStyle(this.FgImgStyle[ITEM_STATE.SELECT]);
			}
			break;			
	}	
}


ListItem.prototype.SetItem = function(ContentsArray){

	if(this.ItemDataType & ITEM_DATA_TYPE.TEXT_ONLY)
	{
		//alert("##mini##SetText(" + ContentsArray[0] + ")");	
		this.LayerArray[this.TextLayerIndex].SetText(ContentsArray[0]);	
	}

	if(this.ItemDataType & ITEM_DATA_TYPE.IMAGE_ONLY)
	{
		this.LayerArray[this.ImageLayerIndex].SetImage(ContentsArray[1]);	
	}
	
	if(this.ItemDataType & ITEM_DATA_TYPE.FG_ONLY) {
		this.LayerArray[this.FgImgLayerIndex].SetImage(ContentsArray[2]);
	}

	this.InputData	= ContentsArray;
	
	if(ContentsArray[0] == null && ContentsArray[1] == null && ContentsArray[2] == null)
	{
		this.ExistData = false;
	}
	else{
		this.ExistData = true;
	}		
	
}

ListItem.prototype.DisableReverse = function(){
	
	this.LayerArray[this.TextLayerIndex].SetReverseDisable(true);
}



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


/*
var DEFAULT_CONTACT_DATA = { 
 
    NAME	            :   "name" ,
    MOOD_MESSAGE        :   "mood message" ,
    AVATA               :   g_Image.IMAGE_LIST_MAIN_CATEGORY_CONTACT_BTN_ICON,
    ONLINE_SATAE        :   g_Image.IMAGE_LIST_MAIN_ONLINE_STATUS_PRESENCE_AVAILABLE ,
}

*/

function ContactItem () {
    
    //this.CurHighlightButton = CONTACT_MBUTTON.NO_SELECT;
        
    this.NameLayerIndex         = -1;
    this.MoodMessageLayerIndex  = -1;
    this.BoxLayerIndex			= -1;	
    this.AvataLayerIndex        = -1;
    this.OnlieStatusLayerIndex  = -1;
	//this.MsgBallonLayerIndex	= -1;
	//this.MsgNumberLayerIndex	= -1;
	this.NewIconLayerIndex		= -1;
	
	this.IdentityName 	= null;			//Skype Name or PSTN number
	this.DisplayName	= null;
	this.AvataType		= null;
	
	
	this.IsNewAlaram =false;
	//his.MsgNum			= 0;
   
    this.BoxStyle			= new Array(ITEM_STATE.MAX);   
    this.AvataStyle			= new Array(ITEM_STATE.MAX);
    this.OnlineStyle		= new Array(ITEM_STATE.MAX);	
	this.NameStyle			= new Array(ITEM_STATE.MAX);
    this.MoodMsgStyle		= new Array(ITEM_STATE.MAX);

	this.NameMarqueeStyle		= null;
	this.NameMarqueeCheckerDiv	= null;	
   
    ListItem.call(this);
}

ContactItem.prototype = new ListItem(); 

ContactItem.prototype.Create = function(eName) {
    
    alert("##mini##ContactItem.Create()");

    this.CreateBG(eName, 20);         
	this.CreateName(eName);	
    this.CreateMoodMessage(eName);	
    this.CreateBox(eName);		
    this.CreateAvata(eName);    
    this.CreateStatus(eName);
    
    this.CreateNewContactIcon(eName);

	
    this.SetBgImage(ITEM_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_NORMAL_BG);
	this.SetBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_HIGHLIGHT_BG);	
	this.SetBgImage(ITEM_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_SELECT_BG);	
	
	this.SetBgStyle(ITEM_STATE.NORMAL, eName + "Normal");
	//this.SetBgStyle(ITEM_STATE.HIGHLIGHT, eName + "Normal");
	
	
	this.SetMoodMsgStyle(ITEM_STATE.NORMAL, "cItem_Mood_Normal");
	//this.SetMoodMsgStyle(ITEM_STATE.HIGHLIGHT, "cItem_Mood_Highlight");
	
	this.SetNameStyle(ITEM_STATE.NORMAL, "cItem_Name_Normal");
	//this.SetNameStyle(ITEM_STATE.HIGHLIGHT, "cItem_Name_Highlight");
	
	this.NameMarqueeStyle = "cItem_Name_Highlight_Marquee";
	this.NameMarqueeCheckerDiv = "contactTextLengthChecker"	

	this.SetOnlineStyle(ITEM_STATE.NORMAL, "cItem_Online_Normal");
//	this.SetOnlineStyle(ITEM_STATE.HIGHLIGHT, "cItem_Online_Highlight");

	
	this.SetAvataStyle(ITEM_STATE.NORMAL, "cItem_Avatar_Normal");
//	this.SetAvataStyle(ITEM_STATE.HIGHLIGHT, "cItem_Avatar_Highlight");
			
	this.SetBoxStyle(ITEM_STATE.NORMAL, "cItem_Box_Normal");
	//this.SetBoxStyle(ITEM_STATE.HIGHLIGHT, "cItem_Box_Highlight");

	this.LayerArray[this.BoxLayerIndex].SetStyle(this.BoxStyle[ITEM_STATE.NORMAL]);	
	this.LayerArray[this.BoxLayerIndex].SetImage(g_Image.IMAGE_CONFERENCE_CALL_AVATAR_FRAME);
	this.LayerArray[this.AvataLayerIndex].SetStyle(this.AvataStyle[ITEM_STATE.NORMAL]);
//	this.SetSmallAvata();
    this.LayerArray[this.MoodMessageLayerIndex].SetStyle(this.MoodMsgStyle[ITEM_STATE.NORMAL]);	
    this.LayerArray[this.OnlieStatusLayerIndex].SetStyle(this.OnlineStyle[ITEM_STATE.NORMAL]); 		
	this.LayerArray[this.NameLayerIndex].SetTextStyle(this.NameStyle[ITEM_STATE.NORMAL]);

}

ContactItem.prototype.CreateName = function(eRootName) {

    var ElementStr = eRootName + "Name";
    
    this.NameLayerIndex = this.LayerArray.length;
    this.AddTextLayer(ElementStr);
    this.LayerArray[this.NameLayerIndex].SetReverseDisable(true);
    this.LayerArray[this.NameLayerIndex].SetIsPlainText(true);
             
}

ContactItem.prototype.CreateMoodMessage = function(eRootName) {

    var ElementStr = eRootName + "Mood";

    this.MoodMessageLayerIndex = this.LayerArray.length;    
    this.AddTextLayer(ElementStr); 
    this.LayerArray[this.MoodMessageLayerIndex].SetReverseDisable(true);  
    this.LayerArray[this.MoodMessageLayerIndex].SetIsPlainText(true); 
  
}

ContactItem.prototype.CreateBox = function(eRootName) {

    var ElementStr = eRootName + "Box";

    this.BoxLayerIndex = this.LayerArray.length;    
    this.AddJPGImageLayer(ElementStr);
	    
	this.LayerArray[this.BoxLayerIndex].SetImage(g_Image.IMAGE_CONFERENCE_CALL_AVATAR_FRAME);
             
}
ContactItem.prototype.CreateNewContactIcon = function(eRootName) {

    var ElementStr = eRootName + "NewIcon";
	this.NewIconLayerIndex = this.LayerArray.length;  
    this.AddImageLayer(ElementStr); 
}

ContactItem.prototype.CreateAvata = function(eRootName) {

    var ElementStr = eRootName + "Avata";

    this.AvataLayerIndex = this.LayerArray.length;    
    this.AddJPGImageLayer(ElementStr);    
             
}

ContactItem.prototype.CreateStatus = function(eRootName) {

    var ElementStr = eRootName + "Online";

    this.OnlieStatusLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr);    
             
}

ContactItem.prototype.CreateMsgBallon = function(eRootName) {

    var ElementStr = eRootName + "MsgBallon";

    this.MsgBallonLayerIndex = this.LayerArray.length;    
    this.AddImageLayer(ElementStr); 
	this.LayerArray[this.MsgBallonLayerIndex].SetImage(g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_MSG_BALLON );  
             
}

ContactItem.prototype.CreateMsgNumber = function(eRootName) {

    var ElementStr = eRootName + "MsgNumber";

    this.MsgNumberLayerIndex = this.LayerArray.length;    
    this.AddTextLayer(ElementStr); 		  	  
            
}

ContactItem.prototype.SetOnlineStyle = function(ItemStateIndex, Style){
    	
	this.OnlineStyle[ItemStateIndex] = Style;
    
}

ContactItem.prototype.SetBoxStyle = function(ItemStateIndex, Style){
    	
	this.BoxStyle[ItemStateIndex] = Style;
    
}


ContactItem.prototype.SetAvataStyle = function(ItemStateIndex, Style){
    	
	this.AvataStyle[ItemStateIndex] = Style;
    
}

ContactItem.prototype.SetNameStyle = function(ItemStateIndex, Style){
    	
	this.NameStyle[ItemStateIndex] = Style;
    
}

ContactItem.prototype.SetMoodMsgStyle = function(ItemStateIndex, MoodMsgStyle){
    	
	this.MoodMsgStyle[ItemStateIndex] = MoodMsgStyle;
    
}

ContactItem.prototype.GetIdentity = function(){

    return this.IdentityName;
}

ContactItem.prototype.GetIdentityName = function(){

    return this.IdentityName;
}

ContactItem.prototype.GetDisplayName = function(){

    return this.DisplayName;
}

ContactItem.prototype.Select = function() {
	
    this.State = ITEM_STATE.SELECT;
	this.ChangeBG();
	this.ChangeLayerForNormal();
}

ContactItem.prototype.Normal = function() {
	
    this.State = ITEM_STATE.NORMAL;
	this.ChangeBG();
	this.ChangeLayerForNormal();
}

ContactItem.prototype.Highlight = function() {
	
	this.State = ITEM_STATE.HIGHLIGHT;
	this.ChangeBG();
	this.ChangeLayerForHighlight();
	
}


ContactItem.prototype.ChangeLayerForHighlight = function() {
	
	alert("##mini##ContactItem.ChangeLayerForHighlight()");

	//$("#"+ this.LayerArray[this.BoxLayerIndex].Obj).css('display', 'none');	
/*
	this.LayerArray[this.BoxLayerIndex].SetStyle(this.BoxStyle[ITEM_STATE.HIGHLIGHT]);
	this.LayerArray[this.BoxLayerIndex].SetImage(g_Image.IMAGE_CONFERENCE_CALL_AVATAR_FRAME);
	this.LayerArray[this.AvataLayerIndex].SetStyle(this.AvataStyle[ITEM_STATE.HIGHLIGHT]);		
//    this.SetBigAvata();
	this.LayerArray[this.MoodMessageLayerIndex].SetStyle(this.MoodMsgStyle[ITEM_STATE.HIGHLIGHT]);	
    this.LayerArray[this.OnlieStatusLayerIndex].SetStyle(this.OnlineStyle[ITEM_STATE.HIGHLIGHT]); 
       */

	if(this.LayerArray[this.NameLayerIndex].CheckTextLength(this.NameMarqueeCheckerDiv, this.DisplayName) > 169)
	{
		this.LayerArray[this.NameLayerIndex].SetTextStyle(this.NameMarqueeStyle);
	}
	else{
		//this.LayerArray[this.NameLayerIndex].SetTextStyle(this.NameStyle[ITEM_STATE.HIGHLIGHT]);
		this.LayerArray[this.NameLayerIndex].SetTextStyle(this.NameStyle[ITEM_STATE.NORMAL]);
	}

}


ContactItem.prototype.ChangeLayerForNormal = function() {

    alert("##mini##ContactItem.ChangeLayerForNormal()");    
	
	//$("#"+ this.LayerArray[this.BoxLayerIndex].Obj).css('display', 'block');
	/*
	this.LayerArray[this.BoxLayerIndex].SetStyle(this.BoxStyle[ITEM_STATE.NORMAL]);	
		this.LayerArray[this.BoxLayerIndex].SetImage(g_Image.IMAGE_CONFERENCE_CALL_AVATAR_FRAME);
		this.LayerArray[this.AvataLayerIndex].SetStyle(this.AvataStyle[ITEM_STATE.NORMAL]);
	//	this.SetSmallAvata();
		this.LayerArray[this.MoodMessageLayerIndex].SetStyle(this.MoodMsgStyle[ITEM_STATE.NORMAL]);	
		this.LayerArray[this.OnlieStatusLayerIndex].SetStyle(this.OnlineStyle[ITEM_STATE.NORMAL]); 	*/	
	this.LayerArray[this.NameLayerIndex].SetTextStyle(this.NameStyle[ITEM_STATE.NORMAL]);
	
	
}


ContactItem.prototype.SetItem = function(ContactDataObject) {
	
	alert("##mini##CContactItem.SetItem()");
	
	this.IdentityName = ContactDataObject.IdentityName;
	this.DisplayName = ContactDataObject.DisplayName;
	this.AvataType = ContactDataObject.AvataImgType;
	
	this.LayerArray[this.NameLayerIndex].SetText(ContactDataObject.DisplayName);

	//TEMPCODE
	var tempSuffix = g_Data.GetImgSuffixPath();
	if(this.AvataType == ENUM_CONTACT_AVATA_TYPE.ONES_IMAGE){
				
		this.LayerArray[this.AvataLayerIndex].SetImage(ContactDataObject.AvataImgPath + tempSuffix);
	}
	else{		
		this.LayerArray[this.AvataLayerIndex].SetImage(ContactDataObject.AvataImgPath);
	}
	
	this.LayerArray[this.OnlieStatusLayerIndex].SetImage(ContactDataObject.OnlineStatusImgPath);
	this.LayerArray[this.MoodMessageLayerIndex].SetText(ContactDataObject.MoodMsg);
		
	this.ExistData = true;

	//alert("##mini##DisplayName = " + ContactDataObject.DisplayName);
	//alert("##mini##IdentityName = " + ContactDataObject.IdentityName);
	//alert("##mini##MoodMsg = " + ContactDataObject.MoodMsg);	
	//alert("##mini##AvataType = " + this.AvataType);
	//alert("##mini##AvataImage = " + ContactDataObject.AvataImgPath + tempSuffix);	
	if(ContactDataObject.IsNewContact){
		this.LayerArray[this.NewIconLayerIndex].SetBgImage(g_Image.IMAGE_LIST_MAIN_CONTACT_ALARM);
	}else{
		this.LayerArray[this.NewIconLayerIndex].SetBgImage("");
	}
}

ContactItem.prototype.SetLiveCallItem = function( callMemberID){

	alert("##mini##CallingLiveItem.SetLiveCallItem()");

	var Avatar;
	
	if(ProcMgr.GetIsConferenceCall()){

		//Set Name
		var NumOfCallMembers = PluginAPIMgr.GetNumOfCallMembers();
		var CallMembersName = "";
		
		for (var i = 0; i < NumOfCallMembers; i++) {
		
			if(i == NumOfCallMembers - 1){
				
				CallMembersName = CallMembersName + PluginAPIMgr.GetCallMemberDisplayName(i);
			}
			else{
				
				CallMembersName = CallMembersName + PluginAPIMgr.GetCallMemberDisplayName(i) + ", "	
			}
				
		}

		this.DisplayName = CallMembersName;		
				
		//Set avatar
		Avatar = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_GROUP;
		this.AvataType = ENUM_CONTACT_AVATA_TYPE.GROUP;
		
	}
	else{

		//Set Name
		this.DisplayName = PluginAPIMgr.GetCallMemberDisplayName();		
				
		//Set avatar
		Avatar = PluginAPIMgr.GetCallMemberAvataImage();
		if(Avatar){
			this.AvataType = ENUM_CONTACT_AVATA_TYPE.ONES_IMAGE;
		}
		else{
			Avatar = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_PSTN;
			this.AvataType = ENUM_CONTACT_AVATA_TYPE.PSTN;
		}
	}

	
	this.IdentityName = callMemberID;//PluginAPIMgr.GetCallMemberID();

	//alert("##mini##Name = " + Name);
	this.LayerArray[this.NameLayerIndex].SetText(this.DisplayName);

	//alert("##mini##AvataType = " + this.AvataType);
	this.LayerArray[this.AvataLayerIndex].SetImage(Avatar);
		
	//Set Status
	var Status = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_CALLING;		
	this.LayerArray[this.OnlieStatusLayerIndex].SetImage(Status);
		
	//Set Duration Time
	var Time = IDWS_MOIP_SKYPE_CALL_DURATION + " : ";
	//alert("##mini##Time = " + Time);
	this.LayerArray[this.MoodMessageLayerIndex].SetText(Time);
	
	this.ExistData = true;

}

ContactItem.prototype.SetDuration = function(strTime){

	var DurationTime = IDWS_MOIP_SKYPE_CALL_DURATION + " : "+ strTime;
	this.LayerArray[this.MoodMessageLayerIndex].SetText(DurationTime);
}

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

function pContactItem () {
    		
    ContactItem.call(this);
}

pContactItem.prototype = new ContactItem(); 

pContactItem.prototype.Create = function(eName) {
    
    alert("##mini##ContactItem.Create()");

    this.CreateBG(eName);         
	this.CreateName(eName);	
    this.CreateMoodMessage(eName);	
    this.CreateBox(eName);		
    this.CreateAvata(eName);    
    this.CreateStatus(eName);

	
    this.SetBgImage(ITEM_STATE.NORMAL, g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_NORMAL_BG);
	this.SetBgImage(ITEM_STATE.HIGHLIGHT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_HIGHLIGHT_BG);	
	this.SetBgImage(ITEM_STATE.SELECT,g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_ITEM_SELECT_BG);	
	
	this.SetBgStyle(ITEM_STATE.NORMAL, eName + "Normal");
	this.SetBgStyle(ITEM_STATE.HIGHLIGHT, eName + "Normal");
	
	
	this.SetMoodMsgStyle(ITEM_STATE.NORMAL, "cItem_Mood_Normal");
	this.SetMoodMsgStyle(ITEM_STATE.HIGHLIGHT, "cItem_Mood_Highlight");
	
	this.SetNameStyle(ITEM_STATE.NORMAL, "cItem_Name_Normal");
	this.SetNameStyle(ITEM_STATE.HIGHLIGHT, "cItem_Name_Highlight");
	
	this.NameMarqueeStyle = "cItem_Name_Highlight_Marquee";
	this.NameMarqueeCheckerDiv = "pContactListTextLengthChecker"	

	this.SetOnlineStyle(ITEM_STATE.NORMAL, "cItem_Online_Normal");
	this.SetOnlineStyle(ITEM_STATE.HIGHLIGHT, "cItem_Online_Highlight");

	
	this.SetAvataStyle(ITEM_STATE.NORMAL, "cItem_Avatar_Normal");
	this.SetAvataStyle(ITEM_STATE.HIGHLIGHT, "cItem_Avatar_Highlight");
			
	this.SetBoxStyle(ITEM_STATE.NORMAL, "cItem_Box_Normal");
	this.SetBoxStyle(ITEM_STATE.HIGHLIGHT, "cItem_Box_Highlight");	
	
}


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



var LIST_NAVI_STYLE = { 
 
    
    STYLE_ROTAION               :   0 , 
    STYLE_PAGE_SCROLL           :   1 ,
    STYLE_FIXED_HIGHLIGHT		:   2,                                          
}

var LIST_SHAPE_STYLE = { 
 
    HORIZONTAL		: 0,
	VERTICAL		: 1,
}


function List() {

    this.NaviStyle          = LIST_NAVI_STYLE.STYLE_ROTAION;	
	this.ShapeStyle			= LIST_SHAPE_STYLE.VERTICAL;					
	
	this.ItemSizeStyle		= ITEM_SIZE_STYLE.FIXED_SIZE;	
	this.ItemDataType		= ITEM_DATA_TYPE.CUSTOM;
	
	this.ItemBGUrl			= new Array(ITEM_STATE.MAX);
	this.ItemBGStyle		= new Array(ITEM_STATE.MAX);
	this.ItemFGUrl 			= new Array(ITEM_STATE.MAX);
	this.ItemFGStyle		= new Array(ITEM_STATE.MAX);	
	this.ItemTextStyle		= new Array(ITEM_STATE.MAX);
	this.ItemImageStyle		= new Array(ITEM_STATE.MAX);	
	
	this.ItemClass			= ListItem;
	
	this.ElimentName		= null;

    this.BGLayer            = null;
   	
	//Item Management
	this.NumOfVisibleItem			= 0;		//sometimes changed
	this.MaxNumOfItem				= 0;		//always fixed	
	this.NumOfCreatedItem			= 0;		//almost fixed.
	this.CurrentItemIndex			= -1; 
	this.PrevItemIndex				= -1; 	
   
	
	//Data Management
	this.MaxNumOfData		= 0;
    this.CurrentDataIndex	= -1;  
	this.StartDataIndex		= -1;
    

    this.ShowState		= false;	
	this.Flag_Focus		= false;
	this.Flag_ClickEvent	= false;
	    
    //array
    this.DataArray = [];
    this.ItemArray = [];  
    this.OnClickFunc = [];     
    this.OnMouseOverFunc = [];
    this.OnMouseOutFunc = [];

	this.ItemPressedCallbackFunc = null;	    
	this.onReturnFunc	= null;
	this.onUpFunc		= null;
	this.onDownFunc		= null;
	this.onLeftFunc		= null;
	this.onRightFunc	= null;
	this.onExitFunc	= null;  
    
     this.helpBar = null;
     
    this.Flag_RTL = true;
	this.divide_num = 0;
}

List.prototype.CreateBG = function(Ename, Divide) {

    alert("##mini##List.CreateBG(" + Ename + ")");
    if(Ename == null) {
        //alert("##mini##CListBase.CreateBG()  >>>   Param is null !!  ");
        return false;
    }
	if(Divide)
    	this.divide_num = Divide;
	this.ElimentName = Ename;
	
    this.BGLayer = new ImageLayer(Ename);
	        
}


List.prototype.SetBGImage = function(ImageUrl) {

    alert("##mini##List.SetBGImage()");

	this.BGLayer.SetImage(ImageUrl);
}

List.prototype.SetItemBgImage = function(ItemState,ImageUrl) {

    alert("##mini##List.SetItemBgImage()");
	this.ItemBGUrl[ItemState] = ImageUrl;
}

List.prototype.SetItemBgStyle = function(ItemState,Style) {

    alert("##mini##List.SetItemBgStyle()");
	this.ItemBGStyle[ItemState]	= Style;
}

List.prototype.SetItemFgImage = function(ItemState,ImageUrl) {

    alert("##mini##List.SetItemFgImage()");
	this.ItemFGUrl[ItemState] = ImageUrl;
}

List.prototype.SetItemFgStyle = function(ItemState,Style) {

    alert("##mini##List.SetItemFgStyle()");
	this.ItemFGStyle[ItemState]	= Style;
}

List.prototype.SetDataType = function(nItemDataType) {

    alert("##mini##List.SetDataType()");
	this.ItemDataType = nItemDataType;
}

List.prototype.SetItemDefualtTextStyle = function(ItemState,Style) {

    alert("##mini##List.SetItemDefualtTextStyle()");
	this.ItemTextStyle[ItemState]	= Style;
}

List.prototype.SetItemDefualtImageStyle = function(ItemState,Style) {

    alert("##mini##List.SetItemDefualtImageStyle()");
	this.ItemImageStyle[ItemState]	= Style;
}


List.prototype.SetItemClass = function(cItemClass) {

 	alert("##mini##List.SetItemClass()");
	this.ItemClass = cItemClass;

}

List.prototype.SetItemSizeStyle = function(nFlag) {

	this.ItemSizeStyle = nFlag;

}
List.prototype.GetBGLayer = function() {

	return this.BGLayer;

}

List.prototype.SetStartDataIndex = function(nIndex) {

	this.StartDataIndex = nIndex;
	this.CurrentDataIndex = nIndex;
}

List.prototype.GetMaxNumOfData = function(){

	return this.MaxNumOfData;
}

//TESTCODE:
List.prototype.SetMaxNumOfData = function(NumOfData){

	this.MaxNumOfData = NumOfData;
}

List.prototype.SetClickEventAvailable = function(bFlag){

	this.Flag_ClickEvent = bFlag;
}

List.prototype.DisableReverse = function(){

	this.Flag_RTL = false;
}


//click  option 
List.prototype.ShowItem = function(){
	
	//if(this.Flag_Init == false) {
	
	alert("##mini##List.ShowItem()");

		
 	for (var i=0; i < this.MaxNumOfItem; i++) {	
	
		//alert("##mini##ItemArray[" + i +"].GetFlagForExistData = " +this.ItemArray[i].GetFlagForExistData() );
		//alert("##mini##ItemArray[" + i +"].GetShowState = " + this.ItemArray[i].GetShowState() );
		
		if(this.ItemArray[i] == null){
			break;			
		}
		
		if(this.ItemArray[i].GetFlagForExistData() == true && this.ItemArray[i].GetShowState() == false) {
			alert("##mini##ItemArray[" + i + "].Show");
			this.ItemArray[i].Show();	
		}
		else if(this.ItemArray[i].GetFlagForExistData() == false && this.ItemArray[i].GetShowState() == true){
			alert("##mini##ItemArray[" + i + "].Hide");
			this.ItemArray[i].Hide();
		}			
		
		//add click event		
		if(this.Flag_ClickEvent == true) {
			alert("##mini##Flag_ClickEvent on -- " + i);
			if(this.ItemArray[i].GetShowState() == true) {
				this.SetClickEvent(i);
			}
			//remove click event
			else {
				this.ResetClickEvent(i);
			}			
		}
		//add mouseover/out event
		this.SetMouseOverEvent(i);
		this.SetMouseOutEvent(i);
		//remove RTL
		if(this.Flag_RTL == false) {
			alert("##mini##Flag_RTL on -- " + i);
			this.ItemArray[i].DisableReverse();
		}
	}	
}

List.prototype.Show = function() {

	alert("##mini##List.Show()");
	
	if(this.ShowState == false){

		$("#"+ this.BGLayer.Obj).css('display', 'block');		
		this.ShowState = true;				
	}

}

List.prototype.Hide = function() {

	alert("##mini##List.Hide()");

	if(this.ShowState == true){
		
		$("#"+ this.BGLayer.Obj).css('display', 'none');
		this.ShowState = false;	
	}	
}



List.prototype.GetShowState = function() {
		 
     return this.ShowState;

}


List.prototype.SetNumOfVisibleItem = function(NumOfItems) {

    alert("##mini##List.SetNumOfVisibleItem()");
	this.MaxNumOfItem = NumOfItems;
			
}

List.prototype.SetShapeStyle = function(ShapeStyle) {

    alert("##mini##List.SetShapeStyle()");
	this.ShapeStyle = ShapeStyle;	
}

List.prototype.CurrentItemInit = function() {
	alert("##mini##List.CurrentItemInit");
    	for (var i=0; i < this.NumOfVisibleItem; i++) {
				this.ItemArray[i].Normal();
	}
}

List.prototype.SetCurrentItem = function(ItemIndex) {
	
	alert("##mini## >>>>>>>>>>>>  List.SetCurrentItem( from " + this.CurrentItemIndex + " to "  + ItemIndex + ")");

	//exception....

	if(ItemIndex != -1 && this.ItemArray[ItemIndex] == null) {
		alert("##mini## ItemArray["+ ItemIndex  + "] is null !!");
		return; 		
	}

	if (this.ItemSizeStyle == ITEM_SIZE_STYLE.REMOVE_SIZE) {
	
		if(this.CurrentItemIndex == -1){
			
			alert("##mini## init state >> " + this.NumOfCreatedItem + "Items initialize");
			
			for (var i=0; i < ItemIndex; i++) {
				this.ItemArray[i].UpNormal();
			}
			for (var i=ItemIndex; i < this.NumOfCreatedItem; i++) {
				this.ItemArray[i].DownNormal();
			}			
		}
		else {

			if (this.CurrentItemIndex < ItemIndex) {
				alert("##mini##CurrentItemIndex < ItemIndex");
				for (var i = this.CurrentItemIndex; i < ItemIndex; i++) {
				
					this.ItemArray[i].UpNormal();
				}
				
			}
			else {
				if (this.CurrentItemIndex > ItemIndex) {
					alert("##mini##CurrentItemIndex > ItemIndex");
					for (var i = this.CurrentItemIndex; i > ItemIndex; i--) {
					
						this.ItemArray[i].DownNormal();
					}
				}
				else {
					return;
				}
			}
		}	
			
	}
	else {
		
		if(this.CurrentItemIndex == -1){
			alert("##mini## init state ..");
			for (var i=0; i < this.NumOfVisibleItem; i++) {
				this.ItemArray[i].Normal();
			}
		}		
		//NumOfVisibleItem >>  createdItem
		else if(this.CurrentItemIndex > -1 && this.CurrentItemIndex < this.NumOfCreatedItem)
		{
			alert("##mini## ItemArray["+ ItemIndex  + "] is normal");
			this.ItemArray[this.CurrentItemIndex].Normal();
		}
		
	}
		
	this.CurrentItemIndex = ItemIndex;

	//case -1 : initialization
	if(ItemIndex > -1 && this.Flag_Focus){  // Modify Jason 121105
		
		this.ItemArray[ItemIndex].Highlight();	
	}

}

//use
List.prototype.GetCurrentDataIndex = function() {
	
    return this.CurrentDataIndex;
}

List.prototype.GetCurrentInputData = function() {
	
	if(this.ItemDataType == ITEM_DATA_TYPE.TEXT_ONLY){
		
		return this.ItemArray[this.CurrentItemIndex].GetDataText();
	}
	else if(this.ItemDataType == ITEM_DATA_TYPE.IMAGE_ONLY){
		
		return this.ItemArray[this.CurrentItemIndex].GetDataImage();
	}
	else{
		return this.ItemArray[this.CurrentItemIndex].GetData();
	}
    
}



List.prototype.GetCurrentItem = function() {

    return this.CurrentItemIndex;
}

List.prototype.GetStartDataIndex = function() {

    return this.StartDataIndex;
}

List.prototype.GetNumOfCreatedItem = function() {

    return this.NumOfCreatedItem;
}

List.prototype.ChangeData = function(DataIndex,DataObject) {

	this.DataArray[DataIndex] = DataObject;    
	
	if(DataIndex >= this.StartDataIndex && DataIndex < this.StartDataIndex + this.NumOfVisibleItem ){
				
		this.ItemArray[DataIndex - this.StartDataIndex].SetItem(DataObject);
	}
	
}

 
List.prototype.DeleteData = function(DataIndex) {
    
    //DataArray[ItemIndex].Delete();
	this.DataArray.splice(this.DataIndex,1);
	this.MaxNumOfData--;
	
}

List.prototype.DeleteDataAll = function() {

	alert("##mini##List.DeleteDataAll ");
	
	if(this.MaxNumOfData == 0){
		alert("##mini##can't delete data because no data!!! ");
		return;
	}
	
	
	this.DataArray.splice(0,this.MaxNumOfData);

	this.MaxNumOfData		= 0;
    this.CurrentDataIndex	= -1;  
	this.StartDataIndex		= -1;
	
	for (var i=0; i < this.NumOfCreatedItem; i++) {
	
		this.ItemArray[i].SetFlagForExistData(false); 	
	}
	
	this.NumOfVisibleItem = 0;


}

List.prototype.AddData = function(DataObject){

	alert("##mini##List.AddData");
	this.DataArray.push(DataObject);
	this.MaxNumOfData++;
	
	
	if(this.MaxNumOfData <= this.NumOfCreatedItem ){
		
		//Added Data's Index
		var CurItemIndex = this.MaxNumOfData - 1;
		this.ItemArray[CurItemIndex].SetItem(DataObject);
		this.NumOfVisibleItem++;
	}
	//Case 2: Create Item
	else if (this.NumOfCreatedItem < this.MaxNumOfItem ) {
		
		
		var CurItemIndex = this.NumOfCreatedItem;	
		var ItemEname = this.ElimentName + "Item";

		alert("##mini##ItemArray["+ CurItemIndex +"] create");
		var cItem = this.ItemClass;
		this.ItemArray[CurItemIndex] = new cItem();	
		this.ItemArray[CurItemIndex].SetDataType(this.ItemDataType);

		this.ItemArray[CurItemIndex].SetItemID(CurItemIndex);	
		if(this.divide_num){
			this.ItemArray[CurItemIndex].Create(ItemEname + (CurItemIndex + 1), this.divide_num);	
		}else{
		this.ItemArray[CurItemIndex].Create(ItemEname + (CurItemIndex + 1));	
		}		
		//init style when layer is default layer style...
		if(this.ItemDataType != ITEM_DATA_TYPE.CUSTOM){
			for (var i=0; i < ITEM_STATE.MAX; i++) {
				
				if(this.ItemBGUrl[i]){
					
					this.ItemArray[CurItemIndex].SetBgImage(i,this.ItemBGUrl[i]);
				}	
				if(this.ItemBGStyle[i]){
					this.ItemArray[CurItemIndex].SetBgStyle(i,this.ItemBGStyle[i]);
				}

				if(this.ItemFGUrl[i]){
					this.ItemArray[CurItemIndex].SetFgImage(i,this.ItemFGUrl[i]);
				}	
				if(this.ItemFGStyle[i]){
					this.ItemArray[CurItemIndex].SetFgStyle(i,this.ItemFGStyle[i]);
				}

				if(this.ItemTextStyle[i])	
				{
					alert("##mini##ItemTextStyle >> ItemTextStyle [" + i + "]");
					this.ItemArray[CurItemIndex].SetTextStyle(i,this.ItemTextStyle[i]);
				}
				
				if(this.ItemImageStyle[i])	
				{
					alert("##mini##ItemTextStyle >> ItemImageStyle [" + i + "]");
					this.ItemArray[CurItemIndex].SetImageStyle(i,this.ItemImageStyle[i]);
				}				
					
			}
				
		}
			

		this.ItemArray[CurItemIndex].SetItem(DataObject);
		this.NumOfCreatedItem++;
		this.NumOfVisibleItem++;

	}
		
	
}

List.prototype.ResetData = function(nDataIndex,DataObject){
	
	this.DataArray[nDataIndex] = DataObject;	
}
 
List.prototype.KeyProcess = function (keyCode) {
  
	alert("##mini##List.KeyProcess");
	PluginAPIMgr.PlayAudio(keyCode);
	
	switch(keyCode){
		case $.sfKey.UP:
			if(this.ShapeStyle == LIST_SHAPE_STYLE.VERTICAL){
				this.Previous();				
			}
			else if(this.ShapeStyle == LIST_SHAPE_STYLE.HORIZONTAL && this.onUpFunc){					
				this.onUpFunc();					
			}			         
			break;    
			
		case $.sfKey.LEFT:
			if(this.ShapeStyle == LIST_SHAPE_STYLE.HORIZONTAL){
				this.Previous();
			}
			else if(this.ShapeStyle == LIST_SHAPE_STYLE.VERTICAL && 
				this.onLeftFunc){					
				this.onLeftFunc();					
			}
			break;  
			
		case $.sfKey.DOWN:
			if(this.ShapeStyle == LIST_SHAPE_STYLE.VERTICAL){
				this.Next();
			}
			else if(this.ShapeStyle == LIST_SHAPE_STYLE.HORIZONTAL && 
				this.onDownFunc){					
				this.onDownFunc();					
			}				
			break;
			
		case $.sfKey.RIGHT:
			if(this.ShapeStyle == LIST_SHAPE_STYLE.HORIZONTAL){
				this.Next();
			}
			else if(this.ShapeStyle == LIST_SHAPE_STYLE.VERTICAL && this.onRightFunc){					
				this.onRightFunc();					
			}				                     
			break;                            

		case $.sfKey.ENTER:
			alert("##mini##KEY_ENTER");
			if(this.ItemPressedCallbackFunc){
				this.ItemPressedCallbackFunc();
			}			
			break;			
                   
		case $.sfKey.RETURN:
			alert("##mini##KEY_RETURN");
			if(this.onReturnFunc){
				this.onReturnFunc();
			}
			$.sfKey.block(event);			
			break;	
			
		case $.sfKey.EXIT:
			alert("##mini##KEY_EXIT");
			if(this.onExitFunc){
				this.onExitFunc();
			}
			$.sfKey.block(event);			
			break;
			
		default:
			$.sfKey.block(event);
			break;
    }

} 
 

List.prototype.Next = function(){
	alert("##mini##List.Next()");
	
	if(this.MaxNumOfData < 2){
		alert("##mini## this.MaxNumOfData < 2 ");
		return;
	}
	
	var CurItemIndex = 	this.CurrentItemIndex + 1;

	this.CurrentDataIndex++;
	
	//to next page	
	if(CurItemIndex == this.NumOfVisibleItem ) {
		
		alert("##mini##move to top");
		CurItemIndex = 0;		
			
		//case: Multi Page 
		if(this.MaxNumOfItem <  this.MaxNumOfData ) 
		{
			alert("##mini##Page scroll ");
			this.StartDataIndex += this.MaxNumOfItem;
			
			//from last page to 1st page 
			if(this.StartDataIndex > this.MaxNumOfData -1 ) {
		
				this.StartDataIndex = 0;
				this.CurrentDataIndex = 0;
			}
			
			this.UpdatePage();			
		}
		else
		{
			this.CurrentDataIndex = 0;
		}		
	}

	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);
	this.SetCurrentItem(CurItemIndex);	
}

List.prototype.Previous = function(){
	alert("##mini##List.Previous()");
	
	if(this.MaxNumOfData < 2){
		alert("##mini## this.MaxNumOfData < 2 ");
		return;
	}	
	
	var CurItemIndex = 	this.CurrentItemIndex - 1;
	//set data index
	this.CurrentDataIndex--;
			
	if(CurItemIndex == -1 ) {				
		alert("##mini##Page scroll");
				
		//case1 : Multi Page 
		if (this.MaxNumOfItem < this.MaxNumOfData) {
						
			this.StartDataIndex -= this.MaxNumOfItem;
			
			//from 1st page to last page
			if(this.StartDataIndex < 0 ) {
			
				var NumOfDataInLastPage = this.MaxNumOfData % this.MaxNumOfItem;
				
				if(NumOfDataInLastPage > 0) {
					
					this.StartDataIndex = this.MaxNumOfData - NumOfDataInLastPage;
				}
				else {
					
					this.StartDataIndex = this.MaxNumOfData - this.MaxNumOfItem;
				}
												
				this.CurrentDataIndex = this.MaxNumOfData - 1;
			}		
			
			//Set NumOfVisibleItem
			this.UpdatePage();
			CurItemIndex = this.NumOfVisibleItem - 1;	
		}
		//case2 : Single page
		else{
			
			CurItemIndex = this.NumOfVisibleItem - 1;
			this.CurrentDataIndex = CurItemIndex;
		}
		//set Data Index whatever single or multi page
						
	}
	
	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);
	this.SetCurrentItem(CurItemIndex);		
}

//for mouse
List.prototype.MoveItem = function(ItemIndex)
{
	alert("##mini##List.MoveItem()");

	alert("##mini##ItemIndex = " + ItemIndex);
	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);
	alert("##mini##CurrentItemIndex = " + this.CurrentItemIndex);
		
	if(this.Flag_Focus == false)
	{
		//CurrentItemIndex == -1
		if(this.CurrentDataIndex < 0)
		{	
			this.CurrentDataIndex = ItemIndex;
		}
		// in multi page.. ex) flag list
		else
		{
			this.CurrentDataIndex = this.CurrentDataIndex + ItemIndex;
		}

		//temp
	    if(this.helpBar)
	    {
	        this.helpBar.visibleObj();
	    }
	    
		this.Flag_Focus = true;	    
		
	}
	else{		
		// highlight 
		this.CurrentDataIndex = this.CurrentDataIndex - this.CurrentItemIndex + ItemIndex;
	}

	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);
	
	this.SetCurrentItem(ItemIndex);		



}


List.prototype.SetItemPressedEventCallback = function(CallbackFunc){
	alert("##mini##List.SetItemPressedEventCallback()");
	this.ItemPressedCallbackFunc = CallbackFunc;
}

List.prototype.SetEventOnReturnFunc = function(Func){
	this.onReturnFunc = Func;
}

List.prototype.SetEventOnUpFunc = function(Func){
	this.onUpFunc = Func;
}

List.prototype.SetEventOnDownFunc = function(Func){
	this.onDownFunc = Func;
}

List.prototype.SetEventOnLeftFunc = function(Func){
	this.onLeftFunc = Func;
}

List.prototype.SetEventOnRightFunc = function(Func){
	this.onRightFunc = Func;
}

List.prototype.SetHighlightForDataIndex = function(DataIndex) {

	alert("##mini##List.SetHighlightForDataIndex");
	this.Flag_Focus	= true;

	var CurPage = parseInt(DataIndex / this.MaxNumOfItem);
	var rest = parseInt(DataIndex % this.MaxNumOfItem);
		
	this.StartDataIndex = CurPage * this.MaxNumOfItem;	
	this.CurrentDataIndex = DataIndex;
	//this.CurrentItemIndex = rest;
	
	this.UpdatePage();
	this.SetCurrentItem(rest);
	
}


List.prototype.ResetHighlight = function(){

	if(this.Flag_Focus == false)
	{
		this.StartDataIndex = 0;	
		this.CurrentDataIndex = 0;
		this.PrevItemIndex = 0;

		this.UpdatePage();
	}
	
}

List.prototype.highlight = function(){
	
	alert("##mini##List.highlight");
	this.Flag_Focus	= true;

	var ItemIndex = this.PrevItemIndex;
	
	if(this.NumOfVisibleItem == 0){
		alert("##mini##No Visible Item!!!!");
		return -1;
	}
	else if(ItemIndex == -1){
		alert("##mini##Prevous Item Index is -1");	
		ItemIndex = 0;
	}
	else if(ItemIndex > this.NumOfVisibleItem - 1){
		ItemIndex = this.NumOfVisibleItem - 1 ;
	}

	this.SetCurrentItem(ItemIndex);

    if( this.helpBar)
    {
         this.helpBar.visibleObj();
    }
    
}

List.prototype.blur = function(){

	alert("##mini##List.blur >>> curIndex : " + this.CurrentItemIndex);	
	this.Flag_Focus	= false;
	
	this.PrevItemIndex = this.CurrentItemIndex;	
    
	this.SetCurrentItem(-1);
    
    if( this.helpBar)
    {
         this.helpBar.hiddenObj();
    }

}

List.prototype.select = function(){
    
   alert("##mini##List.select()");
}

List.prototype.SetPrevItemIndex = function(nIndex){
    
   this.PrevItemIndex = nIndex;
}




//only update page.. inner function
List.prototype.UpdatePage = function(){
	
	alert("##mini##List.UpdatePage(" + this.StartDataIndex + ")");

	var temp;
	var DataSetCount = 0;
	
	//MaxNumOfItem
	for (var i=0; i < this.NumOfCreatedItem; i++) {
	
		temp = this.StartDataIndex + i;
		
		if(temp > (this.MaxNumOfData - 1) ){					
			this.ItemArray[i].SetFlagForExistData(false);	
		}
		else 
		{					
			this.ItemArray[i].SetItem( this.DataArray[temp] );	
			DataSetCount++; 
		}					
	}	
		
	this.NumOfVisibleItem = DataSetCount;
	
	this.ShowItem();

}

List.prototype.PrintListInfo = function(){
	
	alert("##mini########################################");
	alert("##mini##Print Information of Item");
	alert("##mini########################################");
	alert("##mini##NumOfVisibleItem = " + this.NumOfVisibleItem);	
	alert("##mini##MaxNumOfItem = " + this.MaxNumOfItem);
	alert("##mini##NumOfCreatedItem = " + this.NumOfCreatedItem);
	alert("##mini##CurrentItemIndex = " + this.CurrentItemIndex);
	alert("##mini##PrevItemIndex = " + this.PrevItemIndex);
	
	alert("##mini########################################");
	alert("##mini##Print Information of Data");
	alert("##mini########################################");
	alert("##mini##MaxNumOfData = " + this.MaxNumOfData);
	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);
	alert("##mini##StartDataIndex = " + this.StartDataIndex);						
}


List.prototype.InitializeListInfo = function(){
	
	alert("##mini##List.InitListInfo");
	
//	this.NumOfVisibleItem	= 0;	
//	this.CurrentItemIndex	= -1;
//	this.CurrentDataIndex	= -1;
//	this.StartDataIndex		= -1;	
						
}

List.prototype.GetNumOfVisibleItem = function(){
	
	return this.NumOfVisibleItem;
}

List.prototype.registHelpBar= function(obj){
    if(obj)
    {
           this.helpBar = obj;
    }
}

List.prototype.changeHelpBar= function(obj){

    if(this.helpBar == obj)
    {
        return;
    }
    
    if(this.helpBar != null)
    {
           this.helpBar.hiddenObj();
    }
    
     if(obj)
    {
           this.helpBar = obj;
           if(this.flag_highlight ==true)
           {
                this.helpBar.visibleObj();
           }
    } 
}



/***************************** Mouse Event ****************************/
List.prototype.SetOnClickCallbackFunc = function(Index,func)
{
	this.OnClickFunc[Index] = func;
}


List.prototype.SetClickEvent = function(Index)
{	
	if(this.ItemArray[Index] != null && this.OnClickFunc[Index] != null)
	{
		alert("##mini##List.SetClickEvent[" + Index + "]");
		this.ItemArray[Index].SetOnClickCallbackFunc(this.OnClickFunc[Index]);		
	}
	/*
	else
	{
		alert("##mini##SetOnClickCallbackFunc -- OnClickFunc is not exist!!");
		}	*/
	
}

List.prototype.ResetClickEvent = function(Index)
{
	
	//$("a").addClass("test");
	//$("a").removeClass("test");
	
	if(this.ItemArray[Index] != null)
	{
		alert("##mini##List.ResetClickEvent");
		this.ItemArray[Index].ResetOnClickCallbackFunc();
	}
}

List.prototype.SetOnMouseOverCallbackFunc = function(Index, func){
	this.OnMouseOverFunc[Index] = func;
}

List.prototype.SetMouseOverEvent = function(Index){
	if(this.ItemArray[Index] != null && this.OnMouseOverFunc[Index] != null)
	{
		alert("##mini##List.SetMouseOverEvent[" + Index + "]");
		this.ItemArray[Index].SetOnMouseOverCallbackFunc(this.OnMouseOverFunc[Index],this.Flag_RightClick);		
	}
	/*
	else
	{
		alert("##mini##SetOnClickCallbackFunc -- OnClickFunc is not exist!!");
		}*/
	
}

List.prototype.SetOnMouseOutCallbackFunc = function(Index, func){
	this.OnMouseOutFunc[Index] = func;
}

List.prototype.SetMouseOutEvent = function(Index){
	if(this.ItemArray[Index] != null && this.OnMouseOutFunc[Index] != null)
	{
		alert("##mini##List.SetMouseOutEvent[" + Index + "]");
		this.ItemArray[Index].SetOnMouseOutCallbackFunc(this.OnMouseOutFunc[Index],this.Flag_RightClick);		
	}
	/*
	else
	{
		alert("##mini##SetOnClickCallbackFunc -- OnClickFunc is not exist!!");
		}*/
	
}



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

function ScrollList() {

	this.ScrollBar			= null;
	
	this.CurPage	= 1;
	this.TotalPage	= 1;
	
	this.ScrBarStartPosition	= 0;
	this.ScrBarFirstLength		= 0;
	this.ScrBarTotalLength		= 0;	
	
    List.call(this);
}

ScrollList.prototype = new List(); 

ScrollList.prototype.CreateScrBar = function(Ename){
	
	this.ScrollBar = new ScrollBar();
	this.ScrollBar.Create(Ename);
}

ScrollList.prototype.SetScrBarImage = function(BgImage,TopImage,CenterImage,BottomImage){

	this.ScrollBar.SetBGImage(BgImage);
	this.ScrollBar.SetFirstImage(TopImage);
	this.ScrollBar.SetSegmentImage(CenterImage);
	this.ScrollBar.SetLastImage(BottomImage);

}

ScrollList.prototype.SetScrBarStyle = function(style){
	
	alert("##mini##ScrollList.SetScrBarStyle()");
	
	var scrollbarBG = this.ScrollBar.GetBGLayer();
	scrollbarBG.SetStyle(style);

}

ScrollList.prototype.SetScrBarShapeStyle = function(style){

    alert("##mini##ScrollList.SetScrBarShapeStyle()");
	
	this.ShapeStyle = style;	
	var ScrollbarShapStyle;
	
	if(style == LIST_SHAPE_STYLE.HORIZONTAL){
		ScrollbarShapStyle = SCROLLBAR_SHAPE_STYLE.HORIZONTAL;
	}
	else {
		ScrollbarShapStyle = SCROLLBAR_SHAPE_STYLE.VERTICAL;
	}

	this.ScrollBar.SetShapeStyle(ScrollbarShapStyle);
}

ScrollList.prototype.ResetTotalPage = function(){
	
	this.TotalPage = parseInt(this.MaxNumOfData / this.MaxNumOfItem);
	
	if((this.MaxNumOfData % this.MaxNumOfItem) > 0)
	{
		this.TotalPage++;
	}
	//alert("##mini##TotalPage =" + this.TotalPage);	

}


ScrollList.prototype.SetScrBarPosition = function(TotalLength,StartPosition,FirstLength){

	alert("##mini##ScrollList.SetScrBarPosition()");
	this.ScrBarStartPosition	= StartPosition;
	this.ScrBarFirstLength		= FirstLength;
	this.ScrBarTotalLength		= TotalLength;
	
	this.TotalPage = parseInt(this.MaxNumOfData / this.MaxNumOfItem);
	if((this.MaxNumOfData % this.MaxNumOfItem) > 0)
	{
		this.TotalPage++;
	}	
	alert("##mini##TotalPage = " + this.TotalPage);
	this.ScrollBar.SetPosition(this.TotalPage,TotalLength,StartPosition,FirstLength);
	this.ScrollBar.ResetScrollBar();	
		
}



ScrollList.prototype.SetHighlightForDataIndex = function(DataIndex) {

	alert("##mini##ScrollList.SetHighlightForDataIndex");

	this.Flag_Focus	= true;
	
	var CurPage_ = parseInt(DataIndex / this.MaxNumOfItem);	
	var rest = parseInt(DataIndex % this.MaxNumOfItem);
		
	this.StartDataIndex = CurPage_ * this.MaxNumOfItem;
	this.CurrentDataIndex = DataIndex;
	//this.CurrentItemIndex = rest;
	
	this.CurPage = CurPage_ + 1;
	alert("##mini##CurPage = " + this.CurPage);
	
	this.UpdatePage();
	this.SetCurrentItem(rest);
	
}

ScrollList.prototype.DeleteDataAll = function() {

	alert("##mini##List.DeleteDataAll ");
	
	if(this.MaxNumOfData == 0){
		alert("##mini##can't delete data because no data!!! ");
		return;
	}
	
	
	this.DataArray.splice(0,this.MaxNumOfData);

	this.MaxNumOfData		= 0;
    this.CurrentDataIndex	= -1;  
	this.StartDataIndex		= -1;
	this.TotalPage 			= 0;
	this.CurPage			= 0;	
	
	
	for (var i=0; i < this.NumOfCreatedItem; i++) {
	
		this.ItemArray[i].SetFlagForExistData(false); 	
	}
	
	this.NumOfVisibleItem = 0;
	
	


}

ScrollList.prototype.Next = function(){
	alert("##mini##ScrollList.Next()");
	
	var CurItemIndex = 	this.CurrentItemIndex + 1;

	this.CurrentDataIndex++;
	
	//to next page	
	if(CurItemIndex == this.NumOfVisibleItem ) {
		
		alert("##mini##move to top");
		CurItemIndex = 0;		
			
		//case: Multi Page 
		if(this.MaxNumOfItem <  this.MaxNumOfData ) 
		{
			alert("##mini##Page scroll ");
			this.StartDataIndex += this.MaxNumOfItem;
			this.CurPage++;
			
			//from last page to 1st page 
			if(this.StartDataIndex > this.MaxNumOfData -1 ) {
		
				this.StartDataIndex = 0;
				this.CurrentDataIndex = 0;
				this.CurPage = 1;
			}
			
			this.UpdatePage();						
		}
		else
		{
			this.CurrentDataIndex = 0;
		}		
	}

	
	this.SetCurrentItem(CurItemIndex);	
}


ScrollList.prototype.Previous = function(){
	alert("##mini##ScrollList.Previous()");

	if(this.MaxNumOfData < 2){
		alert("##mini## this.MaxNumOfData < 2 ");
		return;
	}
	
	var CurItemIndex = 	this.CurrentItemIndex - 1;
	//set data index
	this.CurrentDataIndex--;
			
	if(CurItemIndex == -1 ) {				
		alert("##mini##Page scroll");
		
		//case1 : Multi Page 
		if (this.MaxNumOfItem < this.MaxNumOfData) {
						
			this.StartDataIndex -= this.MaxNumOfItem;
			this.CurPage--;
			
			//from 1st page to last page
			if(this.StartDataIndex < 0 ) {
			
				var NumOfDataInLastPage = this.MaxNumOfData % this.MaxNumOfItem;
				
				if(NumOfDataInLastPage > 0) {
					
					this.StartDataIndex = this.MaxNumOfData - NumOfDataInLastPage;
				}
				else {
					
					this.StartDataIndex = this.MaxNumOfData - this.MaxNumOfItem;
				}
												
				this.CurrentDataIndex = this.MaxNumOfData - 1;
				this.CurPage = this.TotalPage;
			}		
			
			//Set NumOfVisibleItem
			this.UpdatePage();
			//Set CurItemIndex after call UpdatePage
			CurItemIndex = this.NumOfVisibleItem - 1;	
				
		
		}
		//case2 : Single page
		else
		{
			CurItemIndex = this.NumOfVisibleItem - 1;
			this.CurrentDataIndex = CurItemIndex;
		}				
	}
	
	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);		
	this.SetCurrentItem(CurItemIndex);		
}

//only update page.. inner function
ScrollList.prototype.UpdatePage = function(){
	
	alert("##mini##ScrollList.UpdatePage(" + this.StartDataIndex + ")");
	//alert("##mini##MaxNumOfData = " + this.MaxNumOfData);
	
	var temp;
	var DataSetCount = 0;
	
	//MaxNumOfItem
	for (var i=0; i < this.NumOfCreatedItem; i++) {
	
		temp = this.StartDataIndex + i;
		
		if(temp > (this.MaxNumOfData - 1) ){					
			
			this.ItemArray[i].SetFlagForExistData(false);	
			//alert("##mini##SetFlagForExistData[" + i + "]");
		}
		else 
		{							
			this.ItemArray[i].SetItem( this.DataArray[temp] );	
			DataSetCount++;
			//alert("##mini##SetItem[" + i + "]"); 
		}					
	}	
		
	this.NumOfVisibleItem = DataSetCount;
	
	this.ShowItem();
	
	this.ScrollBar.SetTotalNum(this.TotalPage);
	this.ScrollBar.SetCurrentNum(this.CurPage);
	this.ScrollBar.ResetScrollBar();

}

//refresh current page
//after changing data....
ScrollList.prototype.RefreshPage = function(){
	alert("##mini##ScrollList.RefreshPage");	
/*

<<page>>
this.StartDataIndex

<<scroll>>
this.CurPage

<<highliht>>
this.CurrentDataIndex
this.CurrentItemIndex

*/

	if(this.MaxNumOfData == 0){		
		this.ShowItem();
		this.ScrollBar.SetTotalNum(this.TotalPage);
		this.ScrollBar.SetCurrentNum(this.CurPage);		
		this.ScrollBar.ResetScrollBar();		
	}
	else{
		
		//1.Set StartDataIndex
		if(this.StartDataIndex > this.MaxNumOfData - 1){
			this.StartDataIndex = (this.TotalPage - 1) * this.MaxNumOfItem;
		}
		
		//2.this.CurPage
		if(this.CurPage > this.TotalPage){
			this.CurPage = this.TotalPage;
		}
		else if(this.CurPage == 0){
			this.CurPage = 1;
		}
		
		//check Invalid
		var FirstIndexOfCurPage = (this.CurPage -1)* this.MaxNumOfItem;
		if(this.StartDataIndex != FirstIndexOfCurPage){
			
			alert("##mini##Error StartDataIndex!!!!");
			this.StartDataIndex = FirstIndexOfCurPage;
		}
		
		//3. highliht
		//auto set info when focusing list
		
		this.UpdatePage();
	}

}

ScrollList.prototype.SetCurPage = function(page){
	
	this.CurPage = page;	
}

ScrollList.prototype.GetCurPage = function(){
	
	return this.CurPage;	
}

ScrollList.prototype.PrintListInfo = function(){
	
	alert("##mini########################################");
	alert("##mini##Print Information of Item");
	alert("##mini########################################");
	alert("##mini##NumOfVisibleItem = " + this.NumOfVisibleItem);	
	alert("##mini##MaxNumOfItem = " + this.MaxNumOfItem);
	alert("##mini##NumOfCreatedItem = " + this.NumOfCreatedItem);
	alert("##mini##CurrentItemIndex = " + this.CurrentItemIndex);
	alert("##mini##PrevItemIndex = " + this.PrevItemIndex);
	
	alert("##mini########################################");
	alert("##mini##Print Information of Data");
	alert("##mini########################################");
	alert("##mini##MaxNumOfData = " + this.MaxNumOfData);
	alert("##mini##CurrentDataIndex = " + this.CurrentDataIndex);
	alert("##mini##StartDataIndex = " + this.StartDataIndex);	
	
	alert("##mini########################################");
	alert("##mini##Print Information of Page");
	alert("##mini########################################");
	alert("##mini##TotalPage = " + this.TotalPage);
	alert("##mini##CurPage = " + this.CurPage);
							
}

ScrollList.prototype.SetLastPageInfo = function(){

	alert("##mini##ScrollList.SetLastPageInfo()");

	var newPositionItem = -1;
	//1. Set StartDataIndex
	alert("##mini##1. MaxNumOfData = " + this.MaxNumOfData);
	alert("##mini##1. MaxNumOfItem = " + this.MaxNumOfItem);
	var NumOfDataInLastPage = this.MaxNumOfData % this.MaxNumOfItem;

	if(NumOfDataInLastPage == 0){
		NumOfDataInLastPage = this.MaxNumOfItem;
	}
			
	var lastItemIndex = NumOfDataInLastPage - 1;

	this.StartDataIndex = this.MaxNumOfData - NumOfDataInLastPage;


	alert("##mini##2. NumOfDataInLastPage = " + NumOfDataInLastPage);
	alert("##mini##2. StartDataIndex = " + this.StartDataIndex);	
														
	//2. Set CurrentDataIndex
	if(this.CurrentItemIndex > lastItemIndex)
	{
		//over index
		this.CurrentDataIndex = this.MaxNumOfData -1;
		newPositionItem = lastItemIndex;
		alert("##mini##3. CurrentDataIndex = " + this.CurrentDataIndex);
		alert("##mini##3. newPositionItem = " + newPositionItem);			
	}		
	else
	{
		//under index
		this.CurrentDataIndex = this.StartDataIndex + lastItemIndex;
		alert("##mini##3. CurrentDataIndex = " + this.CurrentDataIndex);
	}

	return newPositionItem;

}


//down - next
ScrollList.prototype.NextPage = function(){
	alert("##mini##ScrollList.NextPage()");
	
	if(this.TotalPage < 2)
	{
		alert("##mini##TotalPage < 2");
		return;
	}
	
	var CurItemPos = -1;
	var BackupCurPage = this.CurPage;
	
	//Change Value!!
	this.CurrentDataIndex	+= this.MaxNumOfItem;
	this.StartDataIndex		+= this.MaxNumOfItem;
	this.CurPage++;
	
	if(BackupCurPage == this.TotalPage)
	{				
		//1. Set CurPage		
		this.CurPage = 1;
		
		//2. Set StartDataIndex
		this.StartDataIndex = 0;
		
		//3. Set CurrentDataIndex
		this.CurrentDataIndex = this.CurrentItemIndex;
		alert("##mini##first page >> CurrentDataIndex = " + this.CurrentDataIndex);	
		
	}
	else if(BackupCurPage == this.TotalPage - 1)
	{
		CurItemPos = this.SetLastPageInfo();
	}
		
	//Set NumOfVisibleItem
	this.UpdatePage();

	if(CurItemPos > -1)
	{
		this.SetCurrentItem(CurItemPos);	
	}	
		
}

//up - previous
ScrollList.prototype.PreviousPage = function(){
	alert("##mini##ScrollList.PreviousPage()");

	if(this.TotalPage < 2)
	{
		alert("##mini##TotalPage < 2");
		return;
	}
	
	var CurItemPos = -1;
	var BackupCurPage = this.CurPage;
	
	//Change Value!!
	this.CurrentDataIndex	-= this.MaxNumOfItem;
	this.StartDataIndex		-= this.MaxNumOfItem;
	this.CurPage--;
	
	if(BackupCurPage == 1)
	{		
		
		// Set CurPage		
		this.CurPage = this.TotalPage;
		CurItemPos = this.SetLastPageInfo();
	}
		
	//Set NumOfVisibleItem
	this.UpdatePage();
	
	if(CurItemPos > -1)
	{
		this.SetCurrentItem(CurItemPos);	
	}	
	
}


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


var MaxNumOfMainItem = 5;
var LiveNumOfContact = 4;

var FUNC_POPUP_PROPERTY_TYPE = { 
 
 	NOTHING		:0,
    INDEX		:1,
	IDENTITY	:2
}

function MainList() {

	this.TotalDataNum			= 0;
	this.TotalPageNum			= 0;     
	this.CurIndex				= -1;
	this.CurPage				= 0;   

	this.ScrollBar			= null;
	this.NotifingLabel		= null;	
	this.ContactListLine 	= Array(4);
	
	this.NoItemString		= null;
	
	this.SceneName			= "miniMainContact";
	
	this.miniLastHighlight	= 0;
						
	List.call(this);
}

MainList.prototype = new List(); 


MainList.prototype.Create = function() {

	alert("##mini##MainList.Create");
	
	this.Costomizing();
	
	//Lable
	this.NotifingLabel = new CompBase(); 
	this.NotifingLabel.CreateBG(this.ElimentName + "Notify");
	this.NotifingLabel.SetBGImage(g_Image.IMAGE_LIST_MAIN_SETTING_BG);
	this.NotifingLabel.AddTextLayer(this.ElimentName + "NotifyText");				
	this.NotifingLabel.SetTextLayer(1,this.NoItemString);
	
	for(var i=0; i<4;i++){
	    this.ContactListLine[i] = new Label("list_main_contact_Line"+i, null);
	    this.ContactListLine[i].SetBgImage(g_Image.IMAGE_LIST_MAIN_CONTACT_LIST_LINE);
    }
	//Set List 
	this.CreateBG(this.ElimentName + "List", 20);    
	this.SetNumOfVisibleItem(MaxNumOfMainItem);		
	this.SetItemSizeStyle(ITEM_SIZE_STYLE.FIXED_SIZE);
	this.CreateItems();

	var Scene = $.sfScene.get({id:this.SceneName, scope:WIDGET.id});
	var This_ = Scene.list;
	
	
	this.SetClickEventAvailable(WndMgr.MouseClickEnable);
	this.SetOnClickCallbackFunc(0,function(){This_.JumpToItem(0);});
	this.SetOnClickCallbackFunc(1,function(){This_.JumpToItem(1);});
	this.SetOnClickCallbackFunc(2,function(){This_.JumpToItem(2);});
	this.SetOnClickCallbackFunc(3,function(){This_.JumpToItem(3);});
	this.SetOnClickCallbackFunc(4,function(){This_.JumpToItem(4);});
	this.SetOnClickCallbackFunc(5,function(){This_.JumpToItem(5);});
	this.SetOnMouseOverCallbackFunc(0,function(){This_.MoveToItem(0);});
    this.SetOnMouseOverCallbackFunc(1,function(){This_.MoveToItem(1);});
    this.SetOnMouseOverCallbackFunc(2,function(){This_.MoveToItem(2);});
    this.SetOnMouseOverCallbackFunc(3,function(){This_.MoveToItem(3);});
    this.SetOnMouseOverCallbackFunc(4,function(){This_.MoveToItem(4);});
    this.SetOnMouseOverCallbackFunc(5,function(){This_.MoveToItem(5);});
    
	
	this.ScrollBar = new ScrollBar();
	this.ScrollBar.Create(this.ElimentName + "ScrollBar");
	this.ScrollBar.SetShapeStyle(SCROLLBAR_SHAPE_STYLE.VERTICAL);
	this.ScrollBar.SetFirstImage(g_Image.IMAGE_LIST_MAIN_SCROLLBAR_TOP);
	this.ScrollBar.SetSegmentImage(g_Image.IMAGE_LIST_MAIN_SCROLLBAR_CENTER);
	this.ScrollBar.SetLastImage(g_Image.IMAGE_LIST_MAIN_SCROLLBAR_BOTTOM);	
	this.ScrollBar.SetPosition(this.TotalPageNum,370,0,3);
	this.ScrollBar.SetBGImage(g_Image.IMAGE_LIST_MAIN_SCROLLBAR_BG_TOP, g_Image.IMAGE_LIST_MAIN_SCROLLBAR_BG_CENTER, g_Image.IMAGE_LIST_MAIN_SCROLLBAR_BG_BOTTOM);


}


MainList.prototype.CreateBG = function(Ename) {

    alert("##mini##MainList.CreateBG(" + Ename + ")");
    if(Ename == null) {
        //alert("##mini##CListBase.CreateBG()  >>>   Param is null !!  ");
        return false;
    }
    	
    this.BGLayer = new ImageLayer(Ename);
	        
}

/*
delete....

MainList.prototype.GetCurIdentity = function(){

	return this.ItemArray[this.CurrentItemIndex].GetIdentity();	
}
*/

MainList.prototype.GetCurItemIdentity = function(){

	//must check no item.....
	if(this.CurrentItemIndex < 0){
		return null;
	}
	return this.ItemArray[this.CurrentItemIndex].GetIdentity();	
}

MainList.prototype.GetCurIdentityName = function(){

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

MainList.prototype.GetCurDisplayName = function(){

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

MainList.prototype.GetCurIndex = function(){

	return this.CurIndex;	
}

MainList.prototype.GetCurPage = function(){

	return this.CurPage;	
}

MainList.prototype.highlight = function(){

	alert("##mini##MainList.highlight"); 
	if(this.GetTotalDataNum() <= 0)
		return;
	this.Flag_Focus	= true;	
	this.Flag_Select = false;	
	this.MoveItem(this.CurrentItemIndex);
	
}

MainList.prototype.blur = function(){
	alert("##mini##MainList.blur >>> curIndex : " + this.CurrentItemIndex);	
	if(this.GetTotalDataNum() <= 0)
		return;
	this.Flag_Focus	= false;
    this.Flag_Select = false;
    this.ItemArray[this.CurrentItemIndex].Normal();
}

MainList.prototype.select = function(){
	alert("##mini##MainList.select >>> curIndex : " + this.CurrentItemIndex);	
	if(this.GetTotalDataNum() <= 0)
		return;
	this.Flag_Select = true;
	//this.Flag_Focus	= false;
    this.ItemArray[this.CurrentItemIndex].Select();
}

MainList.prototype.KeyProcess = function (keyCode) {

	alert("##mini##MainList.KeyProcess");
	
	switch(keyCode) {
		
		case $.sfKey.UP:
			this.Previous();
			break;

		case $.sfKey.DOWN:
			this.Next();
			break;
		case $.sfKey.ENTER:
			this.processEnterKey();
			break;	
        case	ENUM_CALL_BLOCK_KEY_CODE.DUALVIEW:
			WndMgr.StartOneBottonPopup(OneBtnPopupIndex.FUNCTION_ISNT_AVAILABLE);
			break;
		default:
			break;
	}
} 
MainList.prototype.processEnterKey=function(){
	alert("##mini##MainList.processEnterKey"); 
	var ContactName = this.GetCurIdentityName();
	this.GetItemInfo(ContactName);
	alert("##mini##current contactname === "+ ContactName);

	this.miniLastHighlight = ENUM_SCENE_NAVIGATOR.CONTACT_LIST;
	
	if(this.IsContactAddMode){
		this.select();
		StateMgr.Start_Mini_Contact_Add_Menu(this.CurrentItemIndex,ContactName);
	}
	else{
		this.select();
		StateMgr.Start_Mini_Contact_Call_Menu(this.CurrentItemIndex,ContactName,this.IsEnableVideo);
	}
}

MainList.prototype.Next = function(){
	
	alert("##mini##MainList.Next"); 
	
	var CurItemIndex = 	this.CurrentItemIndex + 1;
		
	if(CurItemIndex == this.NumOfVisibleItem )
	{
		
		alert("##mini##Page scroll ");
		
		CurItemIndex = 0;

		//case1 : Multi Page 
		if (this.TotalPageNum > 1) {
			
			//set current page
			if(this.CurPage >= this.TotalPageNum) {
//				this.CurPage = 1;
			}
			else {
				this.CurPage++;
				this.UpdatePage();
			}
		}			
	}

	//Set History Index
	this.CurIndex++;
	if(this.CurIndex >= this.TotalDataNum){
		this.CurIndex = this.TotalDataNum-1;
	} else {
		this.MoveItem(CurItemIndex);
	}
}

MainList.prototype.Previous = function(){

	alert("##mini##MainList.Previous");  

	var CurItemIndex = 	this.CurrentItemIndex - 1;
	
	//page scroll 			
	if(CurItemIndex == -1 ) {		
		alert("##mini##Page scroll ");	
		
		//case1 : Multi Page 
		if (this.TotalPageNum > 1) {

			//set current page
			if(this.CurPage <= 1) {
//				this.CurPage = this.TotalPageNum;
			}
			else {
				this.CurPage--;
				this.UpdatePage();	
			}		
		}		
		//Set Item focus
		CurItemIndex = this.NumOfVisibleItem -1;
 		
	}

	//Set History Index
 	this.CurIndex--;
 
	if(this.CurIndex < 0){					
		this.CurIndex = 0;
	} else {	
		//move Item
		this.MoveItem(CurItemIndex);	
	}
}

MainList.prototype.MoveItem = function(nCurItemIndex){

	alert("##mini##MainList.MoveItem( " + nCurItemIndex + ")" );
	
	//check exception
	if(nCurItemIndex > this.NumOfVisibleItem - 1 || nCurItemIndex < 0){
		
		alert("##mini##Index Error " );
		return;
	}
	this.SetCurrentItem(nCurItemIndex);
	if(this.Flag_Select)
		this.select();
	
	var ItemIdentity = this.GetCurItemIdentity();

	if(ItemIdentity.length > 0)
	{
		$.sfScene.get({id:WIDGET.name, scope:WIDGET.id}).PrintKPILog(ItemIdentity);
	}
	
}

//update index, page, scrollbar, etc....
MainList.prototype.Refresh = function(){
	
	alert("##mini##MainList.Refresh" );
	
	//Reset Data in list
	if(this.Flag_Focus ||this.Flag_Select){//}&& this.PossibleToUpdatePageWithIdentity){
		this.RefreshForCurIdentity();
	}
	else {
		this.RefreshForCurrentPage();
	}	
		
}

//function at 1 more Item
MainList.prototype.RefreshForCurIdentity = function(){

	alert("##mini##MainList.RefreshFoCurIdentity" );
	
	var ItemIdentity = this.GetCurItemIdentity();
	
	if(ItemIdentity == null){

		alert("##mini##=====================================");
		alert("##mini##Error!! no result of CurItemIdentity ");
		alert("##mini##=====================================");		
		
		this.RefreshForCurrentPage();
		
	}
	else{

		var Index = parseInt(this.GetIndexOfData(ItemIdentity));
		alert("##mini##Index = " + Index);	
		
		if(Index >= 0 ){
			
			this.InitializeDataOfPage();		
			
			//reset current page
			this.CurPage = parseInt(Index / MaxNumOfMainItem ) + 1;	
			alert("##mini##CurPage = " + this.CurPage);
			this.CurIndex = Index;	
			
			//reset page & scorllbar
			this.UpdatePage();
			
			var CurItemIndex = Index  % MaxNumOfMainItem;
			
			this.CurrentItemIndex = -1;		
			this.MoveItem(CurItemIndex);
			
		}
		else{
			
			alert("##mini##=====================================");
			alert("##mini##Error!! no result of searching index ");
			alert("##mini##=====================================");		
			
			this.RefreshForCurrentPage();
			
		}		
	}		
}

MainList.prototype.RefreshForCurrentPage = function(){
	
	alert("##mini##MainList.RefreshForCurrentPage" );
	
	// if(this.StopSubState)
		// StateMgr.StopSubState();
	var PrevTotalDataNum = this.TotalDataNum ;
	
	this.InitializeDataOfPage();
	
	if(this.TotalDataNum > 0){

		if(PrevTotalDataNum == 0){
			
			this.NotifingLabel.Hide();				
			
			this.CurPage = 1;
			this.CurrentItemIndex = 0;
		}

		var IsLastIndex = false;
		
		//Reset index of current page 
		if( this.CurPage > this.TotalPageNum){
			
			this.CurPage = this.TotalPageNum;
			IsLastIndex = true;
		}
		
		//update list 	
		this.UpdatePage();
	
		
		var prevItemIndex = this.CurrentItemIndex;
					
		if(IsLastIndex == true || prevItemIndex > this.NumOfVisibleItem - 1){		
			prevItemIndex = this.NumOfVisibleItem - 1;		
		}
		
		this.CurIndex = (this.CurPage - 1) * MaxNumOfMainItem + prevItemIndex;
			
		//reset button mode & position
		this.CurrentItemIndex = -1;
		this.MoveItem(prevItemIndex);
		
	}
	else {
		
		this.ShowNoItemPage();
	}
	
		
}

//Set TotalDataNum & TotalPageNum;
MainList.prototype.InitializeDataOfPage = function(){
	
	var CurDataNum = parseInt(this.GetNumberOfDatas());
	
	if(this.TotalDataNum != CurDataNum){
		
		this.TotalDataNum = CurDataNum;		
				
		if( this.TotalDataNum > 0){
			
			this.TotalPageNum = parseInt(this.TotalDataNum / MaxNumOfMainItem);

			if((CurDataNum % MaxNumOfMainItem) > 0){
				this.TotalPageNum++;
			}						
		}
		else {
			this.InitializeListInfo();					
		}		
	}
		
}

//Initialize data when login
MainList.prototype.Initialize = function(){

	alert("##mini##MainList.Initialize");
	
	var PrevTotalDataNum = this.TotalDataNum ;
	
	this.InitializeDataOfPage();
		
	if(this.TotalDataNum > 0)
	{		
		
		if(PrevTotalDataNum == 0){

			this.NotifingLabel.Hide();
		}
			
		//update page
		this.SetListInfoToStart();
		this.UpdatePage();	
		
		
		//set highlight & other style
		this.SetCurrentItem(0);
	}
	//check code  08.30 
	else {

		this.ShowNoItemPage();			
	}
	
}

MainList.prototype.GetTotalDataNum = function(){
	
	return this.TotalDataNum;	
}

MainList.prototype.CreateItems = function(){

	alert("##mini##MainList.CreateItems");
	
	var cItem = this.ItemClass;
	var ItemEname = this.ElimentName + "Item";
	
	for (var i=0; i < MaxNumOfMainItem; i++) {
		
		this.ItemArray[i] = new cItem();	
		this.ItemArray[i].SetItemID(i);	
		this.ItemArray[i].Create(ItemEname + (i + 1));
		
	}
	
	this.NumOfCreatedItem = MaxNumOfMainItem;	
}

//Initialize info to All data 
MainList.prototype.InitializeListInfo = function(){
	
	alert("##mini##MainList.InitListInfo");
	
	this.NumOfVisibleItem	= 0;	
	this.CurrentItemIndex	= -1;

	this.TotalDataNum		= 0;
	this.TotalPageNum		= 0;     
	this.CurIndex			= -1;
	this.CurPage			= 0;  
		
}

//Set info to start list
MainList.prototype.SetListInfoToStart = function(){
	alert("##mini##MainList.SetListInfoToStart");
	this.CurrentItemIndex	= -1;		//to update style for all item
	this.CurIndex			= 0;		//starting point
	this.CurPage			= 1;		//starting point  
}

//Reset scrool bar & page label
MainList.prototype.ResetPageUI = function(){
	
	alert("##mini##MainList.ResetPageUI");
	
	//make function  later.. 
//	this.PageLabel.SetTextLayer(1,this.CurPage + "/" + this.TotalPageNum + " " + TV_SID_PAGES);

	this.ScrollBar.SetTotalNum(this.TotalPageNum);
	this.ScrollBar.SetCurrentNum(this.CurPage);
	this.ScrollBar.ResetScrollBar();
	
	if(this.TotalPageNum > 1)	{
		this.ScrollBar.Show();
	} else{
		this.ScrollBar.Hide();
	}
	
    
	var Scene = $.sfScene.get({id:this.SceneName, scope:WIDGET.id});
    Scene.ArrowUpdate();
	for (var i=0; i<this.NumOfVisibleItem-1; i++){
		$("#list_main_contact_Line"+i).css("display","block");
	}
	for (var i=this.NumOfVisibleItem-1;i<4;i++){
		$("#list_main_contact_Line"+i).css("display","none");
	}
	
}

MainList.prototype.ShowNoItemPage = function(){
	
	alert("##mini##MainList.ShowNoItemPage");
		
	for(var k = 0; k < MaxNumOfMainItem ; k++) {
		
		if(this.ItemArray[k]){
			this.ItemArray[k].SetFlagForExistData(false);
		}		
	}
	this.ShowItem();

	this.ScrollBar.SetTotalNum(this.TotalPageNum);
	this.ScrollBar.SetCurrentNum(this.CurPage);		

	this.ScrollBar.Hide();
	
	this.NotifingLabel.Show();
	
	//TEMPCODE
	if(this.Flag_Focus){
	//modify
		 $.sfScene.get({id:"miniMainContact", scope:WIDGET.id}).processReturnKey();		
	}

}


MainList.prototype.Show = function() {

	alert("##mini##MainList.Show()");
	
	if(this.ShowState == false){

		$("#"+ this.BGLayer.Obj).css('display', 'block');		
		this.ShowState = true;
//		this.ScrollBar.Show();	
	}

}
MainList.prototype.Hide = function() {

	alert("##mini##MainList.Hide()");


	if(this.ShowState == true){
		
		$("#"+ this.BGLayer.Obj).css('display', 'none');
		this.ShowState = false;	
		
		this.ScrollBar.Hide();
	}	
	for(var i=0; i<4;i++){
		$("#list_main_contact_Line"+i).css("display","none");
	    //this.ContactListLine[i].hiddenObj();
    }
}

//Check!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MainList.prototype.MoveToItem = function(ItemIndex)
{
    alert("##mini##MainList.MoveToItem --" + ItemIndex);
   
    var SNS_Scene = $.sfScene.get({id:WIDGET.name, scope:WIDGET.id});
   if(SNS_Scene.tabFocus==true){
       // SNS_Scene.tabFocus=false;
        //    utilitySet.changeTabBGStatus(WIDGET.id,'focus',true);
           StateMgr.Focus_Current_State();// $.sf.returnFocus();
    }

    var Main_Scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
    Main_Scene.highlight(Main_Scene.list);

    if(ItemIndex < 0 || ItemIndex > MaxNumOfMainItem)
    {
        alert("##mini##ItemIndex error.. only  1 ~ 5"); 
        return;
    }

    this.CurIndex = this.CurIndex - this.CurrentItemIndex + ItemIndex ;

    this.MoveItem(ItemIndex);
}
//Check!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MainList.prototype.JumpToItem = function(ItemIndex)
{
	alert("##mini##MainList.JumpToItem --" + ItemIndex);
	//add by minseok : mouse click
	var SNS_Scene = $.sfScene.get({id:WIDGET.name, scope:WIDGET.id});
	if(SNS_Scene.tabFocus==true){
		SNS_Scene.tabFocus=false;
		utilitySet.changeTabBGStatus(WIDGET.id,'focus',true);
	}
	var Main_Scene = $.sfScene.get({id:"miniMainContact", scope:WIDGET.id});
	Main_Scene.highlight(Main_Scene.list);

	if(ItemIndex < 0 || ItemIndex > MaxNumOfMainItem)
	{
		alert("##mini##ItemIndex error.. only  1 ~ 5"); 
		return;
	}

	this.CurIndex = this.CurIndex - this.CurrentItemIndex + ItemIndex ;

	this.MoveItem(ItemIndex);
	this.processEnterKey();
}

MainList.prototype.PageScroll = function(UpScroll)
{
	alert("##mini##MainList.PageScroll");
	if (this.TotalPageNum > 1) 
	{
		var newPositionItem = -1;
		var lastPage = false;
		
		if(this.SceneName == "ListMainHistory" && ProcMgr.isVoiceMailPlaying == true) {
			ProcMgr.StopHistoryVoicemail(this.CurIndex);	
		}

		if(UpScroll == true)
		{
			//set current page
			if(this.CurPage <= 1) {
				this.CurPage = 1;
				return;
			}
			else {
				this.CurPage--;
			}
		}
		else{
			//set current page
			if(this.CurPage >= this.TotalPageNum) {
				lastPage = true;
				this.CurPage = this.TotalPageNum;
				return;
			}
			else {
				this.CurPage++;
			}			
		}
				
		this.UpdatePage();
		 
		//Check!!! Live call 
		if(UpScroll == true)
		{	
			alert("##mini##UpScroll");
		 	this.CurIndex = this.CurIndex - MaxNumOfMainItem;
		 		 	
			if(this.CurIndex < 0)
			{	
				//case 1. 1 page == > last page
				if(this.CurPage == this.TotalPageNum) 
				{
					if(this.CurrentItemIndex > this.NumOfVisibleItem -1)
					{
						//last page				
						this.CurIndex = this.TotalDataNum -1;
						newPositionItem = this.NumOfVisibleItem -1;
						alert("##mini##CurIndex = " + this.CurIndex);
						alert("##mini##newPositionItem = " + newPositionItem);					
					}
					else
					{
						this.CurIndex = ((this.CurPage - 1) * MaxNumOfMainItem) + this.CurrentItemIndex;
						alert("##mini##CurIndex = " + this.CurIndex);
					}					
				}
			}
		}
		else
		{
			alert("##mini##DownScroll");
			this.CurIndex = this.CurIndex + MaxNumOfMainItem;
			
			//last
			if(this.CurIndex > this.TotalDataNum - 1){
				
				//case 1. last page == > first page
				if(lastPage == true) {
					this.CurIndex = this.CurrentItemIndex;
					alert("##mini##first page >> CurIndex = " + this.CurIndex);	
				}
				//case 2. last - 1 page == > last page
				else {
					//last page	
					if(this.CurrentItemIndex > this.NumOfVisibleItem -1)
					{
						this.CurIndex = this.TotalDataNum -1;
						newPositionItem = this.NumOfVisibleItem -1;
						alert("##mini##CurIndex = " + this.CurIndex);
						alert("##mini##newPositionItem = " + newPositionItem);					
					}
					else
					{
						this.CurIndex = ((this.CurPage - 1) * MaxNumOfMainItem) + this.CurrentItemIndex;
						alert("##mini##CurIndex = " + this.CurIndex);
					}					
				}	
			}
		}
		
		//new case. move item to another position!!!
		if(newPositionItem > -1)
		{
			this.SetCurrentItem(newPositionItem);
		}
		
	}
}


MainList.prototype.GetItemInfo=function(SkypeId)
{
 	alert("##mini##MainList.GetItemInfo() id : " +SkypeId);
	var Availability = null;

	this.IsContactAddMode = false;
	//process exception..
	if(SkypeId && SkypeId.length > 0) {
		Availability = parseInt(PluginAPIMgr.GetContactAvailabilityWithName(SkypeId));
	}
	if(Availability == ENUM_CONTACT_AVAILABILITY.UNKNOWN)
	{
		this.IsContactAddMode = true;
	}
	if(Availability == null) {
		this.IsEnableVideo = true;
	}
	else if(Availability == ENUM_CONTACT_AVAILABILITY.SKYPEOUT || Availability == ENUM_CONTACT_AVAILABILITY.BLOCKED_SKYPEOUT || SkypeId == "echo123") {
		this.IsEnableVideo = false;
	}
}


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



function ContactList() {

	this.ListPropNum	= 7;
	
	//this.LiveCallMode	= false;
	this.PopupMode		= false;
										
	MainList.call(this);	
}

ContactList.prototype = new MainList(); 

ContactList.prototype.Costomizing = function(){

	this.ElimentName = "contact";
	this.ItemClass = ContactItem;
	//this.FuncPopupClass = ContactFuncPopup;
	this.NoItemString = TV_SID_YOU_DONT_HAVE_ANY_SKYPE_CONTACTS_YET + "</p>" + TV_SID_GO_TO_SKYPE_APP_ADD_CONTRACTS;

	//this.FuncPopupPropertyType	= FUNC_POPUP_PROPERTY_TYPE.IDENTITY;
	
	this.SceneName = "miniMainContact";
}
ContactList.prototype.InitListInfo = function(){
	alert("##mini##ContactList.InitListInfo");
	this.CurrentItemIndex	= 0;		//to update style for all item
	this.CurIndex			= 0;		//starting point
	this.CurPage			= 1;		//starting point  
}
//costomize...
ContactList.prototype.GetNumberOfDatas = function(){
	
	var TotalContactNum;
	
	if(this.PopupMode){
		
		TotalContactNum = PluginAPIMgr.GetNumberOfContactsInPopupMode();
	}
	else{
		
		TotalContactNum = PluginAPIMgr.GetNumberOfContacts();
	}
		
	if(ProcMgr.GetIsInCall()){
		
		var CallMemberIdentity = PluginAPIMgr.GetCallMemberID();
		
		if(PluginAPIMgr.IsMyBuddy(CallMemberIdentity)){
			
			return TotalContactNum - 1;	
		}
		else{
			
			return TotalContactNum;
		}
		
	}
	else{
	
		return TotalContactNum;	
	}
	
}

ContactList.prototype.GetIndexOfData = function(DataID){
	
	return PluginAPIMgr.GetIndexOfContact(DataID);
}


//ready for CurPage, but must be correct!!!! over than one contact.
ContactList.prototype.UpdatePage = function(){

	alert("##mini##ContactList.UpdatePage"); 

//LIVECALL
	/*
	if(ProcMgr.GetIsInCall()){
			this.UpdateLiveCallList();
		}
		else{*/
	
		this.UpdateNormalList();
	//}

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

	if((this.TotalDataNum == 1) && (this.ItemArray[0].IdentityName == "echo123"))
	{
		this.NotifingLabel.Show();
	}
	else{
		this.NotifingLabel.Hide();
	}

}

ContactList.prototype.UpdateNormalList = function(){

	var startIndexOfPage = (this.CurPage - 1) * MaxNumOfMainItem;
	//alert("##mini##first Name = " + ContactName );	
	
	var strContactList;
	
	if(this.PopupMode){
		
		strContactList = PluginAPIMgr.GetContactListInPopupMode(startIndexOfPage);
	}
	else{
		
		var ContactName = PluginAPIMgr.GetContactNameWithIndex(startIndexOfPage);	
		strContactList = PluginAPIMgr.GetContactList(ContactName);	
	}
		
	//alert("##mini##String = " + strContactList );

	var SkypeNameArray		= new Array(MaxNumOfMainItem);
	var PSTNNumberArray		= new Array(MaxNumOfMainItem);
	var DisplayNameArray	= new Array(MaxNumOfMainItem);
	var AvailityArray 		= new Array(MaxNumOfMainItem);
	var GenderArray 		= new Array(MaxNumOfMainItem);
	var AvataImgPathArray 	= new Array(MaxNumOfMainItem);
	var MoodMsgArray 		= new Array(MaxNumOfMainItem);	
			
	var NumOfItemInThisPage = 0;						
							
	if(strContactList)
	{				
		var STX = String.fromCharCode(2);
		var ETX = String.fromCharCode(3);
		var splitter = ETX + STX;
	
		var Result = strContactList.split(splitter);	
		NumOfItemInThisPage = parseInt(Result.length / this.ListPropNum);
		alert("##mini##NumOfItemInThisPage = " + NumOfItemInThisPage );
		
		var TokenNum = 0;
		
		for (var i=0; i < NumOfItemInThisPage ; i++) {
					
			TokenNum = i*(this.ListPropNum);						
			
			SkypeNameArray[i] = Result[TokenNum];			
			PSTNNumberArray[i] = Result[TokenNum+1];			
			DisplayNameArray[i] = Result[TokenNum+2];						
			AvailityArray[i] = Result[TokenNum+3];						
			GenderArray[i] = Result[TokenNum+4];						
			AvataImgPathArray[i] = Result[TokenNum+5];					
			MoodMsgArray[i] = Result[TokenNum+6];		
			
/*
			alert("##mini##SkypeNameArray[" + i +"] = " + SkypeNameArray[i] );	
			alert("##mini##PSTNNumberArray[" + i +"] = " + PSTNNumberArray[i] );				
			alert("##mini##DisplayNameArray[" + i +"] = " + DisplayNameArray[i] );
			alert("##mini##AvailityArray[" + i +"] = " + AvailityArray[i] );
			alert("##mini##GenderArray[" + i +"] = " + GenderArray[i] );
			alert("##mini##AvataImgPathArray[" + i +"] = " + AvataImgPathArray[i] );
			alert("##mini##MoodMsgArray[" + i +"] = " + MoodMsgArray[i] );	
*/						
							
		}
	}
		
	var tempData = new Array(MaxNumOfMainItem);
	var tempContctData;
		
			
	for (var j=0; j < NumOfItemInThisPage; j++) {
	
		//alert("##mini##tempData[" + j +"] create");	
		tempData[j] = new ContactData();		
		tempData[j].SetData(SkypeNameArray[j],PSTNNumberArray[j],DisplayNameArray[j],AvailityArray[j],GenderArray[j],AvataImgPathArray[j],MoodMsgArray[j]);
		

		this.ItemArray[j].SetItem(tempData[j]);
		
		//this.ItemArray[j].SetItem(tempData[j]);
				
	}
	
	this.NumOfVisibleItem = NumOfItemInThisPage;
	for(var k = NumOfItemInThisPage; k < MaxNumOfMainItem ; k++) {
		
		//alert("##mini##ItemArray[" + k +"] not include data!!");
		if(this.ItemArray[k]){
			
			this.ItemArray[k].SetFlagForExistData(false);
		}		
	}
}


ContactList.prototype.UpdateLiveCallList = function(){

	var CallMemberName = PluginAPIMgr.GetCallMemberID();
	var CallMemberIndex = PluginAPIMgr.GetIndexOfContact(CallMemberName);
	alert("##mini##CallMemberIndex = " + CallMemberIndex);
		
	var startIndexOfPage = (this.CurPage - 1) * (LiveNumOfContact);

	if(CallMemberIndex < startIndexOfPage)
	{
		startIndexOfPage++;
	}

	var strContactList;
	
	if(this.PopupMode){
		
		strContactList = PluginAPIMgr.GetLiveContactListInPopupMode(startIndexOfPage);
	}
	else{
		
		strContactList = PluginAPIMgr.GetLiveContactList(startIndexOfPage);	
	}

	var SkypeNameArray		= new Array(LiveNumOfContact);
	var PSTNNumberArray		= new Array(LiveNumOfContact);
	var DisplayNameArray	= new Array(LiveNumOfContact);
	var AvailityArray 		= new Array(LiveNumOfContact);
	var GenderArray 		= new Array(LiveNumOfContact);
	var AvataImgPathArray 	= new Array(LiveNumOfContact);
	var MoodMsgArray 		= new Array(LiveNumOfContact);	
			
	var NumOfItemInThisPage = 0;						
							
	if(strContactList)
	{				
		var STX = String.fromCharCode(2);
		var ETX = String.fromCharCode(3);
		var splitter = ETX + STX;
	
		var Result = strContactList.split(splitter);	
		NumOfItemInThisPage = parseInt(Result.length / this.ListPropNum);
		alert("##mini##NumOfItemInThisPage = " + NumOfItemInThisPage );
		
		var TokenNum = 0;
		
		for (var i=0; i < NumOfItemInThisPage ; i++) {
					
			TokenNum = i*(this.ListPropNum);						
			
			SkypeNameArray[i] = Result[TokenNum];			
			PSTNNumberArray[i] = Result[TokenNum+1];			
			DisplayNameArray[i] = Result[TokenNum+2];						
			AvailityArray[i] = Result[TokenNum+3];						
			GenderArray[i] = Result[TokenNum+4];						
			AvataImgPathArray[i] = Result[TokenNum+5];					
			MoodMsgArray[i] = Result[TokenNum+6];		
										
		}
	}
		
	var tempData = new Array(LiveNumOfContact);
	var tempContctData;
	var Idex;
	
	NumOfItemInThisPage++;
	this.ItemArray[0].SetLiveCallItem(CallMemberName);			
			
	for (var j=1; j < NumOfItemInThisPage; j++) {
		
		Idex = j - 1;
		//alert("##mini##tempData[" + Idex +"] create");
	
		tempData[Idex] = new ContactData();		
		tempData[Idex].SetData(SkypeNameArray[Idex],PSTNNumberArray[Idex],DisplayNameArray[Idex],AvailityArray[Idex],GenderArray[Idex],AvataImgPathArray[Idex],MoodMsgArray[Idex]);
			
		this.ItemArray[j].SetItem(tempData[Idex]);
				
	}
	
	this.NumOfVisibleItem = NumOfItemInThisPage;
	for(var k = NumOfItemInThisPage; k < MaxNumOfMainItem ; k++) {
		
		//alert("##mini##ItemArray[" + k +"] not include data!!");
		if(this.ItemArray[k]){
			
			this.ItemArray[k].SetFlagForExistData(false);
		}		
	}

}

ContactList.prototype.ProgressCallDuration = function(DurationTime){

	if(ProcMgr.GetIsInCall()){
		this.ItemArray[0].SetDuration(DurationTime);
	}
}

//TEMPCODE:
ContactList.prototype.RefreshForCurIdentity = function(){

	alert("##mini##ContactList.RefreshFoCurIdentity");
	
	var ItemIdentity = this.GetCurItemIdentity();
	var Index = parseInt(this.GetIndexOfData(ItemIdentity));
	alert("##mini##Index = " + Index);
	
	if (Index >= 0) {
	
//		this.InitializeDataOfPage();

		if(ProcMgr.GetIsInCall()){
			
			var CallingIdentity = PluginAPIMgr.GetCallMemberID();
			var CallingIndex = parseInt(this.GetIndexOfData(CallingIdentity));		
			
			if(Index == CallingIndex){
			
				this.RefreshForCurrentPage();
			}
			else if(Index > CallingIndex){
				
				this.InitializeDataOfPage();

				//reset current page
				this.CurPage = parseInt(Index / LiveNumOfContact);
				var CurItemIndex = Index % LiveNumOfContact;
				
				if (CurItemIndex > 0) {
					this.CurPage++;					
				}
				else{
					CurItemIndex = LiveNumOfContact;
				}
				alert("##mini##CurPage = " + this.CurPage);
				
				this.CurIndex = Index;
				
				//reset page & scorllbar
				this.UpdatePage();			
				
				this.CurrentItemIndex = -1;
				this.MoveItem(CurItemIndex);								

			}
			else{
			
				this.InitializeDataOfPage();
				//reset current page
				this.CurPage = parseInt(Index / LiveNumOfContact) + 1;
				alert("##mini##CurPage = " + this.CurPage);
				
				this.CurIndex = Index;
				
				//reset page & scorllbar
				this.UpdatePage();
				
				var CurItemIndex = (Index % LiveNumOfContact) + 1;
				
								
				this.CurrentItemIndex = -1;
				this.MoveItem(CurItemIndex);
					
			}
						
		}
		else {

			this.InitializeDataOfPage();
			
			//reset current page
			this.CurPage = parseInt(Index / MaxNumOfMainItem) + 1;
			alert("##mini##CurPage = " + this.CurPage);
			this.CurIndex = Index;
			
			//reset page & scorllbar
			this.UpdatePage();
			
			var CurItemIndex = Index % MaxNumOfMainItem;
			
			this.CurrentItemIndex = -1;
			this.MoveItem(CurItemIndex);			
		}		
	}
	else {
	
		alert("##mini##=====================================");
		alert("##mini##Error!! no result of searching index ");
		alert("##mini##=====================================");
		
		this.RefreshForCurrentPage();
		
	}
	
}

ContactList.prototype.InitializeDataOfPage = function(){
	
	this.TotalDataNum = parseInt(this.GetNumberOfDatas());
						
	if( this.TotalDataNum > 0){
		
		var NumOfItem;		
		if(ProcMgr.GetIsInCall()){
			NumOfItem = LiveNumOfContact;
		}
		else {
			NumOfItem = MaxNumOfMainItem;
		}
		
		this.TotalPageNum = parseInt(this.TotalDataNum / NumOfItem);

		if((this.TotalDataNum % NumOfItem) > 0){
			this.TotalPageNum++;
		}						
	}
	else {
		this.InitializeListInfo();					
	}		
		
}



ContactList.prototype.RefreshForIndex = function(Index)
{
	alert("##mini##ContactList.RefreshForIndex---" + Index);

	if(Index < 0)	
	{
		alert("##mini##=====================================");
		alert("##mini##Error!! no result of searching index ");
		alert("##mini##=====================================");		
		return;		
	}

	// if(ProcMgr.GetIsInCall())	
	// {
		// alert("##mini##=====================================");
		// alert("##mini##Error!! in Call state.... ");
		// alert("##mini##=====================================");		
		// return;		
	// }

	this.InitializeDataOfPage();
	
	//reset current page
	this.CurPage = parseInt(Index / MaxNumOfMainItem) + 1;
	alert("##mini##CurPage = " + this.CurPage);
	this.CurIndex = Index;
	
	//reset page & scorllbar
	this.UpdatePage();
	
	var CurItemIndex = Index % MaxNumOfMainItem;
	
	this.CurrentItemIndex = -1;
	this.MoveItem(CurItemIndex);
	
}

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




function ContactData () {
    
	//alert("##mini##ContactData()");
	this.DisplayName			= null;
	this.IdentityName			= null;	
    this.OnlineStatusImgPath	= null;
	this.AvataImgPath			= null;
	this.AvataImgType			= null;
	this.MoodMsg				= null;
	this.IsNewContact =false;

}


ContactData.prototype.SetData = function(SkypeName,PSTN,Display,Availablity,Gender,Avata,Mood) {

	//alert("##mini##ContactDataSetData");
		
	if(Display) {
		this.DisplayName = Display;
		
		if(SkypeName){
			this.IdentityName = SkypeName;
		}
		else if(PSTN){
			this.IdentityName = PSTN;
		}
		else{			
			alert("##mini##################################################################");
			alert("##mini##[ContactData.SetData] Setting Error When Identity");		
			alert("##mini###################################################################");			
		}
	}
	else if(SkypeName) {
		
		this.DisplayName = SkypeName;
		this.IdentityName = SkypeName;
	}
	else if(PSTN) {
		
		this.DisplayName = PSTN;
		this.IdentityName = PSTN;
	}
	else{
		alert("##mini##################################################################");
		alert("##mini##[ContactData.SetData] Setting Error When Identity & DisplayName");		
		alert("##mini###################################################################");
	}

	if(Mood) {
		this.MoodMsg = Mood;
	}
	else {
		this.MoodMsg = "";
	}
	
	
	if (SkypeName == "echo123") {
		this.AvataImgPath = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_TEST_CALL;
		this.AvataImgType = ENUM_CONTACT_AVATA_TYPE.TEST_CALL;
	}		
	else if(Avata) {		
		this.AvataImgPath = Avata;
		this.AvataImgType = ENUM_CONTACT_AVATA_TYPE.ONES_IMAGE;					
	}
	else if (PSTN){
		this.AvataImgPath = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_PSTN;
		this.AvataImgType = ENUM_CONTACT_AVATA_TYPE.PSTN;
	}
	else if (Gender == "1"){
		this.AvataImgPath = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_MALE;
		this.AvataImgType = ENUM_CONTACT_AVATA_TYPE.MALE;
	}
	else if (Gender == "2" ) {
		this.AvataImgPath = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_FEMALE;
		this.AvataImgType = ENUM_CONTACT_AVATA_TYPE.FEMALE;
	}
	else {
		this.AvataImgPath = g_Image.IMAGE_LIST_MAIN_HISTORY_LIST_ITEM_DEFAULT_AVATA_NO_GENDER;
		this.AvataImgType = ENUM_CONTACT_AVATA_TYPE.NO_GENDER;
	}

	//GROUP (Never found)
/*
	if(Availablity == ENUM_CONTACT_AVAILABILITY.GROUP){
		
		this.OnlineStatusImgPath = g_Image.IMAGE_ONLINE_STATUS_PRESENCE_GROUP;
	}
*/
	//BLOCKED & BLOCKED_SKYPEOUT
	if (Availablity == ENUM_CONTACT_AVAILABILITY.BLOCKED ||
		Availablity == ENUM_CONTACT_AVAILABILITY.BLOCKED_SKYPEOUT) {
			
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_BLOCK;
	}
	// PSTN
	else if(PSTN){
		
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_CALLSFORWARD;
	}
	//SkYPEOUT
	else if(Availablity == ENUM_CONTACT_AVAILABILITY.SKYPEOUT){
		
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_OFFLINE;
	}
	//ONLINE	
	else if(Availablity == ENUM_CONTACT_AVAILABILITY.ONLINE || 
		Availablity == ENUM_CONTACT_AVAILABILITY.ONLINE_FROM_MOBILE) {
					
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_ONLINE;
	}
	//OFFLINE
	else if (Availablity == ENUM_CONTACT_AVAILABILITY.OFFLINE ||
		Availablity == ENUM_CONTACT_AVAILABILITY.NOT_AVAILABLE_FROM_MOBILE) {
			
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_OFFLINE;
	}
	//AWAY 
	else if (Availablity == ENUM_CONTACT_AVAILABILITY.AWAY ||
		Availablity == ENUM_CONTACT_AVAILABILITY.AWAY_FROM_MOBILE){
			
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_AWAY;
	}
	//DO_NOT_DISTURB	
	else if (Availablity == ENUM_CONTACT_AVAILABILITY.DO_NOT_DISTURB ||
		Availablity == ENUM_CONTACT_AVAILABILITY.DO_NOT_DISTURB_FROM_MOBILE){
			
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_DONOTDISTURB;
	}
	//CALL_FORWARDING or VOICEMAIL ABLE
	else if (Availablity == ENUM_CONTACT_AVAILABILITY.OFFLINE_BUT_CF_ABLE ||
		Availablity == ENUM_CONTACT_AVAILABILITY.OFFLINE_BUT_VM_ABLE) {
			
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_INVISIBLE;
	}
	//UNKNOWN	
	else if (Availablity == ENUM_CONTACT_AVAILABILITY.PENDINGAUTH ||
		Availablity == ENUM_CONTACT_AVAILABILITY.UNKNOWN) {
					
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_OFFLINE;
	}
	//ELSE
	else{		
		alert("##mini##Availablity is Error");
		this.OnlineStatusImgPath = g_Image.IMAGE_CONFERENCE_CALL_OFFLINE; 
	}	
	
	/// add 12.11
	var Availability = null;
	if(SkypeName && SkypeName.length > 0){
		Availability = parseInt(PluginAPIMgr.GetContactAvailabilityWithName(SkypeName));		
	}
	if(Availability == ENUM_CONTACT_AVAILABILITY.UNKNOWN){
		this.IsNewContact =true;
	}else{
		this.IsNewContact =false;
	}
	
} 




