
function checkAGB(){
	alert('Ohne die Anerkennung der AGBs können Sie leider nicht an unseren Gewinnspielen teilnehmen\nBitte schließen Sie das Fenster, wenn Sie die Gewinnspiel Bedingungen nicht annehmen.');
	document.gewinn.agb.checked=true;
}

function checkAGB_neu(){
alert('Ohne die Anerkennung der AGBs koennen Sie sich leider nicht registrieren.\nBitte schliessen Sie das Fenster, wenn Sie die AGBs nicht annehmen.');
        document.getElementById('agb').checked=true;
}


function par(_par,_nix){
  var _s=parent.location.href;
  var _p=_s.indexOf('?');
  if (_p==-1) {return _nix;}
  _s='&'+_s.substring(_p+1);
  _p=_s.indexOf('&'+_par+'=');
  if (_p==-1) {return _nix;}
  _s=_s.substring(_p+_par.length+2);
  _p=_s.indexOf('&');
  return (_p==-1)?(_s):(_s.substring(0,_p));
}

 


function getgewinn() {
   act=par('act','');
   adr=par('adr','');
  
  if (act!='') {
     act=act.replace(/%20/g,' ');

   if(document.gewinn.spiel){	
     document.gewinn.spiel.value=act;}

     if(document.gewinn.aktion){	
     document.gewinn.aktion.value=act;}
     document.gewinn.sendto.value=adr;
     //document.gewinn.titel.focus();
  }


}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine Emailadresse enthalten.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' muss eine Nummer enthalten.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' muss eine Nummer zwischen '+min+' und '+max+' enthalten.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' ist ein Mussfeld.\n'; }
  }

if (document.forms[0].gebj)
{
	sIndex = document.forms[0].gebj.selectedIndex;
	if (sIndex <= 0) {
	errors += '- Bitte zumindest Geburtsjahr eingeben!\n';
	  }

}

if (document.forms[0].bad)
{
	sIndex = document.forms[0].bad.selectedIndex;
	if (sIndex <= 0) {
	errors += '- Bitte ein Bad auswaehlen!\n';
  }
}

 if (errors) alert('Folgende Fehler sind aufgetreten:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function validateRadiobuttons() {
  if ((document.getElementById('abonnent1').checked==false)&&(document.getElementById('abonnent2').checked==false)) {
      //document.getElementById('abofarbe').style.backgroundColor='#BBBBBB';
      return false;
  }else{
  
return true

  }
}


function validateRadioAqua() {
  
  alert('1:'+document.getElementById('frage1').checked);
  alert('2:'+document.getElementById('frage2').checked);
  alert('3:'+document.getElementById('frage3').checked);
  alert('4:'+document.getElementById('frage4').checked);
  alert('5:'+document.getElementById('frage5').checked);
  alert('6:'+document.getElementById('frage6').checked);
  alert('7:'+document.getElementById('frage7').checked);
  alert('8:'+document.getElementById('frage8').checked);
  alert('9:'+document.getElementById('frage9').checked);
  alert('10:'+document.getElementById('frage10').checked);
  alert('11:'+document.getElementById('frage11').checked);
  
  if ((document.getElementById('frage1').checked==false)||(document.getElementById('frage2').checked==false)||(document.getElementById('frage3').checked==false)||(document.getElementById('frage4').checked==false)||(document.getElementById('frage5').checked==false)||(document.getElementById('frage6').checked==false)||(document.getElementById('frage7').checked==false)||(document.getElementById('frage8').checked==false)||(document.getElementById('frage9').checked==false)||(document.getElementById('frage10').checked==false)||(document.getElementById('frage11').checked==false)) {
  
  alert('Bitte gesamten Fragebogen ausfuellen');
  return false;
  }else{
  return true;

}

}


