function xforum_InsertCode(formattext, codestr, DocumentForm)
{
 var Sel=DocumentForm.selection.createRange();
 
 DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.focus();
 
 if (Sel.text)
 { 
	 switch (codestr)
	 {
	 	case 'bold':		
			Sel.text='[FETT-BEGINN] '+Sel.text+' [FETT-ENDE]';  		
		break;
		case 'italic':
			Sel.text='[KURSIV-BEGINN] '+Sel.text+' [KURSIV-ENDE]';  		
		break;
		case 'underline':
			Sel.text='[UNTERSTRICHEN-BEGINN] '+Sel.text+' [UNTERSTRICHEN-ENDE]';		
		break;
		case 'mail':
			linkstr = prompt('Geben Sie bitte die E-Mailadresse ein!','adresse@domain.de');
			
			if (linkstr!=null)
			 Sel.text='[MAIL-BEGINN '+linkstr+'] '+Sel.text+' [MAIL-ENDE]';			 
		break;
		case 'link':
			linkstr = prompt('Geben Sie bitte die URL der Zielhomepage an!','http://');
			
			if (linkstr!=null)
			 {	
			 	newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
			 	
				if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
				 {
					ToWindow = '_self';
				 }
				else if (newwnd.toUpperCase()=='JA')
				 {
					ToWindow = '_blank';
				 }
				
			 	counted = prompt('Sollen die Klicks auf diesen Link gezählt werden? (JA oder NEIN)','NEIN');
				
				if ( (counted.toUpperCase()!='JA') && (counted!=null) )
				 {
					Sel.text='[LINK-BEGINN TARGET='+ToWindow+' '+linkstr+']'+Sel.text+'[LINK-ENDE]';
				 }
				else if (counted.toUpperCase()=='JA')
				 {
					Sel.text='[LINK-C-BEGINN TARGET='+ToWindow+' '+linkstr+']'+Sel.text+'[LINK-C-ENDE]';
				 }
			 }			 
		break;	
		case 'tabbed':
			tabs = prompt('Geben Sie bitte ein, um wieviele Tabstops eingerückt werden soll!','1');
		
			if (tabs!=null)
			 Sel.text='[TABBED '+Math.ceil(tabs*20)+'] '+Sel.text+' [TABBED-ENDE]';		 
		break;
		case 'textalign-l':
			Sel.text='[TEXT LINKSBUENDIG(LEFT)] '+Sel.text+' [TEXT LINKSBUENDIG ENDE]';			
		break;
		case 'textalign-c':
			Sel.text='[TEXT ZENTRIERT(CENTER)] '+Sel.text+' [TEXT ZENTRIERT ENDE]';			
		break;
		case 'textalign-r':
			Sel.text='[TEXT RECHTSBUENDIG(RIGHT)] '+Sel.text+' [TEXT RECHTSBUENDIG ENDE]';
		break;
		case 'textalign-j':
			Sel.text='[TEXT BLOCKSATZ(JUSTIFY)] '+Sel.text+' [TEXT BLOCKSATZ ENDE]';			
		break;
		case 'font':
			Sel.text='[FONT-BEGINN '+formattext+'] '+Sel.text+' [FONT-ENDE]';			
		break;
		case 'cssfont':
			Sel.text='[CSSFONT-BEGINN '+formattext+'] '+Sel.text+' [CSSFONT-ENDE]';
		break;
		case 'image-l':
			floatingtext = prompt('Soll der Text das Bild umfließen? (JA oder NEIN)','JA');
	
			if (floatingtext!=null)
			{
				linkref = prompt('Geben Sie ggf. eine URL an, auf welche das Bild referenziert!','');
				
				if (linkref!=null)
				{					
					if (linkref!='')
					{
						newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
			 	
						if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
						 {
							ToWindow = '_self';
						 }
						else if (newwnd.toUpperCase()=='JA')
						 {
							ToWindow = '_blank';
						 }
						 
						 linkref=' '+linkref+' TARGET='+ToWindow;
					}
					Sel.text='[BILD '+formattext+' LINKS '+floatingtext.toUpperCase()+linkref+']{'+Sel.text+'}';					
				}
			}			
		break;
		case 'image-r':
			floatingtext = prompt('Soll der Text das Bild umfließen? (JA oder NEIN)','JA');
	
			if (floatingtext!=null)
			{
				linkref = prompt('Geben Sie ggf. eine URL an, auf welche das Bild referenziert!','');
				
				if (linkref!=null)
				{					
					if (linkref!='')
					{
						newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
			 	
						if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
						 {
							ToWindow = '_self';
						 }
						else if (newwnd.toUpperCase()=='JA')
						 {
							ToWindow = '_blank';
						 }
						 
						 linkref=' '+linkref+' TARGET='+ToWindow;
					}
					Sel.text='[BILD '+formattext+' RECHTS '+floatingtext.toUpperCase()+linkref+']{'+Sel.text+'}';					
				}
			}			
		break;
		case 'image-c':
			linkref = prompt('Geben Sie ggf. eine URL an, auf welche das Bild referenziert!','');
			
			if (linkref!=null)
				{					
					if (linkref!='')
					{
						newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
			 	
						if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
						 {
							ToWindow = '_self';
						 }
						else if (newwnd.toUpperCase()=='JA')
						 {
							ToWindow = '_blank';
						 }
						 
						 linkref=' '+linkref+' TARGET='+ToWindow;
				}
				Sel.text='[BILD '+formattext+' ZENTRIERT NEIN'+linkref+']{}\n'+Sel.text;				
			}			
		break;
	}
	Sel.select();
} else
{
	switch (codestr)
 	{
	case 'number':
		pr = prompt('Wieviele Elemente soll die Liste enthalten?','1');
		
		if (pr!=null) {
			resliste='[NUMMERIERTE-LISTE]\n';
			
			for (var i=1; i<=pr; i++)
			{
				resliste=resliste+'  [EL] Element '+i+' [/EL]\n';
			}
			
			resliste=resliste+'[NUMMERIERTE-LISTE-ENDE]';
		
			DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + resliste;
		}
	break;
	case 'bullet':
		pr = prompt('Wieviele Elemente soll die Liste enthalten?','1');
		
		if (pr!=null) {
			resliste='[PUNKTIERTE-LISTE]\n';
			
			for (var i=1; i<=pr; i++)
			{
				resliste=resliste+'  [EL] Element '+i+' [/EL]\n';
			}
			
			resliste=resliste+'[PUNKTIERTE-LISTE-ENDE]';
		
			DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + resliste;
		}
	break;
	case 'hrline':
		pr = prompt('Wie dick soll die Linie sein?','1');
	
		if (pr!=null)
			DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + '[HR color:'+formattext+'; height:'+pr+'px]';
	break;	
	case 'image-l':
		floatingtext = prompt('Soll der Text das Bild umfließen? (JA oder NEIN)','JA');
	
		if (floatingtext!=null)
		{
			linkref = prompt('Geben Sie ggf. eine URL an, auf welche das Bild referenziert!','');
			
			if (linkref!=null)
			{					
					if (linkref!='')
					{
						newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
			 	
						if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
						 {
							ToWindow = '_self';
						 }
						else if (newwnd.toUpperCase()=='JA')
						 {
							ToWindow = '_blank';
						 }
						 
						 linkref=' '+linkref+' TARGET='+ToWindow;
					}
				DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[BILD '+formattext+' LINKS '+floatingtext.toUpperCase()+linkref+']{Hier bitte den Text, der neben dem Bild stehen soll hinein schreiben!}';
			}
		}
	break;
	case 'image-r':
		floatingtext = prompt('Soll der Text das Bild umfließen? (JA oder NEIN)','JA');
	
		if (floatingtext!=null)
		{
			linkref = prompt('Geben Sie ggf. eine URL an, auf welche das Bild referenziert!','');
			
			if (linkref!=null)
			{					
					if (linkref!='')
					{
						newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
			 	
						if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
						 {
							ToWindow = '_self';
						 }
						else if (newwnd.toUpperCase()=='JA')
						 {
							ToWindow = '_blank';
						 }
						 
						 linkref=' '+linkref+' TARGET='+ToWindow;
					}
				DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[BILD '+formattext+' RECHTS '+floatingtext.toUpperCase()+linkref+']{Hier bitte den Text, der neben dem Bild stehen soll hinein schreiben!}';
			}
		}		
	break;
	case 'image-c':		
		linkref = prompt('Geben Sie ggf. eine URL an, auf welche das Bild referenziert!','');
		
		if (linkref!=null)
		{					
			if (linkref!='')
			{
				newwnd = prompt('Soll der Link in einem neuen Browserfenster gezeigt werden? (JA oder NEIN)','JA');
	 	
				if ( (newwnd.toUpperCase()!='JA') && (newwnd!=null) )
				 {
					ToWindow = '_self';
				 }
				else if (newwnd.toUpperCase()=='JA')
				 {
					ToWindow = '_blank';
				 }
				 
				 linkref=' '+linkref+' TARGET='+ToWindow;
			}
			DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n[BILD '+formattext+' ZENTRIERT NEIN'+linkref+']{}';
		}			
	break;
	case 'seperate':
		DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + '[/SEPERATOR/]';
	break;
	case 'vote':
		DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + '[VOTE ID='+formattext+']';
	break;
	case 'bog':
		DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + '[WARENKORB]';
	break;
	case 'shop':
		DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '\n' + '[SHOP]';
	break;
 	}
}
}

