
function show(id) {document.getElementById(id).style.display = "block";}
function hide(id) {document.getElementById(id).style.display = "none";}
function get_mr(id,nr) {
	var MyReq = HttpRequest();
	var sf = 'such';
	MyReq.onreadystatechange = function() {
	if (MyReq.readyState == 4)
		document.getElementById("modellreihe"+nr).innerHTML = '<select name="'+sf+'[modellreihe_id]">'+'<option value="">' + document.getElementById('modellreihe'+nr).firstChild.firstChild.innerHTML + "</option>"+ MyReq.responseText.replace(/#ARCHIV#/g,document.getElementById('archiv_txt').innerHTML)+'</select>';
	};
	var method = 'GET';
	MyReq.open(method, '/mr.php?id='+id, true);
	MyReq.send((method == 'GET') ? null : 'posttest=1');
}
function show_auto(url) {document.getElementById('showauto').style.display = "block";document.getElementById('showauto').src=url;}
function hide_auto() 	{document.getElementById('showauto').style.display = "none";}
function zuruecksetzen() {
	document.getElementsByName("zeige_auch")[0].value ='';
	var auswahl = document.getElementsByTagName("input");
	for (i=0;i<auswahl.length;i++) {
		if (auswahl[i].checked == true && auswahl[i].className =="select_car")	auswahl[i].checked = false;
}	}
function count(id) { 
	if (document.getElementsByName("zeige_auch")[0].value !='')	var anz = document.getElementsByName("zeige_auch")[0].value.split(",").length;
	else														var anz = 0;
	var auswahl = document.getElementsByTagName("input");
	for (i=0;i<auswahl.length;i++) {
		if (auswahl[i].checked == true && auswahl[i].className =="select_car")	anz++;
	}
	if (anz>5) {
		document.getElementById(id).checked = false;
		alert("bitte nicht mehr als 5 Fahrzeuge auswählen.");
	}
}
function showimg(src,alt) {
	var bild_window = window.open("http://"+window.location.hostname+"/bild.php?src="+src.replace(/thumbs/,"")+"&alt="+alt,"Bild","toolbar=no,width=600,height=600,directories=no,scrollbars,status=no,menubar=no,resizable=yes");
	bild_window.document.close();
	bild_window.focus();
}
function addSmiley(id) {
	if (document.selection && document.selection.createRange().text != '')		document.selection.createRange().text = document.selection.createRange().text + "["+id+"]";
	else {
		document.getElementsByTagName('textarea')[0].value += "["+id+"]";
		document.getElementsByTagName('textarea')[0].focus();
}	}
function header() 		{edit("[h]","[/h]","header");}
function list() 		{edit("[list]","[/list]","list");}
function color(color) 	{edit("[color="+color+"]","[/color]","color");}
function fett() 		{edit("[b]","[/b]","fett");}
function italic() 		{edit("[i]","[/i]","italic");}
function uline() 		{edit("[u]","[/u]","uline");}
function url() {
	addurl = prompt("Bitte geben Sie die gewünschte URL ein:", "http://");
	edit("[url="+url+"]","[/url]","url",id);
}
function edit(start,end,id) {
	var textfield = document.getElementsByTagName('textarea')[0];
	if (textfield.selectionStart || textfield.selectionStart == '0') {
		textfield.focus();
		var startPos = textfield.selectionStart;
		var endPos = textfield.selectionEnd;
		strSelection = start + textfield.value.substring(startPos, endPos)+ end;
		textfield.value = textfield.value.substring(0, startPos) + strSelection + textfield.value.substring(endPos, textfield.value.length);
	}
	else if (document.selection && document.selection.createRange().text != '') {
		document.selection.createRange().text = start + document.selection.createRange().text + end;
	}
	else {
		if (document.getElementById(id).style.color=="#aaa") {
			textfield.value += end;
			document.getElementById(id).style.color="blue";
		}
		else {
			textfield.value += start;
			document.getElementById(id).style.color="#aaa";
}	}	}
