function MM_openBrWindow(theURL,winName,features,w_height,w_width) { //v2.0
	var t = 0, l = 0;
	t = screen.height; l = screen.width;
	
	t = t - w_height; l = l - w_width;
	t = t/2; l = l /2
	//window.open(theURL,winName,features);
	features =features+"top= " + t + "px,height=" + w_height + "px,left=" + l + "px,width=" + w_width + "px" ;
	window.open(theURL,winName,features);
}
function OpenWinByHtmlControl(theURL,Control_id)
{
	var control = document.getElementById(Control_id);	
	if(null!=control)
	{
		theURL=theURL + control.value;
		window.open(theURL);
	}
}
function CloseWindow() 
{
	var ua = navigator.userAgent;
	var IEversion = parseFloat(ua.substring(ua.indexOf("MSIE ")+5, ua.indexOf(";",ua.indexOf("MSIE "))));
	if(IEversion< 5.5) {
		var str = '<object id=noTipClose classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">';
		str += '<param name="Command" value="Close"></object>';
		document.body.insertAdjacentHTML("beforeEnd", str);
		document.all.noTipClose.Click();
	}
	else {
		window.opener =null;
		window.close();
	}
}
function timeout_control(url)
{
	if (null!=parent)
	{
		parent.location.assign(url);
	}
	else
	{
		window.location.assign(url);
	}
}

function assign_main(theUrl,navigation_bar)
{
//	window.parent.frames(0).location.assign('top.aspx?navigation_bar='+navigation_bar);
	window.parent.frames(2).location.assign(theUrl);
}
function assign_self(theUrl,navigation_bar)
{
	window.parent.frames(0).location.assign(window.parent.frames(0).location+";"+navigation_bar);
	window.location.assign(theUrl);
}

