jQuery.noConflict();
(function($){
	$(function() {
		
		if ( $('.col3-set').length > 0 ) {
			$('.col3-set .col-2, .col3-set .col-3').cycle();
			$('.col3-set .package-deal, .col3-set .special-offer').css({
				left: '15px',
				top: '15px'													
			});
		}

		$('.banner-slide').not(':first').hide();
		
		$('.banner ul li').each(function(i,e){
			$(e).click(function(event){
				if ($(e).hasClass('selected')){return false}
				$('.banner-slide:visible').fadeOut(function(){
					$('.banner ul li').removeClass('selected').eq(i).addClass('selected');
					$('.banner-slide').eq(i).fadeIn();									
				});
				event.preventDefault();
			});
		});
		
		$('.other-products .products').not(':first').hide();
		
		$('.other-products-menu a').each(function(i,e){
			$(e).click(function(event){
				$('.other-products .products:visible').hide();
				$('.other-products .products').eq(i).show();
				event.preventDefault();
			});
		});
		
		//$('.cart-container').load('/cart.php');
		
/*
		$('#nav>li>a').click(function(event){
			var el = $(this).parent('li'),
			childUl = el.children('ul');
			if ( childUl.length === 0 ) {
				return;
			} else {
				if ( !el.hasClass('active') ) {
					childUl.slideDown();
					el.addClass('active');
				} else {
					childUl.slideUp(function(){
						el.removeClass('active');
					});
				}
				event.preventDefault();	  
			}
		});
*/
		
		$('.product-image-zoom a').click(function(event){
			event.preventDefault();											
		});
		
		var tabs = $('#tabs li a'),
		tab_content = $('#tab_content li');
		tabs.eq(0).addClass('selected');
		tab_content.not(':first').hide();
		tabs.each(function (i, e) {
			$(e).bind('click', function (event) {
				var $this = $(this);
				tabs.removeClass('selected');
				$this.addClass('selected');
				tab_content.fadeOut().eq(i).fadeIn();
				event.preventDefault();
			});
		});
		
		//Sub Nav
		var t;
		$('#sub-nav').bind({
			mouseenter: function () {
				clearTimeout(t);
				$('#sub-nav').show();
			},
			mouseleave: function () {
				t = setTimeout(function () {
					$('#sub-nav').fadeOut();
				}, 500);
			}
		}).hide();
		$('.primary-nav li a.catalogue-nav').bind({
			click: function (e) {
				e.preventDefault();
			},
			mouseenter: function () {
				clearTimeout(t);
				$('#sub-nav').show();
			},
			mouseleave: function () {
				t = setTimeout(function () {
					$('#sub-nav').fadeOut();
				}, 500);
			}
		});
		
		//external links
		$('a[rel="external"]').click(function(){
			window.open($(this).attr('href'));
			return false;
		});
		
	});
})(jQuery);
