jQuery(document).ready(function($) {
	

	//prevent default on links with # as href
	$('body a[href=#]').click(function(event) { event.preventDefault(); });
	
	//cufon
	Cufon.set('fontFamily', 'BillabongBold');
	Cufon.replace('.titlehead span, .cats a', {hover:true});
	
	//Cufon.replace('h2, h3, h4, h5, h6, .print-services .step, , .product-name span, .addtocart, , .sundry-shop span.name, a.button', {hover:true});
	
	$('.print-services .head .step').hover(function() {
		//
		$(this).find('a, strong').css('color', '#B32317');
		Cufon.refresh();
	}, function() {
		//
		$(this).find('a, strong').css('color', '#949CA1');
		Cufon.refresh();
	});
	
	//cycle
	$('#content .cycle').each(function() {
		var wrap = $(this);
		var thumbs = wrap.find('.thumbs');
		wrap.find('.full ul').cycle({
									fx:'fade',
									timeout:4000,
									speed:1000,
									pager:thumbs,
									pagerAnchorBuilder: function(idx, slide) {
										var slide = $(slide).find('img');
										var src = slide.attr('src');
										
										var file = src.substring(src.lastIndexOf('/')+1);
										src = src.replace(file, '');
										src = src + 'thumbs/thumbs_' + file;										
										return '<a href="#"><img src="'+src+'" alt="'+slide.attr('alt')+'" width="80" height="63" /></a>';
									} 
									});
	});
	
	//home cycle
	$('#content .home-cycle').each(function() {
		var wrap = $(this);
		var thumbs = wrap.find('.cycle_nav');
		wrap.find('.cycle_window ul').cycle({
									fx:'fade',
									timeout:5000,
									speed:1000,
									pager:thumbs,
									pagerAnchorBuilder: function(idx, slide) {										
										return '<a href="#"></a>';
									} 
									});
	});
	
	
	//featured cycle
	$('#content .home .featured').each(function() {
		var wrap = $(this);
		wrap.find('ul').cycle({
									fx:'fade',
									timeout:4000,
									speed:500,
									});
	});
		
	//form auto clear
	$('#content form.autoclear').each(function() {
		var wrap = $(this);
		
		//auto clear defaults
		wrap.find('input[type=text], input[type=password], textarea').each(function() {
			var d = $(this).val();
			$(this).focus(function() { if($(this).val() == d) { $(this).val(''); } });
			$(this).blur(function() { if($(this).val() == '') { $(this).val(d); } });
		});
		
	});
	
	//columns of equal height
	function equalHeight(group) {
		tallest = 0;
		group.each(function() {
			thisHeight = $(this).height();
			if(thisHeight > tallest) {
				tallest = thisHeight;
			}
		});
		group.height(tallest);
	}
	
	$('#content .equalize').each(function() {
		equalHeight($(this).find('.eq'));
	});
	
	//checkout JS
	$('#shopp #chargetoaccount').click(function(e) {
		checkCCtoAccount();
	});
	
	function checkCCtoAccount() {
		var cc = $('#credit-card-fields');
		var trig = $('#chargetoaccount');
		if(trig.is(':checked')) {
			cc.hide();
		}else {
			cc.show();
		}
	}
	//init
	checkCCtoAccount();
	
});

/*auto submit shipping zip code
jQuery(document).ready(function($) {
		
	$('#shipping-postcode').keyup(function(e) {
				
		if( $(this).val().length >= 5 ) {
			$(this).closest('form').submit();
		}
		
	});
	
});*/
