//跳转到指定的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;
		}
	}
}
/***************************************************/