

//Smilie POPUP START:
var gibmemysmiliewindow_x = 320;
var gibmemysmiliewindow_y = 280;

function open_gibmemysmilie_window(x_width, y_width, wysiwyg, forumid)
{
		window.open("smilie_show.php", "smilies", "statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=" + x_width + ",height=" + y_width);
}
//Smilie POPUP END:


//BBCodes POPUP START:
var bbcodeswindow_x = 340;
var bbcodeswindow_y = 340;

function open_bbcodes_window(x_width, y_width, wysiwyg, forumid)
{
		window.open("bbcodes_show.php", "BBCodes", "statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=" + x_width + ",height=" + y_width);
}
//BBCodes POPUP END:



//NICHTS ÄNDERN AB HIER!
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_regexp = (window.RegExp) ? true : false;


function getActiveText()
{
	setfocus();
	if ((is_ie && !document.selection) || !document.selection)
	{
		return false;
	}

	var sel = document.selection;
	var rng = sel.createRange();

	if (rng != null && (sel.type == "Text" || sel.type == "None"))
	{
		text = rng.text;
	}
	if (rng != null && theform.textout.createTextRange)
	{
		theform.textout.caretPos = rng.duplicate();
	}
	return true;
}


function gibmemysmilie(thesmilie)
{
	getActiveText();
	var AddSmilie = " " + thesmilie + " ";
	AddText(AddSmilie);
}


function AddText(NewCode)
{
	if (typeof(theform.textout.createTextRange) != "undefined" && theform.textout.caretPos)
	{
		var caretPos = theform.textout.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
		caretPos.select();
	}
	else if (theform.textout.selectionStart || theform.textout.selectionStart == '0')
	{ // its mozilla and we'll need to re-write entire text
		var start_selection = theform.textout.selectionStart;
		var end_selection = theform.textout.selectionEnd;

		// fetch everything from start of text area to selection start
		var start = (theform.textout.value).substring(0, start_selection);
		// fetch everything from start of selection to end of selection
		var middle = NewCode;
		// fetch everything from end of selection to end of text area
		var end = (theform.textout.value).substring(end_selection, theform.textout.textLength);

		theform.textout.value = start + middle + end;
		setfocus();
		theform.textout.selectionStart = end_selection + middle.length;
		theform.textout.selectionEnd = start_selection + middle.length;
		getActiveText();
		AddTxt = "";
		return;
	}
	else
	{
		theform.textout.value += NewCode;
	}
	setfocus();
	getActiveText();
	AddTxt = "";
}


function setfocus()
{
	theform.textout.focus();
}


function alter_box_height(boxid, pixelvalue)
{
	var box = fetch_object(boxid);
	var boxheight = parseInt(box.style.height);
	var newheight = boxheight + pixelvalue;
	if (newheight > 0)
	{
		box.style.height = newheight + "px";
	}
	return false;
}
