function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//跳转到指定的URL
function gotoURL(aUrl)
{
	window.location.href = aUrl;
}

//隐含提交，不刷新当前页面
function synSubmitURL(httpURL)
{
	if(typeof(document.submitframe)=="undefined")
	{
		var newIFrame = document.createElement("<iframe id=submitframe name='submitframe' frameborder=0 width='0' height=0 scrolling=no src=''></iframe>");
		document.body.insertBefore(newIFrame);
	} 
	document.submitframe.location.href=httpURL;
}

//清空指定的Form
function resetForm(aForm)
{
	for(i=0;i<aForm.elements.length;i++)
	{
		aObj = aForm.elements[i];
		if(aObj.type=="text" || aObj.type=="textArea" || aObj.type=="password")
			aObj.value = "";
		else if(aObj.type=="select-one" || aObj.type=="select-multiple")
			aObj.selectedIndex = 0;
	}
}

function queryAll(aForm)
{
	resetForm(aForm);
	aForm.submit();
}

//提交请验证表单
function submitForm(aform)
{
	if (doValidate(aform))
	{
		aform.submit();
	}
}

/********************************************/
//判读checkbox是否选中
function getSelectedDocs() {
  var form = document.dataform;
  var seldocs = new Array();
  if (form.ids == null) {
	return false;
  }
  if (form.ids.length) {
	  for (var i = 0; i < form.ids.length; i++) 
	  {
			if(form.ids[i].checked) 
		  {
			return true;
		  }
	   }
	  return false;
  }  else  {
     if (form.ids.checked)
			return true;
	 else
		    return false;
  }
}
//全选
function selectall() {
	var form = document.dataform;
	myids = document.getElementsByName("ids");
	for(i=0;i<myids.length;i++){
		myids.item(i).checked = form.selectids.checked;
	}
}

//打开新页面
function opennew(mywidth,myheight,url) {
var thiswidth = mywidth;
var thisheight = myheight;
var endposition_x=(window.screen.width-thiswidth)/2
var endposition_y=(window.screen.height-thisheight)/2
window.open(url,"newwindow","width="+thiswidth+",height="+thisheight+",top="+endposition_y+",left="+endposition_x+",toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}

/****************用在多对多页面选择上***********************/
function getMySelectStr(){
	var myselected = document.dataform.myselected.value;
	var aObj = document.all("ids");
	var strTemp = "";
	for(i=0; i<aObj.length; i++)
	{
		if(aObj(i).checked)
		{
			if (!existId(myselected,aObj(i).value))
			{
				myselected = myselected + "," + aObj(i).value;
			}
		}else{
			if (existId(myselected,aObj(i).value))
			{
				myselected =  removeId(myselected,aObj(i).value);
			}
		}
	}
	return myselected;
}

function existId(str,id){
	if (str.indexOf(id) != -1)
		return true;
	return false;
}
function removeId(str,id){
	if (str.indexOf(id) == -1)return;
	str = str.substring(0,str.indexOf(id)-1) + str.substring(str.indexOf(id)+id.length,str.length);
	return str;
}
function onloadcheckId(){
	var myselected = document.dataform.myselected.value;
	var aObj = document.all("ids");
	var strTemp = "";
	for(i=0; i<aObj.length; i++)
	{
		if(existId(myselected,aObj(i).value))
		{
			aObj(i).checked=true;
		}
	}
}
/***************************************************/