// *** Text bei der Eingabeaufforderung ***********
linkname = "Geben Sie bitte den Linknamen an (optional).";
linkadresse = "Geben Sie bitte die vollst\u00E4ndige Adresse des Links an.";
fontsize = "Geben Sie hier die Schriftgr\u00F6\u00DFe an.";
fontcolor = "Schreiben Sie die Farbe in das Textfeld!\nM\u00F6glich sind:\nwhite,gray,dimgray,navy,royalblue,red,orange,yellow,green oder HEX Angaben\n\nSie k\u00F6nnen das Feld auch leerlassen, damit die Webseiten Standardfarbe genommen wird.";
videonummer = "Geben Sie bitte die Nummer des Videos ein:"; 
/*Lightbox ANFANG*/
lightbox = "Geben Sie hier den Bildlink an.\nSie k\u00F6nnen auch mehrere Angeben! Wenn sie das Feld leerlassen wird die Abfrage beendet.\nAlternativ k\u00F6nnen Sie 'Abbrechen' w\u00E4hlen, um den Modus direkt zuverlassen.";
/*Lightbox ENDE*/
emailname = "Geben Sie bitte die E-Mail-Adresse ein.";
listentyp = "F\u00FCr eine numerierte Liste geben Sie eine '1' an.\r\nF\u00FCr eine alphabetische ein 'a'.\r\nF\u00FCr eine einfache Punktliste dr\u00FCcken Sie OK.";
listenwerte = "Geben Sie bitte die Listenpunkte ein und dr\u00FCcken Sie anschliessend OK.\r\nAlternativ k\u00F6nnen Sie 'Abbrechen' w\u00E4hlen, um die Liste direkt fertigzustellen.";

//**** Pop-Fenster **********
function helpwindow(w,h,e) {
 window.open("include.php?path=popup&mode=help&explain="+e,"helpwindow","toolbar=no,scrollbars=yes,resizable=yes,status=no,width="+w+",height="+h);
 }
function smiliewindow(w,h) {
 window.open("include.php?path=popup&mode=smilies&window_w_size="+w+"&window_h_size="+h,"smilies","toolbar=no,scrollbars=yes,resizable=yes,status=no,width="+w+",height="+h);
 }
function finduserID(w,h) {
 window.open("include.php?path=popup&mode=finduser&window_w_size="+w+"&window_h_size="+h,"finduser","toolbar=no,scrollbars=yes,resizable=yes,status=no,width="+w+",height="+h);
 }
function checkall(status,theelement) {
 for (i=0;i<document.myform.length;i++) {if(document.myform.elements[i].name=="" + theelement + "[]") document.myform.elements[i].checked=status;}
 }

/*bbcode*/
var pkBBArea=null;
var pkBBSelected='';

function pkBBFocus() 
	{
	pkBBArea.focus();
	}

/*textselection*/
function pkBBSelection(obj) 
	{
	pkBBArea=obj;
	
	if(window.getSelection)
		pkBBSelected=pkBBArea.value.substring(pkBBArea.selectionStart,pkBBArea.selectionEnd);
	else if(document.getSelection)
		pkBBSelected=pkBBArea.value.substring(pkBBArea.selectionStart,pkBBArea.selectionEnd);
	else if(document.selection)
		pkBBSelected=document.selection.createRange().text;

	if(pkBBArea.createTextRange)
		pkBBArea.caretPos=document.selection.createRange().duplicate();
	
	return true;
	}
	
function pkBBSingle(text)
	{
	text=' '+text+' ';
	pkBBCodeAdd(text);
	}
