﻿

function gethtml(){ 
document.form1.Etools1_textedit.value=htmledit.document.body.innerHTML.toLowerCase(); 

document.getElementById("texteditshow").style.display="block";
document.getElementById("htmleditshow").style.display="none"

} 

function sethtml(){ 
htmledit.document.body.innerHTML=document.form1.Etools1_textedit.value; 

document.getElementById("texteditshow").style.display="none";
document.getElementById("htmleditshow").style.display="block"

} 
function  showpyy (str,id)
{
if(document.getElementById(str).style.display=="none")
{
document.getElementById(str).style.display="block";
}
else
{
if(document.getElementById(str).style.display=="block")
{
document.getElementById(str).style.display="none";
}
}
switch(id)
       {
           case "1":
          if(document.form1.Etools1_textedit.value!="")
{
document.getElementById(str).innerHTML=document.form1.Etools1_textedit.value;
}else
{
if(document.form1.Etools1_textedit.value=="")
{
document.getElementById(str).innerHTML=htmledit.document.body.innerHTML;
}
}
               break;
               case "2":
         if(document.form1.About1_etext.value!="")
{
document.getElementById(str).innerHTML=document.form1.About1_etext.value;
}
               break;
       }




}
function  showkeyword ()
{
if(document.getElementById("keyword").style.display=="none")
{
document.getElementById("keyword").style.display="block";
}
else
{
if(document.getElementById("keyword").style.display=="block")
{
document.getElementById("keyword").style.display="none";
}
}

}
function  initeditor ()
{
htmledit.document.onkeypress =keypress 
}
function  keypress ()
　　{
　　     var  ev  = htmledit.event ;
　　     if (ev.keyCode ==13)
　　    {
　　         insertHTML("<br> &nbsp;");
　　        document.form1.Etools1_textedit.value=htmledit.document.body.innerHTML.toLowerCase(); 
　　         return  false ;
　　      
　　         
　　    }
　　}
function divsshow(s,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13)
{
  switch (s)
        {
            case "1":
             document.getElementById("piconshow").style.display="block";
                break;
                case "2":
             document.getElementById("piconshow").style.display="none";
                break;
        }
        switch (s1)
        {
            case "1":
             document.getElementById("Etools1_showtable").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showtable").style.display="none";
                break;
        }
         switch (s2)
        {
            case "1":
             document.getElementById("Etools1_showpicon").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showpicon").style.display="none";
                break;
        }
          switch (s3)
        {
            case "1":
             document.getElementById("Etools1_showfly").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showfly").style.display="none";
                break;
        }
         switch (s4)
        {
            case "1":
             document.getElementById("Etools1_showface").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showface").style.display="none";
                break;
        }
        switch (s5)
        {
            case "1":
             document.getElementById("Etools1_showsize").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showsize").style.display="none";
                break;
        }
        switch (s6)
        {
            case "1":
             document.getElementById("Etools1_showurl").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showurl").style.display="none";
                break;
        }
          switch (s7)
        {
            case "1":
             document.getElementById("Etools1_showmedia").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showmedia").style.display="none";
                break;
        }
          switch (s8)
        {
            case "1":
             document.getElementById("Etools1_showmap").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showmap").style.display="none";
                break;
        }
           switch (s9)
        {
            case "1":
             document.getElementById("Etools1_showdiv").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showdiv").style.display="none";
                break;
        }
            switch (s10)
        {
            case "1":
             document.getElementById("Etools1_showsmilies").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showsmilies").style.display="none";
                break;
        }
            switch (s11)
        {
            case "1":
             document.getElementById("Etools1_showbl").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_showbl").style.display="none";
                break;
        }
            switch (s12)
        {
            case "1":
             document.getElementById("Etools1_jd").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_jd").style.display="none";
                break;
        }
             switch (s13)
        {
            case "1":
             document.getElementById("Etools1_polls").style.display="block";
                break;
                case "2":
             document.getElementById("Etools1_polls").style.display="none";
                break;
        }

  
}


function eb(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<b>"+sel.text+"</b>"); 
} 

function ei(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<i>"+sel.text+"</i>"); 
} 

function eu(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<u>"+sel.text+"</u>"); 
}

function ejleft(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<p align=\"left\">"+sel.text+"</p>"); 
} 

function ejright(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<p align=\"right\">"+sel.text+"</p>"); 
} 

function ejcenter(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<p align=\"center\">"+sel.text+"</p>"); 
} 

function efull(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<p align=\"justify\">"+sel.text+"</p>"); 
} 

function eideredlist(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<ol><li>"+sel.text+"</li></ol>"); 
} 

function eideredlists(){ 
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<ul><li>"+sel.text+"</li></ul>"); 
} 

