if (!Dvbbs_bIsIE5){
	document.write('<iframe width="260" height="165" id="colourPalette" src="' + getCurrentSkinPath() + 'images/post/nc_selcolor.htm" style="visibility:hidden; position: absolute; left: 0px; top: 0px;" frameborder="0" scrolling="no" ></iframe>');
}
//数据传递
function Dvbbs_CopyData(hiddenid)
{
	ischeck=true
		if(Dvbbs_bTextMode!=1){
				cont=IframeID.document.body.innerText;
				IframeID.document.body.innerHTML=cont;
				IframeID.focus()
			}
	document.Announce.Submit.disabled=true; 
	 
	document.getElementById(hiddenid).value = OSWEBXHTML.GetXHTML(IframeID.document.body);
	//d.body.innerHTML=document.getElementById(hiddenid).value;
} 
 

function Dvbbs_PasteData()
{
	cont = IframeID.document.body.innerHTML;
	IframeID.document.body.innerHTML = cont
}

function CheckUrl(str)
{  var strRegex = "^((https|http)?://)" +   
    "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" // ftp的user@   
+   
    "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184   
+   
    "|" // 允许IP和DOMAIN（域名）   
+   
    "([0-9a-z_!~*'()-]+\.)*" // 域名- www.   
+   
    "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名   
+   
    "[a-z]{2,6})" // first level domain- .com or .museum   
+   
    "(:[0-9]{1,4})?" // 端口- :80   
+   
    "((/?)|" // a slash isn't required if there is no file name   
+   
    "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";   
    var reg = new RegExp(strRegex,"i");    

   return reg.test(str);

}

function Show_Popup(otype)
{	 var showstr="<table width=100% cellspacing=0><tr><td width=400><br>";
	if(otype=='img')
	{ 	showstr+='请输入网络图片地址:<br>	<input id="e_insertimage_param_url" style="WIDTH: 240px" class="txt" type="text" value="http://"><input id="e_insertimage_submit" value="提交" type="button" onclick="insertimagesubmit()">';
    	showstr += '<br><br> 或者从本地电脑上传:<br>	<iframe id="uploadIframe" src="/club/upload.aspx?formid=Announce&ishtml=true" width=350 height=50 frameborder=0 scrolling=no></iframe>	<br> ';
   }
   else if(otype=='file')
   { showstr += '选择本地文件:<br>	<iframe id="uploadIframe" src="/club/upload.aspx?formid=Announce" width=350 height=50 frameborder=0 scrolling=no></iframe>	<br> '; 
		document.getElementById('attlist').style.display = "block";
       }
   else if(otype=='video')
   	{  showstr+='请输入<A href="http://www.youku.com/" target=_blank>优酷网</A>、<A href="http://www.tudou.com/" target=_blank>土豆网</A>、<A href="http://www.ku6.com/" target=_blank>酷6网</A>等视频网站的Flash代码:<br>';
				showstr +='	<input id="e_insertvideo_param_url" style="WIDTH: 300px" class="txt" type="text" value="http://"> <br> 	<center><input id="e_insertvideo_submit" value="提交" type="button" onclick="insertvideosubmit()">&nbsp; <input onclick="Hide_Popup();" value="取消" type="button"></center>'; 
	  }
	  else if(otype=='em')
	  	{
	  		var isstr, EmotPath="/club/img/emot/"; 
	for(i=0;i<32;i++)
	{ 
		if (i<9)
			{istr='em0'+(i+1)}
			else
			{istr='em'+(i+1)}
		showstr+='<img style="cursor: pointer;" onClick=putEmot("'+istr+'"); src="'+EmotPath+istr+'.gif">&nbsp;';
	} 
	  	}
	  showstr += "</td><td valign=top width=20 align=right><a href='javascript:' title='关闭' onclick='Hide_Popup();'><font class=popupclose>x</font></a></td></tr></table>";
	  
   document.getElementById('insert_menu').innerHTML = showstr; 
	 document.getElementById('insert_menu').style.display = "block";  
	  //IE6 下刷新iframe
	   if( navigator.userAgent.indexOf("MSIE 6.0") > -1 && document.getElementById('uploadIframe'))
	   {   
	   	 window.uploadIframe.location.reload();
	  }			  						 
}

