// JavaScript Document
function mailto(part1, part2) {
	location.href = "mailto:"+part1+"@"+part2;
}
function popup(url, w, h) {
	l=Math.round((screen.width-w)/2);
	t=Math.round((screen.height-h)/2);
	args = 'width='+w+',height='+h+',left='+l+',top='+t+',resizable,scrollbars=yes';
	w = window.open(url,'',args)
	if(w) return false;
	return true;
}

function checkfield() {
		meldung="";
		for(i=0;i<checkfield.arguments.length;i=i+2) {
			id=checkfield.arguments[i];
			mld=checkfield.arguments[i+1];
			if(document.getElementById(id).value == "") meldung = meldung + "\n" + mld;			
		}
		
		if(meldung) {
			meldung = "FEHLER:\n" + meldung;
			alert(meldung);
			return false;
		}
	return true;
}

function platzhalter(id, replacement) {
	o = document.getElementById(id);
	o.focus();
	tr = document.selection.createRange();
	if(!replacement) replacement="%TITEL%";
	tr.text =replacement;
}

function checkform(frm) {
	var frm_error = new Array();
	var frm_output="";
	var tmperror="";
	var tmp = new Image();
	for(i=0; i< frm.elements.length; i++) {
		if(chk = frm.elements[i].getAttribute("checkform")) {
			tmperror="";
			if(chk=="notempty") {
				if(frm.elements[i].value=="") {
					frm.elements[i].style.border="1px solid red";
					frm.elements[i].style.backgroundColor="#fee";
					tmperror= "Bitte füllen Sie alle rot markierten Felder aus.";
				}
			}
			if(chk=="notnull") {
				if(frm.elements[i].value=="0") {
					frm.elements[i].style.backgroundColor="#fbb";
					tmperror= "Bitte füllen Sie alle rot markierten Felder aus.";
				}
			}
			for(j in frm_error) if(frm_error[j]==tmperror) tmperror="";
			if(tmperror) frm_error.push(tmperror);
		}
	}
	if(frm_error.length) {
		for(i in frm_error) {
			frm_output += frm_error[i] + "\n";
		}
		tmp.src="/track.php?action=checkform";
		alert(frm_output);
		return false;
	}
	return true;
}
