// ColorPickerPro version 1.0
// http://www.ColorPickerPro.com Copyright. XelaTek. All Rights Reserved.
// You may not copy, distribute, gift, bundle or give away this code without written consent.
// This is not shareware.
// You can purchase ColorPickerPro at http://www.ColorPickerPro.com
// All upgrades are free for life!
// We also have a special color picker for ColdFusion Applications at http://www.eztoolz.com
// Color Picker, color picker ColorPicker, ColorPickerPro, Color Picker Pro, ezColorPicker, ezcolorpicker
// Do not edit this file.
	var CSS = "<style type='text/css'>"
	CSS = CSS + "<!--";
	CSS = CSS + ".ezColorPickerInput {float:left;clear:none;}";
	CSS = CSS + ".ezColorPickerIconArea {width:21px;height:20px;position:relative;float:left;margin-right:2px;margin-left:4px;padding:0px;margin-top:0px;margin-bottom:0px;cursor:pointer;}";
	CSS = CSS + ".ezColorPickerTable {position:absolute;background-color:#000000;width:auto;height:auto;margin:0px;padding:0px;}";
	CSS = CSS + ".ezColorPickerTableTD {margin:0px;padding:0px;height:10px;width:10px;cursor:pointer;}";
	CSS = CSS + ".ezColorPickerTransitionArea {width:63px;height:20px;float:left;border:1px solid #000000;margin:1px;padding:0px;}";
	CSS = CSS + ".ezColorPickerCodeValueArea {float:left;font-family:Arial, Helvetica, sans-serif;font-size:11px;padding:4px;cursor:default;}";
	CSS = CSS + ".ezColorPickerClose {float:right;font-family:Arial, Helvetica, sans-serif;font-size:12px;color:#000000;text-decoration:none;padding:4px 8px;cursor:pointer;}";
	CSS = CSS + "-->";
	CSS = CSS + "</style>";
	document.write(CSS);
	var strCode = new Array("000000","000000","000000","000000","003300","006600","009900","00CC00","00FF00","330000","333300","336600","339900","33CC00","33FF00","660000","663300","666600","669900","66CC00","66FF00",
	"000000","333333","000000","000033","003333","006633","009933","00CC33","00FF33","330033","333333","336633","339933","33CC33","33FF33","660033","663333","666633","669933","66CC33","66FF33",
	"000000","666666","000000","000066","003366","006666","009966","00CC66","00FF66","330066","333366","336666","339966","33CC66","33FF66","660066","663366","666666","669966","66CC66","66FF66",
	"000000","999999","000000","000099","003399","006699","009999","00CC99","00FF99","330099","333399","336699","339999","33CC99","33FF99","660099","663399","666699","669999","66CC99","66FF99",
	"000000","CCCCCC","000000","0000CC","0033CC","0066CC","0099CC","00CCCC","00FFCC","3300CC","3333CC","3366CC","3399CC","33CCCC","33FFCC","6600CC","6633CC","6666CC","6699CC","66CCCC","66FFCC",
	"000000","FFFFFF","000000","0000FF","0033FF","0066FF","0099FF","00CCFF","00FFFF","3300FF","3333FF","3366FF","3399FF","33CCFF","33FFFF","6600FF","6633FF","6666FF","6699FF","66CCFF","66FFFF",
	"000000","FF0000","000000","990000","993300","996600","999900","99CC00","99FF00","CC0000","CC3300","CC6600","CC9900","CCCC00","CCFF00","FF0000","FF3300","FF6600","FF9900","FFCC00","FFFF00",
	"000000","00FF00","000000","990033","993333","996633","999933","99CC33","99FF33","CC0033","CC3333","CC6633","CC9933","CCCC33","CCFF33","FF0033","FF3333","FF6633","FF9933","FFCC33","FFFF33",
	"000000","0000FF","000000","990066","993366","996666","999966","99CC66","99FF66","CC0066","CC3366","CC6666","CC9966","CCCC66","CCFF66","FF0066","FF3366","FF6666","FF9966","FFCC66","FFFF66",
	"000000","FFFF00","000000","990099","993399","996699","999999","99CC99","99FF99","CC0099","CC3399","CC6699","CC9999","CCCC99","CCFF99","FF0099","FF3399","FF6699","FF9999","FFCC99","FFFF99",
	"000000","00FFFF","000000","9900CC","9933CC","9966CC","9999CC","99CCCC","99FFCC","CC00CC","CC33CC","CC66CC","CC99CC","CCCCCC","CCFFCC","FF00CC","FF33CC","FF66CC","FF99CC","FFCCCC","FFFFCC",
	"000000","FF00FF","000000","9900FF","9933FF","9966FF","9999FF","99CCFF","99FFFF","CC00FF","CC33FF","CC66FF","CC99FF","CCCCFF","CCFFFF","FF00FF","FF33FF","FF66FF","FF99FF","FFCCFF","FFFFFF")

