$(function(){	// shorthand for $(document).ready()	
	$("#topnav #topnav_" + section).css("font-weight", "bold");
	$("#topnav #topnav_" + section).html("{" + $("#topnav #topnav_" + section).html() + "}");
	
	var rolltemp = '';
	$("#topnav a").hover(
		function() { 
			rolltemp = $(this).html(); 
			if (rolltemp.indexOf("{") == -1) $(this).html("{" + $(this).html() + "}")
			
			},
		function() {                
			$(this).html(rolltemp);
			
			}
	  );
	 
	 $('#prod_image p').css({opacity: 0.66, backgroundColor: '#fff'});
	 $('#prod_image p').corner();
	 
	 $("#trim_grid ul li").bind('click',
		function(event) {
			//$('#prod_image.prod_preview p').fadeOut("fast");
			$(this).siblings().animate({ opacity: 0.5 }, "fast");
			$(this).animate({ opacity: 1 }, "fast");
			opacity = 1;
			
			swatchcolor = $('#prod_image').css('backgroundColor');
			//alert(swatchcolor);
			//var swatch = $('<div class="swatch" style="width: ' + 50 + 'px;height: ' + 50 +  'px;"></div>').appendTo('#prod_image');
			
			soldout = 0;
			if ($(this).attr('rel') < 1) soldout = 1;
			
			$('#prod_image.prod_preview p').css({backgroundColor: swatchcolor }).html('').removeShadow();
			
			if (soldout) $('#prod_image.prod_preview p').html('Sold<br />Out');
			
			$('#prod_image.prod_preview p').animate({ opacity: 1 }, 1);
			
			$('#prod_image.prod_preview p').fadeIn(1);
			$('#prod_image.prod_preview p').dropShadow({blur: 6});
			
			trim_thumb = $(this).css('backgroundImage');
			trim_photo = trim_thumb.replace(/thumb_/, "");
			$('#prod_image').fadeOut(100, function(){$('#prod_image').css('backgroundImage', trim_photo).fadeIn(100);});
			$('#selectedtrim').html($(this).attr('name'));
			if (!soldout) {
				$('#addtocart').css('visibility', 'visible');
			} else {
				$('#addtocart').css('visibility', 'hidden');
			}
				
			thisid = $(this).attr('id').replace(/trim_/, "");
			$('#trimid').val(thisid);
			
			thisname = $(this).attr('name');
			$('#trimid').attr('rel', thisname);
			}
	  );
	  
	$('#trim_grid ul li').css('opacity',0.5);
	$('#trim_grid ul li p.soldout').css('opacity',0.75);
	
	$('#trim_grid ul li').hover(
		function(){
			$(this).css('cursor', 'pointer');
			opacity = $(this).css('opacity');
			$(this).css('opacity',1); 
		},
		function(){ 
			$(this).css('opacity', opacity); 
			$(this).css('cursor', 'auto');
			//alert($('form#prod_form #trim').val());
			}
	);
	
	var sideCount = (sidebarimages.length);
	var randomSide = Math.floor(Math.random() * (sideCount));
	$('body#default #right').css('background-image', 'url(/img/sidebar/'+ sidebarimages[randomSide] +'?num='+randomSide+')');
	
	$('#footnav li:not(:last)').after(' | ');
	
	$('.hidden').css('opacity', 0);
	cartLoad();
	
	$('#prod_image.prod_preview p').center();
	$('#prod_image.prod_preview p').dropShadow({blur: 6});
	
	$('.shadow').dropShadow({top: 2, left: 0, blur: 4});
	$('.corners, body#default #right').corner("round 5px");

	$('.shadow').redrawShadow();
	//$('#statusbar #cartstatus').center({ vertical: true, horizontal: false } );
	$('.vcenter').center({ vertical: true, horizontal: false });
	$('.center').center({ vertical: false, horizontal: true });

	// SIFR //
	//$.sifr({ path: '/swf/', color: '#fff' }); 
	//$('#topnav a').sifr({font: 'adobe_garamond_pro', color: '#493B35'});
	//$('body#home h2').sifr({font: 'adobe_garamond_pro_bold', color: '#fff'});
});	