function swapBg() {
	var backgroundId = $('#primary').css('background-image');
	var ids = (backgroundId.match(/\hp_(\d)\.jpg/) != null) ? backgroundId.match(/\hp_(\d)\.jpg/) : [0,0];
	var id = (ids[1] - 0);
	id = (id > 3) ? 0: id;
	$('.fader').css('opacity',0).show().css("background-image","url('/userimages/hp_"+(id+1)+".jpg')").animate({opacity: 1},900,function(){
			$('#primary').css("background-image","url('/userimages/hp_"+(id+1)+".jpg')");
			$(this).css('opacity',0);
	});
}

$(document).ready(function(){
			
			$('a[rel*=facebox]').facebox() ;
					
			$('#tryme').livequery('keyup', function(){				
			 	var keepit = $(this).val();
			 	alert(keepit);
			 	$('#wordtext').val(keepit);
			 });
			
						
			$('#carousel a').tooltip({ 
			    track: true, 
			    delay: 0, 
			    showURL: false, 
			    showBody: " - ", 
			    fade: 250 
			});
			
			$('#carousel2 a').tooltip({ 
			    track: true, 
			    delay: 0, 
			    showURL: false, 
			    showBody: " - ", 
			    fade: 250 
			});
			
			$(".carousel-wrap #carousel").jCarouselLite({
			    btnNext: ".next",
			    btnPrev: ".prev",
			    visible: 4,
			    speed: 400,
			    circular: false,
			    scroll: 3
			    
			});
			
			$(".carousel-wrap #carousel2").jCarouselLite({
			    btnNext: ".next2",
			    btnPrev: ".prev2",
			    visible: 4,
			    speed: 400,
			    circular: false,
			    scroll: 1
			    
			});
			
			
			$(".press-wrap #press-carousel").jCarouselLite({
			    btnNext: ".next",
			    btnPrev: ".prev",
			    visible: 4,
			    speed: 400,
			    circular: false,
			    scroll: 4
			    
			});
			
			$(".attr").change(function () {
	          var str = "";
	          var atr = "";
	         // alert('hi');
	          $(".attr option:selected").each(function () {
	                str += $(this).attr('rel') + " ";
	                atr += $(this).attr('title') + " ";
	            });
	          //alert(str);
	          if (str != ' ') {
	        	$("#detail-thumb img").attr("src", str);
	        	$("#detail-thumb").attr("href", atr);
	          }
	        });

			
			
			$(".attr1").change(function () {
	          var str2 = "";
	          var atr2 = "";
	          var quote = "";
	          $(".attr1 option:selected").each(function () {
	                str2 += $(this).attr('rel') + " ";
	                atr2 += $(this).attr('title');
	                quote += $(this).attr('rev');
	                
	            }); 
	            //alert(quote);
	            if (str2 != ' ') {
	        		$("#detail-thumb2 img").attr("src", str2);
	        	}
	        	if (atr2 != '') {
	        		$("#detail-thumb2").attr("href", atr2);
	        	}
	        	if ($('.attr1 option:selected').val() == 'customize your own') {
	        		$('#wordtext').val('');
	        		$('#info').html('Please enter your custom text below.<br /><textarea id="tryme"></textarea>');
	        		$('#wordtext').removeAttr("disabled");
	        	} else {
	        		//alert(quote);
	        		$('#wordtext').val(quote);
	        		$('#info').html(quote);
	        		$('#wordtext').attr("disabled", "disabled");
	        	}
	        });

			
			/*
			$("#carousel a").click(function() {
				//alert('howdy');
			    $("#detail-thumb img").attr("src", $(this).attr("href"));
			    $("#detail-thumb").attr("href", $(this).attr("rel"));
			    return false;
			});
			*/
		
		
		/*
		$("#carousel2 a").click(function() {
				//alert('howdy');
			    $("#detail-thumb2 img").attr("src", $(this).attr("href"));
			    $("#detail-thumb2").attr("href", $(this).attr("rel"));
			    return false;
			});
		*/
		
		$('.view-belt').click(function(){
			//$(this).css(backgroundImage:, 'url(/assets/img/zoom.gif);');
			$('#item-preview').toggle();
		});

		$('.bucket:last').css("border", 'none');

});