function newWindow(link, width, height) {
	params = "menubar=no,scrollbars=yes,resizable=yes,locationbar=no,status=no,screenX=100,screenY=100";
	if (width!=0)	
		params = params + ",width=" + (width+20);
	if (height!=0)	
		params = params + ",height=" + (height+40);
	win = window.open(link, "bild", params);
}

function checkform(of) {
   var reqfields,em,i,f,ty;
   var failed = false;

   if(document.getElementById('required')) {
      reqfields=document.getElementById('required').value.split(',');

      for(i=0;i<reqfields.length;i++) {
         f=document.getElementById(reqfields[i]);
			f.style.background='white';

         if(f) {
            ty=f.type.toLowerCase();
            switch(ty) {
               case 'text':
                  if(f.value=='') {adderr(f.id,of); failed = true;}
                  if(f.id=='EMail' && !isEmailAddr(f.value)) {
                     adderr(f.id,of);
                     failed = true;
                  }
                  break;
               case 'textarea':
                  if(f.value=='') {adderr(f.id,of); failed = true;}
                  break;
               case 'checkbox':
                  if(!f.checked) {adderr(f.id,of); failed = true;}
                  break;
               /* extend as needed */
            }
         }
      }
   }
   if (failed) {
      alert('Bitte füllen Sie alle Pflichtfelder aus!');
      return false;
   }
}

function adderr(id,of) {
   var se,i,nli,na;
   se=document.getElementById(id);
   se.style.background='#fcc';
}

function isEmailAddr(str) {
    return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
}
