function dechex(vDecVal) {
	var iDecVal=parseInt(vDecVal);
	if (iDecVal<0) iDecVal=0;
	if (iDecVal>255) iDecVal=255;
	var sHexVal=iDecVal.toString(16);
	sHexVal=sHexVal.toUpperCase();
	while(sHexVal.length<2) sHexVal="0"+sHexVal;
	return sHexVal;
}

function hsb2rgb(hue, sat, val) {
	var red, grn, blu, i, f, p, q, t;
	hue%=360; 
	if (val==0) {
		red = 0; 
		grn = 0; 
		blu = 0;
	} else {
		sat/=100; 
		val/=100; 
		hue/=60; 
		i = Math.floor(hue); 
		f = hue-i; 
		p = val*(1-sat); 
		q = val*(1-(sat*f)); 
		t = val*(1-(sat*(1-f)));
		switch (i) {
			case 0:
				red=val; grn=t; blu=p;
				break;
			case 1:
				red=q; grn=val; blu=p;
				break;
			case 2:
				red=p; grn=val; blu=t;
				break;
			case 3:
				red=p; grn=q; blu=val;
				break;
			case 4:
				red=t; grn=p; blu=val;
				break;
			case 5:
				red=val; grn=p; blu=q;
				break;
			default:
				break;
		}
		red = Math.floor(red*255); 
		grn = Math.floor(grn*255); 
		blu = Math.floor(blu*255);
	}
	var hstr=dechex(red)+dechex(grn)+dechex(blu);
	//
	return ({r:red, g:grn, b:blu, s:hstr}); 
} 
// 
function rgb2hsb(red, grn, blu) {
	var x, val, f, i, hue, sat, val; 
	red/=255; 
	grn/=255; 
	blu/=255; 
	x = Math.min(Math.min(red, grn), blu); 
	val = Math.max(Math.max(red, grn), blu); 
	if (x==val) {
		hue = undefined;
		sat = 0; 
		val = val*100;
	} else {
		f = (red == x) ? grn-blu : ((grn == x) ? blu-red : red-grn);
		i = (red == x) ? 3 : ((grn == x) ? 5 : 1);
		hue = Math.floor((i-f/(val-x))*60)%360;
		sat = Math.floor(((val-x)/val)*100);
		val = Math.floor(val*100);
	}
	return({h:hue, s:sat, v:val, b:val});
}

//==============================================================================

