$(document).ready(function(){				

$('#feature-slider').easySlider();


$("#callout-product-nav").click(function(){
  $("#product-nav-dock").animate({"left": "0px"}, "slow");
  $(this).hide();
});
$("#close-sidebar-dock").click(function(){
  $("#product-nav-dock").animate({"left": "-240px"}, "slow");
  $("#callout-product-nav").show();
});


				// TABLES
				$('#clickable-matrix tr').click(function() {
        var href = $(this).find("a").attr("href");
        if(href) {
            window.location = href;
        }
    });
	
	$("table.striped tr:odd").addClass("alt-row");
	
	var max_height = 0;
	$("div.product").each(function(){
	if ($(this).height() > max_height) { max_height = $(this).height(); }
	});
	$("div.product").height(max_height);

$('.product').click(function() {
        var href = $(this).find("a").attr("href");
        if(href) {
            window.location = href;
        }
    });

	$(".product:odd").after('<br class="clear" />');	
				
				// UI CHANGES
				$('body#product-category .col-sidebar').append('<img src="/images/leftcol-fade-bottom.png" class="sidebar-fade-bottom" />');	
				$('.product').append('<img src="/images/capsule-small-top.png" class="product-cell-top" />');			
				$('.ribbon-best-seller').append('<img src="/images/ribbon-bestseller.png" class="product-box-badge" />');	
				$('.ribbon-gigabit').append('<img src="/images/ribbon-gigabit.png" class="product-box-badge" />');		
				
				// PRODUCT GALLERY
				$("#product-gallery-slides")
					.cycle({
						next:   '#gallery-next', 
						prev:   '#gallery-prev',
						pause:   1,
						timeout: 5000,
						pager:  '#product-gallery-nav' 	
					});
					$('#gallery-pause').toggle(						
						function () {
						$('#product-gallery-slides').cycle('pause');
					  },
					  function () {
						$('#product-gallery-slides').cycle('resume');
					  }
					);
				
				// LEFT TABS
				$(".tab_content").hide();
				$("ul.tabs_left li:first").addClass("active").show();
				$(".tab_content:first").show();
				$("ul.tabs_left li").click(function() {
				$("ul.tabs_left li").removeClass("active");
				$(this).addClass("active");
				$(".tab_content").hide();
				var activeTab = $(this).find("a").attr("href");
				$(activeTab).fadeIn();
				return false;
				});
			
				
				// TOGGLERS			
				$(".toggle_container").hide();
    
				$("h5.toggler").click(function(){
				 $(this).next(".toggle_container").slideToggle("slow");
				 if ($(this).hasClass('toggler_active')) {
				  $(this).removeClass("toggler_active");
				 }
				 else {
				  $(this).addClass("toggler_active"); 
				 }
				});
				
				$("h5.h5_open_onload").addClass("toggler_active"); 
				$(".open_onload").show();
							
				// SUBNAV TOGGLER 
				$(".subnav_toggle_container").hide();
				$("a.subnav_toggler").click(function(){
				 $(this).next(".subnav_toggle_container").slideToggle("slow");
				 if ($(this).hasClass('subnav_toggler_active')) {
				  $(this).removeClass("subnav_toggler_active");
				 }
				 else {
				  $(this).addClass("subnav_toggler_active"); 
				 }
				});
				
				$("a.subnav_toggler_open_onload").addClass("subnav_toggler_active"); 
				$(".subnav_open_onload").show();

				// SUBNAV ACTIVE NAVS
				$("body.p-ethernet-extenders li#products-subnav-extenders a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-main li#products-subnav-extenders a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-dslam li#products-subnav-dslam a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-lightning li#products-subnav-lightning a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-poe li#products-subnav-poe a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-wireless-wifi li#products-subnav-wireless-wifi a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-wireless-amplifiers li#products-subnav-wireless-amplifiers a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-wireless-antennas li#products-subnav-wireless-antennas a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-av li#products-subnav-av a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();
				$("body.p-wifi li#products-subnav-wifi a").addClass("subnav_toggler_active").next(".subnav_toggle_container").show();


				
				$('#home-bottom-center-slideshow').cycle({ 
					fx: 'fade', 
					timeout: 7000,
					pause: 'true',
					random: 1
				});
				$('#home-bottom-right-slideshow').cycle({ 
					fx: 'fade', 
					timeout: 7000,
					pause: 'true',
					random: 1
				});
					
				$('#bottomSliderMask, #newslets2 UL:first-child').cycle({ 
					fx: 'fade', 
					speed: 4000
				});
				
				$('#newslets2 UL:nth-child(2)').cycle({ 
					fx: 'fade', 
					speed: 4900
				});
				
				$('#newslets2 UL:nth-child(3)').cycle({ 
					fx: 'fade', 
					speed: 5600
				});
				
				$('#newslets2 UL:nth-child(4)').cycle({ 
					fx: 'fade', 
					speed: 6400
				});
				
				$('#newsItems').cycle({ 
				    cleartypeNoBg: 'false',
				    fx: 'fade', 
				    speed: 100, 
				    timeout: 3000,
				    next: '#rightArrow', 
				    prev: '#leftArrow', 
				    pause: 1,
					containerResize: false 
				});
				$('#rightbox UL').cycle({ 
				    fx: 'fade', 
				    speed: 300, 
				    timeout: 7000,
				    next: '#rightArrow', 
				    prev: '#leftArrow', 
				    pause: 1 
				});
				$('#centerbox UL').cycle({ 
				    fx: 'fade', 
				    speed: 300, 
				    timeout: 6000,
				    next: '#rightArrow', 
				    prev: '#leftArrow', 
				    pause: 1 
				});
				$("a.iframe").fancybox({
					'hideOnContentClick '	:	false,
					'type'				: 'iframe',
					'titleShow':false,
					'width'				: 680,
					'height'			: 650
				});
				$("#product-gallery-slides a").fancybox({
					'overlayOpacity': 0.85,
					'overlayColor': '#000',	
					'onStart': function() { $("#slideshow").cycle("pause"); },
					'onClosed': function() { $("#slideshow").cycle("resume"); }	
				});
				$("#video-pop").fancybox({
					'padding'           : 0,
					'autoScale'     	: false,
					'transitionIn'		: 'none',
					'transitionOut'		: 'none'
				});

		});
