//companyUrl 如果传入的是公司companyUrl(注册的名称，比如http://www.vlinetech.com)或注册后得到的ID(比如威蓝公司的ID是5711), 则显示公司帐号列表，
//    若是传入'', 则不显示公司列表
//
//id  是需要呼叫的账号id
//
//说明：如果需要界面的背景色，请改变脚本里控件属性BackColor的VALUE值
//	背景色值的计算方法是：排列方式是bgr，比如红色是0x0000ff = 255, 白色是0xffffff=16777215
//      蓝色0xff0000=16711680
//
//isCallCompany = 'F' 则呼叫的是一个具体的用户，否则呼叫的是公司
//isShowList ='F'， 则不显示用户列表，否则显示用户列表

var ctrlWin;//视频子窗口

function OpenCtrl(companyUrl, id, isCallCompany, isShowList)
{
	var w;
	if (isShowList == 'F') w = 356;
	else w = 590;
	
	if (ctrlWin)
		ctrlWin.close();
		
	ctrlWin = window.open("", "ctrlWin","width=" + w + ",height=460,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no");
	
	ctrlWin.document.writeln("<html><head><title>Web-based Multimedia Sevice Center</title><\/head>");
	ctrlWin.document.writeln("<body marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 rightmargin=0>");
	ctrlWin.document.writeln("<OBJECT id=DGnvCtl codeBase=GnvCtrl.cab #version=2,0,0,2 height=460 width=" + w);
	ctrlWin.document.writeln("classid=clsid:584EF817-906A-43FF-843D-2A906B9751AF VIEWASTEXT>");
	ctrlWin.document.writeln("<PARAM NAME=\"BackColor\" VALUE=\"15658734\"></OBJECT>");
	
	ctrlWin.document.writeln("<SCRIPT LANGUAGE=javascript>");
	ctrlWin.document.writeln("<!--");
	ctrlWin.document.writeln(" try{ ");
	ctrlWin.document.writeln("    DGnvCtl.CompanyURL = \"" + companyUrl + "\";");
	ctrlWin.document.writeln("    DGnvCtl.UserTitle = '部门列表';");
	ctrlWin.document.writeln("    if ('" + isCallCompany + "'== 'F'){");
	ctrlWin.document.writeln("       DGnvCtl.Call(" + id + ");}");
	ctrlWin.document.writeln("    else");
	ctrlWin.document.writeln("       DGnvCtl.CallCompany(" + id + ");");
	ctrlWin.document.writeln(" }catch(Exception){}");
	ctrlWin.document.writeln("\/\/-->");
	ctrlWin.document.writeln("<\/SCRIPT>");
	ctrlWin.document.writeln("<\/body><\/html>");
	
}

function _MyClass()
{
	this.ID = 0;
	this.Status = -2;
	this.showStatus = _MyClass_showStatus;
	this.Self = '';
}

function _MyClass_showStatus(aa)
{
	var i = QStatus.GetStatus(this.ID);
	var txt;
	
	switch (i)
	{
		case -2:
			txt = "无法连接服务器";
			break;
		case -1:
			txt = "等待更新状态";
			break;
		case 0:
			txt = "不在线";
			break;
		case 1:
			txt = "空闲";
			break;
		case 2:
			txt = "正在通话中";
			break;
		case 3:
			txt = "休息中";
			break;
		case 4:
			txt = "会议中";
			break;
		
		default:txt = i;
	}
	
	eval('Dept' + this.ID + '.innerText = txt');
		
	setTimeout(this.Self + '.showStatus()',1000);
}

var g_List = new Array();

function InitStatus() 
{

	QStatus.CompanyID = 57801001;
	
	var j = 0;
	for ( i = 0; i < document.all.length; i++)
	{
		if (document.all[i].id)
		{
			var s = document.all[i].id;
			if (s.indexOf("Dept") == 0)
			{
				g_List[j] = new _MyClass();
				g_List[j].Self = 'g_List[' + j + ']';
				g_List[j].ID = s.substr(4, s.length - 4);
				g_List[j].showStatus();
				j = j + 1;
			}
		}
	}
	
}
