function newWindow(URL,windowname,abilities) {
  		
  	window.open(URL,windowname,abilities);
}

function getSmilie(code) {
		
	var textbox = document.getElementById("gbText");
	
	var startPos = textbox.selectionStart;
	var endPos = textbox.selectionEnd;
	var scrollTop = textbox.scrollTop;
	textbox.value = textbox.value.substring(0, startPos) + code + textbox.value.substring(endPos, textbox.value.length);
	textbox.focus();
	
	var cPos = startPos + code.length;
	textbox.selectionStart = cPos;
	textbox.selectionEnd = cPos;
	textbox.scrollTop = scrollTop;
	
	if(textbox.createTextRange) {
		textbox.caretPos = document.selection.createRange().duplicate();
	}
		
}
	
function insertCode(code) {
	
	var textbox = document.getElementById("gbText");
	var tagOpen = "[" + code + "]";
	var tagClose = "[/" + code + "]";		
    var startPosition = textbox.selectionStart;
	var endPosition = textbox.selectionEnd;
	var scrollTop = textbox.scrollTop;
	var text = (textbox.value).substring(startPosition, endPosition);
		
	if(!text) { 
		text = prompt("Gewünschten Text eingeben:\n["+code+"]xxx[/"+code+"]", "");
	}
		
	if(text.charAt(text.length - 1) == " ") {
		code = tagOpen + text.substring(0, (text.length - 1)) + tagClose + " ";
	} else {
		code = tagOpen + text + tagClose;
	}
		
	textbox.value = textbox.value.substring(0, startPosition) + code + textbox.value.substring(endPosition, textbox.value.length);
	textbox.focus();

	var currentPosition = startPosition + (tagOpen.length + text.length + tagClose.length);
	textbox.selectionStart = currentPosition;
	textbox.selectionEnd = currentPosition;
	textbox.scrollTop = scrollTop;
	
	if(textbox.createTextRange) {
		textbox.caretPos = document.selection.createRange().duplicate();
	}

}
	
function insertURL() {
	
	var textbox = document.getElementById("gbText");
	var tagOpen = "[url";
	var tagClose = "[/url]";
    var startPosition = textbox.selectionStart;
	var endPosition = textbox.selectionEnd;
	var scrollTop = textbox.scrollTop;
	var description = (textbox.value).substring(startPosition, endPosition);
		
	if(!description) { 
		description = prompt("Gewünschte Bezeichnung eingeben:", "");
	}
	
	URL = prompt("Bitte URL eingeben:", "http://");
		
	if((URL != null) && (URL != "")) {
		if((description != null) && (description != "")) {
			code = "[url="+URL+"]"+description+"[/url] ";				
		} else {
			code = "[url]"+URL+"[/url] ";
		}
	}
		
	textbox.value = textbox.value.substring(0, startPosition) + code + textbox.value.substring(endPosition, textbox.value.length);
	textbox.focus();

	var currentPosition = startPosition + (tagOpen.length + text.length + tagClose.length);
	textbox.selectionStart = currentPosition;
	textbox.selectionEnd = currentPosition;
	textbox.scrollTop = scrollTop;
	
	if(textbox.createTextRange) {
		textbox.caretPos = document.selection.createRange().duplicate();
	}
}
	
function changeStatus(description) {
	
	var helpbox = document.getElementById("codeHelp");
		
	helpbox.value = description;
}

function bigImage(imagepath) {
	
	window.open(imagepath, "Image", "width=820,height=630,scrollbars=no");
}

function setLayerVisibility(layerID, status) {
	
	var layer = document.getElementById(layerID);
	
	layer.style.visibility = status;
}