/**
 * Acumen for Magento
 * Made by Gravity Department (http://gravitydept.com)
 * Distributed by ThemeForest (http://themeforest.net)
 *
 * @author     Brendan Falkowski
 * @package    gravdept_acumen
 * @copyright  Copyright 2010 Brendan Falkowski (http://brendanfalkowski.com)
 * @license    All rights reserved.
 * @version    1.1.0
 */


/* 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($){

        
        // ------------------------------------------------------------------------------
	// Stop image zoom from display when navdropdowns are active
	// ------------------------------------------------------------------------------
        $('#nav').mouseover(function(){

            $('#smd-zoom-content').css("z-index",-1000);
        });

        $('#nav').mouseout(function(){

            $('#smd-zoom-content').css("z-index",100);
        });

        
	// ------------------------------------------------------------------------------
	// Progressive enhancement hook
	// ------------------------------------------------------------------------------
		
		$('body').addClass('js');


	// ------------------------------------------------------------------------------
	// FancyBox		
	// ------------------------------------------------------------------------------
		
		if ($().fancybox) {
		
			$("a.zoom").fancybox({
				'padding': 10,
				'imageScale': true,
				'zoomOpacity': true,
				'zoomSpeedIn': 500,
				'zoomSpeedOut': 500,
				'frameWidth': 600,
				'frameHeight': 600,
				'overlayShow': true,
				'overlayOpacity': 0.0,
				'overlayColor': '#FFF',
				'enableEscapeButton': true,
				'showCloseButton': true,
				'hideOnOverlayClick': true,
				'hideOnContentClick': true,
				'centerOnScroll': false
			});
			
		}

		
	// ------------------------------------------------------------------------------
	// 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
			});
		
		}
	
	
	// ------------------------------------------------------------------------------
	// 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);
			}
		});

       $("a.related_vid").click(function() {
            
            
        
	$('a.related_vid').fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
 
	return false;
});
	// ------------------------------------------------------------------------------
	// Popdown
	// ------------------------------------------------------------------------------


        if($.cookie('popdown') == 1) return;
	$('#popdown').show();

	$('#popdown-parent').animate(
		{
			'top': '-230px'
		},
		{
			duration: 1000,
			queue: false,
			complete: function(){
                            $.cookie('popdown', 1,{expires:7});
			}
		}
	);
        
	$('#popdown-parent a').click(function(){
		$('#popdown-parent').animate(
				{
					'top': '230px'
				},
				{
					duration: 1000,
					queue: false,
					complete: function(){
						$('#popdown-parent').remove();
						$('#popdown').hide('fast');
					}
				}
			);
	});
        



        

	
});

