/**
 * Acumen for Magento
 * Made by Gravity Department (http://gravitydept.com)
 * Distributed by ThemeForest (http://themeforest.net)
 *
 * @author     Brendan Falkowski
 * @package    gravdept_acumen
 * @copyright  Copyright 2011 Brendan Falkowski (http://brendanfalkowski.com)
 * @license    All rights reserved.
 * @version    1.2.9
 */

var menu=new menu.dd("menu");
	menu.init("menu","menuhover");
	
/* 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: 4000,
				restart: 6000,
				slidespeed: 400,
				fadespeed: 200,
				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
			});
		
		}
		
	// ------------------------------------------------------------------------------
	// nivoSlider
	// ------------------------------------------------------------------------------	
		
		if ($().nivoSlider) {
        		 $('#slider').nivoSlider({
			        effect: 'fade', // Specify sets like: 'fold,fade,sliceDown'
			        slices: 15, // For slice animations
			        boxCols: 8, // For box animations
			        boxRows: 4, // For box animations
			        animSpeed: 500, // Slide transition speed
			        pauseTime: 6000, // How long each slide will show
			        startSlide: 0, // Set starting Slide (0 index)
			        directionNav: true, // Next & Prev navigation
			        directionNavHide: true, // Only show on hover
			        controlNav: true, // 1,2,3... navigation
			        controlNavThumbs: false, // Use thumbnails for Control Nav
			        controlNavThumbsFromRel: false, // Use image rel for thumbs
			        controlNavThumbsSearch: '.jpg', // Replace this with...
			        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			        keyboardNav: true, // Use left & right arrows
			        pauseOnHover: true, // Stop animation while hovering
			        manualAdvance: false, // Force manual transitions
			        captionOpacity: 0.8, // Universal caption opacity
			        prevText: 'Prev', // Prev directionNav text
			        nextText: 'Next', // Next directionNav text
			        beforeChange: function(){}, // Triggers before a slide transition
			        afterChange: function(){}, // Triggers after a slide transition
			        slideshowEnd: function(){}, // Triggers after all slides have been shown
			        lastSlide: function(){}, // Triggers when last slide is shown
			        afterLoad: function(){} // Triggers when slider has loaded
			    });
		
		}
	
	
	// ------------------------------------------------------------------------------
	// 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);
			}
		});
		
});