function colorpickerpro_v1(FormName, TextFieldName, ElementNumber, ShowPoundSign, DefaultColor, AutoHideDropDowns, TextFieldClass, totalCountOnPage, ApplyToDOM) {
	//alert('colorpickerpro_v1');
	if (arguments.length != 9 ) {alert("Sorry, there are not enough parameters being passed.");return false;}
	var cp_formName = FormName;
	var cp_textFieldName = TextFieldName;
	var cp_elementNumber = ElementNumber;
	var cp_showPoundSign = ShowPoundSign;
	var cp_defaultColor = DefaultColor;
	var cp_autoHideDropDowns = AutoHideDropDowns;
	var cp_textFieldClass = TextFieldClass;
	var cp_applyToDOM = ApplyToDOM;
	var cp_totalCountOnPage = totalCountOnPage; // How many total color pickers will be on the page. Helps to speed up loops	
	ezcolorpicker_build(cp_elementNumber, cp_textFieldName, cp_autoHideDropDowns, cp_formName, cp_showPoundSign, cp_defaultColor, cp_applyToDOM, cp_totalCountOnPage, cp_textFieldClass);
}


function ezColorPickerToggle(oid, oInput, autoHide, oForm, oTotalCount) { // ezColorPickerTable ID, text input name, auto hide <select>'s: (1,0), oForm: form name 
	//alert('ezColorPickerToggle');
	//alert("oid: " + oid);
	//alert("oInput: " + oInput);
	//alert("autoHide: " + autoHide);
	//alert("oForm: " + oForm);
	//alert("oTotalCount: " + oTotalCount);
	var stripOut = /#/g; // regEx to strip out any pound signs (#)
	if (document.getElementById('ezColorPickerTable' + oid).style.visibility == 'hidden') { // open color picker
		if (autoHide == "yes") {
			autoHideDropDowns('hide', oForm);
		}
		closeAllOtherColorPickers(oid, oTotalCount); // Close all other color picker when you open one 
		ezcolorpicker_ChangeZindex(oid, oTotalCount); // change the z-index of all other icons, so that they won't show through the colorTable 
		document.getElementById('ezColorPickerTable' + oid).style.display = 'inline';
		document.getElementById('ezColorPickerTable' + oid).style.visibility = 'visible';
		var inputColor = document.getElementById(oInput).value; // check text input
		if (inputColor.length) { // if input has a value, transfer to color pallete 
			document.getElementById('ezColorPickerTransitionArea' + oid).style.backgroundColor = "#" + inputColor.replace(stripOut, '');
			document.getElementById('ezColorPickerIconArea' + oid).style.backgroundColor = "#" + inputColor.replace(stripOut, '');
			document.getElementById('ezColorPickerCodeValueArea' + oid).innerHTML = "#" + inputColor.replace(stripOut, ''); // strip off # if in input
		} else { // if input has no value, clear transition and code value areas 
			document.getElementById('ezColorPickerTransitionArea' + oid).style.backgroundColor = '';
			document.getElementById('ezColorPickerCodeValueArea' + oid).innerHTML = '';
		}
	} else { // close color picker
		document.getElementById('ezColorPickerTable' + oid).style.display = 'none';
		document.getElementById('ezColorPickerTable' + oid).style.visibility = 'hidden';
		autoHideDropDowns('show', oForm);
	}
}

function colorPick(oid, color, oInput, autoHide, oForm, showPound, oDOM) {
	if (autoHide == "yes") {
		autoHideDropDowns('show', oForm); // show form other form drop-downs
	}
	if (oDOM.length) {
		oDOM = unescape(oDOM) + '="#' + color + '"' // unescape is necessary because the oDOM was escaped
		eval(oDOM); // apply color to any object: document.myform.myinput.style.backgroundColor
	}
	document.getElementById('ezColorPickerIconArea' + oid).style.backgroundColor = "#" + color;
	document.getElementById('ezColorPickerTransitionArea' + oid).style.backgroundColor = color;
	document.getElementById('ezColorPickerTable' + oid).style.display = 'none';
	document.getElementById('ezColorPickerTable' + oid).style.visibility = 'hidden';
	if (showPound == "yes") {
		document.getElementById(oInput).value = "#" + color;
	} else {
		document.getElementById(oInput).value = color;
	}	
	createText();
}
function colorChanger(oid, color) {
	document.getElementById('ezColorPickerCodeValueArea' + oid).innerHTML = color;
	document.getElementById('ezColorPickerTransitionArea' + oid).style.backgroundColor = color;
}

function ezColorPickerClose(oid, oInput, autoHide, oForm, oDOM) { // this will close and clear the text input value and color settings	
	if (autoHide == "yes") {
		autoHideDropDowns('show', oForm);
	}
	if (oDOM.length) { // clear oDOM
		oDOM = unescape(oDOM) + '=""';
		eval(oDOM);
	}
	document.getElementById('ezColorPickerTransitionArea' + oid).style.backgroundColor = '';
	document.getElementById('ezColorPickerIconArea' + oid).style.backgroundColor = '';
	document.getElementById('ezColorPickerCodeValueArea' + oid).innerHTML = '';
	document.getElementById(oInput).value = '';
	document.getElementById('ezColorPickerTable' + oid).style.display = 'none';
	document.getElementById('ezColorPickerTable' + oid).style.visibility = 'hidden';
}

