/* ### ARTIST MENÜ 2-SPALTIG, Martin Wecke für netzameisen.com ### */

$(document).ready(function() {
li_count_1 = $(".artist_nav ul#genre-0 li").size()-1;                                   // anzahl der items der ersten liste
li_count_2 = $(".artist_nav ul#genre-2 li").size()-1;                                   // anzahl der items der zweiten liste
if(li_count_1 > li_count_2) { li_count = li_count_1; } else { li_count = li_count_2 }   // li_count ist die anzahl der größeren Liste
half = Math.ceil(li_count/2);                                                           // die hälfte der anzahl (wenn ungerade aufgerundet)

if(li_count_1 >= half ) {                                                                // Behandlung der retsen Listenötig?
$(".artist_nav ul#genre-0 li").addClass("r1");                                          // allen items ne class geben
  for(i=1;i<=half+1;i++) {
    $(".artist_nav ul#genre-0 li:nth-child(" + i + ")").removeClass("r1");              // der ersten hälfte der items ne andere class geben
    $(".artist_nav ul#genre-0 li:nth-child(" + i + ")").addClass("l1");
  }
  $(".artist_nav ul#genre-0 li").unwrap();                                              // gesamte liste auflösen
  $(".artist_nav .l1").wrapAll("<ul/>");                                                // 2 neue listen bilden nach class
  $(".artist_nav .r1").wrapAll("<ul class='r' />");
}
if(li_count_2 >= half ) {                                                                // und jetzt alles für die zweite liste
$(".artist_nav ul#genre-2 li").addClass("r2");
  for(i=1;i<=half+1;i++) {
    $(".artist_nav ul#genre-2 li:nth-child(" + i + ")").removeClass("r2");
    $(".artist_nav ul#genre-2 li:nth-child(" + i + ")").addClass("l2");
  }
  $(".artist_nav ul#genre-2 li").unwrap();
  $(".artist_nav .l2").wrapAll("<ul/>");
  $(".artist_nav .r2").wrapAll("<ul class='r' />");
}
});