function Hide_Popup()
{
	document.getElementById('insert_menu').style.display = "none"; 
	IframeID.focus();
}
 

function putEmot(thenNo)
{
	var ToAdd = '['+thenNo+']';
	IframeID.document.body.innerHTML+=ToAdd;
	document.getElementById("insert_menu").style.display = "none";
	IframeID.focus();
}
function putphoto(thenNo,path)
{
	var ToAdd = '\\n[img=,'+ thenNo +']' + path + '[/img]';
	
	IframeID.document.body.innerHTML+=ToAdd;
	IframeID.focus();
}
var wysiwyg=true;

function insertimagesubmit() {
	 if(!CheckUrl(  $('e_insertimage_param_url').value)) return; 
	if(wysiwyg) {
		IframeID.document.body.innerHTML+='<img src='+  $('e_insertimage_param_url').value+' border=0 /> ';
	} else {
		IframeID.document.body.innerHTML+='[img]'+ $('e_insertimage_param_url').value+'[/img]';
	}
	Hide_Popup();
	$('e_insertimage_param_url').value = '';
}
function insertvideosubmit() {
	  if(!CheckUrl($('e_insertvideo_param_url').value)) return;
 	  
		IframeID.document.body.innerHTML+='[flash=500,400]'+$('e_insertvideo_param_url').value+'[/flash]';
	 
	Hide_Popup();
	$('e_insertvideo_param_url').value = '';
}

function removeattach(theform)
    {
      var i, length, count;
      
      i = theform.attachlist.selectedIndex;      
      if (i == -1)
      {  
        alert("Please Select FileName.");
        return;
      }
      if (theform.attachlist.options[i].value == "")
      {
        alert("No files are attached");
        return;
      }      
      length = theform.attachlist.options.length;
      for(count = i ;count < length-1;count++)
      {
         theform.attachlist.options[count].value=theform.attachlist.options[count+1].value;
         theform.attachlist.options[count].text=theform.attachlist.options[count+1].text;
      }      
     theform.attachlist.options.length=length-1;
      return;
    }
    
  function attfiles(theform)
    {
      var  length, count;
      length = theform.attachlist.options.length;
      theform.upfiles.value="";
      for(count = 0 ;count < length;count++)
      {
         theform.upfiles.value+=theform.attachlist.options[count].value+"|"+theform.attachlist.options[count].text;
         theform.upfiles.value+=";";
      }      
      return ;
    }
    
function gopreview()
{
document.preview.body.value=OSWEBXHTML.GetXHTML(IframeID.document.body);
var popupWin = window.open('preview.aspx', 'preview_page','scrollbars=yes,width=750,height=450');
document.preview.submit()
}
function gopreview1()
{
document.preview.title.value = document.Announce.subject.value;
document.preview.body.value=OSWEBXHTML.GetXHTML(IframeID.document.body);
var popupWin = window.open('preview.aspx', 'preview_page','scrollbars=yes,width=750,height=450');
document.preview.submit()
}

//--------------------------------------------------------------------------------

function Dvbbs_foreColor()
{
	if (!Dvbbs_validateMode()) return;
	if (Dvbbs_bIsIE5){
		var arr = showModalDialog(getCurrentSkinPath() + "images/post/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0");
		if (arr != null){
			if(Dvbbs_bTextMode==3){
				Dv_ubb("color",arr);
			}else{
				FormatText('forecolor', arr);
			}
		}
		else{ IframeID.focus();}
	}else
		{
		FormatText('forecolor', '');
	}
}

function Dvbbs_correctUrl(cont)
{
	var regExp;
	//var url=location.href.substring(0,location.href.lastIndexOf("/")+1);
	//cont=Dvbbs_rCode(cont,location.href+"#","#");
	//cont=Dvbbs_rCode(cont,url,"");
	regExp = /<a([^>]*) href\s*=\s*([^\s|>]*)([^>]*)/gi
	cont = cont.replace(regExp, "<a href=$2 target=\"_blank\" ");
	regExp = /<a([^>]*)><\/a>/gi
	cont = cont.replace(regExp, "");
	return cont;
}

