﻿var UCNameSpace="http://www.cnpc2006.com/";
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function InsertWebControl(ContentControlID)
{
    
    if(document.all(ContentControlID)!=null)
    {
        var newwin=window.open("/CNPC2006/Control/GetWebControl.aspx?EditControl="+ContentControlID,"ControlView","height=400,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes " );
        newwin.focus();
     
    }
}

//向输入框中插入Webcontrol代码
function InsertWebControlToInput(ContentControlID,CGUID)
{
    if(document.all(ContentControlID)!=null)
    {
           document.all(ContentControlID).focus();
        var range=getUCTextRange();
    
         if(range!=null)
         {          
          document.all(ContentControlID).EditControlHtml= range.text;
         }
        document.all(ContentControlID).insertHtml=InsertHTML
        var theUrl="/CNPC2006/Control/GetWebControl.aspx?EditControl="+ContentControlID
        if(CGUID!=null && CGUID!="" &&CGUID!="undifined")
        {
            theUrl+="&CGUID="+CGUID
        }
        var newwin=window.open(theUrl,"ControlView","height=400,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes " );
        newwin.focus();
      
    }
}
function InsertWebControlToEdit(EditID,CGUID)
{
     if(document.all(EditID)!=null)
    {
        var HtmlEdit= eval("window."+EditID)   
        if(!HtmlEdit.bTextMode)
        { 
            var oDiv= getUC(EditID);
            if(oDiv!=null)
            {
                document.all(EditID).EditControlHtml=oDiv.outerHTML
             }else
             {
                 document.all(EditID).EditControlHtml=""
             }
        }else
        {
              var range=getUCTextRange(EditID);
              if(range!=null)
              {
                document.all(EditID).EditControlHtml= range.text;
               }
               
        }
        
      document.all(EditID).insertHtml=putText
      var newwin=window.open("/CNPC2006/Control/GetWebControl.aspx?CGUID="+CGUID+"&EditControl="+EditID,"ControlView","height=400,width=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes " );
      newwin.focus();
//   
    }
      
}


//Get Control html from for text edit
function getUCTextRange(EditID)
{ 
 var range=null;
   if( EditID==null)
   {
      range=document.selection.createRange();
   }
   else
   {
    var HtmlEdit= eval("window."+EditID);
     range= HtmlEdit.document.selection.createRange();
   }  
   
   var rangestart=range.duplicate(); 
   var rangeEnd=range.duplicate(); 
   var rangeEnd2=range.duplicate();   
    var inEnd=false;
    rangestart.findText("<",-1)
    rangestart.setEndPoint("EndToEnd",range);
    if(rangestart.text.indexOf("</")>=0)
    {
         rangestart.setEndPoint("EndToStart",rangestart);
         rangestart.move("word",-1)
         rangestart.findText("<",-1)
         rangestart.setEndPoint("EndToEnd",range);
         inEnd=true;
    }
    if(inEnd)
    {
      rangeEnd.findText(">",1)
    }
    else
    {
        if(rangeEnd.findText("</",1))
        {
                rangeEnd.findText(">",1)
        }
    }
      range.setEndPoint("StartToStart",rangestart)
    range.setEndPoint("EndToEnd",rangeEnd)
   
    if(range.text.indexOf("<UC:")==0 && range.text.indexOf("</UC:")>0)
    {
        return range.duplicate();
    }else
    {
        return null;
    }
   
}
//Get Control  from for html edit
function getUC(EditID)
{
   var HtmlEdit= eval("window."+EditID)     
   var range= HtmlEdit.document.selection.createRange();  

     if(!HtmlEdit.bTextMode)//If not html edit ,no select userControl 
     {     
     	    iY=range.boundingTop+HtmlEdit.document.body.scrollTop;
	        iX=range.boundingLeft+HtmlEdit.document.body.scrollLeft;	        
	        var odiv=HtmlEdit.document.elementFromPoint(iX, iY);       
	        if(odiv!=null)
	        if(odiv.scopeName=="UC")
	        {	            	             
	            return odiv;	           
	        }

    }
      return null;
   
}

