
	$(document).ready(function(){

		// Font Styling
		Cufon.replace('header #navigation li a.page', { fontFamily: 'Pseudo Bold', hover: true });
		Cufon.replace('header #shop-collections li a', { fontFamily: 'Baby Face', hover: true });
		Cufon.replace('header h2, .product-gallery h2, .product-gallery h4, #product-info h2', { fontFamily: 'Pseudo Bold' });
		Cufon.replace('#wish-list h2a', { fontFamily: 'Pseudo Skinny Bold' });
		// Cufon.replace('#product-info .description', { fontFamily: 'Baby Face' });
		
		
		$('.single-product .product-gallery a').hover(function(){
			$(this).stop().animate({ opacity: 0.2 });
		},function(){
			$(this).stop().animate({ opacity: 1 });			
		})
		
		// Dialog Boxes
		$('a.visit-wish-list, a.add-to-wish-list').click(function(e){
			e.preventDefault();
			$('#wish-list').load($(this).attr('href'), function(){
				$('#modal').show();
				$('#wish-list').dialog({
					width: 482,
					dialogClass: 'wish-list',
					close: function(event, ui) {
						$('#modal').hide();						
					}
				});
			});		
		});
		
		$('#navigation li.shop').hover(function(){
			//$(this).addClass('active');
			$('#shop-collections').show();
		},function(){
			//$(this).removeClass('active');
			$('#shop-collections').hide();
		});
		
		
		/* * * * * * * * * *
		 * SHOPPING CART CONTROLS
		 * * * * * * * * * * * * * * */
		$('#products .list .product .remove').live('click', function(e){ // Delete Product From List 
			e.preventDefault();
			$.ajax({ url: $(this).attr('href') });
			$(this).parent().fadeOut();
		});
		$('#products .sidebar .send-to-store').live('click', function(e){ // Send To Store 
			e.preventDefault();
			$('#wish-list').load($(this).attr('href')).dialog({
				modal: true,
				width: 482,
				dialogClass: 'wish-list send-to-store'
			});
			$('#wish-list').dialog("option", 'position');
		});
		
		var scrollPane = $('.product-gallery'),
			scrollContent = $('.product-content'),
			productWidth = 0;

		$('.product', scrollContent).each(function(){
			productWidth = productWidth + $(this).outerWidth(true);
		});
		scrollContent.css({ width: productWidth });

		var scrollbar = $('.scroll-bar').slider({
			slide: function(event, ui) {
				if (scrollContent.width() > scrollPane.width()) {
					scrollContent.css('margin-left', Math.round(
						ui.value / 100 * (scrollPane.width() - scrollContent.width())
					) + 'px');
				} else {
					scrollContent.css('margin-left', 0);
				}
			}
		});

		var handleHelper = scrollbar.find('.ui-slider-handle')
		.mousedown(function(){
			scrollbar.width(handleHelper.width());
		})
		.mouseup(function() {
			scrollbar.width( "100%" );
		})
		.append('<span class="ui-icon ui-icon-grip-dotted-vertical"></span>')
		.wrap('<div class="ui-handle-helper-parent"></div>').parent();
		
		var remainder = scrollContent.width() - scrollPane.width(),
			proportion = remainder / scrollContent.width(),
			handleSize = scrollPane.width() - (proportion * scrollPane.width());
			
		scrollbar.find(".ui-slider-handle").css({
			width: handleSize,
			"margin-left": -handleSize / 2
		});
		handleHelper.width("").width( scrollbar.width() - handleSize);
		
		
		
		/* *
		 * Product Scripts
		 * * * * * * * * * * * */
		$('.product-type a:first').click(function(e){ // Product Type Toggle 
			e.preventDefault();
			var self = $(this);
			var parent = self.parent();
			if (parent.hasClass('active')) {
				self.next().hide();			
				parent.removeClass('active');	
			} else {
				self.next().show();			
				parent.addClass('active');	
			}
		});		
		$('.product-brand a:first').click(function(e){ // Product Brand Toggle 
			e.preventDefault();
			var self = $(this);
			var parent = self.parent();
			if (parent.hasClass('active')) {
				self.next().hide();			
				parent.removeClass('active');	
			} else {
				self.next().show();			
				parent.addClass('active');	
			}
		});
		

		$(".default-text").focus(function(srcc) {
	        if ($(this).val() == $(this)[0].title) {
	            $(this).removeClass("default-text-active");
	            $(this).val("");
	        }
	    });
	    $(".default-text").blur(function() {
	        if ($(this).val() == "") {
	            $(this).addClass("default-text-active");
	            $(this).val($(this)[0].title);
	        }
	    });
	    $(".default-text").blur();


		/*
		$('.product-gallery').each(function () {
			
		    var ul = $('ul', this);
		    var productWidth = ul.innerWidth() - $(this).outerWidth();

		    var slider = $('.slider', this).slider({ 
				min: 0, 
				max: productWidth, 
				slide: function (ev, ui) {
					ul.css('left', '-' + ui.value + 'px');
				}, 
				stop: function (ev, ui) {
					ul.animate({ 'left' : '-' + ui.value + 'px' }, 500, 'linear');
				}
		    });
		});
		*/
			
	});