function Dvbbs_rCode(s,a,b,i){
	//s原字串，a要换掉pattern，b换成字串，i是否区分大小写
	a = a.replace("?","\\?");
	if (i==null)
	{
		var r = new RegExp(a,"gi");
	}else if (i) {
		var r = new RegExp(a,"g");
	}
	else{
		var r = new RegExp(a,"gi");
	}
	return s.replace(r,b); 
}

function Dvbbs_cleanHtmlOLD()
{
	if (Dvbbs_bIsIE5){
	var fonts = IframeID.document.body.all.tags("FONT");
	}else{
	var fonts = IframeID.document.getElementsByTagName("FONT");
	}
	var curr;
	for (var i = fonts.length - 1; i >= 0; i--) {
		curr = fonts[i];
		if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
	}
}

function Dvbbs_getPureHtml()
{
	var str = "";
	str = IframeID.document.body.innerHTML;
	str=Dvbbs_correctUrl(str);
	return str;
}

function FormatUrl(html)
{
	//var regExp = /<a.*href=\"(.*)\"[^>]*>/gi;
	//html = html.replace(regExp,"<a href=$1 target=\"_blank\" >")
  return html;
}

function Dvbbs_getEl(sTag,start)
{
	while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
	return start;
}

//选择内容替换文本
function Dvbbs_InsertSymbol(str1)
{
	IframeID.focus();
	if (Dvbbs_bIsIE5) Dvbbs_selectRange();
	Dvbbs_edit.pasteHTML(str1);
}


//选择事件
function Dvbbs_selectRange(){
	Dvbbs_selection =	IframeID.document.selection;
	Dvbbs_edit		=	Dvbbs_selection.createRange();
	Dvbbs_RangeType =	Dvbbs_selection.type;
}

//应用html
function Dvbbs_specialtype(Mark1, Mark2){
	var strHTML;
	if (Dvbbs_bIsIE5){
		Dvbbs_selectRange();
		if (Dvbbs_RangeType == "Text"){
			if (Mark2==null)
			{
				strHTML = "<" + Mark1 + ">" + Dvbbs_edit.htmlText + "</" + Mark1 + ">"; 
			}else{
				strHTML = Mark1 + Dvbbs_edit.htmlText +  Mark2; 
			}
			Dvbbs_edit.pasteHTML(strHTML);
			IframeID.focus();
			Dvbbs_edit.select();
		}
		else{window.alert("请选择相应内容！")}	
	}
	else{
		if (Mark2==null)
		{
		strHTML	=	"<" + Mark1 + ">" + IframeID.document.body.innerHTML + "</" + Mark1 + ">"; 
		}else{
		strHTML = Mark1 + IframeID.document.body.innerHTML +  Mark2; 
		}
		IframeID.document.body.innerHTML=strHTML
		IframeID.focus();
	}
}
 
function Dvbbs_getText()
{
	Dvbbs_cleanHtml();
	return IframeID.document.body.innerHTML;
	
}

function Dvbbs_putText(v)
{
	IframeID.document.body.innerHTML = v;
}

function Dvbbs_doSelectClick(str, el)
{
	var Index = el.selectedIndex;
	if (Index != 0){
		el.selectedIndex = 0;
		FormatText(str,el.options[Index].value);
	}
}
//查找配对字符出现次数,没有结果为0
function TabCheck(word,str){
	var tp=0
	chktp=str.search(word);
	if (chktp!=-1)
	{
	eval("var tp=\""+str+"\".match("+word+").length")
	}
	return tp;
}
 

