function checknum(el){
  if (el.value.length>0){
    if (!el.value.match(/^\d+$/)){
      alert('Bitte nur numerische Werte eintragen!');
      el.value = '';
      el.focus();
    }
  }
}

function checkmail(el){
  if (el.value.length>0){
    if (!el.value.match(/\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b/i)){
      alert('Bitte geben Sie eine gültige E-Mail Adresse an!');
      el.value = '';
      el.focus();
    }
  }
}

function checkblz(el){
  if (el.value.length>0){
    if (el.value.length!=8 || !el.value.match(/^\d+$/)){
      alert('Bitte geben Sie eine gültige Bankleitzahl an!');
      el.value = '';
      el.focus();
    }
  }
}

function checkdate(el,mode){

  d = document.getElementsByName('tx_carthforms_pi1[Startdatuma][d]')[0].value;
  m = document.getElementsByName('tx_carthforms_pi1[Startdatuma][m]')[0].value; 
  y = document.getElementsByName('tx_carthforms_pi1[Startdatuma][y]')[0].value;
  
  switch(mode){
    case 'd':
      if (parseInt(d) > 31 || parseInt(d) < 1 ){
        alert('Bitte geben Sie einen gültigen Tag an.');
        el.value = '';
        el.focus();
      }
    break;
    
    case 'm':
      if (parseInt(m) > 12 || parseInt(m) < 1 ){
        alert('Bitte geben Sie einen gültigen Monat an.');
        el.value = '';
        el.focus();
      }    
    break;
    
    case 'y':
      if (parseInt(y) < 2009 ){
        alert('Bitte geben Sie einen gültiges Jahr an.');
        el.value = '';
        el.focus();
      }        
    break;
  }

  if (d && m && y){
    var jetzt = new Date();
    nt = jetzt.getTime();
    
    udate = new Date(y,m,d);
    ut = udate.getTime();

    if(ut){
      if (ut < nt){
        alert('Bitte geben Sie ein Datum an das in der Zukunft liegt.');
        document.getElementsByName('tx_carthforms_pi1[Startdatuma][d]')[0].value = '';
        document.getElementsByName('tx_carthforms_pi1[Startdatuma][m]')[0].value = '';
        document.getElementsByName('tx_carthforms_pi1[Startdatuma][y]')[0].value = '';
      }
    }else{
      alert('Bitte geben Sie ein gültiges Datum an.');
      document.getElementsByName('tx_carthforms_pi1[Startdatuma][d]')[0].value = '';
      document.getElementsByName('tx_carthforms_pi1[Startdatuma][m]')[0].value = '';
      document.getElementsByName('tx_carthforms_pi1[Startdatuma][y]')[0].value = '';
    }
  }

}


function resetdata(){
  fe = document.gband.elements;
  
  for(i=0; i < fe.length; i++){
    if (fe[i].type == 'radio'){
    	fe[i].checked = false;
    }
    if (fe[i].type == 'checkbox'){
    	fe[i].checked = false;
    }
    if (fe[i].type == 'text'){
    	fe[i].value = '';
    }
    if (fe[i].type == 'textarea'){
    	fe[i].value = '';
    }

    if (fe[i].type == 'select-one'){
    	if (fe[i].name == 'tx_carthforms_pi1[Land]'){
    	fe[i].selectedIndex = '24';
    	}else{
    	fe[i].selectedIndex = '0';    	
    	}
    }
  }
  
}