/*Fontsize Modifikation www.kit-coding.de ANFANG*/
function pkBBFont(bbcode){
	text=(pkBBSelected) ? pkBBSelected : '';
	
	size="";
	color="";
	TTcolorAdd="";
	HextoUpper="";
	myCounter=0;
	fine=0;
	TTSize=prompt(fontsize,size);
	
	if(isNaN(TTSize) == false){
		if ((TTSize<30 && TTSize>10) || TTSize=='' || TTSize == null){
			if((TTSize!='') && (TTSize != null)){
				TTcolor=prompt(fontcolor,color);
				HextoUpper=TTcolor.toUpperCase();
				control=HextoUpper.match(/^([0-9A-F]{6})$/ig);
				Farbcode = new Array("white","gray","dimgray","navy","royalblue","red","orange","yellow","green");
				while(myCounter < Farbcode.length){
					if(Farbcode[myCounter]==TTcolor || control){
						fine=1;
					}
					myCounter++;
				}
				if((TTcolor!='') && (TTcolor != null) && fine==1){
					if(control){
						TTcolor=HextoUpper;
					}
					TTcolorAdd="="+TTcolor+"";
				}else{
					if(fine==0 && TTcolor != null && TTcolor != ''){
						alert("Ihre eingegebene Farbe("+TTcolor+") ist uns nicht bekannt!");
					}
					TTcolorAdd="";
				}				
				
				auswahltext = "["+bbcode+"="+TTSize+TTcolorAdd+"]"+text+"[/"+bbcode+"]";
				pkBBCodeAdd(auswahltext);
			}
		}else{
			alert(TTSize + " ist zu gro\u00DF oder zu klein!");
		}
	}else{
		alert(TTSize + " ist keine Zahl!");
	}
}
/*Fontsize Modifikation www.kit-coding.de ENDE*/
function pkBBCodeAdd(text)
	{
	if(pkBBArea==null)
		{
		pkBBArea=document.getElementById('pkBBArea');
		pkBBFocus();
		pkBBSelection(pkBBArea);
		}
/* Cursor Positions Korrektur von Kit-coding.de
Bitte beachten, das  die text.match Zeilen so aussehen müssen: text.match(/\[\/(.*)\]/g)
Dadurch, das dies hier Javascript Code ist, es aber über einen reinen PHP Highlighter hervorgehoben wird, stimmt die Ausgabe nicht ganz.
*/
    if(text.match(/\[\/(.*)\]/g)){
        Ergebnis = text.match(/\[\/(.*)\]/g)
        NewLenght= Ergebnis[0].length;
    }else{
        NewLenght=0;
    }
    
    if(text.charAt(text.length - 1)==' '){
        NewLenght=0; 
    }
    /* Cursor Positions Korrektur von Kit-coding.de */

	if(window.getSelection)
		{
		pos=pkBBArea.selectionStart + text.length - NewLenght;
		scrollPos = pkBBArea.scrollTop;
		pkBBArea.value=pkBBArea.value.substr(0,pkBBArea.selectionStart) + text + pkBBArea.value.substr(pkBBArea.selectionEnd);
		pkBBArea.selectionStart=pos;
		pkBBArea.selectionEnd=pos;		
		}	
	else if(pkBBArea.createTextRange && pkBBArea.caretPos)
		{
		var caretPos = pkBBArea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1)==' ' ? text + ' ' : text;
		}
	else
		pkBBArea.value+=text
	pkBBFocus();
		pkBBArea.scrollTop = scrollPos;
	}

function pkBBCode(bbcode)
	{
	text=(pkBBSelected) ? pkBBSelected : '';
	text="["+bbcode+"]"+text+"[/"+bbcode+"]";
	
	pkBBCodeAdd(text);	
	pkBBFocus();
	}
// [pkHB] Hinweis Boxen BBCode by PimpYourKiT.de & BurnerFM.de Anfang
function pkBBInfobox(bbcode)
	{
	text=(pkBBSelected) ? pkBBSelected : '';

	infotext = prompt("Geben Sie hier den Text ein, der in der Hinweisbox erscheinen soll.",text);

	var fensterausgabe;
	if (bbcode == "MESSAGE") {
		ausgabe = "Geben Sie hier bitte den Message Box Typ ein.\n Verf\u00FCgbare Typen [ info || warn  || success || error ]";
		ausgabeinhalt = "";
		}

	infocode = prompt(ausgabe,ausgabeinhalt);
	if ((infocode != null) && (infocode != "")) {
			auswahltext = "["+bbcode+"="+infocode+"]"+infotext+"[/"+bbcode+"] ";
			pkBBCodeAdd(auswahltext);
			}
	}
// [pkHB] Hinweis Boxen BBCode by PimpYourKiT.de & BurnerFM.de Ende	
/*Lightbox ANFANG*/
function pkBBLight(bbcode){
	text=(pkBBSelected) ? pkBBSelected : '';
	
	LBPath="initial";
	
	while((LBPath!="") && (LBPath != null))
	{
		LBPath=prompt(lightbox,text);
		
		if((LBPath!='') && (LBPath != null)){
			showlist = "["+bbcode+"]"+LBPath+"[/"+bbcode+"]";
			pkBBCodeAdd(showlist);
		}
		showlist ="";
		text="";
	}
}
/*Lightbox ENDE*/	
	/* Videos BB Codes Anfang */
	function myvideos(bbcode)
	{
	text=(pkBBSelected) ? pkBBSelected : '';
	
	Nummer = prompt(videonummer,text);
	
	var fensterausgabe;
	
			if ((Nummer != null) && (Nummer != "")) 
			{
			auswahltext = "["+bbcode+"]"+Nummer+"[/"+bbcode+"]";
			pkBBCodeAdd(auswahltext);
			
			}
			else
			{
				if (bbcode == "Youtube") 
				{
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Youtube Videos";
				}
				if (bbcode == "Myvideo") 
				{
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Myvideo Videos";
				}
				if (bbcode == "Clipfish") {
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Clipfish Videos";
				}
				if (bbcode == "Gametrailer") {
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Gametrailer Videos";
				}
				if (bbcode == "Veoh") {
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Veoh Videos";
				}
				if (bbcode == "Metacafe") {
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Metacafe Videos";
				}
				if (bbcode == "Myspace") {
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Myspace Videos";
				}
				if (bbcode == "Dailymotion") {
				ausgabe = videonummer;
				ausgabeinhalt = "Nummer des Dailymotion Videos";
				}
				Show = prompt(ausgabe,ausgabeinhalt);		
				if ((Show != null) && (Show != "")) {
					if ((Nummer != null) && (Nummer != "")) {
						auswahltext = "["+bbcode+"]"+Show+"[/"+bbcode+"]";
						pkBBCodeAdd(auswahltext);
					}
				}
			}

		
	}
	/* Videos BB Codes ENDE */
