<!--

var targetForColorPicker = false;
var noClose = false;
var onCustomField = false;
var activeCustomField = false;

function getOffsetLeft(el)	{ 
	var eltemp = el;
	var ol = el.offsetLeft; 
	while((eltemp = eltemp.offsetParent) != null) {
		ol += eltemp.offsetLeft;
	}
	return ol;
}

function getOffsetTop (el) { 
	var eltemp2 = el;
	var ot = el.offsetTop; 
	while((eltemp2 = eltemp2.offsetParent) != null) {
		ot += eltemp2.offsetTop;
	}
	return ot;
}

function adjustDefaultColor(type, goback) {
	
	var defaultDropdown = document.generateForm[type + "color_default"];
	var customTextfield = document.generateForm[type + "color_custom"];
	var customShow = document.getElementById('color_show');
	var uArrow = document.getElementById(type + 'color_uarrow');
	var defaultColor = type == "bg" ? "#FFFFFF" : "#000000";
	
	if (goback === true && customTextfield.style.display != 'none') {
		
		customTextfield.style.display='none';
		uArrow.style.display='none';
		defaultDropdown.style.display='block';
		defaultDropdown.value=defaultColor;
	
	} else if (defaultDropdown.value == 'custom') {

		customTextfield.style.display='inline';
		defaultDropdown.style.display='none';
		uArrow.style.display='inline';
		
		customTextfield.value=defaultColor;
		customTextfield.focus();
		customTextfield.select();
		customShow.style.backgroundColor=defaultColor;
		
	} else if (customTextfield.style.display == 'block') {

		customTextfield.style.display='none';
		uArrow.style.display='none';
		defaultDropdown.style.display='block';

	}
	
	adjustCustomColor('text');
	adjustCustomColor('bg');
	
}

function adjustCustomColor() {

	var c = document.getElementById("cpNew");
	var f = document.getElementById("cpNewValue");
	var b = document.getElementById("btnCustom");

	b.style.visibility="visible";

if (f.value.length == 6) {
		try {
			c.style.backgroundColor = "#" + f.value;
			c.style.border="2px outset #" + f.value;
			b.disabled=false;
		} catch(e) { }
	} else {
		b.disabled=true;
	}
	
}

function oC(targetVar) {

	var p = document.getElementById("colorpicker");
	var c = document.getElementById("cpNew");
	var f = document.getElementById("cpNewValue");
	var b = document.getElementById("btnCustom");

	var hf = document.getElementById("color_" + targetVar);
	var bx = document.getElementById("colorbox_" + targetVar);

	targetForColorPicker = targetVar;
	noClose = true;
	setTimeout("noClose=false;", 200);
	

	p.style.top = (getOffsetTop(bx) + 18) + "px";
	p.style.left = (getOffsetLeft(bx)) + "px";
	p.style.display="block";
	mC(hf.value);
	adjustCustomColor();

	
}

function mC(str) {
	
	if (!activeCustomField) {
		var c = document.getElementById("cpNew");
		var f = document.getElementById("cpNewValue");
		var b = document.getElementById("btnCustom");
		
		b.style.visibility="hidden";
		c.style.backgroundColor="#" + str;
		c.style.border="2px outset #" + str;
		f.value=str;
	}
}

function rC(str) {
	
	var p = document.getElementById("colorpicker");
	var c = document.getElementById("cpNew");
	var f = document.getElementById("cpNewValue");
	var b = document.getElementById("btnCustom");
	var e = document.getElementById("example");

	var hf = document.getElementById("color_" + targetForColorPicker);
	var bx = document.getElementById("colorbox_" + targetForColorPicker);
	
	hf.value = str;
	bx.style.backgroundColor = "#" + str;
	p.style.display = "none";
	
	if (targetForColorPicker == "font") {
		e.style.color = "#" + str;
	} else if (targetForColorPicker == "back") {
		e.style.backgroundColor = "#" + str;
	}
	onCustomField = false;
	
}

function changeFont(font) {
	
		var e = document.getElementById("example");
		var fonts = Array("Verdana", "Arial", "'Arial Narrow'", "Tahoma", "Impact","'Times New Roman'");
		e.style.fontFamily = fonts[font];
			  
}

function killPicker() {
	if (!noClose && !onCustomField) {
		try {
			document.getElementById("colorpicker").style.display="none";
		} catch (e) {
		}
	}
}

function checkForm() {
	var line1 = document.getElementById("cLine1").value;
	var line2 = document.getElementById("cLine2").value;
	var line3 = document.getElementById("cLine3").value;
	
	

	if ( (line1.length + line2.length + line3.length) > 0 ) {
		return true;
	} else {
		alert("Please enter some text.");
		document.getElementById("cLine1").focus();
		return false;
	}

}

function trapEnter(e, enterFunction){

      try {

            var key = e.keyCode || e.which;

             if (key == 13){

                    e.cancelBubble = true;

                    if (e.returnValue) e.returnValue = false;

                    if (e.stopPropagation) e.stopPropagation();

                    if (enterFunction) eval(enterFunction);

                    return false;

             } else {

                    return true;

             }     

      }

      catch (e) {  }

}

function gotoLine(ln) {
	document.getElementById("cLine" + ln).select();
	document.getElementById("cLine" + ln).focus();
}

//-->