// JavaScript Document

//复选框全选涵数，theForm为表单对象
function SelectAll(theForm)
{
	var theObjName=event.srcElement.name;
	var theObj=event.srcElement;
	var turn;
	if (theObj.checked){turn=true;}else{turn=false;}
	var length=theForm.elements[theObjName].length;
	var i;
	if(length+""=="undefined")
	{
		theForm.elements[theObjName].checked=turn;
	}
	else
	{
		for(i=0;i<length;i++)
		{
			theForm.elements[theObjName][i].checked=turn;
		}
	}	
}
//查看网站调查
function readinvre(Path,id1,id2){location.href=Path+"/Articleinv.asp?id="+id1+"&topic="+id2;}
//用来查看图片,Img为图片路径
function ViewImg(Img,Folder){
	var ImgPath;
	if(typeof(Img)=="object"){ImgPath=Img.href;}
	else{ImgPath=Img;}
	window.open(Folder+'viewimg.asp?path='+ImgPath,null,'height=1,width=1,top=1,left=1,toolbar=no,menubar=no,scrollbars=no,resizable=yes,location=no, status=no');
	return false;
}
function DispObj(key,obj){if (key.checked){obj.style.display="";}else{obj.style.display="none";}}

//获得鼠标指针的X坐标（相对于页面）
function getPointerX(){var x = getLeft(event.srcElement)+event.offsetX;return x;}
//获得鼠标指针的Y坐标（相对于页面）
function getPointerY(){var y = getTop(event.srcElement)+event.offsetY;return y;}
//获得对象的Y坐标（相对于页面）
function getTop(e){var t=e.offsetTop;while(e=e.offsetParent){t+=e.offsetTop;}return t;}
//获得对象的X坐标（相对于页面）
function getLeft(e){var l=e.offsetLeft;while(e=e.offsetParent){l+=e.offsetLeft;}return l;}
//获得对象的高度
function getHeight(e){var t=e.offsetHeight;return t;}
//获得对象的宽度
function getWidth(e){var t=e.offsetWidth;return t;}

function SelectedUser(cloneObj){
		var isHas=false;
		var left,right;
		right=cloneObj.childNodes[0].innerHTML;
		
		for(var i=1;i<parent.theHiddenObj.parentNode.childNodes.length-1;i++)
		{
			left=parent.theHiddenObj.parentNode.childNodes[i].childNodes[0].innerHTML;
			if(right==left)
			{
				isHas=true;
				break;
			}
		}
		if(!isHas)
		{
			var theObj=parent.theHiddenObj.cloneNode(true);
			theObj.childNodes[0].innerHTML=cloneObj.childNodes[0].innerHTML;
			theObj.childNodes[0].setAttribute("UserId",cloneObj.childNodes[0].getAttribute("UserId"));
			theObj.childNodes[1].innerHTML=cloneObj.childNodes[1].innerHTML;
			theObj.childNodes[2].innerHTML=cloneObj.childNodes[2].innerHTML;
			theObj.childNodes[3].innerHTML=cloneObj.childNodes[3].innerHTML;
			theObj.style.display="";
			theObj.id="Item1";
			if(parent.IsMoreSelect.value!="true")
			{
				parent.theHiddenObj.parentNode.insertBefore(theObj,parent.theHiddenObj);
				parent.window.returnResult();
			}
			else
			{
				parent.theHiddenObj.parentNode.insertBefore(theObj,parent.theHiddenObj);
			}
		}
		else
		{
			alert("系统提示：\n\n用户：“"+right+"”，已经在已选择列表中。");
		}
		//var tempObj=parent.SelectedUserBox.rows[1];
		//tempObj.parentNode.insertBefore(cloneObj,tempObj);
}

function SelectResultUser(Url,IsMoreSelect){
		if(!IsMoreSelect) 
		{
			var Result=showModalDialog(Url,window,"dialogWidth:746px;dialogHeight:340px;toolbar=no;location=no;directories=no;status=no;menubar=NO;scrollbars=no;resizable=no;help=0; status=0");
		}
		else
		{
			var Result=showModalDialog(Url,window,"dialogWidth:746px;dialogHeight:510px;toolbar=no;location=no;directories=no;status=no;menubar=NO;scrollbars=no;resizable=no;help=0; status=0");
		}
		
		if(Result!=null)
			return Result;
		else
			return null;
}
	
function SelectUserInfo(UsernameObj,UserIdObj,Url,IsMoreSelect){
		var Result=SelectResultUser(Url,IsMoreSelect);
		if(Result!=null)
		{
			var Info=Result.split("|");
			if(UsernameObj!=null)
				UsernameObj.value=Info[0];
			if(UserIdObj!=null)
				UserIdObj.value=Info[1];
		}
}