/* ColorPicker by www.Blutrausch-Gilde.com */
function pkBBColor(bbcode)
	{
	text=(pkBBSelected) ? pkBBSelected : '';
	text="[color="+bbcode+"]"+text+"[/color]";
	
	pkBBCodeAdd(text);	
	pkBBFocus();
	}
/* ColorPicker by www.Blutrausch-Gilde.com */	
/*link and email*/
function pkBBLink(bbcode)
	{
	text=(pkBBSelected) ? pkBBSelected : '';
	
	linktext = prompt(linkname,text);
	
	var fensterausgabe;
	if (bbcode == "URL") {
		ausgabe = linkadresse;
		ausgabeinhalt = "http://";
		}
	else {
		ausgabe = emailname;
		ausgabeinhalt = "";
		}
	
	linkurl = prompt(ausgabe,ausgabeinhalt);
	if ((linkurl != null) && (linkurl != "")) {
		if ((linktext != null) && (linktext != "")) {
			auswahltext = "["+bbcode+"="+linkurl+"]"+linktext+"[/"+bbcode+"] ";
			pkBBCodeAdd(auswahltext);
			
			}
		else{
			auswahltext = "["+bbcode+"]"+linkurl+"[/"+bbcode+"] ";
			pkBBCodeAdd(auswahltext);
			}
		}
	}
/**************************************** HIDDEN_HACK Anfang ****************************************/
function hidden(bbcode,wert)
	{
	text=(pkBBSelected) ? pkBBSelected : '';
	
	linktext = prompt("Bitte hier den Text eintragen",text);
	
	var fensterausgabe;
	if (bbcode == "hiddenstatus") {
		ausgabe = "Bitte den status angeben ab wann man diesen Text lesn darf.\nBsp.: (user, member, vip, mod oder admin).";
		ausgabeinhalt = "";
		}
	if (bbcode == "hiddencounter") {
		ausgabe = "Ab wie viele Tage soll diese Nachricht sichtbar werden?\nMaximal " + wert + " Tage m\u00f6glich";
		ausgabeinhalt = "";
		}
	if (bbcode == "hiddenpost") {
		ausgabe = "Ab wie viele Posts darf man diesen Text sehen?\nMaximal " + wert + " Posts m\u00f6glich";
		ausgabeinhalt = "";
		}
		
	if (bbcode == "hiddenid") {
		ausgabe = "Bitte die Userid`s mit Komma eintragen. Bsp.: 1,44,678,543,678";
		ausgabeinhalt = "";
			}

	if (bbcode == "hiddenpw") {
		ausgabe = "Bitte ein Passwort hier eingeben";
		ausgabeinhalt = "";
		}
	
	linkurl = prompt(ausgabe,ausgabeinhalt);
	if ((linkurl != null) && (linkurl != "")) {
		if ((linktext != null) && (linktext != "")) {
			auswahltext = "["+bbcode+"="+linkurl+"]"+linktext+"[/"+bbcode+"] ";
			pkBBCodeAdd(auswahltext);
			
			}
		}
	}
/**************************************** HIDDEN_HACK Ende   ****************************************/
/* list */
function pkBBList()
	{
	listtype=prompt(listentyp,'');
	
	if((listtype == "a") || (listtype == "1"))
		{
		mylist = "[list="+listtype+"]\n";
		listend = "[/list="+listtype+"] ";
		}
	else
		{
		mylist = "[list]\n";
		listend = "[/list] ";
		}
	
	listentry="initial";
	while((listentry!="") && (listentry != null))
		{
		listentry=prompt(listenwerte,'');
		
		if((listentry!='') && (listentry != null))
			mylist = mylist+"[li]"+listentry+"[/li]\n";
		}
	
	pkBBCodeAdd(mylist+listend);
	}