function openEditScript(url, width, height){
	var Win = window.open(url,"openEditScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
}

//预览
function Dvbbs_View()
{
	if (Dvbbs_bTextMode!==1) {
		cont=IframeID.document.body.innerText;
	} else {
		cont=IframeID.document.body.innerHTML;
	}
	//alert(document.Dvform.autofix.checked)
	bodyTag="<html><head><style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\" >";
	cont=Dvbbs_rCode(cont, "\\[dvnews_ad]", '<img src="' + getCurrentSkinPath() + 'images/post/images/pic_ad.jpg" vspace=10 hspace=10 align=left border=1 title="Advertising">');
	cont=Dvbbs_rCode(cont,"\\[dvnews_page]","<br><br><hr size=2 width=95% align=left>&nbsp; <font color=red face='Tahoma,Arail' size=2><b>Next Page ...</b></font><br><hr size=2 width=95% align=left>");
	preWin=window.open('/club/preview.aspx?', 'preview_page', 'eft=0,top=0,width=550,height=400,resizable=1,scrollbars=1, status=1, toolbar=1, menubar=0');
	preWin.document.open();
	preWin.document.write(bodyTag);
	preWin.document.write(cont);
	preWin.document.write("</body></html>");
	preWin.document.close();
	preWin.document.title="Preview";
	preWin.document.charset=Dvbbs_charset;
}

//Function to hide colour pallete
function hideColourPallete() {
	document.getElementById("colourPalette").style.visibility="hidden";
}
 
function Dvbbs_forswf()
{
	var arr = showModalDialog(getCurrentSkinPath() + "images/post/swf.htm", "", "dialogWidth:30em; dialogHeight:10em; status:0; help:0");
	if (arr != null){
		var ss;
		ss=arr.split("*")
		path=ss[0];
		row=ss[1];
		col=ss[2];
		var string;
		string="[flash="+row+","+col+"]"+path+"[/flash]"
		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}

function Dvbbs_forwmv()
{
	var arr = showModalDialog(getCurrentSkinPath() + "images/post/wmv.htm", "", "dialogWidth:30em; dialogHeight:13em; status:0; help:0");
	
	if (arr != null){
		var ss;
		ss=arr.split("*")
		path=ss[0];
		autostart=ss[1];
		width=ss[2];
		height=ss[3];
		ran=rand();
		var string;
		var ubbstring;
		string="[MP="+ width +","+ height +","+ autostart +"]"+ path +"[/MP]";
		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}

function rand() {
	return parseInt((1000)*Math.random()+1);
}
 

//图片与链接事件
function Dvbbs_UserDialog(what)
{
	if (!Dvbbs_validateMode()) return;
	IframeID.focus();
	//插入链接
	if (what == "CreateLink") {
		if (Dvbbs_bIsNC)
		{
			insertLink = prompt("请填写超级链接地址信息：", "http://");			
			if ((insertLink != null) && (insertLink != "") && (insertLink != "undefined")) {
			IframeID.document.execCommand('CreateLink', false, insertLink);
			}else{
			IframeID.document.execCommand('unlink', false, null);
			}
		}
		else {
			IframeID.document.execCommand(what, true, null);
		}
	}
	//去掉添加图片时的src="file://
	if(what == "InsertImage"){
		if (Dvbbs_bIsNC)
		{
		imagePath = prompt('请填写图片链接地址信息：', 'http://');			
		if ((imagePath != null) && (imagePath != "")) {
			IframeID.document.execCommand('InsertImage', false, imagePath);
		}
		IframeID.document.body.innerHTML = (IframeID.document.body.innerHTML).replace("src=\"file://","src=\"");
		}else{
		Dvbbs_forimage();
		}
	}
	 
	Dvbbs_pureText = false;
	IframeID.focus();
}

 

function Dvbbs_CheckTag(item,tagName)
{
	if (item.tagName.search(tagName)!= -1)
	{
		return item;
	}
	if (item.tagName == 'BODY')
	{
		return false;
	}
	item=item.parentElement;
	return Dvbbs_CheckTag(item,tagName);
}
  
function insertSpecialChar()
{

	var arr = showModalDialog(getCurrentSkinPath() +  "images/post/specialchar.html", "","dialogWidth:25em; dialogHeight:15em; status:0; help:0");
	if (arr != null) Dvbbs_InsertSymbol(arr);
	IframeID.focus() ;
}

function doZoom( sizeCombo ) 
{
	if (sizeCombo.value != null || sizeCombo.value != "")
	
	var z = IframeID.document.body.style;
	z.zoom = sizeCombo.value + "%" ;
}
 


function getCurrentSkinPath()
{
	return '/club/';
}
