(function($) {
	$(document).ready(function() {
		

		Cufon.replace('#blockPrice h2, .Left h2, #contactTop h2, #meerkat-content h4', { fontFamily: 'DINCond-Black' });			
		
		// Store menu
		var crapPanel = $('#crap_panel');
		
		$('.crap_panel-links a').hover(
			function() {
				var hoverClass = $(this).attr('class');
				if (hoverClass) { crapPanel.html($('#crap_panel-data .'+hoverClass).html()); }
			},
			function() {
				crapPanel.html('');
			}
		);
		
		$("select, input:checkbox, input:radio, input:file").uniform();
		
		$("ul").children('li').addClass("alpha");
		
		// Side Category List
		$('#SideCategoryList li').has('ul').addClass('standalone');	
		$('#SideCategoryList ul ul').hide();
		
		$('#SideCategoryList li a').click(function() {
			if($(this).next().is('ul')) {
				$(this).next().slideToggle(400);
				//$(this).css("background-position","175px -90px");
				$(this).toggleClass('down_arrow');
				return false;
			}
		});
		
		var m = location.href;
		var n = m.substring(0,m.indexOf('?'));
		var q = n;
		var prodcheck = m.match("/products/");
		var catcheck = m.match("/categories/");
		
		if ((prodcheck !== null) || (catcheck !== null)) {
			if (n.length < 1) {
				q=m;
			}
			
			var p = $('#ProductBreadcrumb li:last').prev().html();
			
			if(p !== null){
				l = p.indexOf("=") + 2;
				r = p.indexOf(">") - 1;
				p = (p.substring(l, r));
				q=p;
			}
			
			$("a[href="+q+"]").parent().parent().parent().parent().show();
			$("a[href="+q+"]").parent().parent().show();
			$("a[href="+q+"]").not('.Content a').css("font-weight","bold");
		}
		
		
		// Front page slides
		$('#specials').nivoSlider({
			'effect':'fade', //Specify sets like: 'fold,fade,sliceDown'
			'slices':4,
			'animSpeed':500, //Slide transition speed
			'pauseTime':4000,
			'startSlide':0, //Set starting Slide (0 index)
			'directionNav':true, //Next & Prev
			'directionNavHide':true, //Only show on hover
			'controlNav':true, //1,2,3...
			'controlNavThumbs':false, //Use thumbnails for Control Nav
			'controlNavThumbsFromRel':false, //Use image rel for thumbs
			'controlNavThumbsSearch': '.jpg', //Replace this with...
			'controlNavThumbsReplace': '_thumb.jpg', //...this in thumb Image src
			'keyboardNav':true, //Use left & right arrows
			'pauseOnHover':true, //Stop animation while hovering
			'manualAdvance':false, //Force manual transitions
			'captionOpacity':0.8 //Universal caption opacity
		});
		
		
		// Accreditation carousel
		/*var accreditation = $('.accreditation');
		
		accreditation.jCarouselLite({
			auto: 5000,
			speed: 1000,
			visible: 5
		});
		
		$('li', accreditation).hover(
			function() {
				$('li', accreditation).css('opacity', '0.5');
				$(this).css('opacity', '1');
			},
			function() {
				$('li', accreditation).css('opacity', '1');
			}
		);*/
		
		// Featured Product carousel
		var featured_container = $('.featured_container');
		
		featured_container.jCarouselLite({
			auto: 0,
			speed: 1000,
			visible: 6,
			circular: 'true',
			btnNext: ".next",
			btnPrev: ".prev"
		});
		
		
		var overlay = $(this).find(".overlay");
		
		
	 	/* This code snippet handles the hover event type */
	 	var overlay;
		$(this).find(".overlay").hide().animate({
			left: -150
		},250);
	 	
	 	$('ul').children().hover(function(){
	 		overlay = $(this).find(".overlay");
			overlay.show().animate({
				left: 0
			},250);	
		}, function() {
			overlay.hide().animate({
				left: -150
			},250);
		});
		
		$("a#inline").fancybox({
				'height': 330,
				'width': 550,
				'autoDimensions': false 
		
		});	
		
		
		$("a#video").click(function() {
			$.fancybox({
				'padding'             : 0,
				'autoScale' 		  : true,
				'transitionIn'        : 'none',
				'transitionOut'       : 'none',
				'title'               : this.title,
				'width'               : 680,
				'height'              : 495,
				'href'                : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
				'type'                : 'swf',    // <--add a comma here
				'swf'                 : {'allowfullscreen':'true'} // <-- flashvars here
			});
			
			return false;
		}); 
		
		// Meerkat Banner
		
		$('#meerkat').meerkat({
			height: '210px',
			width: '748px',
			position: 'bottom',
			close: '.close-meerkat',
			dontShowAgain: '.dont-show',
			animationIn: 'slide',
			animationSpeed: 500
		});
		
		$('#meerkat-wrap').css({'z-index': '1'});
		
	});
})(jQuery);
