/**
 * @author luke.cuthbertson <luke.cuthbertson@heathwallace.com>
 * @projectDescription
 * @version 0.1
 * @date
 */
(function($){
      
      $(function(){
            
            $('div.premierRow').filter(function(i){
                  return !$(this).parent().hasClass('jvsExpandingGrid')
            }).accordion({
                  trigger: 'a.showHideLink',
                  text: {closed: 'Expand', open: 'Collapse'},
                  node: 'div.showHide'
            })
            .bind('accordion.onopening', function(e, data){
                  data.$link.attr('title', 'Collapse');
            })
            .bind('accordion.onclose', function(e, data){
                  data.$link.attr('title', 'Expand');
            });
            
            $('div.premierRow div.jvsAccordion').accordion({
                  trigger: 'a.showHideLink',
                  text: {closed: 'Expand', open: 'Collapse'},
                  node: '.jvsAccordion'
            })
            .bind('accordion.onopening', function(e, data){
                  data.$link.attr('title', 'Collapse');
            })
            .bind('accordion.onclose', function(e, data){
                  data.$link.attr('title', 'Expand');
            });
 
            $('div.premierRow').accordion({
                  trigger: 'a.showHideTitle',
                  node: 'h3'
            });
            
            $('#specialTabs').simpleTabs({
                  content: '.specialTabsContent',
                  transSpeed: 0
            });
            
            $('#premHorTabSet').buildTabs();
            
            $('#carousel').carousel();
            
            $('#cardSliderContent').buildCardSlider();
            
            $('.jvsExpandingGrid').buildExpandingGrid();
 
            var $img = $('a.fauxCheckbox img');
            if ($img.size()) {
                  $img.data('checked', false).attr('src', $img.attr('src').replace('checked', 'unchecked')).closest('a').click(function(e){
                        e.preventDefault();
                        var $img = $(this).children();
                        if ($img.data('checked')) {
                              $img.attr('src', $img.attr('src').replace('checked', 'unchecked')).data('checked', false);
                        }
                        else {
                              $img.attr('src', $img.attr('src').replace('unchecked', 'checked')).data('checked', true);
                        }
                  });
            }
 
            //click handler
            $.benfitsBannerRedirect = function(){
                  $.overlay().html('<div id="benefitsToolFlash" style="height:549px;width:820px;"></div>');
                  var f = new HW.Flash();
                  f.src = [7,'./flash/index.swf'];
                  f.width = 820;
                  f.height = 549;
                  f.load('benefitsToolFlash');
            }
            
            if (document.getElementById('benefitsBanner')) {
                  //load flash
                  var f = new HW.Flash();
                  f.src = [7, './flash/banner.swf?jsFunc=$.benfitsBannerRedirect'];
                  f.width = 205;
                  f.height = 145;
                  f.name = 'benefitsBanner';
                  f.load('benefitsBanner');
                  f.wmode = 'window';
                  //make some CSS adjustments
                  var flashContainer = $('#benefitsBanner').addClass('jvsInitialised');
                  if (flashContainer.parents('div.contentStyleInner').size() == 2) {
                        flashContainer.closest('div.contentStyleInner').css({
                              background: 'none'
                        });
                  }
            }
 
      })
      
})(jQuery);

