// Put CSS code in text box
function textAreaGen(element, newValue) {
	if ((element == undefined) || (element == null) || (newValue == undefined) || (newValue == null)) {
		return;
	}
	element.value = newValue;
	if (element.value != newValue) {
		// should help on Safari
		element.innerText = newValue;
	}
}

// Return code for a single, small button
function getCode(border,text,txtcolor,bgcolor) {
	if (text.length < 15) {
		padding = 30 - (text.length * 2);
	} else {
		padding = 2;
	}
	buttonCode = '<span style="background: #fff; padding: 1px; font-family: Verdana, Geneva, Vera, Arial, Helvetica, sans-serif; font-size: x-small; font-variant: small-caps; border: 1px solid #' + border + ';"><span style="color: #' + txtcolor + '; background: #' + bgcolor + '; padding: 0px ' + padding + 'px;">' + text + '</span></span>';
	return buttonCode;
}
// Return code for a double, small button
function getDCode(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2) {
	if (text2.length < 15) {
		padding = 30 - (text2.length * 2);
	} else {
		padding = 2;
	}
	buttonCode = '<span style="background: #fff; padding: 1px; font-family: Verdana, Geneva, Vera, Arial, Helvetica, sans-serif; font-size: x-small; font-variant: small-caps; border: 1px solid #' + border + ';"><span style="color: #' + txtcolor1 + '; background: #' + bgcolor1 + '; padding: 0px 2px;">' + text1 + '</span><span style="color: #' + txtcolor2 + '; background: #' + bgcolor2 + '; padding: 0px ' + padding + 'px 0px 2px;">' + text2 + '</span></span>';
	return buttonCode;
}
// Return code for a double, small button
function getTCode(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2,text3,txtcolor3,bgcolor3) {
	if (text2.length < 15) {
		padding = 30 - (text2.length * 2);
	} else {
		padding = 2;
	}
	buttonCode = '<span style="background: #fff; padding: 1px; font-family: Verdana, Geneva, Vera, Arial, Helvetica, sans-serif; font-size: x-small; font-variant: small-caps; border: 1px solid #' + border + ';"><span style="color: #' + txtcolor1 + '; background: #' + bgcolor1 + '; padding: 0px 2px;">' + text1 + '</span> <span style="color: #' + txtcolor2 + '; background: #' + bgcolor2 + '; padding: 0px 2px;">' + text2 + '</span> <span style="color: #' + txtcolor3 + '; background: #' + bgcolor3 + '; padding: 0px 2px;">' + text3 + '</span></span>';
	return buttonCode;
}
// Return code for a single, large button
function getLCode(emSize,border,text,txtcolor,bgcolor) {
	if (text.length < 15) {
		padding = 30 - (text.length * 2);
	} else {
		padding = 2;
	}
	buttonCode = '<span style="background: #fff; padding: 1px; font-family: Verdana, Geneva, Vera, Arial, Helvetica, sans-serif; font-size: ' + emSize + 'em; font-variant: small-caps; border: 1px solid #' + border + ';"><span style="color: #' + txtcolor + '; background: #' + bgcolor + '; padding: 0px ' + padding + 'px;">' + text + '</span></span>';
	return buttonCode;
}
// Return code for a double, large button
function getLDCode(emSize,border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2) {
	padding = emSize * 3
	buttonCode = '<span style="background: #fff; padding: 1px; font-family: Verdana, Geneva, Vera, Arial, Helvetica, sans-serif; font-size: ' + emSize + 'em; font-variant: small-caps; border: 1px solid #' + border + ';"><span style="color: #' + txtcolor1 + '; background: #' + bgcolor1 + '; padding: 0px 2px 0px ' + padding + 'px;">' + text1 + '</span><span style="color: #' + txtcolor2 + '; background: #' + bgcolor2 + '; padding: 0px ' + padding + 'px 0px 2px;">' + text2 + '</span></span>';
	return buttonCode;
}

function createButton(border,text,txtcolor,bgcolor) {
	buttonCode = getCode(border,text,txtcolor,bgcolor);
	document.write(' <a href="javascript:makeCode(\'' + border + '\',\'' + text + '\',\'' + txtcolor + '\',\'' + bgcolor + '\');">');
	document.write(buttonCode);
	document.write('</a> ');
}

function createDButton(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2) {
	buttonCode = getDCode(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2);
	document.write(' <a href="javascript:makeDCode(\'' + border + '\',\'' + text1 + '\',\'' + txtcolor1 + '\',\'' + bgcolor1 + '\',\'' + text2 + '\',\'' + txtcolor2 + '\',\'' + bgcolor2 + '\');">');
	document.write(buttonCode);
	document.write('</a> ');
}

function createTButton(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2,text3,txtcolor3,bgcolor3) {
	buttonCode = getTCode(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2,text3,txtcolor3,bgcolor3);
	document.write(' <a href="javascript:makeDCode(\'' + border + '\',\'' + text1 + '\',\'' + txtcolor1 + '\',\'' + bgcolor1 + '\',\'' + text2 + '\',\'' + txtcolor2 + '\',\'' + bgcolor2 + '\',\'' + text3 + '\',\'' + txtcolor3 + '\',\'' + bgcolor3 + '\');">');
	document.write(buttonCode);
	document.write('</a> ');
}

function createLButton(emSize,border,text,txtcolor,bgcolor) {
	buttonCode = getLCode(emSize,border,text,txtcolor,bgcolor);
	document.write(' <a href="javascript:makeLCode(\'' + emSize + '\',\'' + border + '\',\'' + text + '\',\'' + txtcolor + '\',\'' + bgcolor + '\');">');
	document.write(buttonCode);
	document.write('</a> ');
}

function createLDButton(emSize,border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2) {
	buttonCode = getLDCode(emSize,border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2);
	document.write(' <a href="javascript:makeLDCode(\'' + emSize + '\',\'' + border + '\',\'' + text1 + '\',\'' + txtcolor1 + '\',\'' + bgcolor1 + '\',\'' + text2 + '\',\'' + txtcolor2 + '\',\'' + bgcolor2 + '\');">');
	document.write(buttonCode);
	document.write('</a> ');
}

function makeCode(border,text,txtcolor,bgcolor) {
	buttonCode = getCode(border,text,txtcolor,bgcolor);
	elementID = document.getElementById("code");
	textAreaGen(elementID, buttonCode);
}

function makeDCode(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2) {
	buttonCode = getDCode(border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2);
	elementID = document.getElementById("code");
	textAreaGen(elementID, buttonCode);
}

function makeLCode(emSize,border,text,txtcolor,bgcolor) {
	buttonCode = getLCode(emSize,border,text,txtcolor,bgcolor);
	elementID = document.getElementById("code");
	textAreaGen(elementID, buttonCode);
}

function makeLDCode(emSize,border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2) {
	buttonCode = getLDCode(emSize,border,text1,txtcolor1,bgcolor1,text2,txtcolor2,bgcolor2);
	elementID = document.getElementById("code");
	textAreaGen(elementID, buttonCode);
}