function init(width){

if(!width){ width=100};
var bgcolor_focus = '#00509F';
var bgcolor_blur = '#FFFFFF';

var color_focus = '#FFFFFF';
var color_blur = '#333333';

var fontweight_focus = 'bold';
var fontweight_blur = 'normal';

var pflichtfeld_text_nicht_ausgefuellt ='*';
var pflichtfeld_text_ausgefuellt ='<img src="ok.gif" alt=\'Pflichfeld ist ausfuellt\'>';

var input = document.gewinn.getElementsByTagName('input');
var textarea = document.getElementsByTagName('textarea');

//Fokus auf das erste inputfeld
//input[1].focus();


  //alle Eingabefelder bei focus/blur event

  for(i=0;input.length>i;i++){
	 if(input[i].type.indexOf('radio')>-1){continue;} //radiobuttons auslassen
	 if(input[i].type.indexOf('submit')>-1){continue;} //submitbuttons auslassen
	 if(input[i].type.indexOf('checkbox')>-1){continue;} //checkbox auslassen
	 if(input[i].name.indexOf('anz_west')>-1){continue;} //checkbox auslassen
	 //if(i>15){break;}

     input[i].style.width=width;  

    input[i].onfocus = function(){
      this.style.backgroundColor=bgcolor_focus;
      this.style.color=color_focus;
      this.style.fontWeight=fontweight_focus;
    }

    input[i].onblur = function(){

	  
      if(this.name=='plz_rec'){
         var erg = this.value.match(/[0-9]+/);
	     if(erg){
	       if(window.plz['p'+erg[0]] && erg[0].length<5){document.gewinn.ort_rec.value=window.plz['p'+erg[0]];}
	     }
       }	


	   if(this.name=='titel' && document.getElementById('titel_rec')){
		   uebernehmen1(this);	
	   }	

	   if(this.name=='vname' && document.getElementById('vname_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='nname' && document.getElementById('nname_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='str' && document.getElementById('str_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='hausnr' && document.getElementById('hausnr_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='plz' && document.getElementById('plz_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='ort' && document.getElementById('ort_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='land' && document.getElementById('land_rec')){
		   uebernehmen1(this);	
	   }	
	   if(this.name=='tel' && document.getElementById('tel_rec')){
		   uebernehmen1(this);	
	   }	

	  
	  
	  
	  this.style.backgroundColor=bgcolor_blur;
      this.style.color=color_blur;
      this.style.fontWeight=fontweight_blur;
      if(this.name=='vname' || this.name=='nname' || this.name=='str' ||   this.name=='land'){
       this.value=this.value.toUpperCaseFirst();
       }
//       alert(document.getElementById(this.name+'m').id);
      if( document.getElementById(this.name+'m')){
         if(this.value){
           document.getElementById(this.name+'m').innerHTML=pflichtfeld_text_nicht_ausgefuellt;
         }else{
	   document.getElementById(this.name+'m').innerHTML=pflichtfeld_text_nicht_ausgefuellt;
	 }

      if( (this.name=='hausnr') || (this.name=='stiege') || (this.name=='stock') || (this.name=='top')){
				
            if(this.value.match(/\//) || this.value.match(/\-/)){
	          alert("Bitte keinen Slash (/)  oder Bindestrich (-) eingeben");
		  this.focus();
	    }

	      
	   this.value=this.value.replace(/\s/g,'');		
    }






      if(this.name=='plz'){ 
         var erg = this.value.match(/[0-9]+/);
	     if(erg){
	       if(window.plz['p'+erg[0]] && erg[0].length<5){document.gewinn.ort.value=window.plz['p'+erg[0]];}
	     }
       }	



      }
}



  }



//Textarea

  for(i=0;textarea.length>i;i++){
    textarea[i].style.width=width;  

    textarea[i].onfocus = function(){
      this.style.backgroundColor=bgcolor_focus;
      this.style.color=color_focus;
      this.style.fontWeight=fontweight_focus;
    }

    textarea[i].onblur = function(){
      this.style.backgroundColor=bgcolor_blur;
      this.style.color=color_blur;
      this.style.fontWeight=fontweight_blur;
     
      if( document.getElementById(this.name+'m')){
         if(this.value){
           document.getElementById(this.name+'m').innerHTML=pflichtfeld_text_nicht_ausgefuellt;
         }else{
	       document.getElementById(this.name+'m').innerHTML=pflichtfeld_text_nicht_ausgefuellt;
	     }
      }
    

	}









  }






//radiobuttons SN ABONNENT
//Vignettenaktion und testleser blöcke dynamisch zu- bzw. wegschalten 2006-01-18 by mahe
if(document.getElementById('abonnent1')){
        abonnent1 = document.getElementById('abonnent1');

        abonnent1.onclick= function(){
                document.getElementById(this.name+'m').innerHTML='<img src="ok.gif" alt=\'Pflichfeld ist ausfuellt\'>';
                document.getElementById('snabo_vingnette').style.display = 'none';
                document.getElementById('snabo_trenner').style.display = 'none';
                document.getElementById('snabo_gratis').style.display = 'none';
				document.getElementById('check').checked=false;
        }

}



if(document.getElementById('abonnent2')){
        abonnent2 = document.getElementById('abonnent2');

        abonnent2.onclick= function(){
                document.getElementById(this.name+'m').innerHTML='<img src="ok.gif" alt=\'Pflichfeld ist ausfuellt\'>';
                if(navigator.appName=="Microsoft Internet Explorer"){
                        document.getElementById('snabo_vingnette').style.display = 'block';
                        document.getElementById('snabo_trenner').style.display = 'block';
                        document.getElementById('snabo_gratis').style.display = 'block';
						document.getElementById('check').checked=true;

                }else{
                        document.getElementById('snabo_vingnette').style.display = 'table-row';
                        document.getElementById('snabo_trenner').style.display = 'table-row';
                        document.getElementById('snabo_gratis').style.display = 'table-row';
  					    document.getElementById('check').checked=true;
                }
        }

}




}





String.prototype.toUpperCaseFirst=function(){
 var tempChar = this.substring(0,1); 	 
// var tempStrTail  = this.substring(1).toLowerCase(); 	 
 var tempStrTail  = this.substring(1); 	 
 var tempStr = tempChar.toUpperCase();
 tempStr += tempStrTail;
	
 return	tempStr;

}




function uebernehmen1(elem){

  if(document.getElementById('uebernehmen')){
	if(document.getElementById('uebernehmen').checked){
	  document.getElementById(elem.id+'_rec').value=elem.value;
	}

  }
}







