function IColorPicker()
{
	this.loadDiv = "colorPickerDiv";
	this.cellSize = 15;
	this.totalColorsPerRow = 7;
	this.tableClassName = "colorPicker";
	this.load =  loadColorPicker;
	this.getColor = getColor;
	this.hide = hidePicker;
	this.selectedColor;
}


function hidePicker()
{
	document.getElementById(this.loadDiv).style.visibility="hidden";
}


function getColor(assignTo,color,div2Hide)
{
	document.getElementById(assignTo).style.backgroundColor = color; 
	document.getElementById(div2Hide).style.visibility="hidden";
	selectionColor = color;
	var css = findCssClassByName(".rubberBandLayerSelect",0)
	css.style.backgroundColor = color;
	parseRGB(color)
}


function loadColorPicker(obj)
{
	var div =document.getElementById(this.loadDiv)
	div.style.visibility="visible";
	div.style.top = "100px";
	div.style.left = "100px";


	var colors = new Array();
	colors.push("0,255,252","139,0,139","85,107,47","255,140,0","139,0,0","143,188,143","72,61,139");
	colors.push("148,0,211","255,20,147","105,105,105","178,34,34","255,20,240","0,206,209","47,79,79");
	colors.push("34,19,34","30,144,255","220,220,220","0,191,255","105,105,105","0,33,44","255,99,71");
	colors.push("255,25,0","255, 239, 0","255,105,180","205,92,92","240,255,240","216,191,216","0,128,128");
	colors.push("210,180,140","218,165,32","128,128,128","0,128,0","173,255,47","0,0,0","2,66,44");


	//create a variable to hold the table contents in
	var colorTable = '';
	var tdCount = 0;
	
	colorTable+='<table class="'+this.tableClassName+'" border="0" cellspacing="2" cellpadding="0">';
	
	for (var i in colors)
	{
		if (i % this.totalColorsPerRow ==0)
		{
			tdCount = 0;
			colorTable+='\n<tr>\n';
		}
		tdCount++;
		colorTable+='<td width="'+this.cellSize+'" height="'+this.cellSize+'" style="cursor:pointer; border:1px solid #000; background-color:rgb('+colors[i]+');" onClick="getColor(\''+obj.id+'\',this.style.backgroundColor,\''+this.loadDiv+'\'); "></td>\n';
		
		
		if (tdCount==this.totalColorsPerRow)
		{
			colorTable+='</tr>\n';
			tdCount = 0;
		}
	}
	
	colorTable+='<table>';
	document.getElementById(this.loadDiv).innerHTML = colorTable;
}

