$jq(window).load(function() {
	$('#slider').nivoSlider();
});

$(document).ready(function(){
	$('.dropdown').each(function () {
		$(this).parent().eq(0).hoverIntent({
			timeout: 100,
			over: function () {
				var current = $('.dropdown:eq(0)', this);
				current.slideDown(100);
			},
			out: function () {
				var current = $('.dropdown:eq(0)', this);
				current.fadeOut(100);
			}
		});
	});
	
	$jq('div.substeps img').wrap(function(){
		var imageLoc = $(this).attr("src");
		var relID = $(this).parent().parent().attr('id');
		return '<a id="single_image" rel="' + relID + '" href="' + imageLoc + '" />';
	});
	
	var selected = 1;
	$('ul#steps li').click(function(){
		$('ul#steps li#step-'+selected).removeClass('selected');
		var stepID = $(this).attr("id");
		var stepNum = parseInt(/step-(\d+)/.exec(stepID)[1], 10);
		selected = stepNum;
		$('ul#steps li#step-'+selected).addClass('selected');
		$('div.substeps').stop(true, true).fadeOut(300);
		$jq('div#substeps-'+stepNum).delay(300).fadeIn(300);
	});
});

$(document).ready(function(){
	$('a#single_image').fancybox();
	$("table.products").tablesorter();

	$width = ($(document).width() - 20) + "px";
	$left = (((($(document).width() - 960) / (2)) * (-1)) + 10) + "px";
	$('table.products').css('width', $width);
	$('table.products').css('marginLeft', $left);
});
