
colorsArray = new Array;
function setStyleById(i, p, v) 
{
	var thedoc = window.document;
	var n = thedoc.getElementById(i);
	n.style[p] = v;
}

function buildColorArray(color)
{
	var thedoc = window.document;
	//var colorMessage = thedoc.getElementById("message");
	//var arrayMessage = thedoc.getElementById("arrayMessage");
	var j=0;
	var inarray = false;
	var imgState = thedoc.getElementById("color_"+color);
	var colorPrint = "";
	
	for(var i=0; i<colorsArray.length; i++)
	{
		if(colorsArray[i] == color) // If the color exists in the array, delete it
		{
			//thedoc.getElementById("colorPick").value = "";
			delete colorsArray[i];
			colorsArray.sort(); // Move color to be deleted to the end of the array
			colorsArray.pop(); // Delete the last element in the array
			inarray = true;
			imgState.src = "images/color_search/color_"+color+"_off.gif";
		}
	}

	if(!inarray)
	{
		colorsArray.push(color);		
		imgState.src = "images/color_search/color_"+color+"_on.gif";
	}
	colorPrint = colorsArray.join(" "); // Remove the "," from printing the array
	thedoc.getElementById("colorPick").value = colorPrint; // writes color values to a hidden field in the form
	//alert(thedoc.getElementById("colorPick").value);
}

function joinKeywords()
{
	var thedoc = window.document;
	// Change 'thedoc.getElementById("txtKey") to use description search
	var txtKey = thedoc.getElementById("txtKey").value += " "+thedoc.getElementById("colorPick").value;
	thedoc.getElementById("txtKey").value = txtKey;
}


