﻿
function checkfrom(from){
	var nr=document.getElementById('nr');
	if(nr.value!=''){document.getElementById('coment').value=nr.innerHTML;}
	for(var i=0; i< from.elements.length;i++){
	  var element=from.elements[i];
	  if(/^[\s\n\r\t]*$/.test(element.value) && msg[i]!=1){
		alert(msg[i]+'不能为空,请重新输入');
		element.focus();
		return false;
	  }
	}
	//document.from.submit();
}


function ShowHtml(html,title,w,h){
	g_pop=new Popup({contentType:2,isReloadOnClose:false,width:500,height:100});
	
	g_pop.setContent("title",title);
	g_pop.setContent("scrollType","yes");
	g_pop.setContent("contentHtml",html);
	g_pop.build();
	g_pop.show();
}

function InsertImg(name,type){
	var value=Array('','图片','视频');
	var html="<div style='line-height:50px;padding-left:10px;font-size:14px'>"+value[type]+"地址:&nbsp;&nbsp;<input type='text' name='"+name+"' id='"+name+"' size='60' value='http://'><p><input type='button' name='insertimg'  onclick=\"Imgsvod('"+name+"',"+type+")\" value='插入"+value[type]+"' /></p></div>";
	ShowHtml(html,"插入"+value[type]);
}
function Imgsvod(imgname,type){
	var url=document.getElementById(imgname).value;
	var editor = document.getElementById('nr');
	var coments = document.getElementById('coment');
	
	if(type==1){
		var img = document.createElement('img'); 
			img.src = url; 
		editor.appendChild(img); 
	}
	
	if(type==2){
		var vod=document.createElement('embed');
			vod.src=url;
			vod.align="middle";
			vod.quality="high";
			vod.type="application/x-shockwave-flash";
		editor.appendChild(vod); 
	}
	coments.value=editor.innerHTML;

Wclose();
}