function efly(){ 
htmledit.focus(); 

var scrollamount=document.getElementById("Etools1_Fly1_flyscrollamount").value;
var width=document.getElementById("Etools1_Fly1_flywidth").value;
var height=document.getElementById("Etools1_Fly1_flyheight").value;
var scrolldelay=document.getElementById("Etools1_Fly1_flyscrolldelay").value;
var bgcolor=document.getElementById("Etools1_Fly1_flybgcolor").value;
var behavior=document.getElementById("Etools1_Fly1_flybehavior").value;
var loop=document.getElementById("Etools1_Fly1_flyloop").value;
var direction=document.getElementById("Etools1_Fly1_flydirection").value;
var flytext=document.getElementById("Etools1_Fly1_flytext").value;

var html='<marquee scrollamount="'+scrollamount+'" height="'+height+'" width="'+width+'" scrolldelay="'+scrolldelay+'" bgcolor="'+bgcolor+'"  behavior="'+behavior+'" loop="'+loop+'" direction="'+direction+'">'+flytext+'</marquee>';
insertHTML(html); 
} 



function etable()
{
htmledit.focus();


var width =document.getElementById("Etools1_Table1_tabwidth").value;
var height =document.getElementById("Etools1_Table1_tabheight").value;
var bgcolor =document.getElementById("Etools1_Table1_tabbgcolor").value;
var background =document.getElementById("Etools1_Table1_tabbackground").value;
var border =document.getElementById("Etools1_Table1_tabborder").value;
var cellspacing =document.getElementById("Etools1_Table1_tabcellspacing").value;
var cellpadding =document.getElementById("Etools1_Table1_tabcellpadding").value;

var cellwidth =document.getElementById("Etools1_Table1_tabcellwidth").value;
var cellheight =document.getElementById("Etools1_Table1_tabcellheight").value;

var tabrow=document.getElementById("Etools1_Table1_tabrow").value;
var tabcell=document.getElementById("Etools1_Table1_tabcell").value;

var tabname=document.getElementById("Etools1_Table1_tabname").value;

var html = '<table id="'+tabname+'" border="'+border+'" cellspacing="'+cellspacing+'" cellpadding="'+cellpadding+'" background="'+background+'" width="' + (width ? width : '50%') + '" height="' + (height ? height : '50%') + '" class="table"  bgcolor="' + bgcolor + '" >';
for (var row = 0; row <tabrow; row++) {
      
				html += '<tr>\n';
				for (var col = 0; col < tabcell; col++)
				 {
				
					html += '<td style="width: '+cellwidth+'; height:'+cellheight+'">&nbsp;</td>\n';
				}
				html+= '</tr>\n';							
			}
			html += '</table>\n';

	insertHTML(html);
	pkclose();
}



function insertHTML(html) { 
if (htmledit.document.selection.type.toLowerCase() != "none"){ 
htmledit.document.selection.clear() ; 
} 
htmledit.document.selection.createRange().pasteHTML(html) ; 
} 

function document.onreadystatechange() 
{ 
htmledit.document.designMode="On"; 
} 


document.write("<OBJECT id=\"dlgHelper\" CLASSID=\"clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b\" width=\"0px\" height=\"0px\"></OBJECT>");
var ocolorPopup = window.createPopup();
var ecolorPopup=null;

function colordialogmouseout(obj){
  obj.style.borderColor="";
  obj.bgColor="";
}

function colordialogmouseover(obj){
  obj.style.borderColor="#0A66EE";
  obj.bgColor="#EEEEEE";
}

function colordialogmousedown(color){
  ecolorPopup.value=color;
  
  htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 

 insertHTML("<font color="+color+">"+sel.text+"</font>");
 // document.body.bgColor=color;
  
  ocolorPopup.document.body.blur();
}

function colordialogmore(){
  var sColor=dlgHelper.ChooseColorDlg(ecolorPopup.value);
  sColor = sColor.toString(16);
  if (sColor.length < 6) {
    var sTempString = "000000".substring(0,6-sColor.length);
    sColor = sTempString.concat(sColor);
  }
  ecolorPopup.value="#"+sColor.toUpperCase();
  //document.body.bgColor="#"+sColor.toUpperCase();
  ocolorPopup.document.body.blur();
}

