/* $Id: functions.js,v 1.1 2003/11/27 21:58:35 Kai Noltemeyer Exp $ */



function cursor() { 
if (( navigator.userAgent.indexOf("Opera" ) != -1) || ( navigator.userAgent.indexOf("Netscape" ) != -1)) { 
text_before = document.postMsg.postText.value; 
text_after = ""; 
} else { 
document.postMsg.postText.focus(); 
var sel = document.selection.createRange(); 
sel.collapse(); 
var sel_before = sel.duplicate(); 
var sel_after = sel.duplicate(); 
sel.moveToElementText(document.postMsg.postText); 
sel_before.setEndPoint("StartToStart",sel); 
sel_after.setEndPoint("EndToEnd",sel); 
text_before = sel_before.text; 
text_after = sel_after.text; 
} 
} 
function insert(AddCode) { 
cursor(); 

document.postMsg.postText.value = text_before + AddCode + text_after; 
document.postMsg.postText.focus(); 
} 

function init(thisCode) { 

with ( document.postMsg.postText.value ) { 
insert(thisCode); 
document.postMsg.postText.focus(); 
} 
} 


function paste_strinL(strinL){
var input=document.postMsg.elements["postText"];
input.value=input.value+strinL;
}

function isEmail(str) {
// werden regular expressions unterstuetzt?
var supported = 0;
if (window.RegExp) {
var tempStr = "a";
var tempReg = new RegExp(tempStr);
if (tempReg.test(tempStr)) supported = 1;
}
if (!supported)
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
return (!r1.test(str) && r2.test(str));
}
function testEmail(str) {
if (!isEmail(str)) {
alert("Sie haben eine falsche eMail-Adresse eingegeben!\nBitte korrigieren Sie Ihre Eingabe.");
return false;
}
if (document.regform.vorname.value==""){
  alert ("Bitte geben Sie Ihren Vornamen ein.");
  return false;
  }
if (document.regform.name.value==""){
  alert ("Bitte geben Sie Ihren Namen ein.");
  return false;
  }
if (document.regform.anrede.value==""){
  alert ("Bitte wählen Sie eine Anrede aus.");
  return false;
  }
else {
return true;
}
}

