jQuery(document).ready(function($) {
	// Quick contact form
	$('#contact-us, .quick-contact-form').fancybox({
		href: BASE_URL + 'quick-form',
		onComplete:function() {
			// Invoke CUFON to style elements on the loaded page
			Cufon.replace('.cufon');

			// Change form action to take user to full form
			$('#contactForm').attr('action', BASE_URL + 'contacts/index/post')

			// Add current page url for reference
			$('#contactForm textarea:first').val('I was looking at ' + window.location.href + ' ');
		}
	});

	// Content slider
	$('.content-slider').each(function() {
		var content = $(this).find('.content-slider-content:first');
		content.hide();

		$(this).find('.content-slider-toggle:first').click(function(e) {
			e.preventDefault();
			content.slideToggle();
		});
	});

	// Navigation collapsing
	$('#category-nav ul').each(function() {
		if ($(this).find('.active').length == 0) {
			$(this).hide();
		}
	});

	/**
	 * This fixes an issue where on first load, the position of the banners is off
	 */
	setTimeout(function() {
		if (window.scrollApi) {
			$('#large_banners').css('top', 0);
			clearTimeout();
		}
	}, 10);

	// Fancy form styles
	$('input[type=checkbox], input[type=radio]').uniform();

	// Fix for main nav losing style due to cufon
	$('.quick-access li ul').mouseleave(function() {
		Cufon.refresh();
	});

	// Product image lightbox
	if ($.prettyPhoto) {
		$('a[rel^="prettyPhoto"]').prettyPhoto({
			default_width: 640,
			default_height: 480,
			allow_resize: false
		});
	}
});
