// Initialize the Scripts for this site.

$(document).ready(function() {
    
    // Opens up Smart Solutions in new window.
    $('.lnkBlank').click(function() {
        window.open($(this).attr('href'), 'newWindow', '');
        return false;
    });
    
    // Select the text in the search box:
    $('input.txtSearch').focus(function() {
        $(this).select();
    });
    
    // Hides list item images if no src is defined:
    $('img.listItemImage').each(function() {
        if ($(this).attr('src') == '') {
            $(this).hide();
        }
    });
    
    var corners = '<img src="/content-corner-top-left.gif" width="10" height="10" alt="" id="cornerTopLeft" class="cornerImage" />';
    corners += '<img src="/content-corner-top-right.gif" width="10" height="10" alt="" id="cornerTopRight" class="cornerImage" />';
    //corners += '<img src="/content-corner-bottom-left.gif" width="10" height="10" alt="" id="cornerBottomLeft" class="cornerImage" />';
    //corners += '<img src="/content-corner-bottom-right.gif" width="10" height="10" alt="" id="cornerBottomRight" class="cornerImage" />';
    corners += '<img src="/site-corners-bottom.gif" width="978" height="10" alt="" id="cornerBottomCorner" class="cornerImage" />';
    
    $('#themeContainer').append(corners); // assign the corners to the container of the website.
    
    // Inside Corners - Sub Footer
    $('#subFooter').bullNose(
        options = {
            pathToImages:    '/',
            topLeftImg:        'container-corner-top-left.gif',
            topRightImg:    'container-corner-top-right.gif',
            bottomLeftImg:    'container-corner-bottom-left.gif',
            bottomRightImg:    'container-corner-bottom-right.gif',
            imageWidth:        '11',
            imageHeight:    '11',
            imageIdPrefix:    'bcorner',
            positionCornerAbsolute:    true
        }
    );
    
    $('#subFooter dl:not(:first)').css('border-left','solid 1px #9f9fff');
    
    // Newsletter Signup corners
    if ($('#newsletterSignup').length != 0) {
        $('#newsletterSignup').bullNose(
            options = {
                pathToImages:    '/',
                topLeftImg:        'container-corner-top-left.gif',
                topRightImg:    'container-corner-top-right.gif',
                bottomLeftImg:    'container-corner-bottom-left.gif',
                bottomRightImg:    'container-corner-bottom-right.gif',
                imageWidth:        '11',
                imageHeight:    '11',
                positionCornerAbsolute:    true
            }
        );
    }
    
    // Left Category Menu
    $('ul#categoryMenu > li').each(function() {
        if ($(this).children('ul').length > 0) {
            $(this).find('a:eq(0)').addClass('categoryCurrent');
        } else {
            $(this).find('a:eq(0)').addClass('category');
        }
    });
    
    $('ul#categoryMenu >li:last').addClass('last');
    $('ul#categoryMenu li:has(ul:empty)').find('a.categoryCurrent').css('border','0px');
    $('ul#categoryMenu').find('li ul:empty').css('display','none');
  
  // Shop  By  Designer Dropdown
     var dropCss = {
         'position':        'absolute',
         'z-index':         '1000',
         'top':             '27px'
     }
     
    $('#designerDropdown').find('li.main').hover(function() {
         $(this).find('ul:first').show().css(dropCss);
         $(this).addClass('over');
         $(this).find('a.shopLink').click(function() {
             return  false;
         });
     }, function() {
         $(this).find('ul:first').hide();
         $(this).removeClass('over');
     });  
      
        
    // Footer CTA
    $('.footerCTA a:not(:last)').css('margin-right','8px');
    
});