//========================================================================================
// color picker © C Small
// Original found at www.sloppycode.net/webpalette/index2.html
// You're free to use this code as you wish, as long as you keep
// the above copyright intact.
// (this version for A1javascripts.com requires 2 images - you can get them at www.sloppycode.net/webpalette/colorpick2.gif and www.sloppycode.net/webpalette/pixel.gif 
//========================================================================================
var objInput;
var objImg;

function changeColor(wcolor) 
{
	objInput.value = '#' + wcolor;
	objInput.onchange();
	objImg.style.backgroundColor = '#' + wcolor;
	document.getElementById('ColorTable').style.visibility = 'hidden';
}


function ShowColorTable()
{
	var c = new Array();							
	c[1] = "FF";
	c[2] = "CC";			
	c[3] = "99";
	c[4] = "66";
	c[5] = "33";
	c[6] = "00";
	var d = 0;
																			  					
	for (i=1;i <=6;i++)
	{
		if (i >1)
		{
			document.write( "</tr>\n<tr>\n");
		}
																			  						
		for (m=1;m <=6;m++)
		{
			for (n=1;n <=6;n++)
			{
				d++;
				color = c[i] + c[m] + c[n];
				document.write("<td bgcolor=\"#"+color+"\" width=7><a href=\"javascript: //Color Code: #" + color + ";\" onClick=\"changeColor('" + color + "')\"><img src=\"images/pixel.gif\" width=7 height=7 name=\"a"+d+"\" border=0></td>\n");
			}
		}
	}
}

function ShowColors(txtbox, colorimg)
{
	objInput = txtbox;
	objImg = colorimg;
	document.getElementById('ColorTable').style.top = GetY(colorimg) + 17;
	document.getElementById('ColorTable').style.left = GetX(colorimg) + 10;
	document.getElementById('ColorTable').style.visibility = document.getElementById('ColorTable').style.visibility == 'visible' ? 'hidden': 'visible';
}

function GetX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function GetY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

