var isIE = (document.all && window.ActiveXObject && !window.opera) ? true : false;
document.write('<style type="text/css">');
document.write('.color_div_o {width:16px;height:16px;padding:4px 0 0 4px;background:#B6BDD2;cursor:crosshair;}');
document.write('.color_div_t {width:16px;height:16px;padding:4px 0 0 4px;background:#F1F2F3;}');
document.write('.color_div {border:#808080 1px solid;width:10px;height:10px;line-height:10px;font-size:1px;}');
document.write('</style>');
var color_id = 1; var color_bk = color_htm = '';
color_htm += '<table cellpadding="0" cellspacing="0" bgcolor="#2875B9" width="160">';
color_htm += '<tr><td width="2" height="20"> </td>';
color_htm += '<td><input type="text" style="width:60px;height:12px;border:#A0A0A0 1px solid;" value="" id="color_viewview" onblur="color_select(this.value);" onkeyup="color_view(this.value);" ondblclick="this.value=\'\';"/></td>';
color_htm += '<td>&nbsp;&nbsp;&nbsp;</td>';
color_htm += '<td align="right" style="color:#FFFFFF;font-weight:bold;cursor:pointer;" onclick="color_close();" title="Close">&#215;&nbsp;</td>';
color_htm += '</tr>';
color_htm += '</table>';
color_htm += '<div id="eminer_color_show"></div>';
function Eh(t) {
	var t = t ? t : 'select';
	if(isIE) {
		var arVersion = navigator.appVersion.split("MSIE"); var IEversion = parseFloat(arVersion[1]);		
		if(IEversion >= 7 || IEversion < 5) return;
		var ss = document.body.getElementsByTagName(t);					
		for(var i=0;i<ss.length;i++) {ss[i].style.visibility = 'hidden';}
	}
}
function Es(t) {
	var t = t ? t : 'select';
	if(isIE) {
		var arVersion = navigator.appVersion.split("MSIE"); var IEversion = parseFloat(arVersion[1]);		
		if(IEversion >= 7 || IEversion < 5) return;
		var ss = document.body.getElementsByTagName(t);					
		for(var i=0;i<ss.length;i++) {ss[i].style.visibility = 'visible';}
	}
}
function color_show(id, color, obj) {
	Eh();
	if(document.getElementById('eminer_color') == null) {
		var eminer_color_div = document.createElement("div");
		with(eminer_color_div.style) {zIndex = 9999; position = 'absolute'; display = 'none'; width = '160px'; padding = '1px'; top = 0; left = 0; border = '#A0A0A0 1px solid'; backgroundColor = '#FFFFFF';}
		eminer_color_div.id = 'eminer_color';
		document.body.appendChild(eminer_color_div);
	}
	var aTag = obj; var leftpos = toppos = 0;
	do {aTag = aTag.offsetParent; leftpos	+= aTag.offsetLeft; toppos += aTag.offsetTop;
	} while(aTag.offsetParent != null);
	document.getElementById('eminer_color').style.left = (obj.offsetLeft + leftpos) + 'px';
	document.getElementById('eminer_color').style.top = (obj.offsetTop + toppos + 20) + 'px';
	document.getElementById('eminer_color').innerHTML = color_htm;
	color_id = id;
	color_bk = color;
	document.getElementById('eminer_color').style.display = '';
	if(color) color_view(color);
	color_setup(color);
}
function color_hide() {document.getElementById('eminer_color').style.display = 'none'; Es();} 
function color_close() {
	color_hide(); 
	document.getElementById('color_img_'+color_id).style.backgroundColor = 'rgb('+color_bk+')';}
function color_select(color) {document.getElementById('color_input_'+color_id).value = color.replace('rgb(', '').replace(')', ''); document.getElementById('color_img_'+color_id).style.backgroundColor = color; color_hide();}
function color_setup(color) {
	var colors = [
	'rgb(0,0,0)','rgb(153,51,0)','rgb(51,51,0)','rgb(0,51,0)','rgb(0,51,102)','rgb(0,0,128)','rgb(51,51,153)','rgb(51,51,51)','rgb(128,0,0)','rgb(255,102,0)','rgb(128,128,0)','rgb(0,128,0)','rgb(0,128,128)','rgb(0,0,255)','rgb(0,0,0)','rgb(128,128,128)','rgb(255,0,0)','rgb(255,153,0)','rgb(153,204,0)','rgb(51,153,102)','rgb(51,204,204)','rgb(51,102,255)','rgb(128,0,128)','rgb(153,153,153)','rgb(255,0,255)','rgb(255,204,0)','rgb(255,255,0)','rgb(0,255,0)','rgb(0,255,255)','rgb(0,204,255)','rgb(153,51,102)','rgb(192,192,192)','rgb(255,153,204)','rgb(255,204,153)','rgb(255,255,153)','rgb(204,255,204)','rgb(204,255,255)','rgb(153,204,255)','rgb(204,153,255)','rgb(255,255,255)'];
	var colors_select = '';
	colors_select += '<table cellpadding="0" cellspacing="0">'
	for(i = 0; i < colors.length; i++) {
		if(i%8 == 0) colors_select += '<tr>';
		colors_select += '<td width="20" height="20">';
		if(color == colors[i]) {
			colors_select += '<div class="color_div_o" onmouseover="color_view(\''+colors[i]+'\');" onclick="color_select(\''+colors[i]+'\');">';
		} else {
			colors_select += '<div class="color_div_t" onmouseover="this.className=\'color_div_o\';color_view(\''+colors[i]+'\');" onmouseout="this.className=\'color_div_t\';" onclick="color_select(\''+colors[i]+'\');">';
		}
		colors_select += '<div class="color_div" style="background:'+colors[i]+'">&nbsp;</div></div></td>';
		if(i%8 == 7) colors_select += '</tr>';
	}
	colors_select += '</table>';
	document.getElementById('eminer_color_show').innerHTML = colors_select;
}
function color_view(color) {try {document.getElementById('color_viewview').value = color; document.getElementById('color_viewview').style.color = color; document.getElementById('color_img_'+color_id).style.backgroundColor = color;} catch(e) {}}