﻿$m.core.register('.searchPanel', function (hub) {
    var searchButton,
        searchField,
        self = {};

    self.construct = function () {
        searchButton = hub.find('.searchButton');
        searchField = hub.find('.searchField');

        $m.jQuery(searchButton).val('Search Now');
        $m.jQuery(searchField).val('search site');
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.searchPanel', function (hub) {}).construct();
if ($m.core.modules['.searchPanel']) {
    $m.core.modules['.searchPanel'].construct();
}


$m.core.register('.signupPanel', function (hub) {
    var signupButton,
        signupField,
        self = {};

    self.construct = function () {
        signupButton = hub.find('.signupButton');
        signupField = hub.find('.signupField');

        $m.jQuery(signupButton).val('Enroll');
        $m.jQuery(signupField).val('sign up now...');
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.signupPanel', function (hub) {}).construct();
if ($m.core.modules['.signupPanel']) {
    $m.core.modules['.signupPanel'].construct();
}


$m.core.register('.main-nav', function (hub) {
    var isOffScreenOrClipped,
        mainNav,
        self = {};

    self.construct = function () {
        mainNav = hub.find('#mainnav');

        $m.jQuery("#mn-macrowave > a").text(" ");

        //Main nav flyout animation
        $m.jQuery('#mainnav li').hover(
            function () {
                var hoveredItem = this;
                var firstUl = $m.jQuery(hoveredItem).find('ul:first');
                var parentLi = $m.jQuery(firstUl).parents('li');

                //Check if we have sub nav
                if (firstUl.length > 0) {
                    //Check if sub nav is outside visible window
                    isOffScreenOrClipped = self.IsNodeClippedOrOffscreen(firstUl, parentLi);
                    if (isOffScreenOrClipped) {
                        firstUl.addClass('offScreen');
                    }

                    firstUl.filter(':not(:animated)').slideDown({ duration: 180 });
                }

            },
            function () {
                var hoveredItem = this;
                var firstUl = $m.jQuery(hoveredItem).find('ul:first');

                if (firstUl.length > 0) {
                    firstUl.fadeOut(150);
                    if (firstUl.hasClass('offScreen')) {
                        firstUl.removeClass('offScreen');
                    }
                }

            }
        );

        hub.listen({
            'mainNavClone': this.mainNavClone
        });
    };

    self.destruct = function () {

    };

    self.mainNavClone = function (bottomNav) {
        $m.jQuery(mainNav).clone().prependTo(bottomNav);
    };

    self.IsNodeClippedOrOffscreen = function (node, parentLi) {
        var ulPos = node.parent().offset();
        var ulLeftPos = ulPos.left;
        var ulTopPos = ulPos.top;
        var ulWidth = node.outerWidth(true);
        var ulHeight = node.outerHeight(true);

        if (parentLi.length > 1) {
            posX = (ulWidth * 2) + ulLeftPos;
            var bOffScreen = self.CheckIfPointIsOffScreen(posX, ulTopPos);
            var bClipped = self.CheckIfPointIsOffScreen(posX, ulTopPos + ulHeight);
        } else {
            var bOffScreen = self.CheckIfPointIsOffScreen(ulLeftPos, ulTopPos);
            var bClipped = self.CheckIfPointIsOffScreen(ulLeftPos + ulWidth, ulTopPos + ulHeight);
        }

        return (bOffScreen || bClipped);
    };

    self.CheckIfPointIsOffScreen = function (iLeftPos, iTopPos) {
        var iBrowserWidth = $m.jQuery(window).width();
        var iBrowserHeight = $m.jQuery(window).height();
        var bOffScreen = false;

        if (iLeftPos < 0 || iLeftPos >= iBrowserWidth)
            bOffScreen = true;

        if (iTopPos < 0 || iTopPos >= iBrowserHeight)
            bOffScreen = true;

        return bOffScreen;
    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.main-nav', function (hub) {}).construct();
if ($m.core.modules['.main-nav']) {
    $m.core.modules['.main-nav'].construct();
}


$m.core.register('#Bottom-Nav', function (hub) {
    var bottomNav,
        ul,
        self = {};

    self.construct = function () {
        bottomNav = hub.container;

        hub.notify({
            type: 'mainNavClone',
            data: bottomNav
        });

        ul = hub.find('#mainnav');
        $m.jQuery(ul).removeAttr('id');
        $m.jQuery('li', ul).each(function () {
            $m.jQuery(this).removeAttr('id');
        });
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#Bottom-Nav', function (hub) {}).construct();
if ($m.core.modules['#Bottom-Nav']) {
    $m.core.modules['#Bottom-Nav'].construct();
}


$m.core.register('#Store', function (hub) {
    var self = {};

    self.construct = function () {
        //Set cart items to same height
        $m.jQuery(window).load(function () {
            var storeItems = hub.find('.product-list-item');
            var maxHeight = 0;

            $m.jQuery.each(storeItems, function () {
                var itemHeight = $m.jQuery(this).height();

                if (itemHeight > maxHeight) {
                    maxHeight = itemHeight;
                }
            });

            $m.jQuery.each(storeItems, function () {
                $m.jQuery(this).height(maxHeight);
            });
        });
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#Store', function (hub) {}).construct();
if ($m.core.modules['#Store']) {
    $m.core.modules['#Store'].construct();
}


$m.core.register('body', function (hub) {
    var $window,
        self = {};

    self.construct = function () {
        $m.jQuery(hub.container).append("<div id='IE6'><a href='#' class='ie6close'></a><span class='warning'></span> <span>Wow, you're using IE6!</span><br /><p>The browser you're using is very out of date. We beg you to consider upgrading. This website will work for you, but some things may not work as intended because, well, your browser is really old. Upgrade now and be a happier web surfer.</p><a href='http://www.microsoft.com/nz/windows/internet-explorer/default.aspx' class='ie6'></a><a href='http://www.google.com/chrome' class='chrome'></a><a href='http://www.mozilla.com/en-US/firefox/upgrade.html' class='firefox'></a></div>");

        //IE 6 browser detection
        if ($m.jQuery.browser.msie) {
            var version = $m.jQuery.browser.version;

            if (version == '6.0') {
                var cookie = $m.jQuery.cookie('IE6');

                if (cookie != 'set') {
                    $m.jQuery.cookie('IE6', 'set');
                    $m.jQuery('#IE6').show().stop().animate({
                        top: 0
                    }, 1000);
                }

                $m.jQuery('.ie6close').click(function () {
                    $m.jQuery('#IE6').fadeOut(500);
                });
            }
        }
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#Store', function (hub) {}).construct();
if ($m.core.modules['body']) {
    $m.core.modules['body'].construct();
}

$m.core.register('.microwave-content', function (hub) {
    var self = {};

    self.construct = function () {

        //set start video depending on link for microwave
        hassleVideo = new RegExp('hassle\/?$').test(location.pathname);
        messyVideo = new RegExp('messy\/?$').test(location.pathname);
        waitingVideo = new RegExp('waiting\/?$').test(location.pathname);
        iframeContainer = $m.jQuery('.microwave-content .iframe-video');

        if (hassleVideo) {
            console.log(hassleVideo);
            console.log(iframeContainer);
            $m.jQuery(iframeContainer).css('display', 'none');
            $m.jQuery('.try-content').css('display', 'block');
        }

        if (messyVideo) {
            $m.jQuery(iframeContainer).css('display', 'none');
            $m.jQuery('.choose-content').css('display', 'block');
        }

        if (waitingVideo) {
            $m.jQuery(iframeContainer).css('display', 'none');
            $m.jQuery('.listen-content').css('display', 'block');
        }


        //set up the video switch on thumbnail click
        $m.jQuery('.logo').click(function () {
            $m.jQuery('.learn-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.listen-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.choose-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.try-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.main-content').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.nav-learn').click(function () {
            $m.jQuery('.main-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.listen-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.choose-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.try-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.learn-content').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.nav-listen').click(function () {
            $m.jQuery('.main-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.learn-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.choose-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.try-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.listen-content').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.nav-choose').click(function () {
            $m.jQuery('.main-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.learn-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.listen-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.try-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.choose-content').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.nav-try').click(function () {
            $m.jQuery('.main-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.listen-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.choose-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.learn-content').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.try-content').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });


    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.searchPanel', function (hub) {}).construct();
if ($m.core.modules['.microwave-content']) {
    $m.core.modules['.microwave-content'].construct();
}

$m.core.register('#Store', function (hub) {
    var self = {};

    self.construct = function () {
        $m.jQuery('.cart-review-wrapper #review-table th:contains("Product Name")').css('width', '170px');
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.searchPanel', function (hub) {}).construct();
if ($m.core.modules['#Store']) {
    $m.core.modules['#Store'].construct();
}


$m.core.register('.macrowave-choose', function (hub) {
    var self = {};

    self.construct = function () {
        $m.jQuery('.one-shelf').click(function () {
            $m.jQuery('.shelf-4').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-8').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-10').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-24').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-1').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.four-shelf').click(function () {
            $m.jQuery('.shelf-8').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-10').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-24').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-1').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-4').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.eight-shelf').click(function () {
            $m.jQuery('.shelf-10').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-24').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-1').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-4').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-8').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.ten-shelf').click(function () {
            $m.jQuery('.shelf-24').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-8').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-4').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-1').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-10').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });

        $m.jQuery('.twentyfour-shelf').click(function () {
            $m.jQuery('.shelf-10').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-8').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-4').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-1').filter(':not(:animated)').slideUp(400, 'easeInOutQuad');
            $m.jQuery('.shelf-24').filter(':not(:animated)').slideDown(400, 'easeInOutQuad');
        });
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.searchPanel', function (hub) {}).construct();
if ($m.core.modules['.macrowave-choose']) {
    $m.core.modules['.macrowave-choose'].construct();
}

$m.core.register('#SlideShow', function (hub) {
    var slideShow,
        self = {};

    self.construct = function () {
        slideShow = hub.container;
        $m.jQuery('#SlideShow p').cycle({
            fx: 'scrollLeft',
            timeout: 7000,
            speed: 1000,
            cleartypeNoBg: true,
        });
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#SlideShow', function (hub) {}).construct();
if ($m.core.modules['#SlideShow']) {
    $m.core.modules['#SlideShow'].construct();
}


$m.core.register('.store-category-display', function (hub) {
    var $window,
        self = {};

    self.construct = function () {
        $m.jQuery('.store-column-1 .store-main-categories li:contains("Personal")').prepend("<div class='personal'><img src='SiteFiles/501314/images/1ShelfThumb.png' /></div>");
         $m.jQuery('.store-column-1 .store-main-categories li:contains("Home")').prepend("<div class='home-office'><img src='SiteFiles/501314/images/4ShelfThumb.png' /></div>");
          $m.jQuery('.store-column-1 .store-main-categories li:contains("Commercial")').prepend("<div class='commercial-industrial'><img src='SiteFiles/501314/images/24ShelfThumb.png' /></div>");
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#Store', function (hub) {}).construct();
if ($m.core.modules['.store-category-display']) {
    $m.core.modules['.store-category-display'].construct();
}


$m.core.register('.buy-banner', function (hub) {
    var productHoverImage,
        productOffImage,
        productHandler,
        positionOne,
        positionTwo,
        positionThree,
        positionFour,
        positionFive,
        buyBannerContent,
        self = {};

    self.construct = function () {
        buyBannerContent = hub.container;
        positionFive = hub.find('.position-5');
        positionFour = hub.find('.position-4');
        positionThree = hub.find('.position-3');
        positionTwo = hub.find('.position-2');
        positionOne = hub.find('.position-1');
        productHandler = hub.find('.handler');
        productOffImage = hub.find('.off-state');
        productHoverImage = hub.find('.hover-state');



//        $('.imgbuttonclass').hover(function(){
//    $(this).animate({
//        backgroundImage: 'img2.png'
//    },500);
//},function(){
//    $(this).stop(true).animate({
//        backgroundImage: 'img1.png'
//    },500);
//});



        //Hover Product Number 1
        $m.jQuery('.position-1').hover( function () {
            $m.jQuery('.position-1 .product-images .off-state').fadeOut(100, function () {
                $m.jQuery('.position-1 .handler').css('width', '150px');
                $m.jQuery('.position-1 .handler').css('height', '50px');
                $m.jQuery('.position-1 .handler .product-information').slideDown(300);
                
            });
        }, function () {
            
            $m.jQuery('.position-1 .handler').css('width', '17px');
            $m.jQuery('.position-1 .handler').css('height', '17px');
            $m.jQuery('.position-1 .product-images .off-state').fadeIn(100, function () {
                $m.jQuery('.position-1 .handler .product-information').slideUp(300);
            });

        });

        //Hover Product Number 2
        $m.jQuery('.position-2').hover( function () {
            $m.jQuery('.position-2 .product-images .off-state').fadeOut(100, function () {
                $m.jQuery('.position-2 .handler .product-information').slideDown(300);
                
            });
        }, function () {
            
            $m.jQuery('.position-2 .product-images .off-state').fadeIn(100, function () {
                $m.jQuery('.position-2 .handler .product-information').slideUp(300);
            });

        });

        //Hover Product Number 3
        $m.jQuery('.position-3').hover( function () {
            $m.jQuery('.position-3 .product-images .off-state').fadeOut(100, function () {
                $m.jQuery('.position-3').css('z-index', '3');
                $m.jQuery('.position-4').css('z-index', '2');
                $m.jQuery('.position-3 .handler .product-information').slideDown(300);
                
            });
        }, function () {
            
            $m.jQuery('.position-3 .product-images .off-state').fadeIn(100, function () {
                $m.jQuery('.position-3').css('z-index', '2');      
                $m.jQuery('.position-4').css('z-index', '3');          
                $m.jQuery('.position-3 .handler .product-information').slideUp(300);
            });

        });

        //Hover Product Number 4
        $m.jQuery('.position-4').hover( function () {
            $m.jQuery('.position-4 .product-images .off-state').fadeOut(100, function () {
                $m.jQuery('.position-4 .handler .product-information').slideDown(300);
                
            });
        }, function () {
            
            $m.jQuery('.position-4 .product-images .off-state').fadeIn(100, function () {
                $m.jQuery('.position-4 .handler .product-information').slideUp(300);
            });

        });

        //Hover Product Number 5
        $m.jQuery('.position-5').hover( function () {
            $m.jQuery('.position-5 .product-images .off-state').fadeOut(100, function () {
                $m.jQuery('.position-5 .handler .product-information').slideDown(300);
                
            });
        }, function () {
            
            $m.jQuery('.position-5 .product-images .off-state').fadeIn(100, function () {
                $m.jQuery('.position-5 .handler .product-information').slideUp(300);
            });

        });

    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#Store', function (hub) {}).construct();
if ($m.core.modules['.buy-banner']) {
    $m.core.modules['.buy-banner'].construct();
}


$m.core.register('#mn-macrowave', function (hub) {
    var self = {};

    self.construct = function () {
        $m.jQuery('#mn-macrowave > ul').prepend('<div class="macro-nav-products"><table style="width: 800px; background: #AB0C11; border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px; padding: 5px 0px;" border="0"><tbody><tr><td><p style="text-align: center;"><a class="one-shelf" href="/products/personal-chef"><img src="SiteFiles/501314/images/1-shelf-nav.png" alt="" /></a></p></td><td><p style="text-align: center;"><a class="four-shelf" href="/products/model-400"><img src="SiteFiles/501314/images/4-shelf-nav.png" alt="" /></a></p></td><td><p style="text-align: center;"><a class="eight-shelf" href="/products/model-800"><img src="SiteFiles/501314/images/8-shelf-nav.png" alt="" /></a></p></td><td><p style="text-align: center;"><a class="ten-shelf" href="/products/model-1000"><img src="SiteFiles/501314/images/10-shelf-nav.png" alt="" /></a></p></td><td style="text-align: center;"><a class="twentyfour-shelf" href="/products/model-2400"><img src="SiteFiles/501314/images/24-shelf-nav.png" alt="" /></a></td></tr></tbody></table></div>');

        $m.jQuery('#mn-macrowave').hover( function () {
            
            $m.jQuery('.macro-nav-products').animate({ right: '141px', width: '800px' }, { queue: false, duration: 300 });
           
        }, function () {
        });
        
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('#Store', function (hub) {}).construct();
if ($m.core.modules['#mn-macrowave']) {
    $m.core.modules['#mn-macrowave'].construct();
}



$m.core.register('.related-products-list', function (hub) {
    var signupButton,
        signupField,
        self = {};

    self.construct = function () {
        $m.jQuery("img[src='assets/501314/2_1shelf.png']").replaceWith('<img src="SiteFiles/501314/images/shop-footer-industrial-one-shelf.jpg" />');
        $m.jQuery("img[src='assets/501314/2_4shelf.png']").replaceWith('<img src="SiteFiles/501314/images/shop-footer-industrial-four-shelf.jpg" />');
        $m.jQuery("img[src='assets/501314/2_8shelf.png']").replaceWith('<img src="SiteFiles/501314/images/shop-footer-industrial-eight-shelf.jpg" />');
        $m.jQuery("img[src='assets/501314/2_10shelf.png']").replaceWith('<img src="SiteFiles/501314/images/shop-footer-industrial-ten-shelf.jpg" />');
        $m.jQuery("img[src='assets/501314/2_24shelf.png']").replaceWith('<img style="width: 143px; height: 239px;" src="SiteFiles/501314/images/position-5.png" />');
    };

    self.destruct = function () {

    };

    return self;
});
//Calls the construct function of the above module.  We will be able to chain
//this to the end after the next train deploy.
//ex: $m.core.register('.signupPanel', function (hub) {}).construct();
if ($m.core.modules['.related-products-list']) {
    $m.core.modules['.related-products-list'].construct();
}


(function ($, window){
    var vimeoPlayers = $('.microwave-content iframe'),
        player,
        playerLinks,
        playerIdList = {};

    playerLinks = $('.bottom-buttons a');

    $.each(playerLinks, function (index, item){
        $(item).click(function (e){
            e.preventDefault();
            e.stopPropagation();

            $.each(playerIdList, function(index, item){
                item.api('pause');
            });

            return false;
        });
    });

    for (var i = 0, length = vimeoPlayers.length; i < length; i++) {
        player = vimeoPlayers[i];
        $f(player).addEvent('ready', ready);
    }

    function ready(player_id){
        var aa = player_id;
        playerIdList[aa] = $f(player_id);
    }

})(jQuery, window);
