$(document).ready(function(){
	$(".slider-wrapper").css("display","inline-block");
	$(".slider-wrapper").css("position","relative");
	var max_size = 250;
	var min_size = 10;
	var num_imgs = 0;
	var size_inc = 50;
	var set_size = max_size;
	var selected = 1;
	
	var min_marg = -60;
	var max_marg = -3;
	var marg_inc = 10;
	var set_marg;
	var marg_perc_start = 30;
	var marg_multi = 1;

	var set_bot_marg;
	var bot_marg_start = 15;
	var bot_marg_inc = 5;
	
	var max_z = 99;
	var t,a,b,c;
	var speed = 1500;
	
	
	// set up initial display sizes
	$(".slider-wrapper").each(function(){
		num_imgs++;
		$(this).attr("data-index",num_imgs);
	});
	
	// assign hover effect
	$(".slider-wrapper").each(function(){
		$(this).hover(function(){
			selected = $(this).attr("data-index");
			$(".slider-wrapper").each(function(){
				t = $(this).attr("data-index");
				a = Math.abs(t-selected);
				set_size = max_size - (a*size_inc);
				if(set_size < min_size) { set_size = min_size; }
				set_marg = Math.floor(set_size * ((marg_perc_start+((a)*marg_multi))/100))*(-1);
				if(t==selected) { $(this).find("h2").show(); set_bot_marg=0; }
				else { $(this).find("h2").hide(); set_bot_marg = (bot_marg_inc*a) + bot_marg_start; }
				$(this).find("img").stop().animate({
					"width":set_size+"px",
					"height":set_size+"px",
					"margin-bottom":set_bot_marg+"px"},
					speed-1000);
				$(this).stop().animate({"margin-right":set_marg+"px"},
					speed-1000);
				$(this).css("z-index",max_z-a);
			});
		});
	});
	
	$(".slider-wrapper:eq(2)").trigger("mouseover");

	// animate the logo
	$('#logo_bar_m').animate({
		width: '+=21px'
	}, 600, function() {
		$('#logo_bar_t').css('display','block');
		$('#logo_bar_b').css('display','block');
		$('#logo_bar_t').animate({
    			top: '-=18px'
  		}, 600, function() {
    		/* Animation complete. */
  		});
		$('#logo_bar_b').animate({
    			top: '+=18px'
  		}, 600, function() {
    		/* Animation complete. */
  		});
	});
	
});
