// selektiert alle Chechboxen
function checkAll( field ) {
   for ( i = 0; i < field.length; i++ ) {
      field[ i ].checked = true;
   }
}


// deselektiert alle Chechboxen
function checkNone( field ) {
   for ( i = 0; i < field.length; i++ ) {
      field[ i ].checked = false;
   }
}


// blendet einen css-container ein oder aus
function toggleNavi() {
   var e1 = document.getElementById( "suche_ergebnisliste" );
   var e11 = document.getElementById( "themenSelectAll" );
   var e12 = document.getElementById( "themenSelectNone" );
   var e13 = document.getElementById( "themenAnzeigeoptionen" );
   var e14 = document.getElementById( "themenX" );
   var e15 = document.getElementById( "themenEinblenden" );
   var e2 = document.getElementById( "searchresult_tree_footer" );
   var e3 = document.getElementById( "suche_infosmitthema_liste" );
   if( e1.style.display == "none" ) {
      e1.style.display = "block";
      e11.style.display = "block";
      e12.style.display = "block";
      e13.style.display = "block";
      e14.style.display = "block";
      e15.style.display = "none";
      e2.style.display = "block";
      e3.style.marginLeft = "33%";
      e3.style.minWidth   = "65%";
      e3.style.maxWidth   = "65%";
      e3.style.width       = "65%";
   } else {
      e1.style.display = "none";
      e11.style.display = "none";
      e12.style.display = "none";
      e13.style.display = "none";
      e14.style.display = "none";
      e15.style.display = "block";
      e2.style.display = "none";
      e3.style.marginLeft = "0";
      e3.style.minWidth   = "98%";
      e3.style.maxWidth   = "98%";
      e3.style.width       = "98%";
   }
   return true;
}

// stellt sicher, dass die komplette Grafik des Popups links vom Cursor zu sehen ist
function resizeGrafikPopup(width) {
   //document.getElementById("popup_grafik").style.marginLeft = width;
}


function swap_antwort_antwortkurz() {
   var a = document.getElementById( "antwort" );
   var ak = document.getElementById( "antwortkurz" );
   var akt = document.getElementById( "antwort_kuerzen_text" );
   if( a.style.display == "none" ) {
      a.style.display = "block";
      ak.style.display = "none";
      akt.innerHTML="Antwort k&uuml;rzer";
      document.cookie = 'antwortkurz=0;';
   } else {
      a.style.display = "none";
      ak.style.display = "block";
      akt.innerHTML="Antwort l&auml;nger";
      document.cookie = 'antwortkurz=1;';
   }
   return true;
}


function is_antwortkurz() {
   cookie = document.cookie;
   if( cookie ){
      cookiename = cookie.substr( 0, cookie.search( '=' ) );
      cookiewert = cookie.substr( cookie.search( '=' ) + 1, cookie.search( ';' ) );
      if( cookiewert == '' ) {
        cookiewert = cookie.substr( cookie.search( '=' ) + 1, cookie.length );
      }
      if( cookiename == "antwortkurz" )
         return cookiewert == "1";
   }
   return false;
}


function show_antwort() {
   var a = document.getElementById( "antwort" );
   var ak = document.getElementById( "antwortkurz" );
   var akt = document.getElementById( "antwort_kuerzen_text" );
   var azl = document.getElementById( "antwort_zeigen_link" );
   var rfl = document.getElementById( "richtig_falsch_button" );
   var w = document.getElementById( "zwischenweiter" );
   if( rfl != null ) rfl.style.display = "inline";
   if( is_antwortkurz() ) {
      ak.style.display = "block";
      if( akt != null ) akt.innerHTML="Antwort l&auml;nger";
   } else {
      a.style.display = "block";
      if( akt != null ) akt.innerHTML="Antwort k&uuml;rzer";
   }
   if( akt != null ) akt.style.display = "block";
   if( w != null ) w.innerHTML="";
   if( azl != null ) azl.innerHTML="";
}

function show_zwischenantwort( nr, total ) {
   var a = document.getElementById( "zwischenantwort"+nr );
   var w = document.getElementById( "zwischenweiter" );
   a.style.display = "block";
   tmp = nr + 1;
   if( document.getElementById( "zwischenfrage"+tmp ) == null ) {
      w.innerHTML='<a href="#" onClick="show_antwort(); return false;" class="navigational">weiter</a>';
   } else {
      w.innerHTML='<a href="#" onClick="show_zwischenfrage( '+tmp+' ); return false;" class="navigational">weiter</a>';
   }
   for ( i = 1; i <= total; i++ ) {
      var zaa = document.getElementById( "zwischenantwortanchor"+i );
      if( i == nr ) {
         zaa.class = "navigational_active";
         zaa.className = "navigational_active";
      }
      else {
         zaa.class = "navigational";
         zaa.className = "navigational";
      }
      var zfa = document.getElementById( "zwischenfrageanchor"+i );
      zfa.class = "navigational";
      zfa.className = "navigational";
   }
}

function show_zwischenfrage( nr, total ) {
   var a = document.getElementById( "zwischenfrage"+nr );
   var w = document.getElementById( "zwischenweiter" );
   a.style.display = "block";
   tmp = nr * 2 - 1;
   w.innerHTML='<a href="#" onClick="show_zwischenantwort( '+nr+' ); return false;" class="navigational">weiter</a>';
   for ( i = 1; i <= total; i++ ) {
      var zfa = document.getElementById( "zwischenfrageanchor"+i );
      if( i == nr ) {
         zfa.class = "navigational_active";
         zfa.className = "navigational_active";
      }
      else {
         zfa.class = "navigational";
         zfa.className = "navigational";
      }
      var zaa = document.getElementById( "zwischenantwortanchor"+i );
      zaa.class = "navigational";
      zaa.className = "navigational";
   }
}


