/** bbcodes **/
function addBBCode( code,object )
{
	target = document.getElementById( object );

	switch(code)
	{
		// bold, itlaic, underline
		case "B": case "I": case "U":
			text = prompt("Geben Sie einen Text ein", "");
			if((text != "") && (text != null)) {
				target.value = target.value + "["+code+"]"+text+"[/"+code+"]";
			}
			break;

		// align left
		case "ALIGNLEFT":
			text = prompt("Geben Sie einen Text ein", "");
			if((text != "") && (text != null)) {
				target.value = target.value + "[ALIGN=LEFT]"+text+"[/ALIGN]";
			}
			break;

		// align center
		case "ALIGNCENTER":
			text = prompt("Geben Sie einen Text ein", "");
			if((text != "") && (text != null)) {
				target.value = target.value + "[ALIGN=CENTER]"+text+"[/ALIGN]";
			}
			break;

		// align right
		case "ALIGNRIGHT":
			text = prompt("Geben Sie einen Text ein", "");
			if((text != "") && (text != null)) {
				target.value = target.value + "[ALIGN=RIGHT]"+text+"[/ALIGN]";
			}
			break;

		// url, email
		case "URL": case "EMAIL":
			href = prompt("Geben Sie die Homepage-URL ein", "");
			if((href != "") && (href != null)) {
				text = prompt("Geben Sie eine Beschreibung ein (optional)", "");
				if((text != "") && (text != null)) {
					target.value = target.value + "["+code+"="+href+"]"+text+"[/"+code+"]";
				} else {
					target.value = target.value + "["+code+"]"+href+"[/"+code+"]";
				}
			}
			break;

		// image
		case "IMAGE":
			image = prompt("Geben Sie die Bild-URL ein", "");
			if((image != "") && (image != null)) {
				target.value = target.value + "[IMG]"+image+"[/IMG]";
			}
			break;

		// pointlist
		case "POINTLIST":
			theList = "";
			listEntry = "initial";
			while((listEntry != "") && (listEntry != null)) {
				listEntry = prompt("Geben Sie einen Listen-Punkt ein", "");
				if((listEntry != "") && (listEntry != null)) {
					theList = theList+"[*]"+listEntry+"\n";
				}
			}
			if((theList != "") && (theList != null)) {
				target.value = target.value + "[LIST]\n"+theList+"[/LIST]";
			}
			break;

		// quote
		case "QUOTE":
			who = prompt("Wen möchten Sie zitieren?", "");
			if((who != "") && (who != null)) {
				target.value = target.value + "[QUOTE][I]Original von "+who+"[/I]\nGeben Sie hier Ihr Zitat ein\n[/QUOTE]";
			}
			break;
	}
}

/** font-bbcodes **/
function changeFont(value, object)
{
	target = document.getElementById(object);
	text = prompt("Geben Sie einen Text ein", "");
	if((text != "") && (text != null)) {
		target.value = target.value +"[FONT="+ value +"]"+ text +"[/FONT]";
	}
}

function changeFontSize(value, object)
{
	target = document.getElementById(object);
	text = prompt("Geben Sie einen Text ein", "");
	if((text != "") && (text != null)) {
		target.value = target.value +"[SIZE="+ value +"px]"+ text +"[/SIZE]";
	}
}

function changeFontColor(value,object)
{
	target = document.getElementById(object);
	text = prompt("Geben Sie einen Text ein", "");
	if((text != "") && (text != null)) {
		target.value = target.value +"[COLOR="+ value +"]"+ text +"[/COLOR]";
	}
}

/** textarea resize **/
function resize(axis, scale, object)
{
	target = document.getElementById(object);

	switch(axis)
	{
		// X
		case "x":
			switch(scale)
			{
				case "add":
					if(target.cols<80) {
						target.cols=target.cols+5;
					}
					break;
				case "min":
					if(target.cols>50) {
						target.cols=target.cols-5;
					}
					break;
			}
			break;
		// Y
		case "y":
			switch(scale)
			{
				case "add":
					if(target.rows<50) {
						target.rows=target.rows+5;
					}
					break;
				case "min":
					if(target.rows>5) {
						target.rows=target.rows-5;
					}
					break;
			}
			break;
	}
	return;
}