function colordialog(){
  var e=event.srcElement;
  e.onkeyup=colordialog;
  ecolorPopup=e;
  var ocbody;
  var oPopBody = ocolorPopup.document.body;
  var colorlist=new Array(40);
  oPopBody.style.backgroundColor = "#f9f8f7";
  oPopBody.style.border = "solid #999999 1px";
  oPopBody.style.fontSize = "12px";

  colorlist[0]="#000000";  colorlist[1]="#993300";  colorlist[2]="#333300";  colorlist[3]="#003300";
  colorlist[4]="#003366";  colorlist[5]="#000080";  colorlist[6]="#333399";  colorlist[7]="#333333";

  colorlist[8]="#800000";  colorlist[9]="#FF6600";  colorlist[10]="#808000";colorlist[11]="#008000";
  colorlist[12]="#008080";colorlist[13]="#0000FF";colorlist[14]="#666699";colorlist[15]="#808080";

  colorlist[16]="#FF0000";colorlist[17]="#FF9900";colorlist[18]="#99CC00";colorlist[19]="#339966";
  colorlist[20]="#33CCCC";colorlist[21]="#3366FF";colorlist[22]="#800080";colorlist[23]="#999999";

  colorlist[24]="#FF00FF";colorlist[25]="#FFCC00";colorlist[26]="#FFFF00";colorlist[27]="#00FF00";
  colorlist[28]="#00FFFF";colorlist[29]="#00CCFF";colorlist[30]="#993366";colorlist[31]="#CCCCCC";

  colorlist[32]="#FF99CC";colorlist[33]="#FFCC99";colorlist[34]="#FFFF99";colorlist[35]="#CCFFCC";
  colorlist[36]="#CCFFFF";colorlist[37]="#99CCFF";colorlist[38]="#CC99FF";colorlist[39]="#FFFFFF";

  ocbody = "";
  ocbody += "<table CELLPADDING=0 CELLSPACING=3>";
  ocbody += "<tr height=\"20\" width=\"20\"><td align=\"center\"><table style=\"border:1px solid #808080;\" width=\"12\" height=\"12\" bgcolor=\""+e.value+"\"><tr><td></td></tr></table></td><td bgcolor=\"eeeeee\" colspan=\"7\" style=\"font-size:12px;\" align=\"center\">当前颜色</td></tr>";
  for(var i=0;i<colorlist.length;i++){
    if(i%8==0)
      ocbody += "<tr>";
    ocbody += "<td width=\"14\" height=\"16\" style=\"border:1px solid;\" onMouseOut=\"parent.colordialogmouseout(this);\" onMouseOver=\"parent.colordialogmouseover(this);\" onMouseDown=\"parent.colordialogmousedown('"+colorlist[i]+"')\" align=\"center\" valign=\"middle\"><table style=\"border:1px solid #808080;\" width=\"12\" height=\"12\" bgcolor=\""+colorlist[i]+"\"><tr><td></td></tr></table></td>";
    if(i%8==7)
      ocbody += "</tr>";
  }
  //ocbody += "<tr><td align=\"center\" height=\"22\" colspan=\"8\" onMouseOut=\"parent.colordialogmouseout(this);\" onMouseOver=\"parent.colordialogmouseover(this);\" style=\"border:1px solid;font-size:12px;cursor:default;\" onMouseDown=\"parent.colordialogmore()\">其它颜色</td></tr>";
  ocbody += "</table>";

  oPopBody.innerHTML=ocbody;

  ocolorPopup.show(e.offsetLeft+e.offsetWidth*7, e.offsetTop+e.offsetHeight*7, 158, 147, document.body);
  
}

function facechange()
{   

 htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 
insertHTML("<font face="+document.getElementById("Etools1_Face1_face").options[document.getElementById("Etools1_Face1_face").selectedIndex].value+">"+sel.text+"</font>");
}

function sizechange()
{   

 htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 

 insertHTML("<font size="+document.getElementById("Etools1_Size1_size").options[document.getElementById("Etools1_Size1_size").selectedIndex].value+">"+sel.text+"</font>");
}

function urlcreate()
{   
htmledit.focus(); 
var sel = htmledit.document.selection.createRange(); 

 insertHTML("<a href="+document.getElementById("Etools1_Url1_urlhead").options[document.getElementById("Etools1_Url1_urlhead").selectedIndex].value+document.getElementById("Etools1_Url1_url").value+">"+sel.text+"</a>");
}

function checkstrlen(str)
{
var l=30000;
if(l-document.form1.Etools1_textedit.value.length>=0){ 
var s=l-document.form1.Etools1_textedit.value.length;
document.getElementById(str).innerText="最大支持:"+l+"已填写:"+document.form1.Etools1_textedit.value.length+"剩余:"+s; 
}
else
{
if(l-document.form1.Etools1_textedit.value.length<0){ 
document.getElementById(str).innerText="您填写的文本长度超出系统所能承受的极限"; 
}
}
}
function checkstrlen1(str)
{
var l=30000;
if(l-document.form1.About1_etext.value.length>=0){ 
var s=l-document.form1.About1_etext.value.length;
document.getElementById(str).innerText="最大支持:"+l+"已填写:"+document.form1.About1_etext.value.length+"剩余:"+s; 
}
else
{
if(l-document.form1.About1_etext.value.length<0){ 
document.getElementById(str).innerText="您填写的文本长度超出系统所能承受的极限"; 
}
}
}



