$(document).ready(function(){
	// Initialize Nivo slider	
	var total = $('.slider img').length;
	var rand = Math.floor(Math.random()*total);
	$('.slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500,
		pauseTime:3000,
		startSlide:rand, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavHide:true,
		controlNavThumbs:true, //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
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
	
	// Homepage logo animation
	if ($('.temp #product-in-focus').length > 0) {
		$('<div id="big-logo"></div>').hide().prependTo('#wrapper').fadeIn(3000).delay(3000).fadeOut(3000);
		//$('<div id="big-logo"><img src="/CommonResources/Files/www.abecita.se/img/layout/abecita-big-logo.png" /></div>').hide().prependTo('#wrapper').fadeIn(3000).delay(3000).fadeOut(3000);
	}
	
	//zebra striped tables
	//$("table tr:nth-child(2n)").addClass("even");

	//hide and show product tip
	$("#available-products .form").addClass("off-screen");
	$(".tip a").click(function(){
		$(this).parent().parent().next().removeClass("off-screen").addClass("on-screen");
		return false;
	});	

	/* Highlight anchors */
	var hash = document.location.hash;
	if (hash) {
		$(hash).find("h2").addClass("highlight");
	}
	$("a").click(function(){
		 $(this.hash).addClass("highlight");
	});
	
	//Apply hover effect on clickable list items
	$(".clickable-items li").hover(function() {
		$(this).addClass("hover"); //over
	}, function() {
		$(this).removeClass("hover"); //out			
	});
	
	//Make list items clickable, with parent containing class .clickable-items
	$(".clickable-items li").click(function() {
		var the_url = $(this).find("a:first").attr("href");
		if (the_url != null){
			location.href = the_url;
		}
	});
	
});