$(document).ready(function() {
    
    // fancybox
    $('.fb').fancybox({
        'titlePosition': 'inside',
        'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
            var s;
            s = title + '<br />Image';
            if ( currentArray.length > 1 ) s = s + ' ' + (currentIndex + 1) + ' of ' + currentArray.length;
            return s;
        }
    });
    $('.ms').fancybox({
        'titleShow': false
    });
    
    // search (M&S)
    $('.MSdef').focus(function() {
        if ( $(this).attr('value') == 'Search' ) {
            $(this).attr('value', '');
        }
        $(this).addClass('focus');
    });
    
    // MS equalize box height
    $('.supportMS').each(function(){
        var maxHeight1 = Math.max($('.c1 ul').height(), $('.c2 ul').height(), $('.c3 ul').height() );
        var maxHeight2 = Math.max($('.c4 ul').height(), $('.c5 ul').height(), $('.c6 ul').height(), $('.c7 ul').height() );
        
        $('.c1 ul').css('height', maxHeight1);
        $('.c2 ul').css('height', maxHeight1);
        $('.c3 ul').css('height', maxHeight1);
        $('.c4 ul').css('height', maxHeight2);
        $('.c5 ul').css('height', maxHeight2);
        $('.c6 ul').css('height', maxHeight2);
        $('.c7 ul').css('height', maxHeight2);
    });
    
    // MS tooltip
    $('.tooltip').tooltip();
    
});
