//编辑器相关
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("{$web_dir}",Wpath);
		url = url.replace("{$download_dir}",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 doPreviews(objname,Wpath,Upath){
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var urls=obj.value; 

	if (urls){
		urls = urls.split("|");
		url = urls[1]
		url = url.replace("{$web_dir}",Wpath);
		url = url.replace("{$download_dir}",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 InsertEditor(objname,Wpath,Upath)
{
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	var url=obj.value;
		url = url.replace("{$web_dir}",Wpath);
		url = url.replace("{$download_dir}",Upath);
	var sFilePic = getFilePic(url);
	var sPicSrc = Upath + "/FileType/"+sFilePic;
  	var sPicStr = ""
		switch(sFilePic){
		case "gif.gif":
		case "jpg.gif":
		case "bmp.gif":
		case "png.gif":
			sPicStr = "<img src='"+url+"' border='0'><br>" 
			break;
		//case "swf.gif":
		//	sPicStr = "<img src='"+url+"' border='0'><br>" 
		//	break;
		default:
			sPicStr = ""
			break;
		}
	var sFileName = url.substr(url.lastIndexOf("/")+1);
	YSvoidEditor1.YSvoidEditor.focus()
	YSvoidEditor1.insertHTML("<a href='"+url+"' target=_blank>"+sPicStr+"</a><br>");
}

function SetPicUrl(objname,Insobjname)
{
	var obj=document.getElementById(objname);
	if(obj.length==0) return false;
	document.getElementById(Insobjname).value=obj.value;
}

function SetWordimage(objname)
{
var obj=document.getElementById(objname);
  if (ubb_mode_help)
  { alert(ubb_name+"插入图像\n\n在文本中插入一幅图像！\n例如：[IMG]http://www.YSvoid.com/images/logo.gif[/IMG]"); }
  else if (ubb_mode_adv)
  {  
    txt=prompt(ubb_name+"请输入图像的 URL！例：http://www.YSvoid.com/images/logo.gif",obj.value);    
    if(txt!=null) { AddTxt="\n[IMG]"+txt; ubb_addtext(AddTxt); ubb_addtext("[/IMG]\n");
    }       
  }
  else
  { AddTxt="[IMG][/IMG]"; ubb_addtext(AddTxt); }
}


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;
}
