 /**
 * Acumen for Magento
 * http://gravitydept.com/to/acumen-magento
 *
 * @author     Brendan Falkowski
 * @package    gravdept_acumen
 * @copyright  Copyright 2011 Gravity Department http://gravitydept.com
 * @license    All rights reserved.
 * @version    1.2.9
 */


/* avoid PrototypeJS conflicts, assign jQuery to $jQ instead of $ */
var $jQ = jQuery.noConflict();

/* using $jQ(document).ready() because Magento executes Prototype inline and freaks out if jQuery executes beforehand */
/* using function($) to maintain normal jQuery syntax inside */
$jQ(document).ready(function($){

	// ------------------------------------------------------------------------------
	// Progressive enhancement hook
	// ------------------------------------------------------------------------------
		
		$('body').addClass('js');


	// ------------------------------------------------------------------------------
	// ColorBox		
	// ------------------------------------------------------------------------------
		
		if ($().colorbox) {
		
			$("a.zoom").colorbox({
			    'initialWidth': '200px',
			    'initialHeight': '200px',
			    'opacity': 0.75,
				'speed': 350
			});
			
		}

		
	// ------------------------------------------------------------------------------
	// LoopedSlider
	// ------------------------------------------------------------------------------
	
		if ($().loopedSlider) {
		
			$('#spotlight-slider').loopedSlider({
				container: '.slider-box',
				slides: '.slides',
				pagination: '.slider-pager',
				containerClick: false,
				autoStart: 8000,
				restart: 8000,
				slidespeed: 1000,
				fadespeed: 800,
				autoHeight: false,
				addPagination: false
			});
			
			$('#new-slider, #featured-slider').loopedSlider({
				container: '.slider-box',
				slides: '.slides',
				pagination: '.slider-pager',
				containerClick: false,
				autoStart: 0,
				restart: 0,
				slidespeed: 600,
				fadespeed: 300,
				autoHeight: 100,
				addPagination: false
			});
		
		}
	
	
	// ------------------------------------------------------------------------------
	// Catalog toolbar UI
	// ------------------------------------------------------------------------------

		if ($('#options-button').length) {
			
			$('#options-button').click(function(){
				var button = $(this);
				var toolbar = $('#options-bar');
				
				if (button.hasClass('open')) {
					$(this)
						.removeClass('open')
						.find('.label').html('Show Options');
					toolbar.slideUp();
				} else {
					$(this)
						.addClass('open')
						.find('.label').html('Hide Options');
					toolbar.slideDown();
				}
			});
			
		}
	
	
	// ------------------------------------------------------------------------------
	// Newsletter form pre-fill
	// ------------------------------------------------------------------------------

		var newsletterInput = $('#newsletter-email');
		var newsletterDefault = newsletterInput.val();
		
		//  empty on focus if default
		newsletterInput.focus(function() {
			if ( $(this).val()==newsletterDefault ) {
				$(this).val('');
			}
		});
		
		//  restore default on lose focus
		newsletterInput.blur(function() {
			if ( $(this).val()=='' ) {
				$(this).val(newsletterDefault);
			}
		});
		
});