function wd_circle2hsb(iX, iY, iBrightness) {
	var iHsbRadius=170; var iSatRadius=150;
	iX-=iHsbRadius; iY-=iHsbRadius;
	var iAngle=-1;
	var iSaturation=parseInt(Math.sqrt(Math.pow(Math.abs(iX),2)+Math.pow(Math.abs(iY),2))/(iSatRadius/100));
	var iBaseAngle=parseInt(Math.atan(Math.abs(iY)/Math.abs(iX))*180/Math.PI);
	if (iX>0) {
		if (iY>0) {
			iAngle=90+iBaseAngle;
		} else if (iY<0) {
			iAngle=90-iBaseAngle;
		} else { //iY==0
			iAngle=90;
		}
	} else if (iX<0) {
		if (iY>0) {
			iAngle=270-iBaseAngle;
		} else if (iY<0) {
			iAngle=270+iBaseAngle;
		} else { //iY==0
			iAngle=270;
		}
	} else { // iX==0
		if (iY>0) {
			iAngle=180;
		} else if (iY<0) {
			iAngle=0;
		} else { //iY==0
			iAngle=0;
		}
	}
	return ({h:iAngle, s:iSaturation, b:iBrightness});
}
function hsb2xy(fH, iS, iB, iForce) {
	if (!iForce && iS>100) {
		var iRadius=160;
	} else {
		var iRadius=Math.abs(iS*1.5);
	}
		var iLeft=0;
		var iTop=0;
		var fSin=-1; var fCos=-1;
		if (fH==0||fH==360) {
			iLeft=170;
			iTop=170-iRadius;
		} else if (fH<90) {
			fSin=Math.sin((90-fH)/180*Math.PI);
			fCos=Math.cos((90-fH)/180*Math.PI);
			iLeft=170+Math.abs(iRadius*fCos);
			iTop=170-Math.abs(iRadius*fSin);
		} else if (fH==90) {
			iLeft=170+iRadius;
			iTop=170;
		} else if (fH<180) {
			fSin=Math.sin((180-fH)/180*Math.PI);
			fCos=Math.cos((180-fH)/180*Math.PI);
			iLeft=170+Math.abs(iRadius*fSin);
			iTop=170+Math.abs(iRadius*fCos);
		} else if (fH==180) {
			iLeft=170;
			iTop=170+iRadius;
		} else if (fH<270) {
			fSin=Math.sin((270-fH)/180*Math.PI);
			fCos=Math.cos((270-fH)/180*Math.PI);
			iLeft=170-Math.abs(iRadius*fCos);
			iTop=170+Math.abs(iRadius*fSin);
		} else if (fH==270) {
			iLeft=170-iRadius;
			iTop=170;
		} else if (fH<360) {
			fSin=Math.sin((360-fH)/180*Math.PI);
			fCos=Math.cos((360-fH)/180*Math.PI);
			iLeft=170-Math.abs(iRadius*fSin);
			iTop=170-Math.abs(iRadius*fCos);
		}
	return ({x:iLeft, y:iTop});
}
function PosCursor(fH, iS, iB, iCursor) {
	if (!iCursor) iCursor=0;
	var theCursor=document.getElementById("wd_div_cursor"+iCursor);
	if (theCursor) {
		if (fH==-1 && iS==-1 && iB==-1) {
			theCursor.style.left=(-3000)+"px";
			theCursor.style.top=(-3000)+"px";
		} else {
			if (iS==100&&(fH%15==0)) iS+=1;
			var theCoords=hsb2xy(fH, iS, iB);
			theCursor.style.left=theCoords.x-3+"px";
			theCursor.style.top=theCoords.y-3+"px";
		}
	}
}
function FillLine(fH, iS, iB, iLine) {
	var theTr=document.getElementById("wd_tr_line"+iLine);
	if (theTr && fH==-1 && iS==-1 && iB==-1) {
		theTr.cells[0].style.backgroundColor="#F8F9FA";
		theTr.cells[1].style.backgroundColor="#F8F9FA";
		theTr.cells[2].style.backgroundColor="#F8F9FA";
		theTr.cells[3].style.backgroundColor="#F8F9FA";
		theTr.cells[4].style.backgroundColor="#F8F9FA";
		theTr.cells[5].style.backgroundColor="#F8F9FA";
		theTr.cells[6].style.backgroundColor="#F8F9FA";
		theTr.cells[7].style.backgroundColor="#F8F9FA";
		theTr.cells[8].style.backgroundColor="#F8F9FA";
	} else if (theTr) {
		var theRgb=hsb2rgb(fH, iS, iB);
		theTr.cells[0].style.backgroundColor="#"+theRgb.s;
		//
		var iR=theRgb.r; var iG=theRgb.g; var iBl=theRgb.b;
		//
		theRgb=hsb2rgb(fH, (iS/2), 100-(100-iB)/2);
		theTr.cells[3].style.backgroundColor="#"+theRgb.s;
		theRgb=hsb2rgb(fH, (iS/3), 100-(100-iB)/3);
		theTr.cells[2].style.backgroundColor="#"+theRgb.s;
		theRgb=hsb2rgb(fH, (iS/4), 100-(100-iB)/4);
		theTr.cells[1].style.backgroundColor="#"+theRgb.s;
		//
		theRgb=hsb2rgb(fH, 2*(iS/3), 2*(iB/3));
		theTr.cells[4].style.backgroundColor="#"+theRgb.s;
		theRgb=hsb2rgb(fH, 2*(iS/3), 1*(iB/3));
		theTr.cells[5].style.backgroundColor="#"+theRgb.s;
		//
		theRgb=hsb2rgb(fH, (iS/2), iB-(iB-50)/2);
		theTr.cells[8].style.backgroundColor="#"+theRgb.s;
		theRgb=hsb2rgb(fH, (iS/3), iB-(iB-50)/3);
		theTr.cells[7].style.backgroundColor="#"+theRgb.s;
		theRgb=hsb2rgb(fH, (iS/4), iB-(iB-50)/4);
		theTr.cells[6].style.backgroundColor="#"+theRgb.s;
	}
}
function FillTable(iSchema) {
	var arrColors=new Array();
	switch (iSchema) {
		case 1:
			var theTr=document.getElementById("wd_tr_line0");
			arrColors[0]=theTr.cells[0].style.backgroundColor;
			arrColors[1]=theTr.cells[3].style.backgroundColor;
			arrColors[2]=theTr.cells[1].style.backgroundColor;
			arrColors[3]=theTr.cells[4].style.backgroundColor;
			break;
		case 2:
			var theTr=document.getElementById("wd_tr_line0");
			arrColors[0]=theTr.cells[0].style.backgroundColor;
			arrColors[2]=theTr.cells[1].style.backgroundColor;
			var theTr=document.getElementById("wd_tr_line1");
			arrColors[1]=theTr.cells[0].style.backgroundColor;
			arrColors[3]=theTr.cells[1].style.backgroundColor;
			break;
		case 3:
			var theTr=document.getElementById("wd_tr_line0");
			arrColors[0]=theTr.cells[0].style.backgroundColor;
			arrColors[3]=theTr.cells[1].style.backgroundColor;
			var theTr=document.getElementById("wd_tr_line2");
			arrColors[1]=theTr.cells[0].style.backgroundColor;
			var theTr=document.getElementById("wd_tr_line3");
			arrColors[2]=theTr.cells[0].style.backgroundColor;
			break;
		case 4:
		default:
			var theTr=document.getElementById("wd_tr_line0");
			arrColors[0]=theTr.cells[0].style.backgroundColor;
			var theTr=document.getElementById("wd_tr_line1");
			arrColors[1]=theTr.cells[0].style.backgroundColor;
			var theTr=document.getElementById("wd_tr_line2");
			arrColors[2]=theTr.cells[0].style.backgroundColor;
			var theTr=document.getElementById("wd_tr_line3");
			arrColors[3]=theTr.cells[0].style.backgroundColor;
			break;
	}
	//
	var iI=0;
	for (iI=0; iI<4; iI++) {
		var theRow=document.getElementById("wd_tr_row"+iI*2);
		theRow.style.backgroundColor=arrColors[iI];
		if (iI>0) {
			theRow.cells[1].style.backgroundColor=arrColors[1];
			theRow.cells[3].style.backgroundColor=arrColors[0];
			theRow.cells[5].style.backgroundColor=arrColors[2];
			theRow.cells[7].style.backgroundColor=arrColors[3];
		}
		theRow=document.getElementById("wd_tr_row"+(iI*2+1));
		theRow.style.backgroundColor=arrColors[iI];
		if (iI<3) {
			theRow.cells[1].style.backgroundColor=arrColors[1];
			theRow.cells[3].style.backgroundColor=arrColors[0];
			theRow.cells[5].style.backgroundColor=arrColors[2];
			theRow.cells[7].style.backgroundColor=arrColors[3];
		}
	}
}

