/*
+----------------------------------------------------------------+
|   Insight for Dupal 6.x - Version 1.0                          |
|   Copyright (C) 2011 Antsin.com All Rights Reserved.           |
|   @license - Copyrighted Commercial Software                   |
|----------------------------------------------------------------|
|   Theme Name: Insight                                          |
|   Description: Insight by Antsin                               |
|   Author: Antsin.com                                           |
|   Date: 31st October 2011                                      |
|   Website: http://www.antsin.com/                              |
|----------------------------------------------------------------+
|   This file may not be redistributed in whole or               |
|   significant part.                                            |
+----------------------------------------------------------------+
*/ 

(function($) {
  $().ready(function() {
	$('#coda-slider-1').codaSlider({
      autoSlide: true,
      autoSlideInterval: 4000,
      autoSlideStopWhenClicked: true
    });

    $('#coda-slider-3').codaSlider();

	$('.boxgrid.caption').hover(function(){
      $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
	  }, function() {
	  $(".cover", this).stop().animate({top:'130px'},{queue:false,duration:160});
    });

	$("ul.menu").superfish({ 
      delay: 1000,
      animation: {opacity:'show',height:'show'},
      speed: 'slow',
      autoArrows: false,
      dropShadows: false
    });

	$("ul.mega-menu").superfish({ 
      delay: 1000,
      animation: {opacity:'show',height:'show'},
      speed: 'slow',
      autoArrows: false,
      dropShadows: false
    });

	if ($('#view-multi-column').hasClass('triple-column')) {
	  var $children = $('#content-main').find('.vmc-column');
      for(var i = 0, l = $children.length; i < l; i += 3) {
        $children.slice(i, i+3).wrapAll('<div class="vmc-row clearfix"></div>');
      }
	  $('div.vmc-row:first').addClass('first');
	  $('div.vmc-row:last').addClass('last');
	  $('div.vmc-row>div.vmc-column:nth-child(3)').addClass('last');
      equalHeight($(".vmc-column"));
	}

	if ($('#view-multi-column').hasClass('double-column')) {
	  var $children = $('#content-main').find('.vmc-column');
      for(var i = 0, l = $children.length; i < l; i += 2) {
        $children.slice(i, i+2).wrapAll('<div class="vmc-row clearfix"></div>');
      }
	  $('div.vmc-row:first').addClass('first');
	  $('div.vmc-row:last').addClass('last');
	  $('div.vmc-row>div.vmc-column:nth-child(2)').addClass('last');
	  equalHeight($(".vmc-column"));
	}

  });

  function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
	  var thisHeight = $(this).height();
	  if(thisHeight > tallest) {
	    tallest = thisHeight;
	  }
    });
    group.height(tallest);
  }
})(jQuery);
