function $X(element)
{
	element = document.getElementById(element);
	return element;
}

$(document).ready(function(){
	var textElements = [ "glowText", "textColor", "textSize", "textStyle", "textDecoration", "glowColor", "glowStrength" ];
	
	jQuery.each(textElements, function() {
		$("#" + this).change(function () {
			textUpdate();
		}).keyup(function () {
			textUpdate();
		});
	});
	
	$("#glowText").focus(function() { if ($(this).attr("value") == "Example Text") { $(this).attr("value",""); } });
	
	$('#textColor, #glowColor').ColorPicker({
		targetID : '',
		newTimeout : '',
		
		eventName: 'focus',
		
		onSubmit: function(hsb, hex, rgb, el) {
			$(el).val("#" + hex);
			$(el).ColorPickerHide();
			textUpdate();
		},
		onChange: function(cal, hex, el) {
			$("#" + targetID).val('#' + hex);
			
			newTimeout = setTimeout("textUpdate();", 1200); //IE gets slow
		},
		onBeforeShow: function () {
			$(this).ColorPickerSetColor(this.value);
			targetID = this.id;
		}
	});
	
	textUpdate();
});

function textUpdate()
{
	var cssObj = {
		'color' : $("#textColor").val(),
		'font-size' : $("#textSize").val() + 'px',
		'font-family' : $("#textStyle").val(),
		'text-decoration' : $("#textDecoration").val()
	}
	
	$("#gtext").css(cssObj);
	$("#gtext").html($("#glowText").val());
	
	if ((($("#glowColor").val() != '')) && (($("#glowStrength").val() != '')))
	{
		$X("gtext").style.filter ="progid:DXImageTransform.Microsoft.Glow(Color="+ $("#glowColor").val() +", Strength="+ $("#glowStrength").val() +")";
	}
}