//Write html into editor
function putText(v)
{
    var HtmlEdit= eval("window."+this.id)
     HtmlEdit.focus();
     var range=null;

         if(!HtmlEdit.bTextMode)
          {
             var oDiv = getUC(this.id)            
             if(oDiv!=null)
             {
                oDiv.outerHTML= v;            
                 HtmlEdit.focus();
                 return;
            }else
            {
                range= HtmlEdit.document.selection.createRange();
            }
          }
          else
          {
            range= getUCTextRange(this.id);
            if(range==null)  range=  HtmlEdit.document.selection.createRange();
          }
     try
    {  
      if(HtmlEdit.bTextMode) range.text=v
        else   range.pasteHTML(v)
     }catch(ex)
   {
   
   }
    HtmlEdit.focus();
}
//向输入框中插入HTML代码
function InsertHTML(str)
{
		this.focus();
		var range= getUCTextRange();
        if(range==null)  range= document.selection.createRange();
		//var range = document.selection.createRange();
		var ch_text=range.text;
		range.text=str;
		this.focus();
	
}



var bodyTag="<html xmlns:UC=\""+UCNameSpace+"\"><head><style type=\"text/css\">body {font-size:	9pt}</style><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><BODY bgcolor=\"#FFFFFF\" MONOSPACE>"
var EditArray=new Array();
var ControlArray=new Array();
///显示编辑
function LoadEditContent(HtmlEdit,controlID)
{
try{
      var HtmlEdit= eval("window."+HtmlEdit)     
      HtmlEdit.document.open();
      HtmlEdit.document.write(bodyTag+document.all(controlID).value);
      HtmlEdit.document.close();
      HtmlEdit.document.designMode="On"; 
//      HtmlEdit.value.replace(location); 
//      HtmlEdit.value.replace(location.protocol +"//"+ location.host,"");  
      HtmlEdit.bTextMode=false;
      HtmlEdit.InputControl=controlID;
      }catch(ex)
      {
      }
      
    
}

function ReadDate(controlID)
{
    //(event.srcElement)
      var HtmlEdit= eval("window."+event.srcElement.id)
     // document.all(EidtFrame_Content)
     // HtmlEdit.style.height="100%"
     // HtmlEdit.parentNode.style.width="100%"
    
     if(HtmlEdit.bTextMode)
     {
       document.all(controlID).value=HtmlEdit.document.body.innerText
     }else
     {
        document.all(controlID).value=HtmlEdit.document.body.innerHTML
      }
     var  reg= new RegExp(location.protocol +"//"+ location.host,"ig");
     
     document.all(controlID).value=document.all(controlID).value.replace(reg,"");
}

function ChangeEidtHtmlState(HtmlEdit)
{
    var HtmlEdit= eval("window."+HtmlEdit)
    setMode(HtmlEdit,!HtmlEdit.bTextMode)
     //HtmlEdit.document.body.innerHTML=document.all(controlID).value  ;
}

function getText(HtmlEdit)
{
  if (HtmlEdit.bTextMode)
    return HtmlEdit.document.body.innerText;
  else
  {
    cleanHtml(HtmlEdit);
    cleanHtml(HtmlEdit);
    return HtmlEdit.document.body.innerHTML;
  }
}


