var tag
var timeset
var obj = new Object();
function _SetBJ(command,value){
tag=rightpage.document
tag.focus()
sel=tag.selection.createRange().text.length
	if(sel!=0){
		if(value==null){
			tag.execCommand(command)
		}else{
			tag.execCommand(command,"",value)
		}
	_SaveBJ()
	}
}
function _LoadBJ(){
	XMLl("BJ")
	if(BJ.value!=""){rightpage.document.body.innerHTML=BJ.value}
}
 
var sInitColor = null;
function saction(sp,ep){
        sp = parseInt(sp)     
        ep = parseInt(ep) 
        if(isNaN(sp)||isNaN(ep))     
                return;
		tag=rightpage.document.body     
        var rng = tag.createTextRange();   
		rng.moveToElementText(tag)  
        rng.moveEnd("character",-tag.innerText.length)     
        rng.moveStart("character",-tag.innerText.length)     
        rng.collapse(true);
		rng.moveEnd("character",sp+ep)    
        rng.moveStart("character",sp)     
        rng.select();   
}
function _SaveBJ(){
		BJ.value=tag.body.innerHTML
		ul=window.location+""
		re='<IMG src="'+ul.substring(0,(ul.lastIndexOf("/")+1))+PlayerPic+'"> '
		do{
		if(BJ.value.indexOf(re)!=-1){
		BJ.value=BJ.value.replace(re,"")
		}
		}while(BJ.value.indexOf(re)!=-1)
		XMLs("BJ")
}
thisc=function(){
        var sColor = dlgHelper.ChooseColorDlg();
        sColor = sColor.toString(16);
		sColor=ling(sColor)
		return ("#" + sColor)
}
ling=function(str){
while(str.length<6){
str="0"+str
}
return str
}
function rload(){
try{
if(document.all.rightpage.readyState=="complete"){
if(vJD==""){return}
_LoadBJ()
}
}catch(e){}
}
function _ShuQ(){
try{
tag=rightpage.document
tag.focus();
var sel = tag.selection.createRange();
	if(sel.text.length!=0){
	sel.pasteHTML("<span  style='background-color:"+thisc()+"'>"+sel.text+"</span>");
	sel.select();
	_SaveBJ()
	}
}catch(e){if(e.number=="-2147467259"){alert("请选择一行文字或一个自然段,本功能不支持大面积刷屏")}}
}
function _Clear(){
if(Ask("是否清除本页中所有的标记！&　是的　&　否　")!=1||BJ.value==""){return}
BJ.value=""
XMLs("BJ")
rightpage.location.reload()
}
Ask=function(type){ //Ask提示
w=300
h=150
obj.name=type
sd=showModalDialog("Ask.html?"+type+"&id="+Math.random(),window,'dialogWidth:'+w+'px;dialogHeight:'+h+'px;dialogLeft:'+(screen.width-w)/2+'px;dialogTop:'+(screen.height-h)/2+'px;center:yes;help:no;resizable:no;status:no')
return sd
}
