//something like 

// we should keep this out of range of NS4, it's just too complicated, and the new style won't work in NS4.
//if (document.layers) {window.location="mixer_tc_ns4.html"} // just that one redirect for NS4 folks

function make_objects () {
	infoDivObj = new getObj('infoDiv');
}//made objs

function getObj(name)	{

  	if (document.getElementById) { return document.getElementById(name).style; }
  	if (document.all) { return document.all[name].style; }
	
	
}// got objs

function makeColorObj(name) {

	this.name = name;
	this.hex = "CC";
	this.dec = 204;
	this.lock = 0;
	return this;
	
}

redObj = new makeColorObj("red");
greenObj = new makeColorObj("green");
blueObj = new makeColorObj("blue");

colorObj = new Object();
colorObj.red = redObj; colorObj.green = greenObj; colorObj.blue = blueObj;
var thingToColor = "body";

//***********************OK that's object creation ***********************************************



function main (currentColor, decColor) {
	if (colorObj[currentColor].lock) {return 0};
	colorObj[currentColor].name = currentColor;
	colorObj[currentColor].dec = decColor;
	colorObj[currentColor].hex =  getHexColor(decColor);

	//alert ("So far this color is " + colorObj[currentColor].name + " " + colorObj[currentColor].dec + " "+colorObj[currentColor].hex);

	setBoxes (currentColor);
	setItemColor();
	moveArrows(currentColor, decColor);

}//main



function setItemColor () {

	allcol = colorObj.red.hex + colorObj.green.hex  + colorObj.blue.hex;
	if (thingToColor == "body") {
		document.bgColor= eval(hexformat);
		return;
	}
	//else set text color
	infoDivObj.color= eval(hexformat);
	//document.fgColor= eval(hexformat);
}//set color


function setBoxes (currentColor) {

	hexformat= "\"\#" + colorObj.red.hex + colorObj.green.hex  + colorObj.blue.hex + "\"";
	decformat= colorObj.red.dec + "\, " + colorObj.green.dec + "\, " + colorObj.blue.dec;
	if (colorObj[currentColor].lock) {return 0};
	document.forms[1].elements[currentColor + "hexbox"].value = colorObj[currentColor].hex;
	document.forms[1].elements[currentColor + "decbox"].value = colorObj[currentColor].dec;

	if (thingToColor == "body") {
		document.alldisplay.rgbval.value=(decformat);
		document.alldisplay.hexval.value=(hexformat);
		return 0;
	}
	document.forms[2].elements['textHexValue'].value=(hexformat);
	document.forms[2].elements['textRgbValue'].value=(decformat);
	return true;

}//set boxes

function getHexColor (decColor) {

var hexnumbers = "0123456789ABCDEF";

	hexColor = Math.floor(decColor / 16);
	hexdig10 = hexnumbers.substring(hexColor,hexColor+1);
	hexColor *=16;
	hexColor = decColor - hexColor;
	hexdig01 = hexnumbers.substring(hexColor,hexColor+1);
	hexColor = hexdig10 + hexdig01;
	return hexColor;

} //get hex

function moveArrows (col, topPos) {

arrowHeight = ((255 - ( eval(topPos) ) ) -130); // takes  height into calcs for pos

	if (document.getElementById) {
		moverObj = document.getElementById(col + "_arrow").style
		moverObj.top = arrowHeight + "px"
	}
	else {
		//****that should really be the test as to which code gets loaded, unless we get into some freakish mac ie thing
		//alert ("doink");
		"document." + col + "_arrow.top = topPos"
	}
}//fn


function DoLock (lockcol) {

	if (colorObj[lockcol].lock == 0) {
		document.forms[1].elements[lockcol + "statbox"].value = "Lock at " + colorObj[lockcol].hex;
		colorObj[lockcol].lock =1;
		return 0;
	}
	document.forms[1].elements[lockcol + "statbox"].value = "Unlocked"
	colorObj[lockcol].lock =0;
}
