//Smileys einsetzen
function setsmile(Zeichen){
	document.newskom.text.value = document.newskom.text.value + Zeichen;
}

function validator_kontakt(theform){
	if(theform.name.value==""){
		alert("Schreib' Deinen Namen rein! Meinetwegen einen falschen!");
		theform.name.focus();
		return (false);
	}
	if(theform.email.value.indexOf('@')==-1 || theform.email.value.indexOf('.')==-1){
		alert("Keine E-Mail Fakes!");
		theform.email.focus();
		return (false);
	}
	if(theform.comment.value==""){
		alert("Wirklich nichts zu sagen?");
		theform.comment.focus();
		return (false);
	}
	return (true);
}

function BilderVorladen(){
	document.Vorladen = new Array();
	if(document.images){
		for(var i = 0; i < BilderVorladen.arguments.length; i++){
		document.Vorladen[i] = new Image();
		document.Vorladen[i].src = BilderVorladen.arguments[i];
		}
	}
}

//Text formatieren, HTML-Tags einfügen
function format_text(theform,v){
	//IE
	if(document.selection){
		var str = document.selection.createRange().text;
		theform.focus();
		var sel = document.selection.createRange();
		if(v=="line"){
			sel.text = "<hr>"+ str;
		}else if(v=="bild"){
			sel.text = "<img src=\"images/news/" + str + "\" alt=\"\" border=\"0\">";
		}else if(v=="mail"){
			sel.text = "<a href=\"mailto:" + str + "\">" + str + "</a>";
		}else if(v=="link"){
			sel.text = "<a href=\"http://" + str + "\" target=\"_blank\">" + str + "</a>";
		}else sel.text = "<" + v + ">" + str + "</" + v + ">";
		return;
	}
	//Mozilla
	if(document.getElementById && !document.all){
		var txtarea = theform;
		var selLength = txtarea.textLength;
		var selStart = txtarea.selectionStart;
		var selEnd = txtarea.selectionEnd;
		if(selEnd==1 || selEnd==2) selEnd = selLength;
		var s1 = (txtarea.value).substring(0,selStart);
		var s2 = (txtarea.value).substring(selStart, selEnd)
		var s3 = (txtarea.value).substring(selEnd, selLength);
		if(v=="line"){
			txtarea.value = s1 + '<hr>' + s2 + s3;
		}else if(v=="bild"){
			txtarea.value = s1 + '<img src=\"images/news/' + s2 + '\" alt=\"\" border=\"0\">' + s3;
		}else if(v=="mail"){
			txtarea.value = s1 + '<a href=\"mailto:' + s2 + '\">' + s2 + '</a>' + s3;
		}else if(v=="link"){
			txtarea.value = s1 + '<a href=\"http://' + s2 + '\" target=\"_blank\">' + s2 + '</a>' + s3;
		}else txtarea.value = s1 + '<' + v + '>' + s2 + '</' + v + '>' + s3;
		return;
	}
}

function dolist(theform){
	listtype = prompt("Welche Art Liste möchten Sie?\n 1: nummerierte Liste, a: alphabetische Liste, nichts: einfache Punktliste", "");
	if(listtype=="a"){
		thelist = "\n<ol type=\"a\">\n";
		listend = "</ol> ";
	}else if(listtype==1){
		thelist = "\n<ol>\n";
		listend = "</ol> ";
	}else{
		thelist = "\n<ul compact>\n";
		listend = "</ul> ";
	}
	listentry = "initial";
	while ((listentry!="") && (listentry!=null)){
		listentry = prompt("Listenpunkt eingeben.\nNichts eingeben, um die Liste fertigzustellen.", "");
		if((listentry!="") && (listentry!=null)) thelist = thelist+"<li>"+listentry+"</li>\n";
	}
	thelist = thelist+listend+'\n';

	//IE
	if(document.selection){
		var str = document.selection.createRange().text;
		theform.focus();
		var sel = document.selection.createRange();
		sel.text = str + thelist;
		theform.focus();
		return;
	}
	//Mozilla
	if(document.getElementById && !document.all){
		var txtarea = theform;
		var selLength = txtarea.textLength;
		var selStart = txtarea.selectionStart;
		var selEnd = txtarea.selectionEnd;
		if(selEnd==1 || selEnd==2) selEnd = selLength;
		var s1 = (txtarea.value).substring(0,selStart);
		var s2 = (txtarea.value).substring(selStart, selEnd)
		var s3 = (txtarea.value).substring(selEnd, selLength);
		txtarea.value = s1 + s2 + thelist + s3;
		theform.focus();
		return;
	}
}

function openBrWindow(URL){
	window.open(URL,'bigsize','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,screenX=0,screenY=0,top=0,left=0,width=1,height=1');
}

function resizeWindow(window_width,window_height){
	window.resizeTo(window_width,window_height);
}

function onoff(var1){
	if(document.getElementById(var1).style.visibility=='hidden'){
		document.getElementById(var1).style.visibility='visible';
	}else{
		document.getElementById(var1).style.visibility='hidden';
	}
}