//==============================================================================

function SetBaseColorByRgb() {
	var theRgbEl=document.getElementById("el_basecolor");
	var theHueEl=document.getElementById("el_hue");
	var theSaturEl=document.getElementById("el_saturation");
	var theBrightEl=document.getElementById("el_brightness");
	var theImg=document.getElementById("wd_hsblayer");
	//
	var sRgb=theRgbEl.value;
	if (sRgb.length==6) {
		var iR=parseInt(sRgb.substr(0, 2), 16);
		var iG=parseInt(sRgb.substr(2, 2), 16);
		var iB=parseInt(sRgb.substr(4, 2), 16);
		var theHsb=rgb2hsb(iR, iG, iB);
		theHueEl.value=theHsb.h;
		theSaturEl.value=theHsb.s;
		theBrightEl.value=theHsb.b;
		SetBaseColorByHsb(1);
	}
}
function SetBaseColorByHsb(bNeedFill) {
	var theRgbEl=document.getElementById("el_basecolor");
	var theHueEl=document.getElementById("el_hue");
	var theSaturEl=document.getElementById("el_saturation");
	var theBrightEl=document.getElementById("el_brightness");
	var theImg=document.getElementById("wd_hsblayer");
	var theSchema=document.getElementById("el_schema");
	var theSchemangle=document.getElementById("el_schemangle");
	if (theRgbEl && theHueEl && theSaturEl && theBrightEl && theImg) {
		var fH=parseInt(theHueEl.value);
		if (!fH) fH=0; if (fH>360) fH=360; if (fH<0) fH=0;
		var fHc=180+fH; fHc=fHc%360;
		theHueEl.value=fH;
		//
		var iS=parseInt(theSaturEl.value);
		if (!iS) iS=0; if (iS>100) iS=100; if (iS<0) iS=0;
		var iSc=100-iS;
		theSaturEl.value=iS;
		//
		var iB=parseInt(theBrightEl.value);
		if (!iB) iB=0; if (iB>100) iB=100; if (iB<0) iB=0;
		var iBc=100-iB;
		theBrightEl.value=iB;
		//theImg.filters.item("DXImageTransform.Microsoft.Alpha").Opacity=iBc;
		theImg.filters.item("alpha").Opacity=iB;
		//
		if (iS>100) {
			iS=100;
			var iH1=fH%15;
			if (iH1<=7) {
				fH=15*Math.floor(fH/15);
			} else {
				fH=15*Math.ceil(fH/15);
			}
		}
		//
		var theRgb=hsb2rgb(fH, iS, iB);
		//iSc=(iSc>=50?100:0);
		iBc=(iBc>=50?100:0);
		var theRgbCompl=hsb2rgb(fHc, iSc, iBc);
		var sRgb="#"+theRgb.s;
		var sRgbCompl="#"+theRgbCompl.s;
		//
		//theRgbEl.style.backgroundColor=sRgb;
		//theRgbEl.style.color=sRgbCompl;
		theRgbEl.value=sRgb.substr(1);
		//
		var fH1=(fH+180)%360;
		PosCursor(fH, iS, iB, 0);
		if (bNeedFill) FillLine(fH, iS, iB, 0);
		var iAngle=parseInt(theSchemangle.value);
		if (!iAngle) iAngle=0;
		if (iAngle>180) iAngle=180;
		if (iAngle<0) iAngle=0;
		theSchemangle.value=iAngle;
		var iSchema=parseInt(theSchema.value);
		switch (iSchema) {
			case 1:
				PosCursor(-1, -1, -1, 1);
				if (bNeedFill) FillLine(-1, -1, -1, 1);
				PosCursor(-1, -1, -1, 2);
				if (bNeedFill) FillLine(-1, -1, -1, 2);
				PosCursor(-1, -1, -1, 3);
				if (bNeedFill) FillLine(-1, -1, -1, 3);
				break
			case 2:
				PosCursor(fH1, iS, iB, 1);
				if (bNeedFill) FillLine(fH1, iS, iB, 1);
				PosCursor(-1, -1, -1, 2);
				if (bNeedFill) FillLine(-1, -1, -1, 2);
				PosCursor(-1, -1, -1, 3);
				if (bNeedFill) FillLine(-1, -1, -1, 3);
				break;
			case 3:
				var fH2=(fH+iAngle)%360;
				var fH3=fH-iAngle;
				if (fH3<0) {
					fH3=360+fH3;
				} else {
					fH3=fH3%360;
				}
				PosCursor(fH1, iS, iB, 1);
				if (bNeedFill) FillLine(fH1, iS, iB, 1);
				PosCursor(fH2, iS, iB, 2);
				if (bNeedFill) FillLine(fH2, iS, iB, 2);
				PosCursor(fH3, iS, iB, 3);
				if (bNeedFill) FillLine(fH3, iS, iB, 3);
				break;
			case 4:
			default:
				var fH2=(fH+iAngle)%360;
				var fH3=(fH2+180)%360;
				PosCursor(fH1, iS, iB, 1);
				if (bNeedFill) FillLine(fH1, iS, iB, 1);
				PosCursor(fH2, iS, iB, 2);
				if (bNeedFill) FillLine(fH2, iS, iB, 2);
				PosCursor(fH3, iS, iB, 3);
				if (bNeedFill) FillLine(fH3, iS, iB, 3);
				break;
		}
		//
		var theSatCurPnt=hsb2xy(20+parseInt(iS/2), 114, 100, 1);
		var theSatDiv=document.getElementById("wd_cursor_sat");
		theSatDiv.style.left=theSatCurPnt.x+"px";
		theSatDiv.style.top=theSatCurPnt.y-7+"px";
		//
		var theBrtCurPnt=hsb2xy(180+20+parseInt(iB/2), 114, 100, 1);
		var theBrtDiv=document.getElementById("wd_cursor_brt");
		theBrtDiv.style.left=theBrtCurPnt.x-7+"px";
		theBrtDiv.style.top=theBrtCurPnt.y+"px";
		//
		var theHueCurPnt=hsb2xy(270+9+parseInt(fH/5), 114, 100, 1);
		var theHueDiv=document.getElementById("wd_cursor_hue");
		theHueDiv.style.left=theHueCurPnt.x-7+"px";
		theHueDiv.style.top=theHueCurPnt.y-7+"px";
		//
		FillTable(iSchema);
	}
}