//set next ctrl focus when enter keydown event fire
function EnterKeyPress(nextid) { 
	var KeyCode = window.event.keyCode;  
	if(KeyCode == 13)
	{
		FocusThisControl(nextid);
	}
}
//set focus by ctrl's ID
function FocusThisControl(ctrlid) {
	//var ctrl = document.all.item(ctrlid);
	var ctrl = document.getElementById(ctrlid);
	if(null == ctrl)
		return;
	if(true == ctrl.disabled)
		return;
	ctrl.focus();
}
//limit text input length
function LimitTextLength(ctrlid, length) {
	//var ctrl = document.all.item(ctrlid);
	var ctrl = document.getElementById(ctrlid);
	if(null == ctrl)	return;	
	var text = ctrl.value;
	if(text.length <= length)
		return;
	ctrl.value = text.substring(0, length);
}
//check all or not items in DataGrid
function CheckAllGridItem(outckbid, gridid, gridckbid) 
{
	var temp = null;
	
	temp = document.getElementById(gridid);
	if(null == temp)	return;
	var gridlength = temp.rows.length;
	var star_index
	var canchecked = false;
	for (var i = 0; i < 4; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + i + "_" + gridckbid);
		if(null == temp)
		{
			continue;
		}
		else
		{
			canchecked = true;
			star_index=i;
			break;
		}
	}
	
	for (var i = 0; i < 4; i ++) 
	{
		var name=gridid + ":" + "_ctl" + i + ":" + outckbid
		temp = document.getElementById(name);
		if(null == temp)
		{
			continue;
		}
		else
		{
			break;
		}
	}
			
	if(null == temp)	return;

	if(!canchecked)
	{
		temp.checked = false;
	}
	var checkedall = temp.checked;
	for (var i = -3; i < gridlength+star_index; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + (i+3) + "_" + gridckbid);
		if(null == temp)	continue;
		temp.checked = checkedall;
	}
}
//change check all status by checked status in DataGrid
function CheckOneGridItem(outckbid, gridid, gridckbid) 
{
	var temp = null;
	
	temp = document.getElementById(gridid);
	if(null == temp)	return;
	var gridlength = temp.rows.length;
	
	var checkedall = false;
	for (var i = 0; i < 4; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + i + "_" + gridckbid);
		if(null == temp)	continue;
		checkedall = true;	break;
	}
	
	for (var i = -3; i < gridlength; i ++) {
		temp = document.getElementById(gridid + "_" + "_ctl" + (i+3) + "_" + gridckbid);
		if(null == temp)	continue;
		if(temp.checked)	continue;
		else {
			checkedall = false;
			break;
		}
	}
	for (var i = 0; i < 4; i ++) 
	{
		var name=gridid + ":" + "_ctl" + i + ":" + outckbid
		temp = document.getElementById(name);
		if(null == temp)
		{
			continue;
		}
		else
		{
			break;
		}
	}
	
	if(null == temp)	return;
	temp.checked = checkedall;
}
function  onKeyPress(aim){  
	var  KeyCode=window.event.keyCode;  
	if  (KeyCode==13)  
	{
		aim.focus();
	}
}
function refresh_opener(request_full)
{
	if(request_full!=null)
	{
		var index_full=-1;
		var str_address_full=window.opener.location.href;
		index_full=str_address_full.indexOf("?");
		if(index_full<0)
		{
			window.opener.location.assign(window.opener.location+"?"+request_full);
		}
		else
		{
			window.opener.location.assign(window.opener.location+"&"+request_full);
		}
	}
	else
	{
		window.opener.location.assign(window.opener.location);
	}
}
function  onKeyPress_dark()
{  
var  KeyCode=window.event.keyCode;  
if  (KeyCode==13)  
	{
	document.all.btn_DarkQuery.focus();
	}
}
function  onKeyPress()
{
var  KeyCode=window.event.keyCode;  
if  (KeyCode==13)  
	{
	document.all.btn_search.focus();
	}
}
function OpenOfRefresh()
{
	if(null!=window.opener)
	{
		try{
			var openwin = window.opener;
			openwin.location.reload();		
		}
		catch(e){
			return;
		}
	}
}
function ParentOfRefresh()
{
	if(null!=window.parent)
	{
		window.parent.location.assign(window.parent.location);	
	}
	else
	{}
}
function replace(szMain,szBeforereplace,szAfterreplace) 
{ 
  strMain=new String(szMain) 
  arrMain=strMain.split(szBeforereplace) 
  var szReturn 
  szReturn=''; 
  for(var i=0;i<arrMain.length-1;i++) 
{ 
szReturn=szReturn+arrMain[i]+szAfterreplace; 
} 
return szReturn+arrMain[arrMain.length-1]; 
} 
function onload_setfocus(txt_id)
{
	var focus_txt=document.getElementById(txt_id);
	if(focus_txt!=null)
	{
		focus_txt.focus();
	}
	else
	{
	}
}
function trim(value){return value.replace(/(^\s+)|(\s+$)/g,"");}
function loadtitle(vUrl,vHeight)
{
	document.write("<iframe src="+vUrl+" frameBorder=0 width=100% scrolling=no height="+vHeight+"></iframe>");
}
//以下是帖子详情页的js
function getsubject(){
var haha=document.getElementById("HTML_speak_subject");
if(haha!=null)
{haha.value="Re:"+document.title;}
}
function quote(announceid,title,username,dtime){
	var hehe =  document.getElementById("HTML_quotebody"+announceid);
	var she=document.getElementById("HTML_speak_subject");
	if(null!=hehe)
	{
		if(null!=document.getElementById("HTML_speak_Content"))
		{
		document.getElementById("HTML_speak_Content").value ="[quote]"+"[B]以下是引用[I]"+username+"[/I]在"+dtime+"的发言：[/B]\n\n"+hehe.value.replace("<table","").replace(" cellpadding=0 cellspacing=0 border=0 WIDTH=94% bgcolor=#000000","").replace(" align=center>","").replace("<tr>","").replace("<td>","").replace("<table width=100% cellpadding=5 cellspacing=1 border=0","").replace("style=\"font-size:13px\">","").replace("<TR>","").replace("<TD BGCOLOR=#EFF3F9>","").replace("</td>","").replace("</tr>","").replace("</table>","").replace("</td>","").replace("</tr>","").replace("</table>","").replace("\n","") + "[/quote]";
		document.getElementById("announceid").value = announceid;
		document.getElementById("HTML_speak_Content").focus();
		}
	}
	if(she!=null)
	{she.value="Re:"+title;}
}

