function JM_cc(ob){
var obj=MM_findObj(ob); if (obj) { 
obj.select();js=obj.createTextRange();js.execCommand("Copy");}
}

var SelRGB = '';
var DrRGB = '';
var SelGRAY = '120';
var SelRGB2 = '';
var DrRGB2 = '';
var SelGRAY2 = '120';
var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
function ToHex(n)
{	var h, l;
	n = Math.round(n);
	l = n % 16;
	h = Math.floor((n / 16)) % 16;
	return (hexch[h] + hexch[l]);
}
function DoColor(c, l)
{ var r, g, b;
  r = '0x' + c.substring(1, 3);
  g = '0x' + c.substring(3, 5);
  b = '0x' + c.substring(5, 7);
  if(l > 120)
  {
    l = l - 120;
    r = (r * (120 - l) + 255 * l) / 120;
    g = (g * (120 - l) + 255 * l) / 120;
    b = (b * (120 - l) + 255 * l) / 120;
  }else
  {
    r = (r * l) / 120;
    g = (g * l) / 120;
    b = (b * l) / 120;
  }
  return '#' + ToHex(r) + ToHex(g) + ToHex(b);
}
function EndColor(x)
{ var i;    
  if(x==0){
  if(DrRGB != SelRGB)
  {
    DrRGB = SelRGB;
    for(i = 0; i <= 30; i ++)
    //多个颜色选择器   
      GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 8);      
   }
   SelColor.value = DoColor(SelRGB,SelGRAY);
  ShowColor.style.backgroundColor =  SelColor.value;  
  }  
    if(x==1){
  if(DrRGB2 != SelRGB2)
  {
    DrRGB2 = SelRGB2;
    for(i = 0; i <= 30; i ++)
    //多个颜色选择器     
      GrayTable2.rows(i).bgColor = DoColor(SelRGB2, 240 - i * 8);       
   }
   SelColor2.value = DoColor(SelRGB2,SelGRAY2);
  ShowColor2.style.backgroundColor =  SelColor2.value;  
  }  
   okhtml();
}

function okhtml(){
var t_size = document.all.Layer_num.value ;
var t_height = document.all.theight.value ;
var t_width = document.all.twidth.value ;
var t_width2 ;
var t_color = document.all.SelColor.value ;
var t_texture = document.all.texturex.value ;
var t_SelColor2 =  document.all.SelColor2.value;
var t_curl =  document.all.curl.value;
var t_curl2 =  document.all.curl2.value;
var t_text =  document.all.entertext.value;
var  t_bold_htm ='';
var t_bold_htm2 ='';
function JM_cc(ob){
var obj=MM_findObj(ob); if (obj) { 
obj.select();js=obj.createTextRange();js.execCommand("Copy");}
}
var under_htm = '';
if(document.all.t_bold.checked==true){ 
t_bold_htm ='<b>';
t_bold_htm2 ='</b>';
}
var html ;
if(document.all.tcheck.checked==true){
  t_height=document.all.theight.value=parseInt(document.all.Layer_num.value)+6;
  t_width=document.all.twidth.value=parseInt(document.all.entertext.value.length)*(parseInt(document.all.Layer_num.value));
 }
t_width2 = t_width * 0.97 ;
var css_rad = document.all.take;
if ( css_rad[0].checked ) {
html = '<div id="texture" style="width: '+t_width+'px; height:'+t_height+'px"><img height="1" src="'+t_curl+'" width="'+t_width+'px" align="right"><img height="'+t_height+'px" src="'+t_texture+'" width="'+t_width2+'px" align="right">';
html = html +'<div style="font-size: '+t_size+'px; filter: chroma(color='+t_SelColor2+'); float: left; width: '+t_width+'px; height:'+t_height+'px; background-color:'+t_color+'" align="center"><font color='+t_SelColor2+'>'+t_bold_htm+t_text+t_bold_htm2+'</font></div></div>';
}else if(css_rad[1].checked ) {
 if(document.all.checkunder.checked==true){ 
under_htm='background-repeat:repeat-x;background-position:left bottom;';
}
html = '<table><tr><td><div style="font-size: '+t_size+'px; background-color:'+t_color+'">(前段內容)+</div></td><td style="'+under_htm+'" background='+t_curl2+'><div style="font-size: '+t_size+'px; background-color:'+t_color+'"><font color='+t_SelColor2+'>'+t_bold_htm+t_text+t_bold_htm2+'</font></div></td><td><div style="font-size: '+t_size+'px; background-color:'+t_color+'">+(后段內容)</div></td></tr></table>';
}else if(css_rad[2].checked ) {
     if(document.all.checkunder.checked==true){ 
under_htm=';background-image:url('+t_curl2+');background-repeat:repeat-x;background-position:bottom;';
}
html = '<div id="texture2" style="width: '+t_width+'px; height:'+t_height+'px;background-image:url('+t_texture+');">';
html = html +'<div style="font-size: '+t_size+'px; FILTER: Chroma(color='+t_SelColor2+'); width: '+t_width+'px; height:'+t_height+'px; background-color:'+t_color+under_htm+'" align="center"><font color='+t_SelColor2+'>'+t_bold_htm+t_text+t_bold_htm2+'</font></div></div>';
}else if(css_rad[3].checked ) {
     if(document.all.checkunder.checked==true){ 
under_htm=';background-image:url('+t_curl2+');background-repeat:repeat-x;background-position:bottom;';
}
html = '<div id="texture3" style="font-size: '+t_size+'px; width: '+t_width+'px; height:'+t_height+'px; background-color:'+t_color+under_htm+'" align="center"><font color='+t_SelColor2+'>'+t_bold_htm+t_text+t_bold_htm2+'</font></div>';
}
document.all.outhtml.value = html ;
document.all.divResult.innerHTML = "复制起点→ ●"+html+"● ←复制终点";
}