/* vim:set ts=2 sw=2 sts=2 ai si nu et ft=javascript ff=dos:

  Last Change: 18-September-2008 13:15:56.
  Author: Technical team.
  Copyright: (C)Anchor Group K.K.

  URL: http://www.anchor-gr.jp/labo.html
  EMAIL: info@anchor-gr.jp

  Include: http://jquery.com/
    (jQuery. Special Thanks!)

  Filename: autostripe.js

 ---------------------------------------------------------*/

var AutoStripeVersion = "1.1.0";

function olStripe(ol_class, class_even, class_odd)
{
  $('ol.'+ol_class+' li')
    .filter(':nth-child(even)')
      .filter(':not(*[class])').addClass(class_even).end()
    .end()

    .filter(':nth-child(odd)')
      .filter(':not(*[class])').addClass(class_odd).end()
    .end()
  ;
  return;
}

function ulStripe(ul_class, class_even, class_odd)
{
  $('ul.'+ul_class+' li')
    .filter(':nth-child(even)')
      .filter(':not(*[class])').addClass(class_even).end()
    .end()

    .filter(':nth-child(odd)')
      .filter(':not(*[class])').addClass(class_odd).end()
    .end()
  ;
  return;
}

function dlStripe(dl_class, class_even, class_odd)
{
  $('dl.'+dl_class)
    .find('dt')
      .filter(':even')
        .filter(':not(*[class])').addClass(class_even).end()
      .end()

      .filter(':odd')
        .filter(':not(*[class])').addClass(class_odd).end()
      .end()
    .end()

    .find('dd')
      .filter(':even')
        .filter(':not(*[class])').addClass(class_even).end()
      .end()

      .filter(':odd')
        .filter(':not(*[class])').addClass(class_odd).end()
      .end()
    .end()
  ;
  return;
}

function trStripe(table_class, class_even, class_odd)
{
  $('table.'+table_class+' tr')
    .filter(':nth-child(even)')
      .filter(':not(*[class])').addClass(class_even).end()
    .end()

    .filter(':nth-child(odd)')
      .filter(':not(*[class])').addClass(class_odd).end()
    .end()
  ;
  return;
}

function tdStripe(table_class, class_even, class_odd, mode)
{
  if(mode == 'col'){
    /* col */
    $('table.'+table_class+' tr')
      .find('td')
        .filter(':nth-child(even)')
          .filter(':not(*[class])').addClass(class_even).end()
        .end()
        .filter(':nth-child(odd)')
          .filter(':not(*[class])').addClass(class_odd).end()
        .end()
      .end()
    ;
  }else{
    /* row */
    $('table.'+table_class+' tr')
      .filter(':nth-child(even)')
        .find('td')
          .filter(':not(*[class])').addClass(class_even).end()
        .end()
      .end()

      .filter(':nth-child(odd)')
        .find('td')
          .filter(':not(*[class])').addClass(class_odd).end()
        .end()
      .end()
    ;
  }
  return;
}