function autoHideDropDowns(visibility, oForm) { // Automatically hide or show other form drop-downs
	for (var i=0; i < document.forms[oForm].length; i++) {
		if (document.forms[oForm].elements[i].type.toString().charAt(0) == "s" & document.forms[oForm].elements[i].type.toString() != "submit") {	
			if (visibility == 'show') {				
				document.forms[oForm].elements[i].style.display='inline';
				document.forms[oForm].elements[i].style.visibility='visible';
			} else {
				document.forms[oForm].elements[i].style.display='none';
				document.forms[oForm].elements[i].style.visibility='hidden';
			}
		}		
	}
}

function closeAllOtherColorPickers(oid, oTotalCount) { // close all other color picker's
	var donotclose=oid
	var totalCount = oTotalCount + 1; 
	for (var i=0; i < totalCount; i++) {
		if (i != donotclose) { // will not always exist
			try {
				document.getElementById('ezColorPickerTable' + i).style.display = 'none';
				document.getElementById('ezColorPickerTable' + i).style.visibility = 'hidden';			
			} catch (e) {}
		}
	}	
}

function ezcolorpicker_ChangeZindex(oid, oTotalCount) { // change z-index so that icons don't show through color picker table	
	//alert('ezcolorpicker_ChangeZindex');
	var increaseZindex=oid;
	document.getElementById('ezColorPickerTable' + oid).style.zIndex = '1'; // increase z-index for the once you picked
	for (var i=0; i < oTotalCount; i++) {
		if (i != increaseZindex) { // will not always exist
			try {
				document.getElementById('ezColorPickerTable' + i).style.zIndex = '0';	// decrease z-index for all others
			} catch (e) {}
		}
	}	
}

function ezcolorpicker_build(oid, oInput, autoHide, oForm, showPound, defaultColor, oDOM, oTotalCount, oClass) {
	//alert("ezcolorpicker_build");
	//alert("oid: " + oid);
	//alert("oInput: " + oInput);
	//alert("autoHide: " +autoHide);
	//alert("oForm: " + oForm);
	//alert("showPound: " + showPound);
	//alert(defaultColor);
	//alert(oDOM);
	//alert(oClass);
	if (showPound == "yes") {pound = '#';} else {pound = '';} // pound: for # sign. showPound: for yes and no stings.
	var cc=0;
	document.write('<div class="ezColorPickerInput" id="ezColorPickerInput' + oid + '"><input name="' + oInput + '" type="text" size="7" maxlength="7" id="' + oInput + '" value="' + pound + defaultColor + '" class="' + oClass + '" onchange="createText();"/></div>');
	document.write('<div class="ezColorPickerIconArea" id="ezColorPickerIconArea' + oid + '" onclick="javascript:ezColorPickerToggle(' + oid + ', \'' + oInput + '\', \'' + autoHide + '\', \'' + oForm + '\', \'' + oTotalCount + '\')"><img src="/i/ezcolorpickericon.gif" alt="click to select color" width="21" height="20" border="0" align="absmiddle" id="ezColorPickerImage" /></div>');
	document.write('<table class="ezColorPickerTable" id="ezColorPickerTable' + oid + '" border="0" align="center" cellpadding="0" cellspacing="1" style="position:absolute;display:none;visibility:hidden;z-index:0">');
	document.write('<tr><td bgcolor="#ECE9D8" colspan="21" height="24">');
	document.write('<div class="ezColorPickerTransitionArea" id="ezColorPickerTransitionArea' + oid + '">&nbsp;</div>');
	document.write('<div class="ezColorPickerCodeValueArea" id="ezColorPickerCodeValueArea' + oid + '"></div><div class="ezColorPickerCodeValueArea"><font color="#ECE9D8">ezColorPicker</font></div>');
	document.write('<div class="ezColorPickerClose" onclick="javascript:ezColorPickerClose(' + oid + ', \'' + oInput + '\', \'' + autoHide + '\', \'' + oForm + '\', \'' + oDOM + '\');">x</div>');
	document.write('</td></tr>');
	// start table row
	for (var i=0; i < 12; i++) {
	document.write('<tr>');
	// create tale cell
	for (var td=0; td < 21; td++) { 
	document.write('<td class="ezColorPickerTableTD" width="10" height="10" bgcolor=#' + strCode[cc] + ' onclick="javascript:colorPick(' + oid + ', \'' + strCode[cc] + '\', \'' + oInput + '\', \'' + autoHide + '\', \'' + oForm + '\', \'' + showPound + '\', \'' + oDOM + '\')" onmouseover="javascript:colorChanger(' + oid + ', \'#' + strCode[cc] + '\')"><img src="/i/ezcolorpickertrans.gif" width="10" height="10"></td>'); // trans image is for Opera fix 
		cc++;
	}
	document.write('</tr>');
	}
	document.write('</table>');
	// if default value was given change color in icon area to that color
	var stripOut = /#/g; // regEx to strip out any pound signs (#)
	var thisColor = defaultColor
	if (thisColor.length >= 6) { 
		document.getElementById('ezColorPickerIconArea' + oid).style.backgroundColor="#" + thisColor.replace(stripOut, '');
	}
}
