common_wev8.js 27.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957
//切换美化checkbox是否选中
function changeCheckboxStatus4tzCheckBox(obj, checked) {
	//jQuery(obj).attr("checked", checked);
	if (obj.checked) {
		jQuery(obj).next("span.tzCheckBox").addClass("checked");
		jQuery(obj).next("span.jNiceCheckbox").addClass("jNiceChecked");
	} else {
		jQuery(obj).next("span.tzCheckBox").removeClass("checked");
		jQuery(obj).next("span.jNiceCheckbox").removeClass("jNiceChecked");
	}
}
//切换美化radio是否选中
function changeRadioStatus4tzRadio(obj, checked) {
	//jQuery(obj).attr("checked", checked);
	if (obj.checked) {
		jQuery(obj).next("span.jNiceRadio").addClass("jNiceChecked");
	} else {
		jQuery(obj).next("span.jNiceRadio").removeClass("jNiceChecked");
	}
}
//切换美化checkbox是否只读
function disOrEnableCheckbox4tzCheckBox(obj, disabled) {
	jQuery(obj).attr("disabled", disabled);
	if(!disabled){
		jQuery(obj).attr("disabled","");
		jQuery(obj).removeAttr("disabled");
	}
}

var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
/*RGB颜色转换为16进制*/
String.prototype.colorHex = function(){
	var that = this;
	if(/^(rgb|RGB)/.test(that)){
		var aColor = that.replace(/(?:\(|\)|rgb|RGB)*/g,"").split(",");
		var strHex = "#";
		for(var i=0; i<aColor.length; i++){
			var hex = Number(aColor[i]).toString(16);
			if (hex.length == 1) {
				hex = "0" + hex;
			}
			strHex += hex;
		}
		if(strHex.length !== 7){
			strHex = that;	
		}
		return strHex;
	}else if(reg.test(that)){
		var aNum = that.replace(/#/,"").split("");
		if(aNum.length === 6){
			return that;	
		}else if(aNum.length === 3){
			var numHex = "#";
			for(var i=0; i<aNum.length; i+=1){
				numHex += (aNum[i]+aNum[i]);
			}
			return numHex;
		}
	}else{
		return that;	
	}
};

	function  generateCss1(r_id,r_attr,color){
		var sheet = $("#divContainer").find("style")[0].sheet;
		var theRules;
		if (sheet.cssRules)
			theRules = sheet.cssRules
		else if (sheet.rules)
			theRules = sheet.rules
		//alert(theRules)
		var isheadovercheck=false;
		var hasfonthover=false,hasheadhover=false;
		if($("input[name='isbgcolopen']").get(0)!=undefined){
			isheadovercheck=$("input[name='isbgcolopen']").get(0).checked;
		}
		//底边颜色开关
        var isbtcolcheck=false;
		if($("input[name='isbtcolopen']").get(0)!=undefined){
			isbtcolcheck=$("input[name='isbtcolopen']").get(0).checked;
		}
		var addflag=false;	
		
		for( i=0;i<theRules.length;i++){
			var rule = theRules[i];
			var selector= rule.selectorText //选择器
			var value=rule.cssText;
			var replaceStr = "#item_"+styleid+" ";
			selector = selector.replace(new RegExp(replaceStr,'gm'),'');
			//alert(selector);
			
			if(r_id==='font_hover'){
				if(selector==='.font:hover'  &&  color!==''){
					hasfonthover=true;
					rule.style.setProperty('color',color,"important");
					//break;
				}else if(selector==='.font:hover'  &&  color==='')
					//alert(2);
					//alert(rule.style.color);
					rule.style.setProperty('color',"","");
					//break;
		  }
		  
		  	if(r_id==='font'){
		  		if(selector==='.font'  &&  color!==''){
		  			rule.style.setProperty('color',color,"important");
		  			//break;
		  		}
		  		
		  	}
		  if(r_id==='head_hover'){
				if(selector==='.header:hover' &&  color!==''){
					hasheadhover=true;
					rule.style.setProperty('background-color',color,"important");
					//alert(3);
					//alert(rule.style.backgroundColor);
					//break;
				}else if(selector==='.header:hover' &&  color===''){
					//alert(4);
					rule.style.setProperty('background-color',"","");
					//continue;
					//break;
			}
					
			}
			//如果鼠标背景色开关关闭,则直接继续
			if(selector==='.header:hover' && !isheadovercheck){
				//alert(5);
				//alert(rule.style.backgroundColor);
				rule.style.setProperty('background-color',"","");
			   //break;
			}
			
			if(r_id==='title'){
				if(selector==='.title'  &&  color!==''){
					//alert(r_attr+"$"+color);
			  		rule.style.setProperty(r_attr,color,"important");
			  		//$("#divContainer").find("style")[0].sheet.cssRules[i].style.setProperty("border-bottom-width","0","");
			  		//break;
				}
			}
		}
		
		if(!hasfonthover){
			generateCss();
			if($("#css").val().indexOf(".font:hover")<0){
		    	$("#divContainer").find("style").text($("#css").val()+" \n .font:hover{  color:"+color+"!important; }")
			}
		}
		

		//若无改设置,则添加标题栏鼠标样式设置
		if(!hasheadhover  && isheadovercheck===true){
			generateCss();
			if($("#css").val().indexOf(".header:hover")<0){
				$("#divContainer").find("style").text($("#css").val()+" \n .header:hover{  background-color:"+color+"!important; }")
			}
		  	/*write(".header:hover{");
            write("  background-color:"+color+";");
		    write("}");		*/
		}
	
		
		
		//generateCss();
	}
	
	//保存样式方法
	function generateCss(){
		$("#css").val("");
		if(true){
				$("#css").val("");
				var replaceStr = "#item_"+styleid;
				
				var sheet = $("#divContainer").find("style")[0].sheet;
				var theRules;
				if (sheet.cssRules)
					theRules = sheet.cssRules
				else if (sheet.rules)
					theRules = sheet.rules
				for( i=0;i<theRules.length;i++){
						var rule = theRules[i];
						var value=rule.cssText;
						$("#css").val($("#css").val()+value.replace(new RegExp(replaceStr,'gm'),'').replace(new RegExp(';','gm'),';\n').replace(new RegExp('{','gm'),'{\n').replace(new RegExp('}','gm'),'}\n'));
				}
				//$("#css").val($("#divContainer").find("style").text().replace(new RegExp(replaceStr,'gm'),''));
				return;
		}
		var str=$("#cssBak").val();
		str=str.replace(/(\r|\n)+/g,"");
		var re = /(.*?){(.*?)}/g;
		var arr;
		var index=0;
		//鼠标背景色是否开启
		var isheadovercheck=false;
		if($("input[name='isbgcolopen']").get(0)!=undefined){
			isheadovercheck=$("input[name='isbgcolopen']").get(0).checked;
		}
		//底边颜色开关
        var isbtcolcheck=false;
		if($("input[name='isbtcolopen']").get(0)!=undefined){
			isbtcolcheck=$("input[name='isbtcolopen']").get(0).checked;
		}
		var addflag=false;

		//新增的三种设置
		var hasfonthover=false,hasheadhover=false;
		while ((arr = re.exec(str)) != null){
			var selector= $.trim(arr[1]); //选择器
			var value=arr[2]; //值
			if(selector==='.font:hover'  &&  value!==''){
				hasfonthover=true;
			}else if(selector==='.font:hover'  &&  value==='')
				 continue;
			if(selector==='.header:hover' &&  value!==''){
				hasheadhover=true;
			}else if(selector==='.header:hover' &&  value==='')
				continue;
			
			//如果鼠标背景色开关关闭,则直接继续
			if(selector==='.header:hover' && !isheadovercheck){
			   continue;
			}
			

			write(selector+"{");
			
			jQuery.each(value.split(";"),function(i,field){
				field=$.trim(field);
				if(field!=""){
					var pos=field.indexOf(":");
					field=$.trim(field.substring(0,pos));
					//如果鼠标背景色开关关闭,则直接继续
					
					writeAttr(selector,field,index);
					if(selector==='.title' && !isbtcolcheck  && !addflag ){
					    write("border-bottom-width:0px !important;");
						addflag=true;
					}else if(selector==='.title' && isbtcolcheck && field==='border-bottom-width'){
					     write("border-bottom-width:2px;");
					}
				}
			});

			if(selector==='.title' && isbtcolcheck){
				//添加底边设置属性
				if(value.indexOf("border-bottom-width")<0){
				   write("border-bottom-width:2px;");
				}
				if(value.indexOf("border-bottom-style")<0){
				   write("border-bottom-style:solid;");
				}
				if(value.indexOf("border-bottom-color")<0){
				   write("border-bottom-color:"+$("#border_bottom_color").html()+";");
				}
				
			}
			
		

            write("}");		
			index++;
		}
		//若无改设置,则添加字体鼠标样式设置
		if(!hasfonthover){
		  	write(".font:hover{");
            write("  color:"+$("#font_hover").html()+"!important;");
		    write("}");		
		}
		

		//若无改设置,则添加标题栏鼠标样式设置
		if(!hasheadhover  && isheadovercheck===true){
		  	write(".header:hover{");
            write("  background-color:"+$("#head_hover").html()+"!important;");
		    write("}");		
		}

	}
	
	function RGBToHex(rgb){ 
	   var regexp = /[0-9]{0,3}/g;  
	   var re = rgb.match(regexp);//利用正则表达式去掉多余的部分,将rgb中的数字提取
	   var hexColor = "#"; var hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];  
	   for (var i = 0; i < re.length; i++) {
			var r = null, c = re[i], l = c; 
			var hexAr = [];
			while (c > 16){  
				  r = c % 16;  
				  c = (c / 16) >> 0; 
				  hexAr.push(hex[r]);  
			 } hexAr.push(hex[c]);
			 if(l < 16&&l != ""){        
				 hexAr.push(0)
			 }
		   hexColor += hexAr.reverse().join(''); 
		}  
	   //alert(hexColor)  
	   return hexColor;  
	}  

    function toHex(value){
       var items;
      if(value.indexOf("rgb")>=0){
	     value=RGBToHex(value);
       }
       return value;
    } 
    
	function writeAttr(classid,attr,index){
		try		{
			var value="";
 
			if(attr=="font-weight"){ //特殊处理
				
				var posBegin=classid.lastIndexOf(".");
				var tempClassid=classid.substring(posBegin+1);
				//alert("tempClassid:"+tempClassid)mm
				
				if($(".font-weight[r_id="+tempClassid+"]")[0].checked){
					value="bold";
				} else {
					value="normal";
				}	
				
			}  else if(classid==".header" && attr=="width"|| classid==".content" &&  attr=="width"){
				value="100%";
			}else {
				var pos=classid.indexOf(":hover");
				if(pos!=-1){
					
					 if(classid==='.font:hover'){
                         var hovercol=$("#font_hover").html();
					     value =  hovercol+"!important";
					 }else if(classid==='.header:hover'){
					     var hovercol=$("#head_hover").html();
					     value =  hovercol+"!important";
					 }else{

						//alert(index)
						var ruleId=index;
						var attrScript=getScriptStyleString(attr);
						var styleMenu=document.getElementById("styleMenu");
						var oStyleSheet=document.getElementById("styleMenu").styleSheet||document.getElementById("styleMenu").sheet;
						var rules=oStyleSheet.rules||oStyleSheet.cssRules;
						value=eval("rules["+ruleId+"].style."+attrScript);
						if(attr=='color'||attr=='font-family'){
							if(value.indexOf("important")<0){
								value =  value+"!important";
							}
						}
						var posTemp=value.indexOf("url(");
						if(posTemp!=-1){
							var posTemp2=value.indexOf(")",posTemp);
							if(posTemp2!=-1){
								value=value.substring(posTemp+4,posTemp2);
							}
							value="url("+value+")";
						}
					 }
                //字体设置
				} else if(classid==='.font'  &&  attr=='color' ){
				
				     value =  $("#font_color").html()+"!important";
				}else{		
					if(classid==='.toolbar'){
			             value=$(" .item "+classid).css(attr);	
			         }else{
					     value=$(classid).css(attr);
						 if(classid==='.title' &&  attr==='border-bottom-color'){
							 value=toHex(value);
						 }
					 }   
					if(attr=='color'||attr=='font-family' || attr==='border-bottom-color'){
						value =  value+"!important";
					}
					
				}
			}

			//以下消除image相关的http部分
			var pos=value.indexOf("http://");
			if(pos!=-1){
				var pos2=value.indexOf("/",pos+7);
				if(pos!=-1) value=value.substring(0,pos)+value.substring(pos2);
			}
			if("0"==(value+"").indexOf("rgb")){
				//alert(value)
				if(value.indexOf("important")>-1){
					value= value.replace("!important","");
					value =  value.colorHex();
					value = value+"!important";
				}else{
					value = value.colorHex();
				}
			
				//alert("¥"+value)
			}
			write("	"+attr+":"+value+";");
		}
		catch (e){			
			//alert("|"+classid+"|:|"+attr+"|"+"|"+e)
		}
		
	}
	function write(str){
		//alert($("#css").val()+"\n"+str);
		$("#css").val($("#css").val()+"\n"+str);
	}

	String.prototype.endWith=function(str){   
		if(str==null||str==""||this.length==0||str.length>this.length)   
		  return false;   
		if(this.substring(this.length-str.length)==str)   
		  return true;   
		else   
		  return false;   
		return true;   
	};
	
	function ItemCount_KeyPress()
{
	var evt = getEvent();
	var keyCode = evt.which ? evt.which : evt.keyCode;
 if(!(((keyCode>=48) && (keyCode<=57))|| keyCode==45))
  {
     if (evt.keyCode) {
     	evt.keyCode = 0;evt.returnValue=false;     
     } else {
     	evt.which = 0;evt.preventDefault();
     }
     
	 
	 
  }
} 
	$(document).ready(function(){

			//以下处理所有spin插件
			$('input.spin').bind("keypress",ItemCount_KeyPress);
			$('input.spin').spin({min:1, max:100,imageBasePath:'/js/jquery/plugins/spin/'});	

			//以下处理所有filetree插件
			$(".filetree").each(function(){
				var r_id=$(this).attr("r_id");
				var r_attr=$(this).attr("r_attr");
				var value="";
				if(r_id!=null){
					if(r_attr=="src"){
						value=$("."+r_id).attr("src");

						if(value==undefined) value="none";
						var pos=value.indexOf("http://");			
						
						if(pos!=-1) {
							var pos2=value.indexOf("/",pos+7);							
							value=value.substring(pos2);
							//alert(value)
						}
					} else {
						value=getScriptStyleValue(r_id,r_attr);
						
						var posTemp=value.indexOf("url(");
						if(posTemp!=-1){
							var posTemp2=value.indexOf(")",posTemp);
							if(posTemp2!=-1){
								value=value.substring(posTemp+4,posTemp2);
							}
						}
						
						
						var pos=value.indexOf("http://");			
						
						if(pos!=-1) {
							var pos2=value.indexOf("/",pos+7);							
							value=value.substring(pos2);
							//alert(value)
						}
						if(value==undefined) value="none";
						 pos=value.indexOf("//");							
						if(pos!=-1) {
							
							var pos2=value.indexOf("/",pos+2);
							var pos3=value.indexOf("\")",pos2);
							value=value.substring(pos2,pos3);
						}
					}

				}
				value=value.replace(/"/g, "");
				if(value.endWith("none")){
					value = "";
				}
				this.value=value;
				$(this).filetree({
					file:value,
					call:function(src){
							if(r_attr=="src"){
								$("."+r_id).attr("src",src);
							}else {
								if(src == ""){
									setScriptStyleValue(r_id,r_attr,"");
								}else{
									setScriptStyleValue(r_id,r_attr,"url('"+src+"')");
								}
								
								//$("."+r_id).css(r_attr,"url('"+src+"')");
							}
					}
				});
				$(this).bind("change",function(){
					if($(this).val() == ""){
						setScriptStyleValue(r_id,r_attr,"");
					}
				});
			});
			
			var language = readCookie("languageidweaver");
			//以下处理所有color插件
				
			
            //设置颜色
            function  setColor(obj,piccolor){
				   
				    var currentSetSpan=obj.prev();
					var value=piccolor;
					var color=piccolor;
				
					currentSetSpan.text(value);
					currentSetSpan.css("background-color",value);
					//currentSetSpan.css("color",color==""?"#fff":color);
					
					//alert($("#"+objFormId).html())

					var r_id=currentSetSpan.attr("r_id");
					var r_attr=currentSetSpan.attr("r_attr");
				   
					if(r_id==='head_hover'){
						 generateCss1(r_id,"background-color",value);
						 //$("#divContainer").find("style").html($("#css").val());
						 return;
					}else if(r_id==='font_hover'){
						 generateCss1(r_id,"color",value);
						// $("#divContainer").find("style").html($("#css").val()); 
						return;
					}else if(r_id==='font'){
						 generateCss1(r_id,"color",value);
						// $("#divContainer").find("style").html($("#css").val());
						  return;
					}else if(r_id==='title' && r_attr==='border-bottom-color'){
							  if($("input[name='isbtcolopen']").get(0).checked){
							  	  //$(".title").css('border-bottom-width','0px');
								 // $(".title").css('border-bottom-color',$("#border_bottom_color").html());
							  	   generateCss1(r_id,"border-bottom-width","2px");
							  	  generateCss1 (r_id,"border-bottom-style","solid");
								   generateCss1(r_id,"border-bottom-color",$("#border_bottom_color").html());
								  //generateCss1("title","")
							  }else{
							 		 //$(".title").css('border-bottom-style','none');
							 		  generateCss1(r_id,"border-bottom-width","0");
							 		  
							  }
							  //generateCss1(r_id,"color",value);
							 // $("#divContainer").find("style").html($("#css").val());
							 return;
						 
					}
					
					setScriptStyleValue(r_id,r_attr,value);			
			}

			$(".colorblock").each(function(){				
				    
				var r_id=$(this).attr("r_id");
				var r_attr=$(this).attr("r_attr");
				var color="#ffffff";
				if(r_id!=null){
					if(r_id==='font_hover'){
					   color=getHoverColor('.font:hover','color'); 
					   
					}else if(r_id==='head_hover'){
					   color=getHoverColor('.header:hover','background-color'); }
					 else if(r_id==='title' &&  r_attr==='border-bottom-color'){
					   color=getHoverColor('.title','border-bottom-color');   
					 }else
					 color=getScriptStyleValue(r_id,r_attr);
				}
				color=$.trim(color);
				if(color.indexOf("rgb")>-1){
					color =color.colorHex();
				}
				$(this).text(color);							
				$(this).css("background-color",color);
				
				var colorpic=$("<img src='/js/jquery/plugins/farbtastic/color_wev8.png' style='cursor:hand;margin-left:5px'  border=0/>");
                $(this).after(colorpic);
                
  
                colorpic.spectrum({
					showPalette:true,
					showInput:true,
					allowEmpty:false,
					preferredFormat: "hex",
					chooseText:SystemEnv.getHtmlNoteName(3451,language),
					cancelText:SystemEnv.getHtmlNoteName(3516,language),
					color:color,
					noclickhide:true,
					hide: function(color) {
	                		color = color.toHexString(); // #ff0000
							setColor(colorpic,color);
					},
					move: function(color) {
						    //console.dir(this);
							color = color.toHexString(); // #ff0000
							setColor(colorpic,color);
							
					},
					palette: [
							["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],
							["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],
							["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],
							["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],
							["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],
							["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],
							["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],
							["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]
						]
				});



				//$(this).after("<img src='/js/jquery/plugins/farbtastic/color_wev8.png' style='cursor:hand;margin-left:5px'  onclick='doColorClick(this,event)' border=0/>"); 

				if(color=="transparent") {
					//this.parentNode.style.visibility='hidden';
					$(this).text("#ffffff");
				}

				$(this).width(60);
			});	
			
			////以下处理所有背景透明的checkbox框
			$(".transparent").each(function(){
				var t_id=$(this).attr("t_id");
				var tObj=$("#"+t_id)[0];
			
				//if(tObj==undefined) break;
				var r_id=$(tObj).attr("r_id");
				var r_attr=$(tObj).attr("r_attr");

				var color="#ffffff";
				if(r_id!=null){
					color=$("."+r_id).css(r_attr);
				}
				
				//alert(color)
				if(color=="transparent") this.checked=true;

				$(this).bind("click", function(){
				  //得到所关联的对像
				  var t_id=$(this).attr("t_id");
				  var tObj=$("#"+t_id)[0];
				  var r_id=$(tObj).attr("r_id");
				  var r_attr=$(tObj).attr("r_attr");

				  if(this.checked==true){ //透明					
					$("."+r_id).css(r_attr,"transparent");//设置背景
					tObj.parentNode.style.visibility='hidden';
				  } else {//非透明
					$("."+r_id).css(r_attr,$(tObj).text());//设置背景
					$(tObj).parent()[0].style.visibility='visible';
				  }
				}); 
			});


			//字体加粗
			$(".font-weight").each(function(){
				var r_id=$(this).attr("r_id");
				var r_attr=$(this).attr("r_attr");
				var cValue=getScriptStyleValue(r_id,r_attr);
						
				//alert(cValue)
				if(cValue=="700" || cValue=="bold") this.checked=true;

				changeCheckboxStatus4tzCheckBox(this, this.checked);

				$(this).bind("click",function(){
					//alert(this.checked)
					if(this.checked)
						setScriptStyleValue(r_id,r_attr,"700");						
					else 
						setScriptStyleValue(r_id,r_attr,"400");
				});	
			});
			
			//字体样式
			$(".font-style").each(function(){
				var r_id=$(this).attr("r_id");
				var r_attr=$(this).attr("r_attr");
				var cValue=getScriptStyleValue(r_id,r_attr);
				cValue=$.trim(cValue);

				if(cValue=="italic") this.checked=true;

				changeCheckboxStatus4tzCheckBox(this, this.checked);
				
				$(this).bind("click",function(){
					if(this.checked)
						setScriptStyleValue(r_id,r_attr,"italic");							
					else 
						setScriptStyleValue(r_id,r_attr,"normal");
				});


			});	
            
			  //添加字体下边框checkbox	
			  $("input[name='isbtcolopen']").each(function(){
				  var current=$(this);
				  var btchecktitle=$("#border_bottom_color");
				  if(btchecktitle.html()!=='#ffffff' && $(".title").css("border-bottom-width")!=='0px'){
					  this.checked=true;
					  changeCheckboxStatus4tzCheckBox(this,true); 
				  }
				   current.bind("click",function(){
				     var colorobj = $(current).parents(".fieldName:first").find(".colorblock");
					  setColor(colorobj.next(),colorobj.text());
					 //  $("#divContainer").find("style").html($("#css").val());
				   
				  });
			   });	

			 $("input[name='isbgcolopen']").each(function(){
				  var current=$(this);
				  var btchecktitle=$("#head_hover").html();
				  if(getRuleStyleCssText("header:hover")!=''){
					  this.checked=true;
					  changeCheckboxStatus4tzCheckBox(this,true); 
				  }
				   current.bind("click",function(){
					   var colorobj = $(current).parents(".fieldName:first").find(".colorblock");
					  setColor(colorobj.next(),colorobj.text());
				       //$("#divContainer").find("style").html($("#css").val());
				   });
			   });	


			$(".line-style").each(function(){
				var r_id=$(this).attr("r_id");
				var r_attr=$(this).attr("r_attr");
				var cValue=$("."+r_id).css(r_attr);
				cValue=$.trim(cValue);
				for(var i=0;i<this.children.length;i++){
					var span_child=this.children[i];
					var child = $(span_child).find("input")[0];
					
					$(span_child).bind("click",function(){
						$("."+r_id).css(r_attr,$(this).find("input").val());
						setSheetStyle(r_id,r_attr,$(this).find("input").val(),'important');
					});

					if(child.value==cValue){
						child.checked=true;
						//$(child).trigger("click");
					}
					
					changeRadioStatus4tzRadio(child, child.checked);
					
				}
			});

			$(".height").each(function(){
				var r_id=$(this).attr("r_id");
				var r_attr=$(this).attr("r_attr");
				var cValue=getScriptStyleValue(r_id,r_attr);
				cValue=$.trim(cValue);
				
				if(cValue=="medium"){
					cValue=3; 
				} else {
					var tempPos=cValue.indexOf("px");
					if(tempPos!=-1) cValue=cValue.substring(0,tempPos);		
				}
				
				this.value=cValue;
				$(this).bind("change",function(){
					//alert(r_id+"^"+r_attr+"$"+this.value)
					setScriptStyleValue(r_id,r_attr,this.value);
				});
				
			});
	});	

	//获取鼠标悬浮颜色
	function getHoverColor(classname,attr){
	     
		var str=$("#cssBak").val();
		str=str.replace(/(\r|\n)+/g,"");
		var re = /(.*?){(.*?)}/g;
		var arr,fieldname,val='#000000';
		var index=0;
		while ((arr = re.exec(str)) != null){
			var selector= $.trim(arr[1]); //选择器
			if(selector===classname){
				var value=arr[2]; //值	
			    jQuery.each(value.split(";"),function(i,field){
	    			field=$.trim(field);
					if(field!=""){
						var pos=field.indexOf(":");
						fieldname=field.substring(0,pos);
						if(fieldname===attr){
							val=$.trim(field.substring(pos+1));		
							pos=val.indexOf("!important");
							if(pos>0){
							   val=val.substring(0,pos);
							}
						}
					}
		    	});
                break;
		   }
	   }
       return val;
	}

	function getScriptStyleString(str){
		var returnStr=str;
		if(str=="font-size") returnStr="fontSize";
		else if(str=="font-family") returnStr="fontFamily";
		else if(str=="font-weight") returnStr="fontWeight";
		else if(str=="font-style") returnStr="fontStyle";
		else if(str=="background-color") returnStr="backgroundColor";
		else if(str=="background-image") returnStr="backgroundImage";		
		return returnStr;
	}
	function getScriptStyleValue(r_id,r_attr){
		var returnStr="";

		var pos=r_id.indexOf("rule");
		if(pos!=-1){
			r_attr=getScriptStyleString(r_attr);			
			var ruleId=r_id.substring(pos+4);
			var styleMenu=document.getElementById("styleMenu");
			var oStyleSheet=document.getElementById("styleMenu").styleSheet||document.getElementById("styleMenu").sheet;
			var rules=oStyleSheet.rules||oStyleSheet.cssRules;
			returnStr=eval("rules["+ruleId+"].style."+r_attr);
			
			var posTemp=returnStr.indexOf("url(");
			if(posTemp!=-1){
				var posTemp2=returnStr.indexOf(")",posTemp);
				if(posTemp2!=-1){
					returnStr=returnStr.substring(posTemp+4,posTemp2);
				}
			}			
			//alert("oStyleSheet.rules["+ruleId+"].style."+r_attr+":"+returnStr)
		} else {	
			if(r_attr=='color'||r_attr=='font-family'){
				returnStr =  returnStr+"!important";
			}
			returnStr=$("."+r_id).css(r_attr);
		}
			if("0"==(returnStr+"").indexOf("rgb")){
				returnStr=returnStr.colorHex();
			}
			return returnStr;
	}
	function setScriptStyleValue(r_id,r_attr,value){
		//alert(r_id)
		if(r_attr!="font-weight" && r_attr!="font-style"){
			if(!isNaN(value)&&value!=''){
					value=value+"px"
			}
		}
		var pos=r_id.indexOf("rule");
		if(pos!=-1){
			var ruleId=r_id.substring(pos+4);
			var styleMenu=document.getElementById("styleMenu");
			var oStyleSheet=document.getElementById("styleMenu").styleSheet||document.getElementById("styleMenu").sheet;
			var rules=oStyleSheet.rules||oStyleSheet.cssRules;
		
			$(rules[ruleId]).css('cssText',$(rules[ruleId])[0].style.cssText+";"+r_attr+':'+value+'!important');
		} else {
			if(r_id=="title"||r_id=="icon"||r_id=="toolbar"){
				if(""==value){
					//还原到页面的样式
					$("."+r_id).css("font-family","");
					//alert($("."+r_id).css('cssText'));
					$("."+r_id).css('cssText',$("."+r_id)[0].style.cssText+";"+r_attr+':'+value+'!important;position:absolute');
					//alert($("."+r_id).css('cssText'));
				}else{
					//alert(r_id)
					
					setSheetStyle(r_id,r_attr,value,'important');
					setSheetStyle(r_id,"position","absolute",'');	
					//$("."+r_id).css('cssText',$("."+r_id)[0].style.cssText+";"+r_attr+':'+value+'!important;position:absolute');
				}
			}else{
					//$("."+r_id).css('cssText',$("."+r_id)[0].style.cssText+";"+r_attr+':'+value+'!important;');
				//$("."+r_id).css(r_attr,value);
					setSheetStyle(r_id,r_attr,value,'important');
					//setSheetStyle(r_id,"position","absolute",'');	
			}
			
		}
		
		
	}
	
	function setSheetStyle(r_id,attr,value,important){
			var sheet = $("#divContainer").find("style")[0].sheet;
			var theRules;
			if (sheet.cssRules)
				theRules = sheet.cssRules
			else if (sheet.rules)
				theRules = sheet.rules
			
			for( i=0;i<theRules.length;i++){
					var rule = theRules[i];
					var selector= rule.selectorText //选择器
					var replaceStr = "#item_"+styleid+" ";
					selector = selector.replace(new RegExp(replaceStr,'gm'),'');
					//var value=rule.cssText;
					
					if(selector==="."+r_id){
						
						rule.style.setProperty(attr,value,important);
						
					}
			}
	}
	
	function getRuleStyleCssText(r_id){
			var sheet = $("#divContainer").find("style")[0].sheet;
			var theRules;
			if (sheet.cssRules)
				theRules = sheet.cssRules
			else if (sheet.rules)
				theRules = sheet.rules
			
			for( i=0;i<theRules.length;i++){
					var rule = theRules[i];
					var selector= rule.selectorText //选择器
					var replaceStr = "#item_"+styleid+" ";
					selector = selector.replace(new RegExp(replaceStr,'gm'),'');
					//var value=rule.cssText;
					
					if(selector==="."+r_id){
						
						return rule.style.cssText;
					}
			}
			
			return "";
	}