function SetBaseColorByClick(iX, iY, bNeedFill) {
	var theRgbEl=document.getElementById("el_basecolor");
	var theHueEl=document.getElementById("el_hue");
	var theSaturEl=document.getElementById("el_saturation");
	var theBrightEl=document.getElementById("el_brightness");
	var theSchema=document.getElementById("el_schema");
	var theSchemangle=document.getElementById("el_schemangle");
	//
	var iBrightness=parseInt(theBrightEl.value);
	if (!iBrightness) iBrightness=0;
	if (iBrightness>100) iBrightness=100;
	//
	var theHsb=wd_circle2hsb(iX, iY, iBrightness);
	//
	var fH=parseInt(theHsb.h);
	var iS=parseInt(theHsb.s);
	var iB=parseInt(theHsb.b);
	//
	if (iS>100) {
		if (iS>112) {
			return true;
		} else {
			iS=100;
			var iH1=fH%15;
			if (iH1<=7) {
				fH=15*Math.floor(fH/15);
			} else {
				fH=15*Math.ceil(fH/15);
			}
		}
	}
	//
	var fH1=(fH+180)%360;
	PosCursor(fH, iS, iB, 0);
	if (bNeedFill) FillLine(fH, iS, iB, 0);
	/*PosCursor(fH1, iS, iB, 1);
	FillLine(fH1, iS, iB, 1);*/
	var iAngle=parseInt(theSchemangle.value);
	if (!iAngle) iAngle=0;
	if (iAngle>180) iAngle=180;
	if (iAngle<0) iAngle=0;
	theSchemangle.value=iAngle;
	var iSchema=parseInt(theSchema.value);
		switch (iSchema) {
			case 1:
				PosCursor(-1, -1, -1, 1);
				if (bNeedFill) FillLine(-1, -1, -1, 1);
				PosCursor(-1, -1, -1, 2);
				if (bNeedFill) FillLine(-1, -1, -1, 2);
				PosCursor(-1, -1, -1, 3);
				if (bNeedFill) FillLine(-1, -1, -1, 3);
				break
			case 2:
				PosCursor(fH1, iS, iB, 1);
				if (bNeedFill) FillLine(fH1, iS, iB, 1);
				PosCursor(-1, -1, -1, 2);
				if (bNeedFill) FillLine(-1, -1, -1, 2);
				PosCursor(-1, -1, -1, 3);
				if (bNeedFill) FillLine(-1, -1, -1, 3);
				break;
			case 3:
				var fH2=(fH+iAngle)%360;
				var fH3=fH-iAngle;
				if (fH3<0) {
					fH3=360+fH3;
				} else {
					fH3=fH3%360;
				}
				PosCursor(fH1, iS, iB, 1);
				if (bNeedFill) FillLine(fH1, iS, iB, 1);
				PosCursor(fH2, iS, iB, 2);
				if (bNeedFill) FillLine(fH2, iS, iB, 2);
				PosCursor(fH3, iS, iB, 3);
				if (bNeedFill) FillLine(fH3, iS, iB, 3);
				break;
			case 4:
			default:
				var fH2=(fH+iAngle)%360;
				var fH3=(fH2+180)%360;
				PosCursor(fH1, iS, iB, 1);
				if (bNeedFill) FillLine(fH1, iS, iB, 1);
				PosCursor(fH2, iS, iB, 2);
				if (bNeedFill) FillLine(fH2, iS, iB, 2);
				PosCursor(fH3, iS, iB, 3);
				if (bNeedFill) FillLine(fH3, iS, iB, 3);
				break;
		}
		//
		FillTable(iSchema);
	//
		var theSatCurPnt=hsb2xy(20+parseInt(iS/2), 114, 100, 1);
		var theSatDiv=document.getElementById("wd_cursor_sat");
		theSatDiv.style.left=theSatCurPnt.x+"px";
		theSatDiv.style.top=theSatCurPnt.y-7+"px";
		//
		var theBrtCurPnt=hsb2xy(180+20+parseInt(iB/2), 114, 100, 1);
		var theBrtDiv=document.getElementById("wd_cursor_brt");
		theBrtDiv.style.left=theBrtCurPnt.x-7+"px";
		theBrtDiv.style.top=theBrtCurPnt.y+"px";
		//
		var theHueCurPnt=hsb2xy(270+9+parseInt(fH/5), 114, 100, 1);
		var theHueDiv=document.getElementById("wd_cursor_hue");
		theHueDiv.style.left=theHueCurPnt.x-7+"px";
		theHueDiv.style.top=theHueCurPnt.y-7+"px";
	//
	var fHc=180+fH; fHc=fHc%360;
	var iSc=100-iS;
	var iBc=100-iB;
	var theRgb=hsb2rgb(fH, iS, iB);
	//iSc=(iSc>=50?100:0);
	iBc=(iBc>=50?100:0);
	var theRgbCompl=hsb2rgb(fHc, iSc, iBc);
	var sRgb="#"+theRgb.s;
	var sRgbCompl="#"+theRgbCompl.s;
	//
	if (theRgbEl) {
		//theRgbEl.style.backgroundColor=sRgb;
		//theRgbEl.style.color=sRgbCompl;
		theRgbEl.value=sRgb.substr(1);
	}
	if (theHueEl) theHueEl.value=fH;
	if (theSaturEl) theSaturEl.value=iS;
	if (theBrightEl) theBrightEl.value=iB;
}
function SetByDrag(bNeedFill) {
	var sName=event.srcElement.name;
	if (sName=="wd_img_cursor2"||sName=="wd_img_cursor3") {
		/*event.returnValue = false;
		event.dataTransfer.effectAllowed = "move";
		event.dataTransfer.dropEffect = "move";*/
		var theCircle=wd_circle2hsb(event.x, event.y, 100);
		var theSchemangle=document.getElementById("el_schemangle");
		var theHueEl=document.getElementById("el_hue");
		var fHue=parseInt(theHueEl.value);
		var fCurr=theCircle.h;
		if (fCurr>=fHue) {
			var fAngle=fCurr-fHue;
		} else {
			var fAngle=fCurr+(360-fHue);
		}
		if (fAngle>180) {
			var theSchema=document.getElementById("el_schema");
			var iSchema=parseInt(theSchema.value);
			switch (iSchema) {
				case 3:
					fAngle=360-fAngle;
					break;
				case 4:
				default:
					fAngle=fAngle-180;
					break;
			}
		}
		theSchemangle.value=fAngle;
		SetBaseColorByHsb(bNeedFill);
	} else if (sName=="wd_img_cursor0") {
		/*event.returnValue = false;
		event.dataTransfer.effectAllowed = "move";
		event.dataTransfer.dropEffect = "move";*/
		SetBaseColorByClick(event.x, event.y, bNeedFill);
	} else if (sName=="wd_img_cursat") {
		var theCircle=wd_circle2hsb(event.x, event.y, 100);
		var theSaturEl=document.getElementById("el_saturation");
		theCircle.h=(theCircle.h-20)*2;
		if (theCircle.h<=0) theCircle.h=0;
		if (theCircle.h>=100) theCircle.h=100;
		theSaturEl.value=theCircle.h;
		SetBaseColorByHsb(bNeedFill);
	} else if (sName=="wd_img_curbrt") {
		var theCircle=wd_circle2hsb(event.x, event.y, 100);
		var theBrtEl=document.getElementById("el_brightness");
		theCircle.h=(theCircle.h-20-180)*2;
		if (theCircle.h<=0) theCircle.h=0;
		if (theCircle.h>=100) theCircle.h=100;
		theBrtEl.value=theCircle.h;
		SetBaseColorByHsb(bNeedFill);
	} else if (sName=="wd_img_curhue") {
		var theCircle=wd_circle2hsb(event.x, event.y, 100);
		var theHueEl=document.getElementById("el_hue");
		theCircle.h=(theCircle.h-9-270)*5;
		if (theCircle.h<=0) theCircle.h=0;
		if (theCircle.h>=360) theCircle.h=360;
		theHueEl.value=theCircle.h;
		SetBaseColorByHsb(bNeedFill);
	}
}

//==============================================================================

function wd_ReturnMixedPalette() {
	var arrAnswer=new Array();
	//
	var theTr=document.getElementById("wd_tr_line0");
	arrAnswer['_0']=new Array();
	for (iI=0; iI<9; iI++) arrAnswer['_0'][iI]=theTr.cells[iI].style.backgroundColor;
	var theTr=document.getElementById("wd_tr_line2");
	arrAnswer['_2']=new Array();
	for (iI=0; iI<9; iI++) arrAnswer['_2'][iI]=theTr.cells[iI].style.backgroundColor;
	var theTr=document.getElementById("wd_tr_line3");
	arrAnswer['_3']=new Array();
	for (iI=0; iI<9; iI++) arrAnswer['_3'][iI]=theTr.cells[iI].style.backgroundColor;
	var theTr=document.getElementById("wd_tr_line1");
	arrAnswer['_1']=new Array();
	for (iI=0; iI<9; iI++) arrAnswer['_1'][iI]=theTr.cells[iI].style.backgroundColor;
	//
	window.returnValue=arrAnswer;
	self.close();
	return false;
}

//==============================================================================
