$(function() {
  $('a[href*=#]').velvetyScroll({
    speed: 400,
    easing: 'easeInOutExpo'
  });
  
  var bodyId = $('body').attr('id');
  
  if (bodyId == 'home') {
  	$('#slider ul').cycle();
  	$('#sec_re .action a').colorbox({iframe: true, width: '700px', height: '515px'});
  }

  if (bodyId == 'lineup') {
    $('#content .row section:nth-child(3n+1)').css({marginLeft: 0});

    var count = 1,
    vCount = 1,
    num = $('#content .row section').length;
    for (var i = 1; i <= num; i++) {
      $('#content .row section:nth-child(' + i + ')').addClass('heightLine-group' + count);
      if (vCount == 3) {
        count++;
        vCount = 1;
      } else {
        vCount++;
      }
    }
  }
  
  if (bodyId == 'detail') {
    var num = $('.sc-list ul li').length;
    if (num > 3) {
      $('.sc-list').jcarousel({
        scroll: 1,
        auto: 4,
        wrap: 'circular'
      });
    } else if (num == 0) {
      $('.sc-list').prepend('<p class="thin">同クラスの車種はございません。</p>');
    }
    
    $('.dc-photo li:not(:first-child)').click(function() {
      var _src = $(this).children().attr('src');
      $('.dc-photo li:first-child').children().attr('src', _src);
    });
  }
  
  if (bodyId == 'client') {
    $('#content div section:last').addClass('last-child');
  }
  
  if (bodyId == 'price') {
    $('#tab').tabSwitch();
    $('#content table tr th:first-child').css({width: '130px'});
    $('#content table tr td:nth-child(2)').css({width: '45px', textAlign: 'center'});
    $('#content table tr td:nth-child(3)').css({width: '32px', textAlign: 'center'});
    $('#content table tr td:nth-child(4)').css({width: '48px', textAlign: 'center'});
    $('#content table tr td:nth-child(5)').css({textAlign: 'center'});
    $('#content table tr td:nth-child(6)').css({textAlign: 'center'});
    $('#content table tr td:nth-child(7)').css({textAlign: 'center'});
    $('#content table tr td:nth-child(8)').css({textAlign: 'center'});
    $('#content table tr td:nth-child(9)').css({textAlign: 'center'});
  }
  
  if (bodyId == 'contact') {
    $('#contact_postcode').zip2addr('#contact_address');
    var validation = $('#form').exValidation({
      rules: {
        contact_name: 'chkrequired',
        contact_email: 'chkrequired chkemail chkhankaku',
        contact_email2: 'chkrequired chkretype-contact_email',
        contact_message: 'chkrequired'
      },
      stepValidation: true
    });
  }
});
