﻿$m.core.register('#Site-Search', function (hub) {
    var searchButton,
        searchField,
        self = {};

    self.construct = function () {
        searchButton = hub.find('.searchButton');
        searchField = hub.find('.searchField');
        $m.jQuery(searchButton).val('');
        $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['#Site-Search']) {
    $m.core.modules['#Site-Search'].construct();
}

$m.core.register('#Newsletter', function (hub) {
    var searchButton,
        searchField,
        self = {};

    self.construct = function () {
        searchButton = hub.find('.signupButton');
        searchField = hub.find('.signupField');
        $m.jQuery(searchButton).val('Sign Up');
        $m.jQuery(searchField).val('enter email');
    };

    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['#Newsletter']) {
    $m.core.modules['#Newsletter'].construct();
}

$m.core.register('#subnav', function (hub) {
    var self = {};

//    if (!$j('#subnav').length) {
//        $j('.side-nav').fadeOut(300);
//        $j('.side-nav').css('backgroundImage', 'none');
//        $j('.column2-content').stop().animate({
//            marginTop: '0px'
//        }, 400);
//    }
    
    self.construct = 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('.searchPanel', function (hub) {}).construct();
if ($m.core.modules['#subnav']) {
    $m.core.modules['#subnav'].construct();
}

// this is not being used, the #Bottom-Nav is actually hidden via CSS

//$m.core.register('#Bottom-Nav', function (hub) {
//    var bottomNav,
//        ul,
//        self = {};

//    //    if ($j('#Bottom-Nav').length) {
//    //        $j('.main-nav').clone().prependTo('#Bottom-Nav');
//    //    }

//    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('.product-list', function (hub) {
    var items,
        maxHeight = 0,
        self = {};

    self.construct = function () {
        items = hub.find('.product-list-item');
        for (var i = 0; i < items.length; i++) {
            maxHeight = $m.jQuery(items[i]).height() > maxHeight ? $m.jQuery(items[i]).height() : maxHeight;
        }

        for (var i = 0; i < items.length; i++) {
            items[i].style.height = maxHeight + "px";
        }
    };

    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['.product-list']) {
    $m.core.modules['.product-list'].construct();
}