function cleanHtml(HtmlEdit)
{
  var fonts = HtmlEdit.document.body.all.tags("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 setMode(EditcontrolID,newMode)
{
//debugger;
  var HtmlEdit= eval("window."+EditcontrolID)
   var cont
  HtmlEdit.bTextMode = newMode;
  if (HtmlEdit.bTextMode) {
    cleanHtml(HtmlEdit);
    cleanHtml(HtmlEdit);

    cont=HtmlEdit.document.body.innerHTML;
     var reg= new RegExp(location.href.replace(new RegExp("&","g"),"&amp;"),"ig");
    cont=cont.replace(reg,""); 
    reg= new RegExp(location.protocol +"//"+ location.host,"ig");
    cont=cont.replace(reg,"");
    HtmlEdit.document.body.innerText=cont;
  }
  else {
    cont=HtmlEdit.document.body.innerText;
    HtmlEdit.document.body.innerHTML=cont;
     var reg= new RegExp(location.href.replace(new RegExp("&","g"),"&amp;"),"ig");
   HtmlEdit.document.body.innerHTML=HtmlEdit.document.body.innerHTML.replace(reg,""); 
     reg= new RegExp(location.protocol +"//"+ location.host,"ig");
   HtmlEdit.document.body.innerHTML=HtmlEdit.document.body.innerHTML.replace(reg,"");
  }
  HtmlEdit.focus();
}


function getPureHtml(HtmlEdit)
{
  var str = "";
  var paras = HtmlEdit.document.body.all.tags("P");
  if (paras.length > 0)	{
    for	(var i=paras.length-1; i >= 0; i--) str	= paras[i].innerHTML + "\n" + str;
  }
  else {
    str	= HtmlEdit.document.body.innerHTML;
  }
  return str;
}

function doCMSSearch(KeyinputID,ScopeinputID,PageNum,AlertText)
{
    var SearchUrl="/CNPC2006/page/search.aspx?";
    if(PageNum!=null&&PageNum!="")
    SearchUrl="/CNPC2006/page/StaticSearch.aspx?"
    var KeyInput= document.all(KeyinputID);
    
    var ScopeInput= document.all(ScopeinputID);
    if(KeyInput!=null)
    {
       if(KeyInput.value!="")
       {
          var channelGUID=""; 
          if(ScopeInput!=null)
          {
            channelGUID=ScopeInput.value;
          } 
        if(PageNum==null||PageNum=="")
        { 
          navigate(SearchUrl+"keyString=" + encodeURI(KeyInput.value) + "&ChannelID=" + channelGUID);
         }else
         {
          
           navigate(SearchUrl+"keyString=" + encodeURI(KeyInput.value) + "&ChannelPath=" + channelGUID);
         }
       }else
       {
                if(AlertText==null||AlertText=="")
                    alert("请输入要查询的关键字");
                else
                    alert(AlertText);
       }
    }
    
}
    function SowEditControl(HtmlEdit,ControlID,CGUID)
    {
        var Control=document.all(ControlID);
        var EditFramestr=" <select ID=\"formatSelect\" class=\"TBGen\" onchange=\"format('"+HtmlEdit+"','FormatBlock',this[this.selectedIndex].value);this.selectedIndex=0\"> <option selected>段落格式</option>    <option VALUE=\"&lt;P&gt;\">普通</option>    <option VALUE=\"&lt;PRE&gt;\">已编排格式</option>    <option VALUE=\"&lt;H1&gt;\">标题一</option>    <option VALUE=\"&lt;H2&gt;\">标题二</option>    <option VALUE=\"&lt;H3&gt;\">标题三</option>    <option VALUE=\"&lt;H4&gt;\">标题四</option>    <option VALUE=\"&lt;H5&gt;\">标题五</option>    <option VALUE=\"&lt;H6&gt;\">标题六</option>    <option VALUE=\"&lt;H7&gt;\">标题七</option>  </select>  "+
       "<select id=\"specialtypeL\" class=\"TBGen\" onchange=\"specialtype('"+HtmlEdit+"',this[this.selectedIndex].value);this.selectedIndex=0\">    <option selected>特殊格式</option>    <option VALUE=\"SUP\">上标</option>    <option VALUE=\"SUB\">下标</option>    <option VALUE=\"DEL\">删除线</option>    <option VALUE=\"BLINK\">闪烁</option>    <option VALUE=\"BIG\">增大字体</option>    <option VALUE=\"SMALL\">减小字体</option>  </select>"+        
       "<img class=\"Ico\" TITLE=\"插入栏目框\" src=\"/CNPC2006/Images/btn/fieldset.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"FIELDSET('"+HtmlEdit+"')\">  "+     
       "<img class=\"Ico\" TITLE=\"插入网页\" src=\"/CNPC2006/Images/btn/htm.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"iframe('"+HtmlEdit+"')\">  "+     
       "<img class=\"Ico\" TITLE=\"插入图片URL\" src=\"/CNPC2006/Images/btn/img.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"pic('"+HtmlEdit+"')\">  "+     
      
      "<img class=\"Ico\" TITLE=\"插入flash多媒体文件\" src=\"/CNPC2006/Images/btn/flash.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"swf('"+HtmlEdit+"')\">  "+     
      "<img class=\"Ico\" TITLE=\"插入视频文件，支持格式为：avi、wmv、asf\" src=\"/CNPC2006/Images/btn/wmv.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"wmv('"+HtmlEdit+"')\">  "+     
     // "<img class=\"Ico\" TITLE=\"插入RealPlay文件，支持格式为：rm、ra、ram\" src=\"/CNPC2006/Images/btn/rm.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"rm('"+HtmlEdit+"')\">  "+     
      
       "<img class=\"Ico\" TITLE=\"插入表格\" src=\"/CNPC2006/Images/btn/table.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"InsertTable('"+HtmlEdit+"')\">  "+     
       "<img class=\"Ico\" TITLE=\"插入控件\" src=\"/CNPC2006/Images/btn/help.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"InsertWebControlToEdit('"+HtmlEdit+"','"+CGUID+"')\">  " +
  	    "<img class=\"Ico\" TITLE=\"左对齐\" src=\"/CNPC2006/Images/btn/aleft.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','justifyleft')\">  "+
        "<img class=\"Ico\" TITLE=\"居中\" src=\"/CNPC2006/Images/btn/acenter.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','justifycenter')\">  "+
        "<img class=\"Ico\" TITLE=\"右对齐\" src=\"/CNPC2006/Images/btn/aright.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','justifyright')\">  "+
        "<img class=\"Ico\" TITLE=\"编号\" src=\"/CNPC2006/Images/btn/num.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','insertorderedlist')\">  "+
      " <img class=\"Ico\" TITLE=\"项目符号\" src=\"/CNPC2006/Images/btn/list.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','insertunorderedlist')\">  "+
        "<img class=\"Ico\" TITLE=\"减少缩进量\" src=\"/CNPC2006/Images/btn/outdent.gif\" WIDTH=\"18\" HEIGHT=\"18\"  onclick=\"format('"+HtmlEdit+"','outdent')\">  "+
       " <img class=\"Ico\" TITLE=\"增加缩进量\" src=\"/CNPC2006/Images/btn/indent.gif\" WIDTH=\"18\" HEIGHT=\"18\"  onclick=\"format('"+HtmlEdit+"','indent')\">  "+
        "<img class=\"Ico\" TITLE=\"删除文字格式\"  src=\"/CNPC2006/Images/btn/clear.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','RemoveFormat')\"> "
      
    
    EditFramestr+="<select id=\"FontName\" class=\"TBGen\" onchange=\"format('"+HtmlEdit+"','fontname',this[this.selectedIndex].value);this.selectedIndex=0\">"+
    "<option selected>字体</option>"+
    "<option value=\"宋体\">宋体</option>"+
    "<option value=\"黑体\">黑体</option>"+
    "<option value=\"楷体_GB2312\">楷体</option>"+
    "<option value=\"仿宋_GB2312\">仿宋</option>"+
    "<option value=\"隶书\">隶书</option>"+
    "<option value=\"幼圆\">幼圆</option>"+
    "<option value=\"Arial\">Arial</option>"+
    "<option value=\"Arial Black\">Arial Black</option>"+
    "<option value=\"Arial Narrow\">Arial Narrow</option>"+
    "<option value=\"Brush Script	MT\">Brush Script MT</option>"+
    "<option value=\"Century Gothic\">Century Gothic</option>"+
   " <option value=\"Comic Sans MS\">Comic Sans MS</option>"+
    "<option value=\"Courier\">Courier</option>"+
    "<option value=\"Courier New\">Courier New</option>"+
    "<option value=\"MS Sans Serif\">MS Sans Serif</option>"+
   " <option value=\"Script\">Script</option>"+
    "<option value=\"System\">System</option>"+
    "<option value=\"Times New Roman\">Times New Roman</option>"+
    "<option value=\"Verdana\">Verdana</option>"+
    "<option value=\"Wide	Latin\">Wide Latin</option>"+
    "<option value=\"Wingdings\">Wingdings</option>"+
 " </select>"+
  " <select id=\"FontSize\" class=\"TBGen\" onchange=\"format('"+HtmlEdit+"','fontsize',this[this.selectedIndex].value);this.selectedIndex=0\">"+
   "  <option selected>字号</option>"+
   "  <option value=\"7\">一号</option>"+
  "   <option value=\"6\">二号</option>"+
  "   <option value=\"5\">三号</option>"+
  "   <option value=\"4\">四号</option>"+
   "  <option value=\"3\">五号</option>"+
   "  <option value=\"2\">六号</option>"+
   "  <option value=\"1\">七号</option>"+
 "  </select>"
        EditFramestr+="<img class=\"Ico\" src=\"/CNPC2006/Images/btn/fgcolor.gif\" title=\"字体颜色\" WIDTH=\"18\" HEIGHT=\"18\"  onclick=\"foreColor('"+HtmlEdit+"')\">"+
        "<img class=\"Ico\" src=\"/CNPC2006/Images/btn/bold.gif\" TITLE=\"加粗\" WIDTH=\"18\" HEIGHT=\"18\"  onclick=\"format('"+HtmlEdit+"','bold')\">"+
        "<img class=\"Ico\" src=\"/CNPC2006/Images/btn/italic.gif\" TITLE=\"斜体\" WIDTH=\"18\" HEIGHT=\"18\"  onclick=\"format('"+HtmlEdit+"','italic')\">"+
        "<img class=\"Ico\" src=\"/CNPC2006/Images/btn/underline.gif\" TITLE=\"下划线\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','underline')\"> "+ 
    "   <img class=\"Ico\" src=\"/CNPC2006/Images/btn/sup.gif\"  TITLE=\"上标\"  WIDTH=\"18\" HEIGHT=\"18\"  onclick=\"format('"+HtmlEdit+"','superscript')\"> "+
   "   <img class=\"Ico\" src=\"/CNPC2006/Images/btn/sub.gif\"  TITLE=\"下标\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','subscript')\"> "+
   
     " <img class=\"Ico\"  TITLE=\"插入超级连接\" src=\"/CNPC2006/Images/btn/url.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"UserDialog('"+HtmlEdit+"','CreateLink')\"> "+
    "<img class=\"Ico\" TITLE=\"取消超级链接\"  src=\"/CNPC2006/Images/btn/nourl.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"UserDialog('"+HtmlEdit+"','unLink')\">"+    
   " <img class=\"Ico\" TITLE=\"插入普通水平线\" src=\"/CNPC2006/Images/btn/line.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"format('"+HtmlEdit+"','InsertHorizontalRule')\">"+ 
    " <img class=\"Ico\" TITLE=\"插入特殊水平线\" src=\"/CNPC2006/Images/btn/sline.gif\" WIDTH=\"18\" HEIGHT=\"18\" onclick=\"hr('"+HtmlEdit+"')\"> "+    "<nobr><input id=\"EditMode\" onclick=\"setMode('"+HtmlEdit+"',this.checked)\" type=\"checkbox\">"+    " 查看HTML源代码</nobr>";
    
      Control.innerHTML=EditFramestr;
     }

function UserDialog(EditcontrolID,what)
{ 
   var HtmlEdit= eval("window."+EditcontrolID)
  //if (!validateMode(HtmlEdit)) return;

  HtmlEdit.document.execCommand(what, true);

  pureText = false;
  HtmlEdit.focus();
}

function format(EditcontrolID,what,opt)
{
     var HtmlEdit= eval("window."+EditcontrolID)
      if (!validateMode(HtmlEdit)) return;
      if (opt=="removeFormat")
      {
        what=opt;
        opt=null;
      }
      if (opt==null) HtmlEdit.document.execCommand(what);
      else HtmlEdit.document.execCommand(what,"",opt);

      pureText = false;
      HtmlEdit.focus();
}
function validateMode(HtmlEdit)
{
  if (!	HtmlEdit.bTextMode) return true;

  HtmlEdit.focus();
  return false;
}
function specialtype(EditcontrolID,Mark){

    var HtmlEdit= eval("window."+EditcontrolID)
  //if (!Error()) return;
  var sel,RangeType
  sel = HtmlEdit.document.selection.createRange();
  RangeType = HtmlEdit.document.selection.type;
  if (RangeType == "Text"){
    sel.pasteHTML("<" + Mark + ">" + sel.text + "</" + Mark + ">");
    sel.select();
  }
  HtmlEdit.focus();
}

function hr(EditcontrolID)
{  var HtmlEdit= eval("window."+EditcontrolID)
  if (!	validateMode(HtmlEdit))	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/hr.htm", "", "dialogWidth:30em;dialogHeight:12em; status:0;help:0"); 
  if (arr != null){
  var ss;
  ss=arr.split("*")
  a=ss[0];
  b=ss[1];
  c=ss[2];
  d=ss[3];
  e=ss[4];
  var str1;
str1="<hr"
str1=str1+" color='"+a+"'"
str1=str1+" size="+b+"'"
str1=str1+" "+c+""
str1=str1+" align="+d+""
str1=str1+" width="+e
str1=str1+">"
  content=HtmlEdit.document.body.innerHTML;
  content=content+str1;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}


function FIELDSET(EditcontrolID)
{
var HtmlEdit= eval("window."+EditcontrolID)
  if (!	validateMode(HtmlEdit))	return;
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/fieldset.htm", "", "dialogWidth:25em; dialogHeight:10em; status:0;help:0");
  if (arr != null){
  var ss;
  ss=arr.split("*")
  a=ss[0];
  b=ss[1];
  c=ss[2];
  d=ss[3];
  var str1;
str1="<FIELDSET "
str1=str1+"align="+a+""
str1=str1+" style='"
if(c.value!='')str1=str1+"color:"+c+";"
if(d.value!='')str1=str1+"background-color:"+d+";"
str1=str1+"'><Legend"
str1=str1+" align="+b+""
str1=str1+">Title</Legend>Content</FIELDSET>"
  content=HtmlEdit.document.body.innerHTML;
  content=content+str1;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}
function InsertTable(EditcontrolID)
{
var HtmlEdit= eval("window."+EditcontrolID)

if (!	validateMode(HtmlEdit))	return;

  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/table.HTM", "", "dialogWidth:300pt;dialogHeight:236pt;help:0;status:0");

  if (arr != null){
	range.pasteHTML(arr);
  }
  HtmlEdit.focus();
}

function foreColor(EditcontrolID)
{var HtmlEdit= eval("window."+EditcontrolID)

  if (!	validateMode(HtmlEdit))	return;
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/color.htm", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null) format(EditcontrolID,'forecolor', arr);
  else HtmlEdit.focus();
}


function iframe(EditcontrolID)
{
  var HtmlEdit= eval("window."+EditcontrolID)

if (!	validateMode(HtmlEdit))	return;

  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/iframe.htm", "", "dialogWidth:30em; dialogHeight:13em; status:0;help:0");  
  if (arr != null){
  var ss;
  ss=arr.split("*")
  a=ss[0];
  b=ss[1];
  c=ss[2];
  d=ss[3];
  e=ss[4];
  f=ss[5];
  g=ss[6];
  var str1;
str1="<iframe src='"+a+"'"
str1+=" scrolling="+b+""
str1+=" frameborder="+c+""
if(d!='')str1+=" marginheight="+d
if(e!='')str1+=" marginwidth="+e
if(f!='')str1+=" width="+f
if(g!='')str1+=" height="+g
str1=str1+"></iframe>"
  content=HtmlEdit.document.body.innerHTML;
  content=content+str1;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}

function wmv(EditcontrolID)
{
var HtmlEdit= eval("window."+EditcontrolID)

if (!	validateMode(HtmlEdit))	return;


  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/media.html", "", "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="<object classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' width="+row+" height="+col+"><param name=Filename value="+path+"><param name='BufferingTime' value='5'><param name='AutoSize' value='-1'><param name='AnimationAtStart' value='-1'><param name='AllowChangeDisplaySize' value='-1'><param name='ShowPositionControls' value='0'><param name='TransparentAtStart' value='1'><param name='ShowStatusBar' value='1'></object>"
  content=HtmlEdit.document.body.innerHTML;
  content=content+string;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}


function rm(EditcontrolID)
{
var HtmlEdit= eval("window."+EditcontrolID)

if (!	validateMode(HtmlEdit))	return;

 
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/rm.html", "", "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="<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width="+row+" height="+col+"><param name='CONTROLS' value='ImageWindow'><param name='CONSOLE' value='Clip1'><param name='AUTOSTART' value='-1'><param name=src value="+path+"></object><br><object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'  width="+row+" height=60><param name='CONTROLS' value='ControlPanel,StatusBar'><param name='CONSOLE' value='Clip1'></object>"
  content=HtmlEdit.document.body.innerHTML;
  content=content+string;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}


function pic(EditcontrolID)
{
var HtmlEdit= eval("window."+EditcontrolID)

if (!	validateMode(HtmlEdit))	return;

 
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/pic.html", "", "dialogWidth:30em; dialogHeight:15em; status:0;help:0");  
  if (arr != null){
  var ss;
  ss=arr.split("*")
  a=ss[0];
  b=ss[1];
  c=ss[2];
  d=ss[3];
  e=ss[4];
  f=ss[5];
  g=ss[6];
  h=ss[7];
  i=ss[8];
  
  var str1;
str1="<img src='"+a+"' alt='"+b+"'"
if(d.value!='')str1=str1+"width='"+d+"'"
if(e.value!='')str1=str1+"height='"+e+"' "
str1=str1+" border='"+i+"' align='"+h+"' vspace='"+f+"' hspace='"+g+"'  style='"+c+"'"
str1=str1+">"
  content=HtmlEdit.document.body.innerHTML;
  content=content+str1;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}

function swf(EditcontrolID)
{
var HtmlEdit= eval("window."+EditcontrolID)

if (!	validateMode(HtmlEdit))	return;

 
  HtmlEdit.focus();
  var range = HtmlEdit.document.selection.createRange();
  var arr = showModalDialog("/CNPC2006/CONTROL/Editor/flash.html", "", "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="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width="+row+" height="+col+"><param name=movie value="+path+"><PARAM NAME='WMode' VALUE='Transparent'><param name=quality value=high><embed src="+path+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width="+row+" height="+col+"></embed></object>"
  content=HtmlEdit.document.body.innerHTML;
  content=content+string;
   HtmlEdit.document.body.innerHTML=content;
  }
  else HtmlEdit.focus();
}


function MCSMenu_HoverDynamic(Td)
{
    var element=document.all(Td.id+"Items");
    if(element==null||element=='undefined'){ return};
    if(element.style.display=="block")
	{
			return;
	}	
	    var node=Td;
	    if(node != null)
	    {			
			var rect1=node.getBoundingClientRect()
			var rect2=element.getBoundingClientRect()
		
				var top=rect1.bottom-5	
	    		var left=rect1.left -2
				element.style.left=left+document.body.scrollLeft
				element.style.top=top+document.body.scrollTop
				if(element.offsetWidth<node.offsetWidth)
				{
					element.style.width = node.offsetWidth+2
				}			
					
					
		}			
		newrect2=element.getBoundingClientRect()		
		left=rect1.left-2
		
		if(newrect2.left<0)
		{
					element.style.left = left+document.body.scrollLeft;
					element.curpop="2";
		}		
		CheckNodePostion(element)	
		MCSMenu_ShowHidden(element,"show");

}


function MCSMenu_Unhover(Td)
{
    var element=document.all(Td.id+"Items");
    MCSMenu_ShowHidden(element,"hide");
}


function  MCSMenu_ShowHidden(obj,v) { //v6.0 
    try{
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; 
    }catch(ex)
    {
    }}



function CheckNodePostion(node)		
{
	try{	
		var rect1=node.getBoundingClientRect()
		if(rect1.bottom>document.body.clientHeight)
		{
			node.style.top = parseInt(document.body.clientHeight)- parseInt(node.clientHeight) + parseInt(document.body.scrollTop)
		}
	}catch(ex)
	{
	}	
}
function doCMSSearchNew(KeyinputID,ScopeinputID,PageNum,AlertText)
{
 var SearchUrl = "/cn/search/default.htm?";
 var ScopeInput = document.all("selectsearch").value;
 if (ScopeInput == "zbcp_CN") {
     var KeyInput = document.all(KeyinputID);
     if (KeyInput.value == "") 
     {
        alert("请输入要查询的关键字"); 
     }
     else 
     {
         SearchUrl = "http://www.cnpc.com.cn/chanpinWeb/ProductsSearch_CN.aspx?";
        navigate(SearchUrl + "ProductsName=" + escape(KeyInput.value));
     }
}
else
{
if(PageNum!=null&&PageNum!="")
    SearchUrl="/cn/search/default.htm?"
    var KeyInput= document.all(KeyinputID);
    
    var ScopeInput= document.all(ScopeinputID);
    if(KeyInput!=null)
    {
       if(KeyInput.value!="")
       {
          var channelGUID=""; 
          if(ScopeInput!=null)
          {
            channelGUID=ScopeInput.value;
          } 
        if(PageNum==null||PageNum=="")
        { 
          navigate(SearchUrl+"keyString=" +  encodeURI(KeyInput.value) + "&ChannelID=" + channelGUID);
         }else
         {
          
           navigate(SearchUrl+"keyString=" + encodeURI(KeyInput.value) + "&ChannelPath=" + channelGUID);
         }
       }else
       {
                if(AlertText==null||AlertText=="")
                    alert("请输入要查询的关键字");
                else
                    alert(AlertText);
       }
    }

}
   
    
    
}
