
function translate(urlText){if(ifPlainText) return urlText;
 var pathName=window.location.pathname
 
 for(var i=0;i<pathName.length;i++)
 {
  if(pathName.charAt(i)!="/")
  {pathName=pathName.substr(i);break}
 }
 
 var r=pathName.search("/")
 pathName=pathName.substring(0,r)
 //
 
 var url="/"+window.location.protocol+"\\/\\/"+window.location.host+"\\/+"+pathName+"/gi"

 var reg=/\./g
 var nurl=url.replace(reg, "\\.");


var re=eval(nurl)
var  rr = urlText.replace(re, "../..");
return(rr);
}



var allTags=new Array//文档中所有的标签对象集合
var ifPlainText=true//编辑器当前状态
//标签类
var richEditorObj=function (title,content){
    //name上部标签显示的名字
  
    //编辑内容
    if(content!=null)this.content=content
    if(this.content==null)this.content="";
    this.name=title;
    var tagId="_richEditorText_tag_"+encodeURIComponent(title);
    
    document.write("<td style=\"cursor:default\" id=\""+tagId+"\">")
    //document.write("<nobr>")
    document.write(this.name)
    //document.write("</nobr>")
	document.write("</td>")
	this.tagObj=document.getElementById(tagId);
	this.tagObj.className="tag_back";
    this.tagObj.onclick = function()

                        {
                             for(var i=0;i<allTags.length;i++)
                             { 
                             
                               if(allTags[i].tagObj.className!="tag_back")
                                 {//标签改变
                                   
                                   allTags[i].tagObj.className = "tag_back";
                                    
                                   allTags[i].content=getEditorValue();
                                   getEditorMode();
                                  }
                                
                             }
                             
                             
                             for(var i=0;i<allTags.length;i++)
                             { if(allTags[i].tagObj==event.srcElement)
                                 {//标签改变this
                                   

                                   allTags[i].tagObj.className = "tag_top";
                                   setEditorValue(allTags[i].content);
                           
                                  }
                                
                             }
                          //for(var i=0;i<allTags.length;i++)allTags[i].tagObj.className = "tag_back";alert(allTags[i].tagObj.className+"="+i)
                          
                          //currentEditor().focus();
                          
                         }
                         
           allTags[allTags.length]=this;

    }
    function init(arr){
         for(var i=0;i<allTags.length;i++)
             {
                 allTags[i].tagObj.className = "tag_back";
                 allTags[i].content="";
                 if(arr!=null){
                   if(arr[i]!=null)allTags[i].content=arr[i];
                 }
                 
              }
        allTags[0].tagObj.className = "tag_top";
         if(arr!=null){ifPlainText=arr[allTags.length]}
        setEditorValue(allTags[0].content);
        
    }
 	     function getEditorValue(){
	     //得到编辑器的值
	        var oEditor = FCKeditorAPI.GetInstance('FCKeditor1');
	        if (oEditor.EditMode == FCK_EDITMODE_WYSIWYG)
            {return oEditor.GetXHTML(true);}
            else
            {var t=oEditor.GetHTML(false);return t;}
	     }
	     function getEditorMode(){
	     //得到编辑器的状态。文本状态返回true;
	        var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
	        if (oEditor.EditMode == FCK_EDITMODE_WYSIWYG)
	        ifPlainText= false;
	        else
	        ifPlainText= true;
	     }
         function setEditorValue(value){
         //设置编辑器的值和状态
            var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
            if(((ifPlainText)&&(oEditor.EditMode !=FCK_EDITMODE_SOURCE))||((!ifPlainText)&&(oEditor.EditMode !=FCK_EDITMODE_WYSIWYG)))
            oEditor.SwitchEditMode();
            oEditor.SetHTML(value,false);
            oEditor.Focus();
            
         }        
       
	function getTest()
{//保存当前的编辑内容
  
  for(var i=0;i<allTags.length;i++)
                             { 
                             
                               if(allTags[i].tagObj.className!="tag_back")
                                 {
                                    
                                   allTags[i].content=getEditorValue();
                                   getEditorMode();
                                   break;
                                  }
                                
                             }
  
 return parent.submitInfo(ifPlainText,allTags);
}

