function MaxWin()
{
	window.focus();
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);	
}

function ShowWin(action,type)
{
	if(action=="exit")
	{
		switch(type)
		{
			case "0":
				if(window.confirm("你确定要注销当前用户吗？"))
				{
					window.parent.location = "../Default.aspx";
				}
				break;
			case "1":
				if(window.confirm("你确定要退出系统吗？"))
				{
					window.parent.opener = null;
					window.parent.close();
				}
				break;
		}
	}
}

function MenuControl(frame)
{
	var menu = window.parent.document.getElementById("main");
	var left = window.parent.document.getElementById("menu").width;
	var right = window.parent.document.getElementById("online").width;
	
	if(frame == "menu")
	{
		if(left != 0)
		{
			left = "0";
		}
		else
		{
			left = "200";
		}		
	}
	
	if(frame == "online")
	{
		if(right != 200)
		{
			parent.online.location = "../xmldata/online.xml";
			right = "200";
		}
		else
		{
			parent.online.location = "../message/blank.htm";
			right = "0";
		}
	}
	
	menu.cols = left + ",*," + right;
}

function ReNew(textbox)
{
	document.getElementById(textbox).innerText = "";
}

function ReClickUser(hidden)
{
	var users = document.getElementById(hidden).value;
	if(users.length>2)
	{
		document.getElementById(hidden).value = "";
		users = users.substring(0,users.length-1);
		var us = users.split(";")
		for(i=0;i<us.length;i++)
		{
			document.getElementById("cbx_uid_" + us[i]).checked = true;
		}
	}
}

function ReClickJob(hidden)
{
	var jobs = document.getElementById(hidden).value;
	if(jobs.length >= 2)
	{
		jobs = jobs.substring(0,jobs.length-1);
		var js = jobs.split(";")
		for(i=0;i<js.length;i++)
		{
			document.getElementById("jid_" + js[i]).checked = true;
		}
	}
}

function ClickGroup(level,clicker)
{
	var c = document.getElementById(clicker);
	CheckClick(document.getElementById(level),c.checked);					
}

function ClickUser(clicker)
{
	var c = document.getElementById(clicker);
	var uid = clicker.substring(4,clicker.length);
	CheckUser(uid,"ToUid",c.checked);
}

function CheckClick(level,checked)
{
	if(level.childNodes.length > 0)
	{
		for(var i=0;i<level.childNodes.length;i++)
		{
			CheckClick(level.childNodes.item(i),checked);
		}
	}
	else
	{
		if(level.tagName =="INPUT")
		{
			if(level.checked != checked)
			{
				level.checked = checked;
				if(level.id.substring(0,1) == "u")
				{
					var uid = level.id.substring(4,level.id.leng);
					CheckUser(uid,"ToUid",checked);		
				}
			}
		}
	}
}

function CheckUser(uerID,hiddenName,checked)
{
	var hidden = document.getElementById(hiddenName);
	if(checked)
	{
		hidden.value += uerID + ";";				
	}
	else
	{
		hidden.value = hidden.value.replace(uerID+";","");
	}
}

function OpenWindow(url,width,height)
{
	var t = (screen.availHeight - height) /2;
	var w = (screen.availWidth - width) /2;	
	var f = "width=" + width + ",height=" + height + ",top=" + t + ",left=" + w + ",status=no,toolbar=no,menubar=no,location=no";
	window.open(url,null,f);
}

function SetRead(id)
{
	window.opener.document.getElementById("m_" + id).style.backgroundImage="url(../images/message_read.gif)";
}

function CloseWindow()
{
	window.opener = null;
	window.close();
}

function ReMessage(id)
{
	var frm = window.opener.parent.document.getElementById("content");
	frm.src = "Message.aspx?type=re&id=" + id;
	CloseWindow();
}

function GoUrl(url)
{
	window.location = url;
}

function Reflesh()
{
	window.location.reload();
}

function Back()
{
	window.history.back();
}

function InsertImage(imageid)
{				
	var img = "<img src='../general/NewsAttachs/" + imageid + "' border='0'>";
	FTB_API['ftbContent'].InsertHtml(img);
}

function InsertJob(jobid)
{
	var c = document.getElementById("jid_" + jobid);
	var tbx = document.getElementById("tbxJobs");
	
	if(c.checked)
	{
		tbx.value += jobid + ";";				
	}
	else
	{
		tbx.value = tbx.value.replace(jobid+";","");
	}	
}

function OpenSelectUserWindow()
{
	var winUrl = "../xmldata/SelectUsers.xml";
	var winWidth = "500";
	var winHeight = "400";
	var t = (screen.availHeight-400)/2;
	var l = (screen.availWidth-500)/2;
	var f = "width=" + winWidth + ",height=" + winHeight + ",top=" + t + ",left=" + l + ",status=no,toolbar=no,menubar=no,location=no";
	window.open(winUrl,"message",f);
}

function CopyUids(tbxRec)
{
	var or = document.getElementById("ToUid");
	var tr = window.parent.document.ElementById(tbxRec);
	tr.value = or.value;
}

function CopyUids(tbxRec)
{
	var or = document.getElementById("ToUid");
	var tr = window.opener.document.getElementById(tbxRec);
	tr.value = or.value;
	CloseWindow();
}

function RollTop(div)
{
	var objRoll = document.getElementById(div);
	objRoll.scrollIntoView(true);
}

function AutoCloseWindow(time)
{
	setTimeout("SetMsg(" + time + ")",1000);	
}	

function AutoGoToUrl(time,url)
{
	setTimeout("GoUrl('" + url + "')",time * 1000);	
}	

function SetMsg(time)
{	
	if(time >0)
	{				
		document.getElementById("msg").innerText = time + "秒后自动关闭此窗口....";		
		time -= 1;			
		setTimeout("SetMsg(" + time + ")",1000);
	}
	else
	{
		CloseWindow();
	}
}	

function GetCookie(sName)
{
  var aCookie = document.cookie.split("; ");
	
  for(var i=0;i<aCookie.length;i++)
  {
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
		return unescape(aCrumb[1]);
  }
  
  return null;
}
