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 ParentOfRefresh()
{
	if(null!=window.parent)
	{
		window.parent.location.assign(window.parent.location);	
	}
	else
	{}
}

function OpenOfRefresh()
{
	if(null!=window.opener)
	{
		try{
			var openwin = window.opener;
			openwin.location.reload();		
		}
		catch(e){
			return;
		}
	}
}

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();
	}
}

//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;
}


//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;
	}
}
function openwindow(url)
{
	window.open(url,"","width=600,height=400,toolbar=no,location=no,directories=no,status=no,resizable=no","")
}
function $(_sId){
	return document.getElementById(_sId);
}
function exist(s){return $(s)!=null;}
function hideList(_sId,_sStr,_iBegin,_iEnd)
{
	for(var i = _iBegin; i <= _iEnd; i++)
	{
		if(exist(_sId + i))
		{		
			$(_sId + i).style.display = _sStr;
		}
	}
}
function hide(_sId)
{
	$(_sId).style.display = $(_sId).style.display == "none" ? "" : "none";
}
function copyToClipBoard(content)
{
    window.clipboardData.setData("Text",content);
    alert("¸´ÖÆ³É¹¦£¡");
}
function resizeM(el)
{

 if(el.runtimeStyle)
 {
	el.runtimeStyle.behavior="none";
 }

 var tempM = new Image();
 tempM.src = el.src ;
 tempM.el = el;
 tempM.onload = resizeMonLoad;
 tempM.doload = resizeMonLoad;
 if(el.fileSize && (el.fileSize>0)){; tempM.doload();};
}


function resizeMonLoad()
{
     var el = this.el;
	 var maxW = 400;
	 var maxH = 400;
	 el.style.visibility="visible";

	 if(this.width>=this.height)
	 {
		  if(this.width >= maxW)
		  {; 
			  var r = maxW / this.width;
			  el.style.height = (this.height * r ) + "px";
			  el.style.width = maxW + "px";
		  }
	 }else
	 {
		if(this.height >= maxH)
		{
			var r = maxH / this.height;
			el.style.width = (this.width * r )+ "px";
			el.style.height = maxH + "px";
		}
	 }

	 if(this.width < maxW)
	 {
         el.style.width = this.width + "px";
	 }

	  if(this.height < maxH)
	 {
         el.style.height = this.height + "px";
	 }



}

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 EnterKeyPress(nextid) { 
	var KeyCode = window.event.keyCode;  
	if(KeyCode == 13)
	{
		FocusThisControl(nextid);
	}
}