// Drop-Down Widgets

// Color Table --------------------------------------------------------------------------------------
var arrColors = new Array();
var arrCodes = new Array('00','33','66','99','CC','FF');
var i=0;
for (r=0; r<arrCodes.length; r++){
	for (g=0; g<arrCodes.length; g++){
		for (b=0; b<arrCodes.length; b++){
			arrColors[i] = arrCodes[r] + arrCodes[g] + arrCodes[b];
			i++;
		}
	}	
}
document.write('<table id="colortable" cellspacing="0" cellpadding="0" '	
	+ 'style="position:absolute;visibility:hidden;border:thin solid #000;background-color:#999;cursor:pointer;font-size:8px;font-family:sans-serif;">');
	+ 'onmouseout="closeOut();" '
	document.write('<tr>');
	for (i=0; i<arrColors.length; i+=18) {
	document.write('<tr>');
	for (c=i; c<i+18; c++) {
		document.write('<td style="height:7px;width:7px;background-color:' + arrColors[c] + ';border:thin solid;border-color:' + arrColors[c] + ';cursor:hand;" '
			+ 'onmouseover="colorOver();" '
			+ 'onmouseout="colorOut();" '
			+ 'onclick="colorClick();">&nbsp;</td>');
	}
	document.write('</tr>');
}
document.write('</table>');


var EventEditor_BGColorField, fldValue;
var popupColorVisible = false;

function hidePopupColor()
{
	popupColorVisible = false;
	document.getElementById('colortable').style.visibility = "hidden";
	if (EventEditor_BGColorField.name!="merge_bgcolor")
	{
		document.getElementById('dur_hour').style.visibility	= "visible";
		document.getElementById('dur_min').style.visibility	= "visible";
		document.getElementById('month').style.visibility	= "visible";
		document.getElementById('day').style.visibility		= "visible";
		document.getElementById('year').style.visibility 	= "visible";
		document.getElementById('start_hour').style.visibility	= "visible";
		document.getElementById('start_min').style.visibility	= "visible";
		document.getElementById('start_ampm').style.visibility	= "visible";
	}
}

function popupColor(field, atImg)
{
	if (atImg!=null)
		getPos(atImg)

	if (popupClockVisible)
		hidePopupClock();


	if (popupColorVisible)
	{
		hidePopupColor();
	}
	else
	{
		EventEditor_BGColorField = document.getElementById(field);
		if (EventEditor_BGColorField.name!="merge_bgcolor")
		{
			document.getElementById('dur_hour').style.visibility	= "hidden";
			document.getElementById('dur_min').style.visibility	= "hidden";
			document.getElementById('month').style.visibility	= "hidden";
			document.getElementById('day').style.visibility		= "hidden";
			document.getElementById('year').style.visibility 	= "hidden";
			document.getElementById('start_hour').style.visibility	= "hidden";
			document.getElementById('start_min').style.visibility	= "hidden";
			document.getElementById('start_ampm').style.visibility	= "hidden";
		}
		popupColorVisible = true;
		fldValue = EventEditor_BGColorField.value;
		with (document.getElementById('colortable')){
			style.visibility = "visible";
			style.top  = posY+1;	   	
			style.left = posX-(18*10-1); 
		}
	}
}
function colorOver() 
{
	EventEditor_BGColorField.value = event.srcElement.style.backgroundColor.substring(1);
	event.srcElement.style.borderColor = "#fff";
}
function colorOut() 
{
	event.srcElement.style.borderColor = event.srcElement.style.backgroundColor;
}

function closeOut() 
{
	event.srcElement.style.backgroundColor = "#999";
	event.srcElement.style.color = "#000";
}

function ehDefault(desc,page,line,chr)
{
	return false;
}
function ehBadColor(desc,page,line,chr)
{

	alert("That color value is not supported by your browser.\n\nIf you are using a Hex color code, it must be 6 characters.\n\nIf you are using a color name, note that only 16 named colors are supported by the W3C HTML 4.0 standard\n(aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow)");
	window.onerror = ehDefault;
	return true;
}

function setDescriptionColor(colorValue)
{
	$("#event_title").css("background",colorValue);
	$("#event_description").css("background",colorValue);
}

function colorClick() 
{
	hidePopupColor();
	
	colorValue = EventEditor_BGColorField.value;
	
	if (EventEditor_BGColorField.name!="merge_bgcolor")
		setDescriptionColor(colorValue);
}


