/*********选择和取消选择所有的checkbox********/
function selAll(id1,id2)
{
	for(i=0;i<id2.length;i++)
	{
		if(id1.checked==true)
		{
			id2[i].checked=true
		}else{
			id2[i].checked=false
		}
	}
}
/*******************************************/
/*********控制一系列栏目显示与隐藏********/
function itemShow(itemName,showId,num,bgItemName,clsName)       //(itemName+num)系列栏目名称，showID需要显示的编号
{
	var clsNameArr=new Array(2)
	if(clsName.indexOf("|")<=0){
		clsNameArr[0]=clsName
		clsNameArr[1]=""
	}else{
		clsNameArr[0]=clsName.split("|")[0]
		clsNameArr[1]=clsName.split("|")[1]
	}
	
	for(i=1;i<=num;i++)
	{
		if(document.getElementById(itemName+i)!=null)
			document.getElementById(itemName+i).style.display="none"
		if(document.getElementById(bgItemName+i)!=null)
			document.getElementById(bgItemName+i).className=clsNameArr[1]
		if(i==showId)
		{
			if(document.getElementById(itemName+i)!=null)
				document.getElementById(itemName+i).style.display=""
			else
				alert("未找到您请求的内容!")
			if(document.getElementById(bgItemName+i)!=null)
				document.getElementById(bgItemName+i).className=clsNameArr[0]
		}
	}
}
/*******************************************/

/*********建立动态层********/
function createDiv(newName,vis,htmlTxt)
{
	var newDiv=document.createElement("div");
	newDiv.id=newName;
	newDiv.style.visibility = vis;
	newDiv.setAttibute = ("name",newName);
	newDiv.style.position = "absolute";
	newDiv.style.width = "100";
	newDiv.style.backgroundColor = "#cccccc";
	newDiv.innerHTML=htmlTxt;
	document.body.appendChild(newDiv);
}	
/*******************************************/

/*********选择select框********/
function sltChk(obj,val)
{
	for(var i=0;i<obj.length;i++)
	{
		if(obj.options[i].value==val)
			obj.options[i].selected=true;
	}
}
/*******************************************/


/*********选择单选、复选框********/
function chbChk(obj,val)
{
	if(val=='False')
		val="0"
	else if(val=='True')
		val="1"
	var arr=val.split(",");
	for(var i=0;i<obj.length;i++)
	{
		for(var j=0;j<arr.length;j++)
		{
			if(obj[i].value==arr[j])
				obj[i].checked=true;
		}
	}
}
/*******************************************/

/*********根据地址显示图片（需要层之类的容器）********/
function showPic(id,src,vis,width,height)
{
	var txt=""
	var arr=new Array()
	if(src!=null && src!="")
	{
		arr=src.split(".")
		if(arr[1].toLowerCase()=="swf")
		{
			txt+="<object id =\"mymovie\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+width+"\" height=\""+height+"\">"
			txt+="<param name=\"movie\" value=\"../../"+src+"\">"
			txt+="<param name=\"quality\" value=\"high\">"
			txt+="<embed name=\"mymovie\" src=\""+src+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" swLiveConnect=\"true\"><\/embed>"
			txt+="<\/object>"       
		}else{
			txt="<img src='../../"+src+"' border=0 width="+width+" height=\""+height+"\">"
		}
		id.innerHTML=txt
		id.style.visibility=vis
	}
}
/*******************************************/

/*********复制表单内容到剪贴板********/
function copyToClipBoard(obj)
{
	var clipBoardContent="";
	clipBoardContent+=obj.value;
	window.clipboardData.setData("Text",clipBoardContent);
    //alert("复制成功");
}
/*******************************************/

/*********iframe自适应高********/
function iframeHeight(iframeName) {
	var pTar = null;
	if (document.getElementById){
		pTar = document.getElementById(iframeName);
	}
	else{
		document.getElementById('pTar = ' + iframeName + ';');
	}
	if (pTar && !window.opera){
		pTar.style.display="block"
		if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight)
		{
			pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;
		}else if (pTar.Document && pTar.Document.body.scrollHeight)
		{
			pTar.height = pTar.Document.body.scrollHeight;
		}
	}
}
/*******************************************/

/*******获取showModalDialog的返回值**********/
function getShowModalDialog(url,width,height)
{
	var result = window.showModalDialog(url,self,'center:1;status:0;help:1;resized:0;unadorned:1;dialogwidth:'+width+'px;dialogheight:'+height+'px')
	if(result=="" || result == null)
	{
		return false
	}else{
		return result
	}
}
/*******************************************/

/*******用户上传图片及显示**********/
function showUploadPic(uploadUrl,textBoxID,showDivID)
{
	var result = getShowModalDialog(uploadUrl,350,120);
	if(result!=false)
	{
		document.getElementById(textBoxID).value = result
		if(showDivID!="" && showDivID!=null)
			document.getElementById(showDivID).innerHTML = "<img src='"+result+"' onload='javascript:if(this.width)>400{this.width=400}'>";
	}
}
function sc(id1,id2)
{
	var pic = document.getElementById(id1);
	if(pic.value != "" && pic.value != null)
	{
		document.getElementById(id2).innerHTML = "<img src='"+pic.value+"' onload='javascript:if(this.width)>400{this.width=400}'>"
	}
}
/*******************************************/