function UBBCode(tag,val){
	document.all.form1.content.focus();
	var obj=document.selection;
	var con=obj.createRange();
	
	if(con.text.length!=0){
		if(val==''){
			con.text="["+tag+"]"+con.text+"[/"+tag+"]";
		}else{
			con.text="["+tag+"="+val+"]"+con.text+"[/"+tag+"]";
		}
	}
	document.selection.empty();
	//document.all.form1.content.focus();
}

function UBBCodeLink(){
	var copyValue='';
	var msg=prompt('请输入连接地址',copyValue)+"";

	document.all.form1.content.focus();
	var obj=document.selection;
	var con=obj.createRange();

	if(msg!=null &&  msg!='' && msg!='http://' && msg!='null'){
		if(con.text.length==0){
			con.text="[link="+msg+"]"+msg+"[/link]";
		}else{
			con.text="[link="+msg+"]"+con.text+"[/link]";
		}
	}
	document.selection.empty();
}

function UBBCodeIMG(){
	var copyValue='';
	
	var msg=prompt('请输入图片地址',copyValue)+"";
	document.all.form1.content.focus();
	
	var obj=document.selection;
	var con=obj.createRange();

	if( msg=='' || msg=='null'){
		//
	}else{
		con.text+="[img]"+msg+"[/img]";
	}
}
function showVote(){
	if(document.all.voteCon.style.display=='none'){
		document.all.voteCon.style.display='block';
	}else{
		document.all.voteCon.style.display='none';
	}
}
function addEM(id){
	document.all.form1.content.focus();
	var obj=document.selection;
	var con=obj.createRange();

	con.text+=" [em:"+id+"] ";
}
function useUBB(){
	if(!form1.checkbox.cheched){
		document.all.form1.isUseUBB.value=0;
	}else{
		document.all.form1.isUseUBB.value=1;
	}
}

function UBBCodeFlash(){
	var copyValue='';
	
	var msg=prompt('请输入Flash地址',copyValue)+"";
	document.all.form1.content.focus();
	
	var obj=document.selection;
	var con=obj.createRange();
	
	if( msg=='' || msg=='null'){
		//
	}else{
		con.text+="[flash=400,300]"+msg+"[/flash]";
	}
}

function sixgreen_Real(){
	var copyValue='';
	
	var msg=prompt('请输入影片地址',copyValue)+"";
	document.all.form1.content.focus();
	
	var obj=document.selection;
	var con=obj.createRange();
	
	if( msg=='' || msg=='null'){
		//
	}else{
		con.text+="[rm=400,300]"+msg+"[/rm]";
	}
}

function UBBAlignCode(tag){
	document.all.form1.content.focus();
	var obj=document.selection;
	var con=obj.createRange();

	if(con.text.length!=0){
		con.text="[align="+tag+"]"+con.text+"[/align]";
	}
}
function sixgreen_pic() {
	var pic=window.showModalDialog('/content/bbs/images.htm',window,'dialogWidth:600px;dialogHeight:600px;help:0;status:0;resizeable:1;');
	if(pic!=null){
		document.all.form1.content.focus();

		var obj=document.selection;
		var con=obj.createRange();

		con.text+=" [face="+pic+"] ";
	}
}
//-------------------cookie的写入和读取-------------------------
function writeCookie(theName,theValue){
	document.cookie  = theName + "=" + theValue;
}

function readCookie(theName){
	var theNameLength = theName.length;
	var theValue = document.cookie;
	var theCookieLength = theValue.length;
	var i = 0;
	var theCookieEnd;
	while(i < theCookieLength){
		var j = i + theNameLength;
		if(theValue.substring(i,j) == theName){
			theCookieEnd = theValue.indexOf(";",j);
			if (theCookieEnd == -1){
				theCookieEnd = theValue.length;
			}
			return theValue.substring(j+1,theCookieEnd);	
		}
		i++;
	}
}

function copyContent2Clipboard(contentId){
	//alert(document.getElementById("copy2Clipboard").checked)
	try{
	if(document.getElementById("copy2Clipboard").checked==true){
		window.clipboardData.setData("Text",document.getElementById(contentId).value);
	}
	}catch(e){
		//alert(e.message);
	}
}