<!--

var IE4 = document.all;

function hexColors(sel) {
	sel.value = sel.value.toUpperCase();
	if (sel.value.match(/^#/) == null) {
		sel.value = '#' + sel.value;
	}
	var hexColor = (/#[0-9A-F]{6}/);
	var result = sel.value.match(hexColor);
	if (result != null) {
		colorChange();
	} else {
		var msg = "WARNING: You have selected a color value outside of the standard color map.\n" +
		          "Select OK to continue or Cancel to enter a new value";
		if (!confirm(msg)) {
			sel.select();
			if (IE4) sel.style.background = '#FFFFFF';
		} else {
			if (IE4) sel.style.background = '#FFFFFF';
		}
	}
}

function fontColor(hex) {
	var hexArray = new Array();
	var count = 0;
	hex = hex.toString();
	var a = hex.substr(0, 2);
	var b = hex.substr(2, 2);
	var c = hex.substr(4, 2);
	a = '0x' + a;
	b = '0x' + b;
	c = '0x' + c;
	a = parseInt(a, 16);
	b = parseInt(b, 16);
	c = parseInt(c, 16);
	hexArray[0] = a;
	hexArray[1] = b;
	hexArray[2] = c;
	for (var i = 0; i < hexArray.length; i++) {
		if (hexArray[i] < 160) count++;
	}
	return count;
}


function colorChange() {

	var hexColor = (/#[0-9A-F]{6}/);
	
	if (document.frmDesign.UserColor.value.match(hexColor) != null) {
		var hex = new String(document.frmDesign.UserColor.value);
		hex = hex.match(/\w+/);
		var count = fontColor(hex);
		//alert(document.all("SampleNick").innerText);
		if (IE4) {
			if (count >= 2) {	
				document.frmDesign.UserColor.style.color = '#FFFFFF';
				document.frmDesign.dbTxt_ForeColor.value = '#FFFFFF';
				document.all("SampleNick").style.color = '#FFFFFF';
			} else {
				document.frmDesign.UserColor.style.color = '#000000';
				document.frmDesign.dbTxt_ForeColor.value = '#000000';
				document.all("SampleNick").style.color = '#000000';
			}
			document.frmDesign.UserColor.style.background = document.frmDesign.UserColor.value;
			document.all("SampleNick").style.background = document.frmDesign.UserColor.value;
		}
	}
	
}

function colorMap(color) {
		//alert(color);
		document.frmDesign.UserColor.value = color;
		hexColors(document.frmDesign.UserColor);
}
//-->
