var flist = new Array('Georgia','Palatino','Times New Roman','Lucida Grande','Verdana','Arial','Courier','');
function cff(form) {
styleP('fontFamily', flist[form.options[form.selectedIndex].value]);
}
function cfs(field){
var theSize = field.value;
if (theSize < 8) { theSize = 8;} else if (theSize > 35) { theSize = 35;}
field.value = theSize;
var size = theSize +'pt';
styleP('fontSize', size);
}
function cfcm(color){
styleP('color', color);
var field=document.getElementById('fcolor');
field.value = color;
}
function cfcf(field){
var theColor = field.value;
if(validateColor(theColor)) {
styleP('color', theColor);
} else {document.theForm.fcolor.focus();}
}
function ctw(field){
var theSize = field.value;
if (theSize < 25) { theSize = 25;} else if (theSize > 100) { theSize = 100;}
field.value = theSize;
size = theSize +'%';
var div=document.getElementById('textDiv');
div.style.width=size;
}
function cta(form) {
var div=document.getElementById('textDiv');
div.style.marginLeft=form.options[form.selectedIndex].value;
}
function cpcm(color) {
var div=document.getElementById('backgroundDiv');
div.style.backgroundColor=color;
var field=document.getElementById('page');
field.value = color;
}
function cpcf(field) {
var theColor = field.value;
if(validateColor(theColor)) {
var div=document.getElementById('backgroundDiv');
div.style.backgroundColor=theColor;
} else {document.theForm.page.focus();}
}
function cbcm(color) {
var div=document.getElementById('textDiv');
div.style.backgroundColor=color;
var field=document.getElementById('back');
field.value = color;
}
function cbcf(field) {
var theColor = field.value;
if(validateColor(theColor)) {
var div=document.getElementById('textDiv');
div.style.backgroundColor=theColor;
} else {document.theForm.back.focus();}
}
function sp(form) {
var ssty = form.options[form.selectedIndex].value;
if (ssty == '1') {
styleP('lineHeight','4ex');
styleP('textIndent','3em');
styleP('fontFamily','Courier');
styleP('margin','0px');
} else {
var fselect = document.getElementById('fontFam');
styleP('lineHeight','2.5ex');
styleP('textIndent','0');
styleP('fontFamily',flist[fselect.options[fselect.selectedIndex].value]);
styleP('marginBottom','2ex');
}
}
function validateColor(theColor) {
var re = new RegExp(/^#[0-9a-f]{3}$|^#[0-9a-f]{6}$/); 
if(theColor.search(re) != -1) { return true;} else {
alert('Invalid Color Code. Code must be in the form: #xxx or #xxxxxx (that\'s three or six of them). x can be a number from 0 to 9 or a letter from \'a\' to \'f\' only.');
return false;
}
}
function resetPreview() {
var size = fvalues[0] +'pt';
styleP('fontSize',size);
styleP('fontFamily',flist[fvalues[6]]);
styleP('color',fvalues[1]);
var div=document.getElementById('textDiv');
var theWidth = fvalues[2] +'%';
div.style.width=theWidth;
div.style.marginLeft=fvalues[3];
div.style.backgroundColor=fvalues[4];
var div=document.getElementById('backgroundDiv');
div.style.backgroundColor=fvalues[5];
}
function styleP(prop, itsVal) {
var p=document.getElementsByTagName('p');
var len = p.length;
var i;
for (i = 0; i<len; i++){
eval('p[i].style.' + prop + '=\'' + itsVal + '\'');
}
}
