/* JavaScript f. Kontakt-Seiten V3 */

$(function(){


/* Thema in Radiobuttons anzeigen */
var defaultThema = 'Festnetz, Internet, TV';
var txtThema = $('form.contactform select[name=strThema],form.contactform input[name=strThema]').val();
txtThema = txtThema=='' ? defaultThema : txtThema;
$('form.contactform2 input[name=strThema]').val([txtThema]);

/* Nur passende Listeneintraege anzeigen */
var thema = $('form.contactform2 input[name=strThema]:checked').attr('id');
thema = typeof(thema)=='undefined' ? 'thema0' : thema;
$('form.contactform2 select[name=strUThema] option').not('.'+thema).remove();

/* Unterthema in Auswahlliste anzeigen */
var txtUThema = $('form.contactform select[name=strUThema],form.contactform input[name=strUThema]').val();
$('form.contactform2 select[name=strUThema]').val(txtUThema);

/* Ggf. Auswahlliste ergaenzen */
if ($('form.contactform2 select[name=strUThema]').val()=='' && txtUThema!='') {
  $('form.contactform2 select[name=strUThema]').append('<option>'+txtUThema+'</option>');
  $('form.contactform2 select[name=strUThema]').val(txtUThema);
};

/* Thema/Unterthema in Dachzeile anzeigen */
if (typeof(txtUThema)!='undefined') {
  var txtHead = txtUThema + (txtThema=='Mobilfunk' ? ' ('+txtThema+')' : '');
  $('a[name=anker76656]').text(txtHead);
};

/* Leere Dachzeile bzw. Vorschaubild aus-, Hinweispfeil einblenden */
if (txtUThema=='') {
  $('#tkp76656').hide();
  $('#ltc76482 .FlowTextRight img').show();
} else {
  $('#ktt78334').hide();
};


/* onbeforeunload */
$('#btnSuccess,#btnNoSuccess').mousedown(function() {
  warning = false;
});


});


/* Submit */
function radioSubmit(){
  $('form.contactform2 select[name=strUThema]').val('');
  document.forms['contactform2'].submit();
};

function selectSubmit(){
  document.forms['contactform2'].submit();
};


/* onbeforeunload */
function closeIt(){
  if (warning){
      return unescape("Ihre Anfrage wurde NOCH NICHT ABGESENDET. Wir empfehlen Ihnen%2C auf der aktuellen Seite zu bleiben. W%E4hlen Sie mit den Buttons auf der aktuellen Seite%2C ob Sie Ihre Anfrage absenden m%F6chten oder nicht.");
  }
};

function nowarning(){
  warning = false;
};
