//编辑附件页面
function editAttach(formToken){
var url=getPath() +"/LoadFiles.action?formToken="+formToken;
window.open(url,'',getMode(400,360));
}

function getMode(winWidth, winHeight, pmode){
  if (getMode.arguments.length>2)
    mode=pmode+',';
  else  
    mode='alwaysRaised=yes,location=no, toolbar=no,scrollbars=no,';

  mode=mode + 'width=' + winWidth + ',height=' + winHeight;
  //窗口置中
  mode=mode + ',left='+((screen.width - winWidth)/2 - 10) + ',top='+ (screen.height - winHeight)/3;

  return mode;
}

function disableenter(){
	if(event.keyCode==13){
		return false;
	}
}

 function getPath(){
   if (window.context)
 	  strContext=window.context;
   else  
 	  strContext=(opener)? opener.top.context : top.context;
   return strContext;
	//var ref = window.location.href;
	//var pos=ref.indexOf('//')+2;
	//pos=ref.indexOf('/',pos)+1;
	//pos=ref.indexOf('/',pos);
	//return ref.substring(0, pos);
 
 }
 
 function getRootPath(){
 	// return http://127.0.0.1:8080
	var ref = window.location.href;
	pos=ref.indexOf('//')+2;
	pos=ref.indexOf('/',pos);
	return ref.substring(0, pos);
 }
 
function openwindow(url){
	var mode='toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=no,'
	var size='left='+screen.width/8+',top='+screen.height/10+',width='+screen.width*3/4+',height='+screen.height*3/4;
	window.open(url, '', mode+size);
}
function openwindow1(url,w,h)
{
	var sh=screen.availHeight;
	var sw=screen.availWidth;
	if (!w) w=sw*3/4;
	if (!h) h=sh*3/4
	var mode='toolbar=no,location=no,directions=no,status=no,menubar=no,scrollbars=yes,revisable=no,resizable=yes,';
	var size='width='+w+',height='+h+',top='+(sh-h)/2+',left='+(sw-w)/2+'';
	return window.open(url,'',mode+size);
}
function openwindow2(url,w,h,t,l)
{
	var mode='toolbar=no,location=no,directions=no,status=no,menubar=no,scrollbars=yes,revisable=no,resizable=yes,';
	var size='width='+w+',height='+h+',top='+t+',left='+l+'';
	return window.open(url,'',mode+size);
}
function openwindow3(url)
{
	var mode='toolbar=no,location=no,directions=no,status=no,menubar=no,scrollbars=yes,revisable=no,resizable=yes,';
	var size='width=1,height=1,top='+ screen.availHeight + ',left=' + screen.availWidth;
	return window.open(url,'',mode+size);
}
function openwindow4(url){
	var mode='toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=yes,'
	var size='left='+screen.width/8+',top='+screen.height/10+',width='+screen.width*3/4+',height='+screen.height*3/4;
	window.open(url, '', mode+size);
}
function openwindow5(url,w,h)
{
	var sh=screen.availHeight;
	var sw=screen.availWidth;
	if (!w) w=sw*3/4;
	if (!h) h=sh*3/4
	var mode='toolbar=no,location=no,directions=no,status=no,menubar=no,scrollbars=no,revisable=no,resizable=yes,';
	var size='width='+w+',height='+h+',top='+(sh-h)/2+',left='+(sw-w)/2+'';
	return window.open(url,'',mode+size);
}
function bodyBusy(){
	window.parent.bodyframe.onBusy("正在执行操作,请稍候...");
}
function commonBusy(){
	onBusy("正在执行操作,请稍候...");
}
function navi(l){
	window.parent.bodyframe.location.href = l;
}

var _uniqueWindow;
function openWindow(url,modeSize){
   if (!_uniqueWindow || _uniqueWindow.closed)
 	   _uniqueWindow=window.open(url,'',modeSize);
   else
      _uniqueWindow.focus();

}

/*//打开查询页面
function openSearchPage(formName, otherParams){
	var mode='toolbar=no,location=no,directories=no,status=no,resizable=yes,scrollbars=no,';
	var size='left=' + (screen.width/2 - 230) + ',top=' + (screen.height/2 - 120) + ',width=410,height=230';
 	if (openSearchPage.arguments.length>1)
   		window.open(getPath()+"/Search.action?formName="+formName+otherParams,'',mode+size);
 	else  
   		window.open(getPath()+"/Search.action?formName="+formName,'',mode+size);
} */
 
//移动当前窗口到屏幕中心 
function moveCenter(winWidth, winHeight){
  window.moveTo((screen.width - winWidth)/2, (screen.height - winHeight) / 2);
} 

function getCenterXY(winWidth, winHeight){
	var s = new Object();
	s.xx = (screen.width - winWidth)/2 - 10;
	s.yy = (screen.height - winHeight) / 2;
	return s;
}

function tomailsetup(){
	var tc = eval("window.opener.toinbox");
	if (window.opener.main == "true"){
		alert(context);
		window.opener.top.bottomframe.location.replace(context + "/layout.action?module=mailsetup");
	}else{
		window.opener.location.replace("editSetup.action");
	}
	window.close();
}


function checkname(s){
    if(s.indexOf("$")!=-1 || s.indexOf("%")!=-1 || s.indexOf("^")!=-1 || s.indexOf("&")!=-1 || s.indexOf("~")!=-1 || s.indexOf("\'")!=-1 || s.indexOf('\"')!=-1 || s.indexOf("<")!=-1 || s.indexOf(">")!=-1 || s.indexOf("\\")!=-1)
	{
	alert("标题不能包含$ % ^ & ~ \' \" < > \\ 等字符");
	return false;
	}
	return true;
}

function checkLength(str,maxLength){
	if ((maxLength > -1) && (getBytes(str) > parseInt(maxLength)))
         return false;  
    else            
         return true;
}

function getBytes(str){
	var cArr = str.match(/[^\x00-\xff]/ig);
    return str.length + (cArr == null ? 0 : cArr.length);
}

function otherModule(){
	var mode= 'toolbar=no,location=no,resizable=yes,directories=no,status=no,scrollbars=yes,';
	var size = 'left='+screen.width*4/9+',top='+screen.height/6+',width=140,height=450';
	window.open("list_other_modules.jsp",'',mode+size)
}

//替换当前位置为黄色图片---2005.06.29 by caiyn
function changeImgs(imgId)
{
	var oList = eval('document.all("folderImg")');
	if (oList)
	{	
		for(var i=1;i<oList.length;i++)
		{
			var oId = oList[i].id;
			if(oId == imgId)
				document.getElementById(oId).src=getRootPath()+getWindowContextPath()+"/images/applib/folder_opened.gif";
			else
				document.getElementById(oId).src=getRootPath()+getWindowContextPath()+"/images/applib/folder_closed.gif";
		}
	}
}
//直接返回context的值(="<%=request.getContextPath()%>")---2007.02.07 by caiyn
function getWindowContextPath(){
   return window.context;
}