/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 *
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com)
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 *
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 *
 */

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","visible");
		});
	}
})(jQuery);


function getFitment(params)
{
	$.colorbox({href:"/site/?command=epimGetPage&modulePage=itemFitmentList&ajax=1&ajdt=1"+params,width:800,height:600});
}

/*function viewProdImage(params)
{
	$.colorbox({href:"'.$imagePath.'"+params,width:800,height:600});
}*/


function expandNavTab($clicked)
{	
	if ($clicked.hasClass('expanded'))
	{
	$clicked.removeClass('expanded');
		$clicked.parents('li').find('.subNav').slideUp('slow');	
		
	} else {
		$('.expanded').parents('li').find('.subNav').slideUp('slow').removeClass('expanded');
		$clicked.addClass('expanded');
		$clicked.parents('li').find('.subNav').slideDown('slow');
	}
	return false;
}







// Alternate background colors // set equal coumn heights // hide / reveal items.
$(document).ready(function(){
$('ul.navBlock li a.expandable').click(function(){return expandNavTab($(this));});

	
  $(".alternate:odd").addClass("alternate-odd");
  $(".alternate:even").addClass("alternate-even");
  $(".revealTarget").addClass("hide");
//########### REMOVE IF USING RESIZING COLUMNS ##########
//  $(".column").equalHeights();
//########### REMOVE IF USING RESIZING COLUMNS ##########

  // Show / Hide gallery items.
  $("a.revealLink").click(function(){
    var $myTarget = $(this).attr("href");

    $($myTarget).children(".galleryBox").children("a").children(".replaceThumb").each(function(){
      $(this).attr("src",$(this).attr("title"));
    });

    if ($($myTarget).hasClass("hide")){$($myTarget).removeClass("hide");}
    else {$($myTarget).addClass("hide");}
//########### REMOVE IF USING RESIZING COLUMNS ##########
//    $(".column").equalHeights();
//########### REMOVE IF USING RESIZING COLUMNS ##########
  });

  // Show all / Used in the FAQ page.
  $("a.revealer").click(function(){
    var $count = 0;
    $(".hide").each(function(){
      $count = ($count + 1);
    });
    if ($count > 0){
      $("a.revealer").text("Colapse All");
      $(".hide").removeClass("hide");
    }
    else {
      $("a.revealer").text("Expand All");
      $(".revealTarget").addClass("hide");
    }
//########### REMOVE IF USING RESIZING COLUMNS ##########
 //   $(".column").equalHeights();
//########### REMOVE IF USING RESIZING COLUMNS ##########
  });
});

