jQuery(function() {
	jQuery('.child-active').parent().show();
	
	jQuery('.carousel ul').simplyScroll({
		className: 'vert',
		horizontal: false,
		frameRate: 20,
		speed: 2
	});
			
	var sI = 0;
	jQuery('.simply-scroll-list li').mouseover(function() {
		sI = setInterval(function() {
			var clip = jQuery('.simply-scroll-clip');
			var kids = clip.children();
			var itemMax = kids[0].offsetHeight;
			var posMax = kids.length * itemMax;		
				
			if(clip.scrollTop() < (posMax-clip.height())) {
				clip.scrollTop(clip.scrollTop()+2);
				jQuery('.simply-scroll-back').removeClass('disabled');
			} else {
				clearInterval(sI);
				jQuery('.simply-scroll-forward').addClass('disabled');
			}
		}, 50);
	}).mouseout(function() {
		clearInterval(sI);
	});
		
	jQuery('.option_Engraving select').live('change', function() {
		if(jQuery('.option_Engraving select option:selected').text() == "") {
			jQuery('.template_Initials, .template_Font').hide();
		}	
	});
	
	jQuery("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'facebook'
	});
	
	var quotes = [
		'<p>"I never thanked you for your help.  I actually went to Rothman\'s, where you\'d arranged for an abalone M-Clip to be held for me, and bought it that day.  It was a bit of a splurge, but I LOVE it.  Thanks again for your help."</p><p style="float: left"><span style="font-weight: bold">Terry K.</span></p>',
		'<p>"Just letting you know I received the order yesterday and they look great...thank you so much."</p><p style="float: left"><span style="font-weight: bold">Bradley S.</span></p>',
		'<p>"Received M-Clips first thing this morning.  Thank you for your great customer service!!  Will recommend!!</p><p>Thanks again"</p><p style="float: left"><span style="font-weight: bold">Kim I.</span></p>',
		'<p>"Thank you and I love your product."</p><p style="float: left"><span style="font-weight: bold">Brian L.</span> | AUSTRALIA</p>',
		'<p>"Thanks again for working with us on this, and thanks for the excellent workmanship and service."</p><p style="float: left"><span style="font-weight: bold">Henry\'s Fork Anglers</span></p>',
		'<p>"I just received my M-Clip all brushed stainless version and can\'t tell you how much I am enjoying it already.  Unmatched quality and functionality!"</p><p style="float: left"><span style="font-weight: bold">Scott A.</span></p>',
		'<p>"The M-Clip is truly the world\'s finest money clip. I bought several for my top clients and received great responses from all. Not only does this clip hold everything I need, but it looks good too!"</p><p style="float: left"><span style="font-weight: bold">Jim D.</span> | ORLANDO, FL</p>',
		'<p>"I want to tell you how much I am enjoying my purchase from M-Clip. I have owned multiple money clips over the years ranging from twenty dollars to several hundred. I\'ve tried magnetics, spring tension clips, hybrid clips... anything that looked like it would securely hold a lot of cash... I am so happy with this purchase. The sliding lever design insures that the money can\'t and won\'t go anywhere until the lever is slid and pushed. And the compliments I\'ve gotten on this clip keep coming!</p><p>Thank you for designing the only money clip that really makes sense for men. You have answered a problem we\'ve had for years!</p><p>I\'m one VERY happy customer."</p><p style="float: left"><span style="font-weight: bold">Ben N.</span> | JACKSONVILLE, FL</p>'
	];	
	jQuery('.calloutContent').html(function() {
		var randomQuote = Math.floor(Math.random() * quotes.length);
		return quotes[randomQuote] + '<p style="float: right"><a href="Testimonials.aspx" title="View more Testimonials">more ></a></p><div class="clear"></div>';
	});	
	
	jQuery('#testimonials').html(function() {
		var testimonials = '';
		jQuery.each(quotes, function() {
			testimonials += this + '<hr class="clear" style="border: none; background: #ccc; height: 1px" />';
		});
		
		return testimonials;
	});
			
	
	jQuery('.cs-nav a, .top-sellers a').each(function() {
		var curlink = window.location;
		var link = this.href;
		curlink = curlink.toString();
		link = link.toString();
		if(curlink.match(link)) jQuery(this).addClass("current")
	})	
	
	jQuery('#datepicker').datepicker({
		buttonImage: '../images/calendar.png',
		buttonImageOnly: true,
		showOn: 'both',
		onSelect: function(date) {
			jQuery('#date-month').val(date ? date.substring(0, 2) : '');
			jQuery('#date-day').val(date ? date.substring(3, 5) : '');
			jQuery('#date-year').val(date ? date.substring(6, 10) : '');
		}
	});

	jQuery('#date-month,#date-day,#date-year').change(function() {
		jQuery('#datepicker').datepicker('setDate', new Date(
			parseInt(jQuery('#date-year').val(), 10),
			parseInt(jQuery('#date-month').val(), 10) - 1,
			parseInt(jQuery('#date-day').val(), 10))
		);
	});
	
	jQuery('#featured ul').innerfade({
		speed: 'slow',
		timeout: 5000,
		type: 'sequence',
		containerheight: '116px'	
	});
	
	jQuery('#literature').click(function(e) {
		e.preventDefault();
		$(this).next('ul').slideToggle();
	}).next('ul').hide();
	
	var active_color = '#303030'; 
	var inactive_color = '#4f4f4e';

	jQuery("input.default-value").css("color", inactive_color);
	var default_values = new Array();
	jQuery("input.default-value").focus(function() {
		if (!default_values[this.id]) {
			default_values[this.id] = this.value;
		}
		if (this.value == default_values[this.id]) {
			this.value = '';
			this.style.color = active_color;
		}
		jQuery(this).blur(function() {
			if (this.value == '') {
				this.style.color = inactive_color;
				this.value = default_values[this.id];
			}
		});
	});			
});