function forum_InsertCode(codestr, DocumentForm, addition)
{
	if (codestr!='hrline' && codestr!='image') {
			reltext = prompt('Bitte geben Sie den zu formatierenden Text ein!','');
		}
	
	switch (codestr)
	{
		case 'bold':
			if (reltext!=null) { DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[B] '+reltext+' [/B]'; }
		break;
		case 'underline':
			if (reltext!=null) { DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[U] '+reltext+' [/U]'; }
		break;
		case 'italic':
			if (reltext!=null) { DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[I] '+reltext+' [/I]'; }
		break;
		case 'hrline':
			DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[HLINE '+addition+']';
		break;
		case 'mail':
			href = prompt('Bitte geben Sie eine E-Mailadresse ein!','mail@domain.de');			
			
			if (reltext!=null && href!=null) {
				DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[EMAIL '+href+'] '+reltext+' [/EMAIL]';
				}
		break;
		case 'link':
			href = prompt('Bitte geben Sie eine URL ein!','http://');
			
			if (reltext!=null && href!=null) {
				DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[LINK '+href+'] '+reltext+' [/LINK]';
				}
		break;
		case 'cite':		
			if (reltext!=null) { DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[CITE] '+reltext+' [/CITE]'; }
		break;
		case 'image':			
			DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[IMAGE %'+addition+']';
		break;
		case 'font':			
			if (reltext!=null) { DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value=DocumentForm.FORUM_SUBMIT_CREATEPOST.forum_createpost_text.value + '[FONT '+addition+']'+reltext+'[/FONT]'; }
		break;
	}
}