var kefuListContent = document.getElementById("KefuListContent");

function getShiftsCallBack()
{
	if (shifts_request.readyState == 4) 
	{ 
		if (shifts_request.status == 200) 
		{ 
			DIV_Shifts.innerHTML = shifts_request.responseText;		
		} 
		else 
		{ 
			DIV_Shifts.innerHTML = "无法显示，稍候再试。";
		}
	}
}

function getKefuListCallBack(res)
{
	if (kefu_request.readyState == 4) 
	{ 
		if (kefu_request.status == 200) 
		{ 
			kefuListContent.innerHTML =   kefu_request.responseText;			
		} 
		else 
		{ 
			kefuListContent.innerHTML = "无法显示，稍候再试。";
		}
	}
	
}

function doSelectKefuListTab(colId,internalSiteDomainName)
{	
	GetShifts(internalSiteDomainName);
	
	selectKefuListTab(colId);
	var kefuId = document.getElementById("kefuMoreName");
	if(kefuId != null)
	{
		document.getElementById("KefuMoreName").innerText = "查看更多";
	}
	DefaultPageKefuListLoading();
	GetKefuList(internalSiteDomainName);	
	
		
}


function doSelectKefuListMore(colId)
{		
	
	e = document.getElementById(colId); 
  var y = e.offsetTop;
  var x = e.offsetLeft;
  while (e = e.offsetParent)
  {
      y += e.offsetTop;
      x += e.offsetLeft;
  }
  
  var menu = document.getElementById("MoreKefuListMenu");  
  menu.style.top = y;
  menu.style.left = x+3;	
  
  showMoreKefuListMenu(true);
}

function doSelectKefuListMenu(colId,internalSiteDomainName,internalSiteName)
{
  GetShifts(internalSiteDomainName);
  selectKefuListTab(colId);
  document.getElementById("KefuMoreName").innerHTML = internalSiteName;
  
  DefaultPageKefuListLoading();
	GetKefuList(internalSiteDomainName);	
	showMoreKefuListMenu(false);
}

function selectKefuListTab(colId)
{
	for (var i=0; i<document.getElementById("trKefuListTabContainer").cells.length-1; i++)
	{
	
		
		if (document.getElementById(colId) == document.getElementById("trKefuListTabContainer").cells[i])
		{			
			document.getElementById(colId).style.background = 'url(' + viewKefuListTabOpenKefuImg + ')';	
		}
		else
		{
			if(document.getElementById("trKefuListTabContainer").cells[i].innerHTML != "")
			{
				document.getElementById("trKefuListTabContainer").cells[i].style.background = 'url(' + viewKefuListTabCloseKefuImg + ')';
			}
		}
		
	}
	
}

function showMoreKefuListMenu(b)
{	
   document.getElementById("MoreKefuListMenu").style.display = b ? "block" : "none";
	
}

function menuOnMouseOver(col)
{
	col.style.backgroundColor= "#efefef";
}

function menuOnMouseOut(col)
{
	col.style.backgroundColor= "#ffffff";
}

function DefaultPageKefuListLoading()
{
	document.getElementById("KefuListContent").innerHTML = "<div style='padding-top:20;text-align:center'>正在加载数据...</div>";
}

document.onclick = onDocumentClick;
function onDocumentClick(e) 
{ 
	e = e || window.event;	
	var eSrc = e.srcElement ? e.srcElement : e.target;	
	if (eSrc.getAttribute("controlname")==null)
	showMoreKefuListMenu(false);
	
}

var kefu_request = false;
function GetKefuList(domainName)
{
	
	
	if(window.XMLHttpRequest) { 
		kefu_request = new XMLHttpRequest();
		if (kefu_request.overrideMimeType) {
			kefu_request.overrideMimeType("text/xml");
		}
		
	}
	else if (window.ActiveXObject) { 
		try {
			kefu_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				kefu_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!kefu_request) { 
		window.alert("不能创建XMLHttpRequest 对象实例.");
		return false;
	}
	kefu_request.onreadystatechange = getKefuListCallBack;
	
	kefu_request.open("POST", 'ajax.axd?methodName=viewKefu&domainName='+domainName, true);
	kefu_request.send("");
}

var shifts_request = false;
function GetShifts(domainName)
{
	
	
	if(window.XMLHttpRequest) { 
		shifts_request = new XMLHttpRequest();
		if (shifts_request.overrideMimeType) {
			shifts_request.overrideMimeType("text/xml");
		}
		
	
	}
	else if (window.ActiveXObject) { 
		try {
			shifts_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				shifts_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!shifts_request) { 
		window.alert("不能创建XMLHttpRequest 对象实例.");
		return false;
	}
	shifts_request.onreadystatechange = getShiftsCallBack;
	
	shifts_request.open("POST", 'ajax.axd?methodName=shifts&domainName='+domainName, true);
	shifts_request.send("");
}


