// 修改编辑栏高度
function admin_Size(num,objname)
{
	var obj=document.getElementById(objname);
	if (parseInt(obj.rows)+num>=3) {
		obj.rows = parseInt(obj.rows) + num;
	}
	if (num>0)
	{
		obj.width="90%";
	}
}
//SELECT表单选取
function CheckSel(Voption,Value)
{
	var obj = document.getElementById(Voption);
	for (i=0;i<obj.length;i++){
		if (obj.options[i].value==Value){
		obj.options[i].selected=true;
		break;
		}
	}
}
function chkradio(Obj,Val)
{
	if (Obj)
	{
	for (i=0;i<Obj.length;i++){
		if (Obj[i].value==Val){
		Obj[i].checked=true;
		break;
		}
	}
	}
}
function Getcolor(img_val,input_val){
	var arr = showModalDialog("../Editor/Dialog/selcolor.htm?action=title", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0");
	if (arr != null){
		document.getElementById(input_val).value = arr;
		img_val.style.backgroundColor = arr;
		}
}
function ToValue(type,objname,strvalue)
{ 
	var obj=document.getElementById(objname)
	if (type=="add"){
		obj.value='|||'+obj.value
		obj.value=obj.value.replace(strvalue,'');
		obj.value=obj.value+strvalue;
		obj.value=obj.value.replace('|||','');
		obj.value=obj.value.replace('||','');
		}
	else if (type=="+"){obj.value=parseInt(obj.value)+parseInt(strvalue);}
	else{obj.value=strvalue;}
	obj.focus(); 
 return; 
}
function AddUrl(cname,objname){
  var obj=document.getElementById(objname);
  var thisurl=cname+(obj.length+1)+'|http://'; 
  var url=prompt('请输入'+cname+'名称和链接，中间用“|”隔开：',thisurl);
  if(url!=null&&url!=''){obj.options[obj.length]=new Option(url,url);}
}
function ModifyUrl(cname,objname){
  var obj=document.getElementById(objname);
  if(obj.length==0) return false;
  var thisurl=obj.value; 
  if (thisurl=='') {alert('请先选择一个'+cname+'，再点修改按钮！');return false;}
  var url=prompt('请输入'+cname+'名称和链接，中间用“|”隔开：',thisurl);
  if(url!=thisurl&&url!=null&&url!=''){obj.options[obj.selectedIndex]=new Option(url,url);}
}
function DelUrl(cname,objname){
  var obj=document.getElementById(objname);
  if(obj.length==0) return false;
  var thisurl=obj.value; 
  if (thisurl=='') {alert('请先选择一个'+cname+'，再点删除按钮！');return false;}
  if(obj.selectedIndex==0){alert('不能删除第一个'+cname+'！');return false;}
  obj.options[obj.selectedIndex]=null;
}
function UpUrl(cname,objname) {
	var obj=document.getElementById(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==0)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的"+cname+"！");
		return;
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex-1].value;
	//var sHTML=obj.options[nIndex].innerHTML;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex-1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex-1;
}
function DownUrl(cname,objname) {
	var obj=document.getElementById(objname);
	var nIndex = obj.selectedIndex;
	var nLen = obj.length;
	if ((nLen<1)||(nIndex==nLen-1)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的"+cname+"！");
		return;
	}
	var sValue=obj.options[nIndex].value;
	var sValue2=obj.options[nIndex+1].value;
	obj.options[nIndex]=new Option(sValue2,sValue2);
	obj.options[nIndex+1]=new Option(sValue,sValue);
	obj.selectedIndex=nIndex+1;
}
function SelectFiles(sModuleID,type,objname,objname2){
  var arr=showModalDialog('Admin_Files.asp?FileType=select', '', 'dialogWidth:760px; dialogHeight:600px; help: no; scroll: yes; status: yes');
	if(arr!=null){
		var obj = document.getElementById(objname);
		var strT=arr.split('|');
		if (sModuleID=='2'&&type=='3'){
			var url='下载地址'+(obj.length+1)+'|'+strT[0];
			obj.options[obj.length]=new Option(url,url);
		}
		else if (sModuleID=='3'&type=='4'){
			var url='图片地址'+(obj.length+1)+'|'+strT[0];
			obj.options[obj.length]=new Option(url,url);
		}
		else if (sModuleID=='4'&type=='2'){
			var url='影片地址'+(obj.length+1)+'|'+strT[0];
			obj.options[obj.length]=new Option(url,url);
		}
		else {
			obj.value=strT[0];
		}
		if (objname2!='') {document.getElementById(objname2).value=strT[1];}
	}
}
function SelectUserGroup(objname){
  var arr=showModalDialog('Admin_SelectUserGroup.asp', '', 'dialogWidth:200px; dialogHeight:320px; help: no; scroll: no; status: no');
	if(arr!=null){
		document.getElementById(objname).value=arr;
	}
}
function doPreview(objname,Wpath,Upath){
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var url=obj.value; 

	if (url){
		url = url.replace("{%gqwebdir%}",Wpath);
url = url.replace("Upload/",Wpath+"Upload/");
		url = url.replace("{%uploaddir%}",Upath);
		var sExt=url.substr(url.lastIndexOf(".")+1);
		sExt=sExt.toUpperCase();
		var sHTML;
		switch(sExt){
		case "GIF":
		case "JPG":
		case "BMP":
		case "PNG":
			tdPreview.innerHTML = "<img border=0 src='" + url + "' width='170' height='140'>";
			break;
		//case "SWF":
		//	sHTML = "<img border=0 src='" + url + "' width='170' height='140'>";
		//	break;
		default:
			tdPreview.innerHTML = "";
			break;
		}
		//tdPreview.innerHTML = sHTML;
	}else{
		tdPreview.innerHTML = "";
	}
}
function doPreviewa(objname,Wpath,Upath){
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var url=obj.value; 

	if (url){
		url = url.replace("{%gqwebdir%}",Wpath);
url = url.replace("Upload/",Wpath+"Upload/");
		url = url.replace("{%uploaddir%}",Upath);
		var sExt=url.substr(url.lastIndexOf(".")+1);
		sExt=sExt.toUpperCase();
		var sHTML;
		switch(sExt){
		case "GIF":
		case "JPG":
		case "BMP":
		case "PNG":
			tdPreview.innerHTML = "<img border=0 src='../" + url + "' width='170' height='140'>";
			break;
		//case "SWF":
		//	sHTML = "<img border=0 src='" + url + "' width='170' height='140'>";
		//	break;
		default:
			tdPreview.innerHTML = "";
			break;
		}
		//tdPreview.innerHTML = sHTML;
	}else{
		tdPreview.innerHTML = "";
	}
}
function getFilePic(url){
	var sExt;
	sExt=url.substr(url.lastIndexOf(".")+1);
	sExt=sExt.toUpperCase();
	var sPicName;
	switch(sExt){
	case "TXT":
		sPicName = "txt.gif";
		break;
	case "DOC":
		sPicName = "doc.gif";
		break;
	case "PDF":
		sPicName = "pdf.gif";
		break;
	case "MDB":
		sPicName = "mdb.gif";
		break;
	case "GIF":
		sPicName = "gif.gif";
		break;
	case "JPG":
		sPicName = "jpg.gif";
		break;
	case "BMP":
		sPicName = "bmp.gif";
		break;
	case "PNG":
		sPicName = "pic.gif";
		break;
	case "ASP":
	case "JSP":
	case "JS":
	case "PHP":
	case "PHP3":
	case "ASPX":
		sPicName = "code.gif";
		break;
	case "HTM":
	case "HTML":
	case "SHTML":
		sPicName = "htm.gif";
		break;
	case "ZIP":
		sPicName = "zip.gif";
		break;
	case "RAR":
		sPicName = "rar.gif";
		break;
	case "EXE":
		sPicName = "exe.gif";
		break;
	case "AVI":
		sPicName = "avi.gif";
		break;
	case "MPG":
	case "MPEG":
	case "ASF":
		sPicName = "mp.gif";
		break;
	case "RA":
	case "RM":
		sPicName = "rm.gif";
		break;
	case "MP3":
		sPicName = "mp3.gif";
		break;
	case "MID":
	case "MIDI":
		sPicName = "mid.gif";
		break;
	case "WAV":
		sPicName = "audio.gif";
		break;
	case "XLS":
		sPicName = "xls.gif";
		break;
	case "PPT":
	case "PPS":
		sPicName = "ppt.gif";
		break;
	case "SWF":
		sPicName = "swf.gif";
		break;
	default:
		sPicName = "unknow.gif";
		break;
	}
	return sPicName;
}
function InsertEditor(objname,Wpath,Upath)
{
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var url=obj.value;
	url = url.replace("{%gqwebdir%}",Wpath);
	url = url.replace("{%uploaddir%}",Upath);
	var sFilePic = getFilePic(url);
	var sPicSrc = Wpath + "Editor/Images/File/"+sFilePic;
	var sFileName = url.substr(url.lastIndexOf("/")+1);
	editor.Editor.focus()
	editor.insertHTML("<img border=0 src='"+sPicSrc+"'><a href='"+url+"' target=_blank>"+sFileName+"</a>");
}
function SetPicUrl(objname,Insobjname)
{
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	document.getElementById(Insobjname).value=obj.value;
}