/*
 * Custom Script by Glide Design for Yeti Coolers
 * 
 * Author: Chris Canada for Glide Design
 * Author URI: http://www.glidedesign.com/
 *
 */

/* ********************* BEGIN JQUERY ********************** */
 
$(function() {


/* *********************** DEFINITIONS *********************** */

//Random filter
jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
	{
		random: function(a, i, m, r) {
			if (i == 0) {
				jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
			};
		return i == jQuery.jQueryRandom;  
	}
});
	
//Equal Heights
$.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","auto");
	});
}





/* *********************** TESTIMONIALS ********************** */

//Sidebar Testimonials
$('#sidebar-testimonials div').
	hide();
$('#sidebar-testimonials').
	find('div:random').
	show();

//Bottom Testimonials
$('#bottom-testimonials p').
	hide();
$('#bottom-testimonials').
	find('p:random').
	show();





/* ********************** EQUAL HEIGHTS ********************** */

//Section Panels
$(".section-panel").
	equalHeights();





/* ************************ SLIDESHOWS *********************** */

//Home Page
$('#slide-wrap').
	cycle({ 
		fx:     'fade', 
		speed:  'fast', 
		timeout: 9000, 
		next:   '#next', 
		prev:   '#prev' 
	});
//Tundra Pages
$('#product-slideshow').
	cycle({ 
		fx:     'fade', 
		speed:  'fast', 
		timeout: 9000, 
		next:   '#next', 
		prev:   '#prev' 
	});





/* *********************** FLOWPLAYER ************************ */

$("a.video-link").
	flowplayer(
		"http://www.yeticoolers.com/wp-content/themes/yeti/swf/flowplayer.commercial-3.1.1.swf",
		{key: '$8880dba84aa37c35a55'}
	);





/* ************************** VIDEOS ************************* */

//Home Page
$('#home-video-box div').
	hide();
$('#home-video-box div:first').
	show();
$('#video-list').
	find('li a.vid-link').
	bind("click", function(){
		tabHref = $(this).attr('href');
		$('#home-video-box div').
			hide();
		$(tabHref).
			show();
		return false;
	});





/* ************************** BINDS ************************** */

//Videos Page - Grizzly
$('a[href=#video-grizzly-shorter]').
	hide();
$('#video-grizzly-longer').
	hide();
$('a[href=#video-grizzly-longer]').
	bind("click", function(){
		var tarGet = $(this).attr("href");
		$(tarGet).
			show();
		$('#video-grizzly-shorter').
			hide();
		$(this).
			hide();
		$('a[href=#video-grizzly-shorter]').
			show();
			return false;
	});
$('a[href=#video-grizzly-shorter]').
	bind("click", function(){
		var tarGet = $(this).attr("href");
		$(tarGet).
			show();
		$('#video-grizzly-longer').
			hide();
		$(this).
			hide();
		$('a[href=#video-grizzly-longer]').
			show();
		return false;
	});

//Videos Page - 500 Lb. Man
$('a[href=#video-500-shorter]').
	hide();
$('#video-500-longer').
	hide();
$('a[href=#video-500-longer]').
	bind("click", function(){
		var tarGet = $(this).attr("href");
		$(tarGet).
			show();
		$('#video-500-shorter').
			hide();
		$(this).
			hide();
		$('a[href=#video-500-shorter]').
			show();
		return false;
	});
$('a[href=#video-500-shorter]').
	bind("click", function(){
		var tarGet = $(this).attr("href");
		$(tarGet).
			show();
		$('#video-500-longer').
			hide();
		$(this).
			hide();
		$('a[href=#video-500-longer]').
			show();
		return false;
	});

//Contact Page - Map
$('#map-illustrated').
	hide();
$('a[href=#mappress0]').
	bind("click", function(){
		var tarGet = $(this).attr("href");
		$(tarGet).
			show();
		$('#map-illustrated').
			hide();
		return false;
	});
$('a[href=#map-illustrated]').
	bind("click", function(){
		var tarGet = $(this).attr("href");
		$(tarGet).
			show();
		$('#mappress0').
			hide();
		return false;
	});





/* ********************** PRODUCT PAGES ********************** */
	
$('.SubCategoryListGrid li:odd').hide();





/* ********************* ROUNDED CORNERS ********************* */

$('#tab-links a').
	corner('top 7px');
$('#floating-sidebar').
	corner('tr br 7px');






});

/* *********************** END JQUERY *********************** */