/* Suzuki JS */

(function($) {
Drupal.Suzuki = Drupal.Suzuki || {};
Drupal.Suzuki.thumbList = Drupal.Suzuki.thumbList || {};
  
$(document).ready(function() {
  
  $('.field-name-field-model-label').corner('3px');
  $('.field-name-brochure-pdf a').corner('3px');
  $('.node-webform.view-mode-brochure .group-footer').corner('3px');
  $('.field-name-suzuki-media-full .watch-button').corner('3px');
  $('#block-suzuki-general-quicklinks').corner('3px');
  $('.selection-data').corner('3px');
  $('table#packages-table .package-sub-title').corner('5px');
  $('table#technical-properties-table .package-sub-title').corner('5px');
  
  // Hover on motorisatie tab.
  if ($('tr', '#motorisatie-table').length > 0) {
    $('tr', '#motorisatie-table').click(function() {
      var $el = $(this);
      var classes = $el.attr('class');
      var id = classes.match(/motor-([0-9]+)/);
      if (id.length && id.length > 0) {
        var motorId = id[0].replace('motor-', '');
        var url = $('#motor-' + motorId).val();
        window.location = url;
      }
    });  
  }
  
  // jQuery scrollpane on dealer list.
  if ($('#dealer-list').length > 0) {
    $('#dealer-list').jScrollPane();
  }
  
  // jQuery scrollpane on motorisations list.
  if ($('#tab-package').length > 0) {
    $('#tab-package .wrapper').jScrollPane();
    
  }
  
  // Equal height on models list.
  if ($('#models').length > 0) {
    Drupal.Suzuki.equalHeight($('#models .node'));
  }
  
  // Equal height on three col panel.
  if ($('#contact .panel-panel .inside').length > 0) {
    Drupal.Suzuki.equalHeight($('#contact .panel-panel .inside'));
  }  

  // Equal height on three col panel.
  if ($('#finance .panel-panel .inside').length > 0) {
    Drupal.Suzuki.equalHeight($('#finance .panel-panel .inside'));
  }  
  
  // Add onclick event on model list items.
  if ($('.node-model.view-mode-teaser').length > 1) {
    $('.node-model.view-mode-teaser').mouseover(function() {
      $(this).unbind('click');
      $(this).click(function() {
        window.location= $('h2 a', this).attr('href');
      })
    });
  }
  
  // Action links: open tab onclick for test drive and brochure.
  if ($('.node .test-drive').length > 0) {
    $('.node .test-drive').click(function() {
      $('#tab-test-drive').closest('.vertical-tabs-pane').data('verticalTab').focus();
      window.location = '#tab-test-drive';
      return false;
    });
    $('.node .brochure').click(function() {
      $('#tab-brochure').closest('.vertical-tabs-pane').data('verticalTab').focus();
      window.location = '#tab-brochure';
      return false;
    });
  }
  
  // Packages tab - open or close section.
  if ($('#packages-table').length > 0) {
    
    // Remove any open tr which do not have hiddens.
    $('#packages-table .opentr .open').each(function() {
      openclass = 'hidden-' + $(this).attr('class').replace('open ', '');
      if ($('.' + openclass).length == 0) {
        var row = $(this).parents('tr');
        row.hide();
      }
    });
    
    // Toggle hidden rows.
    $('#packages-table .opentr .open').click(function() {
      var openclass = 'hidden-' + $(this).attr('class').replace('open ', '').replace('clicked', '');
      if ($(this).hasClass('clicked')) {
        $(this).removeClass('clicked');
        $(this).css({'background': 'transparent url(/sites/all/themes/suzuki_theme/images/package-open.png) no-repeat 0% 50%'});
      }
      else {
        $(this).addClass('clicked');
        $(this).css({'background': 'transparent url(/sites/all/themes/suzuki_theme/images/package-close.png)  no-repeat 0% 50%'});
      }
      $('#packages-table td.' + openclass).toggle();
      
      // recalculate sticky header table cells.
      Drupal.Suzuki.tableHeader.resize();
      $('.jspContainer').css("height", $('#packages-table').outerHeight() + 20);
      
      return false;
    });
  }
  
  // Set some defaults for the slideshow thumbnail animation.
  // The actual events are stores in the views.
  if ($('.views-slideshow-controls-bottom').length > 0) {
    Drupal.Suzuki.window = $('.views-slideshow-controls-bottom .widget_pager');
    Drupal.Suzuki.thumbList = $('.views-slideshow-controls-bottom .widget_pager_inner');
    Drupal.Suzuki.step = 58; // The height of a thumbnail.
    Drupal.Suzuki.speed = 500;
    Drupal.Suzuki.thumbVisible = 3; // the number of visible thumbs.
    var totalThumbs = $('.views_slideshow_pager_field_item', Drupal.Suzuki.thumbList).length
    Drupal.Suzuki.thumbsTotal = totalThumbs; // the total number of thumbs.

    if ($('#block-views-promo-block-1').length > 0) {
   	  last_cookie = $.cookie('promo-block_1');
   	  if (last_cookie != null && last_cookie >= 3) {
   	    to_call = last_cookie - 3;
   	    skip_pixels = to_call * Drupal.Suzuki.step;
        Drupal.Suzuki.thumbList.animate({top: - skip_pixels + "px"}, Drupal.Suzuki.speed);
   	    for (i=0; i <= to_call; i++) {
   	      // Move the top item to the bottom.
   	      $('.views-slideshow-pager-field-item', Drupal.Suzuki.window).eq(0).appendTo(Drupal.Suzuki.thumbList)
   	      if (Drupal.Suzuki.thumbList.css("top","0px")){
   	    	Drupal.Suzuki.thumbList.css("top","0px");  
   	      }
   	    }
   	  }
    }
  }

  // Homepage selection zoomer.
  if ($('#block-suzuki-general-models-homepage').length > 0) {
    $('.homepage-selection .homepage-selection-image').hover(
      function() {
        
        // Switch image.
        original_image = $('.selection-image', this).attr('src');
        switch_image = $('.selection-switch', this).val();
        $('img', this).attr({'src': switch_image});
        
        // Animate image.
        $('img', this).stop(true, false).animate({'width': '140', 'height': '75', 'margin-top': '0',  'margin-left': '0'}, 300, function () {});
      },
      function() {

        // Restore image.
        $('img', this).attr({'src': original_image});
        
        var $data = $('.selection-data', this);
        // Animate image.
        $('img', this).animate({'width': '100', 'height': '54', 'margin-top': '20px', 'margin-left': '20px'}, 300, function () {});
      }
    );
  }
  
  // Popup thumbs and videos on car and model.
  if ($('#popup-thumbs .media-thumb').length > 0) {
    $('#popup-thumbs .media-thumb').eq(0).addClass('active');
    $('#popup-thumbs .media-thumb').click(function() {
      var $el = $(this);
      if (!$el.hasClass('active')) {
        var id = $el.attr('id').replace('thumb', 'large');
        $('.media-large').fadeOut('fast');
        $('#' + id).fadeIn();
        $('#popup-thumbs .active').removeClass('active');
        $el.addClass('active');
      }
    });
    $('#popup-content .media-large').click(function() {
      var $el = $(this);
      if ($el.next().length > 0) {
        if ($('#popup-thumbs-wrapper .next').is(':visible')) {
          $('#popup-thumbs-wrapper .next').click();
        }
        else {
          var id = '#' + $el.attr('id').replace('large', 'thumb');
          $(id).next('.media-thumb').click();
        }
      }
    });
  }

  // Exterior video image switch.
  if ($('#media-exterior-swap').length > 0) {
    $('#media-exterior-swap').click(function() {
      if ($('#media-exterior-video').is(':hidden')) {
        $('#media-imagemap').hide();
        $('#media-exterior-video').show();
        $('#media-exterior-swap').html(Drupal.t('Image'));
      }
      else {
        $('#media-imagemap').show();
        $('#media-exterior-video').hide();        
        $('#media-exterior-swap').html(Drupal.t('Video'));
      }
    });
  }
  
  // Media popup horizontal scroller.
  if ($('#popup-thumbs').length > 0) {
    $window = $('#popup-thumbs');
    $list = $('#popup-thumbs-inner');
    $prev = $('#popup-thumbs-wrapper .prev');
    $next = $('#popup-thumbs-wrapper .next');
    $step = 85;
    
    var listWidth = 0;
    $list.children('.media-thumb').each(function(index) {
      listWidth += $step;
    });
    
    if (listWidth > $window.width()) {
      $list.width(listWidth);
      $window.width($window.width() - $prev.outerWidth() - $next.outerWidth());
      $window.css({'left': $prev.outerWidth()});
      
      var doPrev = true;
      var doNext = true;
      $prev.show().bind('click', function() {
        if (doPrev) {
          if (parseInt($list.css('left')) < 0) {
            $list.animate({'left': parseInt($list.css('left')) + $step}, function () {
              doPrev = true;
            });
          }
          else {
            doPrev = true;
          }
          $('div.active', $list).prev().children('img').click();          
        }
      });
      $next.show().bind('click', function() {
        if (doNext) {
          doNext = false;
          if ($list.width() + parseInt($list.css('left')) > $window.width()) {
            $list.animate({'left': parseInt($list.css('left')) - $step}, function () {
              doNext = true;
            });
          }
          else {
            doNext = true;
          }
          $('div.active', $list).next().children('img').click();
        }
      });
    }
  }
  
  // Google analytics track events.
  // Brochure send (nl and fr).
  if ($('#webform-client-form-39').length > 0) {
    $('#webform-client-form-39 .form-submit').click(function() {
      suzuki_ga('application', 'application-send', 'application-send-test-brochure');
    });
  }
  if ($('#webform-client-form-41').length > 0) {
    $('#webform-client-form-41 .form-submit').click(function() {
      suzuki_ga('application', 'application-send', 'application-send-test-brochure');
    });
  }
  // testdrive send (nl and fr).
  if ($('#webform-client-form-87').length > 0) {
    $('#webform-client-form-87 .form-submit').click(function() {
      suzuki_ga('application', 'application-send', 'application-send-test-drive');
    });
  }
  if ($('#webform-client-form-88').length > 0) {
    $('#webform-client-form-88 .form-submit').click(function() {
      suzuki_ga('application', 'application-send', 'application-send-test-drive');
    });
  }
  // show cars button.
  if ($('#suzuki-cars-block-car-selector').length > 0) {
    $('#suzuki-cars-block-car-selector #submit-link').click(function() {
      suzuki_ga('cars', 'cars-show', 'cars-show-model');
    });
  }
  // download pdf.
  if ($('.field-name-brochure-pdf').length > 0) {
    $('.field-name-brochure-pdf').click(function() {
      suzuki_ga('pdf', 'pdf-download', 'pdf-download-brochure');
    });
  }
  // all tabs on model/cars page (possible at all??)
  if ($('.field-name-suzuki-tabs').length > 0) {
    $('#link-tab-motor').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-motorisation');
    });
    $('#link-tab-ext').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-exterior');
    });
    $('#link-tab-int').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-interior');
    });
    $('#link-tab-tp').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-technical-data');
    });
    $('#link-tab-prices').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-prices');
    });
    $('#link-tab-ga').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-warranty-assistance');
    });
    $('#link-tab-car-conf').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-carconfigurator');
    });
    $('#link-tab-brochure').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-brochure');
    });
    $('#link-tab-test-drive').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-test-drive');
    });
    $('a.tab-special').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-special-series');
    });
  }
  // Show all photos.
  if ($('.watch-button').length > 0) {
    $('.watch-button').click(function() {
      suzuki_ga('tabs', 'tabs-click', 'tabs-click-show-all-photos');
    });
  }  
  // E-mail dealers.
  if ($('.node-dealer a.spamspan').length > 0) {
    $('a.spamspan').click(function() {
      url = window.location.href;
      var arr1 = url.split('/');
      var alb = arr1[arr1.length - 1].split('.')[0];
      suzuki_ga('dealer', 'dealer-click', alb);
    });
  }  

  /**
   * Helper function to send to Google Analytics.
   */
  function suzuki_ga(category, action, label) {
    //console.log(category);
    //console.log(action);
    //console.log(label);
    _gaq.push(['_trackEvent', category, action, label]);
  }
  
  	// Catch Column controller click (open/close)
	$('#column_selection').click(function() {
	  $('#column_selection_controller').toggle();
	  return false;
	});
  
});

/**
 * Theme vertical tabs.
 */
Drupal.theme.prototype.verticalTab = function (settings) {
  var extra_class = '';
  var href_id = 'link-' + settings.fieldset.attr('id');
  if ($(settings.fieldset).hasClass('tab-special')) {
    extra_class = ' class="tab-special"';
  }
  var tab = {};
  tab.item = $('<li class="vertical-tab-button" tabindex="-1"></li>')
    .append(tab.link = $('<a id="'+ href_id +'" href="#"'+ extra_class +'></a>')
      .append(tab.title = $('<strong></strong>').text(settings.title))
      .append(tab.summary = $('<span class="summary"></span>')
    )
  );
  return tab;
};
  
/**
 * Scroll the slideshow thumbnails down.
 */
Drupal.Suzuki.slideShowThumbNext = function () {
  index = $('.views-slideshow-pager-field-item.active', Drupal.Suzuki.thumbList).index();
  // Scroll the thumbs up if we are at the last visible item.
  if (index > 1 && Drupal.Suzuki.thumbList) {
    Drupal.Suzuki.thumbList.animate({top: - Drupal.Suzuki.step + "px"}, Drupal.Suzuki.speed, function() {
      // Move the top item to the bottom.
      $('.views-slideshow-pager-field-item', Drupal.Suzuki.window).eq(0).appendTo(Drupal.Suzuki.thumbList);
      if(Drupal.Suzuki.thumbList){
    	  Drupal.Suzuki.thumbList.css("top","0px");
      }
    });
  }
}


/**
 * Scroll the slideshow thumbnails up.
 */
Drupal.Suzuki.slideShowThumbPrev = function () { 
  index = $('.views-slideshow-pager-field-item.active', Drupal.Suzuki.thumbList).index();
  // Move the last item to the beginning.
  $('.views-slideshow-pager-field-item', Drupal.Suzuki.window).eq($('.views-slideshow-pager-field-item', Drupal.Suzuki.window).length - 1).prependTo(Drupal.Suzuki.thumbList);
  Drupal.Suzuki.thumbList.animate({top: - Drupal.Suzuki.step + "px"}, 0, function() {
    Drupal.Suzuki.thumbList.animate({top: "0px"}, Drupal.Suzuki.speed, function() {
    });
  });  
}

/**
 * Set a cookie on switching slides.
 */
Drupal.Suzuki.slideShowSetCookie = function (slideNumber) {
  document.cookie = 'promo-block_1=' + slideNumber++;
}

/**
 *  Equal height calculator.
 */
Drupal.Suzuki.equalHeight = function (group) {
  var tallest = 0;
  if (group.length > 1) {
    group.each(function() {
      var thisHeight = $(this).outerHeight();
      if(thisHeight > tallest) {
        tallest = thisHeight;
      }
    });
    group.height(tallest);
  }
}
 
/**
 * Attaches custom sticky table headers.
 * This sticky header is used on the packages table to
 * work together with jscrollPane.
 */
Drupal.behaviors.suzukiTableHeader = {
  attach: function (context, settings) {
    if (!$.support.positionFixed) {
      return;
    }

    $('div > table#packages-table', context).once('suzuki-tableHeader', function () {
      $(this).data("suzuki-tableheader", new Drupal.Suzuki.tableHeader(this));
    });
  }
};

/* Store some general table elements as objects */
Drupal.Suzuki.stickyHeader = null;
Drupal.Suzuki.stickyTable = null;
Drupal.Suzuki.originalTable = null;
Drupal.Suzuki.originalHeader = null;
Drupal.Suzuki.originalHeaderCells = null;


/**
 * Constructor for the tableHeader object. Provides sticky table headers.
 *
 * @param table
 *   DOM object for the table to add a sticky header to.
 */
/**
 * @param table
 * @returns
 */
Drupal.Suzuki.tableHeader = function (table) {

  Drupal.Suzuki.originalTable = $(table);
  Drupal.Suzuki.originalHeader = $(table).children('thead');
  Drupal.Suzuki.originalHeaderCells = Drupal.Suzuki.originalHeader.find('> tr > th');

  // Clone the table header so it inherits original jQuery properties. Hide
  // the table to avoid a flash of the header clone upon page load.
  Drupal.Suzuki.stickyTable = $('<table class="suzuki-sticky-header"/>')
    .insertBefore(Drupal.Suzuki.originalTable)
    .css({ position: 'absolute', top: '0px', left: '0px' });
  Drupal.Suzuki.stickyHeader = Drupal.Suzuki.originalHeader.clone(true)
    .hide()
    .appendTo(Drupal.Suzuki.stickyTable);
  Drupal.Suzuki.stickyHeaderCells = Drupal.Suzuki.stickyHeader.find('> tr > th');
  
  Drupal.Suzuki.originalTable.addClass('sticky-table');
  $(window)
    .bind('scroll.suzuki-tableheader', $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
    .bind('resize.suzuki-tableheader', { calculateWidth: true }, $.proxy(this, 'eventhandlerRecalculateStickyHeader'))
    // Make sure the anchor being scrolled into view is not hidden beneath the
    // sticky table header. Adjust the scrollTop if it does.
    .bind('drupalDisplaceAnchor.drupal-tableheader', function () {
      window.scrollBy(0, -Drupal.Suzuki.stickyTable.outerHeight());
    })
    // Make sure the element being focused is not hidden beneath the sticky
    // table header. Adjust the scrollTop if it does.
    .bind('drupalDisplaceFocus.drupal-tableheader', function (event) {
      if (self.stickyVisible && event.clientY < (Drupal.Suzuki.stickyOffsetTop + Drupal.Suzuki.stickyTable.outerHeight()) && event.$target.closest('sticky-header').length === 0) {
        window.scrollBy(0, -Drupal.Suzuki.stickyTable.outerHeight());
      }
    })
    .triggerHandler('resize.drupal-tableheader');

  // Calculate the correct dimensions.
  Drupal.Suzuki.tableHeader.resize();
    
  // We hide the header to avoid it showing up erroneously on page load;
  // we need to unhide it now so that it will show up when expected.
  Drupal.Suzuki.stickyHeader.show();
  
};

/**
 * Resize sticky header and its cell widths.
 */
Drupal.Suzuki.tableHeader.resize = function() {
  Drupal.Suzuki.stickyHeaderCells.not('.invisible_column').each(function (index) {
    var cellWidth = Drupal.Suzuki.originalHeaderCells.not('.invisible_column').eq(index).width();
    // Exception for IE7.
    if (cellWidth == 'auto') {
      cellWidth = Drupal.Suzuki.originalHeaderCells.get(index).clientWidth + 'px';
    }
    $(this).css('width', cellWidth);
  });
  Drupal.Suzuki.stickyTable.css('width', Drupal.Suzuki.originalTable.css('width'));
}

/**
 * Event handler: recalculates position of the sticky table header.
 *
 * @param event
 *   Event being triggered.
 */
Drupal.Suzuki.tableHeader.prototype.eventhandlerRecalculateStickyHeader = function (event) {
  var calculateWidth = event.data && event.data.calculateWidth;

  // Reset top position of sticky table headers to the current top offset.
  Drupal.Suzuki.stickyOffsetTop = Drupal.settings.tableHeaderOffset ? eval(Drupal.settings.tableHeaderOffset + '()') : 0;
  Drupal.Suzuki.stickyTable.css('top', this.stickyOffsetTop + 'px');
  // Save positioning data.
  var viewHeight = document.documentElement.scrollHeight || document.body.scrollHeight;

  //if (calculateWidth || this.viewHeight !== viewHeight) {
    this.viewHeight = viewHeight;
    this.vPosition = parseInt($(window).scrollTop() - Drupal.Suzuki.originalTable.offset().top + Drupal.Suzuki.originalTable.position().top + Drupal.Suzuki.stickyOffsetTop);
    this.vLength = Drupal.Suzuki.originalTable[0].clientHeight - 100;
    calculateWidth = true;
  //}
  // Set vertical top.  
    Drupal.Suzuki.stickyTable.css({top: this.vPosition});
  // Calculate and set scrollbar height
  var scrollbar_pos = ($(window).height()-18)+this.vPosition;
  // Check for Chrome, needs less space
  if( $.browser.safari && /chrome/.test(navigator.userAgent.toLowerCase()) ){
//  	var scrollbar_pos = ($(window).height()-82)+this.vPosition;
  }
  $('#tab-package .jspHorizontalBar').css({top: scrollbar_pos});
  // Check if we're at the end of the element, then don't scroll it further
  if (scrollbar_pos >= $('#packages-table').height()){
	  $('#tab-package .jspHorizontalBar').css({top: ''});
  }
  var api = $('#tab-package .wrapper').data('jsp');
  //console.log(api.getContetPositionY());
  
  // Set visibility.
  var vOffset = this.vPosition;
  this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
  Drupal.Suzuki.stickyTable.css({visibility: this.stickyVisible ? 'visible' : 'hidden' });
};

/**
 * Show/hide Columns
 *
 * @param columnIndex
 *   Column index that nees to be hidden/shown
 */
Drupal.Suzuki.hide_column = function (columnIndex) {
  var api = $('#tab-package .wrapper').data('jsp');
  if ($('#packages-table td:nth-child('+(columnIndex+1)+')').is(":visible")){
    $('#packages-table td:nth-child('+(columnIndex+1)+'), #packages-table th:nth-child('+(columnIndex+1)+')').addClass("invisible_column").css({'width': 0});

    $('.suzuki-sticky-header th:nth-child('+(columnIndex+1)+')').addClass("invisible_column");

    $('#column_img_'+columnIndex).removeClass("yes");
    $('#column_img_'+columnIndex).addClass("no");
    api.reinitialise();
    
  }
  else {
	  $('#packages-table td:nth-child('+(columnIndex+1)+'), #packages-table th:nth-child('+(columnIndex+1)+')').removeClass("invisible_column");

    $('.suzuki-sticky-header th:nth-child('+(columnIndex+1)+')').removeClass("invisible_column");

    $('#column_img_'+columnIndex).removeClass("no");
    $('#column_img_'+columnIndex).addClass("yes");
    api.reinitialise();
  }
  
  // recalculate sticky header table cells.
  Drupal.Suzuki.tableHeader.resize(); 
  return false;
};

})(jQuery);;
/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.01 (08-SEP-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round). 
 *  corners: one or more of: top, bottom, tr, tl, br, or bl. 
 *           by default, all four corners are adorned. 
 *  width:   width of the effect; in the case of rounded corners this is the radius. 
 *           specify this value using the px suffix such as 10px (and yes, it must be pixels).
 *
 * @author Dave Methvin (http://methvin.com/jquery/jq-corner.html)
 * @author Mike Alsup   (http://jquery.malsup.com/corner/)
 */
;(function($) { 

var moz = $.browser.mozilla && /gecko/i.test(navigator.userAgent);
var webkit = $.browser.safari && $.browser.version >= 3;

var expr = $.browser.msie && (function() {
    var div = document.createElement('div');
    try { div.style.setExpression('width','0+0'); }
    catch(e) { return false; }
    return true;
})();
    
function sz(el, p) { 
    return parseInt($.css(el,p))||0; 
};
function hex2(s) {
    var s = parseInt(s).toString(16);
    return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
    for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
        var v = $.css(node,'backgroundColor');
        if (v == 'rgba(0, 0, 0, 0)')
            continue; // webkit
        if (v.indexOf('rgb') >= 0) { 
            var rgb = v.match(/\d+/g); 
            return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
        }
        if ( v && v != 'transparent' )
            return v;
    }
    return '#ffffff';
};

function getWidth(fx, i, width) {
    switch(fx) {
    case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
    case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
    case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
    case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
    case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
    case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
    case 'curl':   return Math.round(width*(Math.atan(i)));
    case 'tear':   return Math.round(width*(Math.cos(i)));
    case 'wicked': return Math.round(width*(Math.tan(i)));
    case 'long':   return Math.round(width*(Math.sqrt(i)));
    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
    case 'dog':    return (i&1) ? (i+1) : width;
    case 'dog2':   return (i&2) ? (i+1) : width;
    case 'dog3':   return (i&3) ? (i+1) : width;
    case 'fray':   return (i%2)*width;
    case 'notch':  return width; 
    case 'bevel':  return i+1;
    }
};

$.fn.corner = function(options) {
    // in 1.3+ we can fix mistakes with the ready state
	if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).corner(options);
            });
        }
        return this;
	}

    return this.each(function(index){
		var $this = $(this);
		var o = (options || $this.attr($.fn.corner.defaults.metaAttr) || '').toLowerCase();
		var keep = /keep/.test(o);                       // keep borders?
		var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
		var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
		var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
		var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
		var fx = ((o.match(re)||['round'])[0]);
		var edges = { T:0, B:1 };
		var opts = {
			TL:  /top|tl|left/.test(o),       TR:  /top|tr|right/.test(o),
			BL:  /bottom|bl|left/.test(o),    BR:  /bottom|br|right/.test(o)
		};
		if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
			opts = { TL:1, TR:1, BL:1, BR:1 };
			
		// support native rounding
		if ($.fn.corner.defaults.useNative && fx == 'round' && (moz || webkit) && !cc && !sc) {
			if (opts.TL)
				$this.css(moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
			if (opts.TR)
				$this.css(moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
			if (opts.BL)
				$this.css(moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
			if (opts.BR)
				$this.css(moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
			return;
		}
			
		var strip = document.createElement('div');
		strip.style.overflow = 'hidden';
		strip.style.height = '1px';
		strip.style.backgroundColor = sc || 'transparent';
		strip.style.borderStyle = 'solid';
	
        var pad = {
            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0
        };

        if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = $.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                var d = document.createElement('div');
                $(d).addClass('jquery-corner');
                var ds = d.style;

                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    if (expr)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
                    
                    // fix ie6 problem when blocked element has a border width
                    if (expr) {
                        var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
                    }
                    else
                        ds.width = '100%';
                }
                else {
                	ds.position = 'relative';
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
                }

                for (var i=0; i < width; i++) {
                    var w = Math.max(0,getWidth(fx,i, width));
                    var e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }
            }
        }
    });
};

$.fn.uncorner = function() { 
	if (moz || webkit)
		this.css(moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
	$('div.jquery-corner', this).remove();
	return this;
};

// expose options
$.fn.corner.defaults = {
	useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
	metaAttr:  'data-corner' // name of meta attribute to use for options
};
    
})(jQuery);
;
/*
 * jScrollPane - v2.0.0beta10 - 2011-04-04
 * http://jscrollpane.kelvinluck.com/
 *
 * Copyright (c) 2010 Kelvin Luck
 * Dual licensed under the MIT and GPL licenses.
 */
(function(b,a,c){b.fn.jScrollPane=function(f){function d(E,P){var aA,R=this,Z,al,w,an,U,aa,z,r,aB,aG,aw,j,J,i,k,ab,V,ar,Y,u,B,at,ag,ao,H,m,av,az,y,ax,aJ,g,M,ak=true,Q=true,aI=false,l=false,aq=E.clone(false,false).empty(),ad=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aJ=E.css("paddingTop")+" "+E.css("paddingRight")+" "+E.css("paddingBottom")+" "+E.css("paddingLeft");g=(parseInt(E.css("paddingLeft"),10)||0)+(parseInt(E.css("paddingRight"),10)||0);function au(aU){var aS,aT,aN,aP,aO,aL,aK,aR,aQ=false,aM=false;aA=aU;if(Z===c){aK=E.scrollTop();aR=E.scrollLeft();E.css({overflow:"hidden",padding:0});al=E.innerWidth()+g;w=E.innerHeight();E.width(al);Z=b('<div class="jspPane" />').css("padding",aJ).append(E.children());an=b('<div class="jspContainer" />').css({width:al+"px",height:w+"px"}).append(Z).appendTo(E)}else{E.css("width","");aQ=aA.stickToBottom&&L();aM=aA.stickToRight&&C();aL=E.innerWidth()+g!=al||E.outerHeight()!=w;if(aL){al=E.innerWidth()+g;w=E.innerHeight();an.css({width:al+"px",height:w+"px"})}if(!aL&&M==U&&Z.outerHeight()==aa){E.width(al);return}M=U;Z.css("width","");E.width(al);an.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}if(aU.contentWidth){U=aU.contentWidth}else{aS=Z.clone(false,false).css("position","absolute");aT=b('<div style="width:1px; position: relative;" />').append(aS);b("body").append(aT);U=Math.max(Z.outerWidth(),aS.outerWidth());aT.remove()}aa=Z.outerHeight();z=U/al;r=aa/w;aB=r>1;aG=z>1;if(!(aG||aB)){E.removeClass("jspScrollable");Z.css({top:0,width:an.width()-g});o();F();S();x();aj()}else{E.addClass("jspScrollable");aN=aA.maintainPosition&&(J||ab);if(aN){aP=aE();aO=aC()}aH();A();G();if(aN){O(aM?(U-al):aP,false);N(aQ?(aa-w):aO,false)}K();ah();ap();if(aA.enableKeyboardNavigation){T()}if(aA.clickOnTrack){q()}D();if(aA.hijackInternalLinks){n()}}if(aA.autoReinitialise&&!ax){ax=setInterval(function(){au(aA)},aA.autoReinitialiseDelay)}else{if(!aA.autoReinitialise&&ax){clearInterval(ax)}}aK&&E.scrollTop(0)&&N(aK,false);aR&&E.scrollLeft(0)&&O(aR,false);E.trigger("jsp-initialised",[aG||aB])}function aH(){if(aB){an.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));V=an.find(">.jspVerticalBar");ar=V.find(">.jspTrack");aw=ar.find(">.jspDrag");if(aA.showArrows){at=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aF(0,-1)).bind("click.jsp",aD);ag=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aF(0,1)).bind("click.jsp",aD);if(aA.arrowScrollOnHover){at.bind("mouseover.jsp",aF(0,-1,at));ag.bind("mouseover.jsp",aF(0,1,ag))}am(ar,aA.verticalArrowPositions,at,ag)}u=w;an.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){u-=b(this).outerHeight()});aw.hover(function(){aw.addClass("jspHover")},function(){aw.removeClass("jspHover")}).bind("mousedown.jsp",function(aK){b("html").bind("dragstart.jsp selectstart.jsp",aD);aw.addClass("jspActive");var s=aK.pageY-aw.position().top;b("html").bind("mousemove.jsp",function(aL){W(aL.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",ay);return false});p()}}function p(){ar.height(u+"px");J=0;Y=aA.verticalGutter+ar.outerWidth();Z.width(al-Y-g);try{if(V.position().left===0){Z.css("margin-left",Y+"px")}}catch(s){}}function A(){if(aG){an.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));ao=an.find(">.jspHorizontalBar");H=ao.find(">.jspTrack");i=H.find(">.jspDrag");if(aA.showArrows){az=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aF(-1,0)).bind("click.jsp",aD);
y=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aF(1,0)).bind("click.jsp",aD);if(aA.arrowScrollOnHover){az.bind("mouseover.jsp",aF(-1,0,az));y.bind("mouseover.jsp",aF(1,0,y))}am(H,aA.horizontalArrowPositions,az,y)}i.hover(function(){i.addClass("jspHover")},function(){i.removeClass("jspHover")}).bind("mousedown.jsp",function(aK){b("html").bind("dragstart.jsp selectstart.jsp",aD);i.addClass("jspActive");var s=aK.pageX-i.position().left;b("html").bind("mousemove.jsp",function(aL){X(aL.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",ay);return false});m=an.innerWidth();ai()}}function ai(){an.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){m-=b(this).outerWidth()});H.width(m+"px");ab=0}function G(){if(aG&&aB){var aK=H.outerHeight(),s=ar.outerWidth();u-=aK;b(ao).find(">.jspCap:visible,>.jspArrow").each(function(){m+=b(this).outerWidth()});m-=s;w-=s;al-=aK;H.parent().append(b('<div class="jspCorner" />').css("width",aK+"px"));p();ai()}if(aG){Z.width((an.outerWidth()-g)+"px")}aa=Z.outerHeight();r=aa/w;if(aG){av=Math.ceil(1/z*m);if(av>aA.horizontalDragMaxWidth){av=aA.horizontalDragMaxWidth}else{if(av<aA.horizontalDragMinWidth){av=aA.horizontalDragMinWidth}}i.width(av+"px");k=m-av;af(ab)}if(aB){B=Math.ceil(1/r*u);if(B>aA.verticalDragMaxHeight){B=aA.verticalDragMaxHeight}else{if(B<aA.verticalDragMinHeight){B=aA.verticalDragMinHeight}}aw.height(B+"px");j=u-B;ae(J)}}function am(aL,aN,aK,s){var aP="before",aM="after",aO;if(aN=="os"){aN=/Mac/.test(navigator.platform)?"after":"split"}if(aN==aP){aM=aN}else{if(aN==aM){aP=aN;aO=aK;aK=s;s=aO}}aL[aP](aK)[aM](s)}function aF(aK,s,aL){return function(){I(aK,s,this,aL);this.blur();return false}}function I(aN,aM,aQ,aP){aQ=b(aQ).addClass("jspActive");var aO,aL,aK=true,s=function(){if(aN!==0){R.scrollByX(aN*aA.arrowButtonSpeed)}if(aM!==0){R.scrollByY(aM*aA.arrowButtonSpeed)}aL=setTimeout(s,aK?aA.initialDelay:aA.arrowRepeatFreq);aK=false};s();aO=aP?"mouseout.jsp":"mouseup.jsp";aP=aP||b("html");aP.bind(aO,function(){aQ.removeClass("jspActive");aL&&clearTimeout(aL);aL=null;aP.unbind(aO)})}function q(){x();if(aB){ar.bind("mousedown.jsp",function(aP){if(aP.originalTarget===c||aP.originalTarget==aP.currentTarget){var aN=b(this),aQ=aN.offset(),aO=aP.pageY-aQ.top-J,aL,aK=true,s=function(){var aT=aN.offset(),aU=aP.pageY-aT.top-B/2,aR=w*aA.scrollPagePercent,aS=j*aR/(aa-w);if(aO<0){if(J-aS>aU){R.scrollByY(-aR)}else{W(aU)}}else{if(aO>0){if(J+aS<aU){R.scrollByY(aR)}else{W(aU)}}else{aM();return}}aL=setTimeout(s,aK?aA.initialDelay:aA.trackClickRepeatFreq);aK=false},aM=function(){aL&&clearTimeout(aL);aL=null;b(document).unbind("mouseup.jsp",aM)};s();b(document).bind("mouseup.jsp",aM);return false}})}if(aG){H.bind("mousedown.jsp",function(aP){if(aP.originalTarget===c||aP.originalTarget==aP.currentTarget){var aN=b(this),aQ=aN.offset(),aO=aP.pageX-aQ.left-ab,aL,aK=true,s=function(){var aT=aN.offset(),aU=aP.pageX-aT.left-av/2,aR=al*aA.scrollPagePercent,aS=k*aR/(U-al);if(aO<0){if(ab-aS>aU){R.scrollByX(-aR)}else{X(aU)}}else{if(aO>0){if(ab+aS<aU){R.scrollByX(aR)}else{X(aU)}}else{aM();return}}aL=setTimeout(s,aK?aA.initialDelay:aA.trackClickRepeatFreq);aK=false},aM=function(){aL&&clearTimeout(aL);aL=null;b(document).unbind("mouseup.jsp",aM)};s();b(document).bind("mouseup.jsp",aM);return false}})}}function x(){if(H){H.unbind("mousedown.jsp")}if(ar){ar.unbind("mousedown.jsp")}}function ay(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(aw){aw.removeClass("jspActive")}if(i){i.removeClass("jspActive")}}function W(s,aK){if(!aB){return}if(s<0){s=0}else{if(s>j){s=j}}if(aK===c){aK=aA.animateScroll}if(aK){R.animate(aw,"top",s,ae)}else{aw.css("top",s);ae(s)}}function ae(aK){if(aK===c){aK=aw.position().top}an.scrollTop(0);J=aK;var aN=J===0,aL=J==j,aM=aK/j,s=-aM*(aa-w);if(ak!=aN||aI!=aL){ak=aN;aI=aL;E.trigger("jsp-arrow-change",[ak,aI,Q,l])}v(aN,aL);Z.css("top",s);E.trigger("jsp-scroll-y",[-s,aN,aL]).trigger("scroll")}function X(aK,s){if(!aG){return
}if(aK<0){aK=0}else{if(aK>k){aK=k}}if(s===c){s=aA.animateScroll}if(s){R.animate(i,"left",aK,af)}else{i.css("left",aK);af(aK)}}function af(aK){if(aK===c){aK=i.position().left}an.scrollTop(0);ab=aK;var aN=ab===0,aM=ab==k,aL=aK/k,s=-aL*(U-al);if(Q!=aN||l!=aM){Q=aN;l=aM;E.trigger("jsp-arrow-change",[ak,aI,Q,l])}t(aN,aM);Z.css("left",s);E.trigger("jsp-scroll-x",[-s,aN,aM]).trigger("scroll")}function v(aK,s){if(aA.showArrows){at[aK?"addClass":"removeClass"]("jspDisabled");ag[s?"addClass":"removeClass"]("jspDisabled")}}function t(aK,s){if(aA.showArrows){az[aK?"addClass":"removeClass"]("jspDisabled");y[s?"addClass":"removeClass"]("jspDisabled")}}function N(s,aK){var aL=s/(aa-w);W(aL*j,aK)}function O(aK,s){var aL=aK/(U-al);X(aL*k,s)}function ac(aX,aS,aL){var aP,aM,aN,s=0,aW=0,aK,aR,aQ,aU,aT,aV;try{aP=b(aX)}catch(aO){return}aM=aP.outerHeight();aN=aP.outerWidth();an.scrollTop(0);an.scrollLeft(0);while(!aP.is(".jspPane")){s+=aP.position().top;aW+=aP.position().left;aP=aP.offsetParent();if(/^body|html$/i.test(aP[0].nodeName)){return}}aK=aC();aQ=aK+w;if(s<aK||aS){aT=s-aA.verticalGutter}else{if(s+aM>aQ){aT=s-w+aM+aA.verticalGutter}}if(aT){N(aT,aL)}aR=aE();aU=aR+al;if(aW<aR||aS){aV=aW-aA.horizontalGutter}else{if(aW+aN>aU){aV=aW-al+aN+aA.horizontalGutter}}if(aV){O(aV,aL)}}function aE(){return -Z.position().left}function aC(){return -Z.position().top}function L(){var s=aa-w;return(s>20)&&(s-aC()<10)}function C(){var s=U-al;return(s>20)&&(s-aE()<10)}function ah(){an.unbind(ad).bind(ad,function(aN,aO,aM,aK){var aL=ab,s=J;R.scrollBy(aM*aA.mouseWheelSpeed,-aK*aA.mouseWheelSpeed,false);return aL==ab&&s==J})}function o(){an.unbind(ad)}function aD(){return false}function K(){Z.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ac(s.target,false)})}function F(){Z.find(":input,a").unbind("focus.jsp")}function T(){var s,aK,aM=[];aG&&aM.push(ao[0]);aB&&aM.push(V[0]);Z.focus(function(){E.focus()});E.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aP){if(aP.target!==this&&!(aM.length&&b(aP.target).closest(aM).length)){return}var aO=ab,aN=J;switch(aP.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aP.keyCode;aL();break;case 35:N(aa-w);s=null;break;case 36:N(0);s=null;break}aK=aP.keyCode==s&&aO!=ab||aN!=J;return !aK}).bind("keypress.jsp",function(aN){if(aN.keyCode==s){aL()}return !aK});if(aA.hideFocus){E.css("outline","none");if("hideFocus" in an[0]){E.attr("hideFocus",true)}}else{E.css("outline","");if("hideFocus" in an[0]){E.attr("hideFocus",false)}}function aL(){var aO=ab,aN=J;switch(s){case 40:R.scrollByY(aA.keyboardSpeed,false);break;case 38:R.scrollByY(-aA.keyboardSpeed,false);break;case 34:case 32:R.scrollByY(w*aA.scrollPagePercent,false);break;case 33:R.scrollByY(-w*aA.scrollPagePercent,false);break;case 39:R.scrollByX(aA.keyboardSpeed,false);break;case 37:R.scrollByX(-aA.keyboardSpeed,false);break}aK=aO!=ab||aN!=J;return aK}}function S(){E.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function D(){if(location.hash&&location.hash.length>1){var aL,aK;try{aL=b(location.hash)}catch(s){return}if(aL.length&&Z.find(location.hash)){if(an.scrollTop()===0){aK=setInterval(function(){if(an.scrollTop()>0){ac(location.hash,true);b(document).scrollTop(an.position().top);clearInterval(aK)}},50)}else{ac(location.hash,true);b(document).scrollTop(an.position().top)}}}}function aj(){b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack")}function n(){aj();b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack",function(){var s=this.href.split("#"),aK;if(s.length>1){aK=s[1];if(aK.length>0&&Z.find("#"+aK).length>0){ac("#"+aK,true);return false}}})}function ap(){var aL,aK,aN,aM,aO,s=false;an.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aP){var aQ=aP.originalEvent.touches[0];aL=aE();aK=aC();aN=aQ.pageX;aM=aQ.pageY;aO=false;s=true}).bind("touchmove.jsp",function(aS){if(!s){return}var aR=aS.originalEvent.touches[0],aQ=ab,aP=J;
R.scrollTo(aL+aN-aR.pageX,aK+aM-aR.pageY);aO=aO||Math.abs(aN-aR.pageX)>5||Math.abs(aM-aR.pageY)>5;return aQ==ab&&aP==J}).bind("touchend.jsp",function(aP){s=false}).bind("click.jsp-touchclick",function(aP){if(aO){aO=false;return false}})}function h(){var s=aC(),aK=aE();E.removeClass("jspScrollable").unbind(".jsp");E.replaceWith(aq.append(Z.children()));aq.scrollTop(s);aq.scrollLeft(aK)}b.extend(R,{reinitialise:function(aK){aK=b.extend({},aA,aK);au(aK)},scrollToElement:function(aL,aK,s){ac(aL,aK,s)},scrollTo:function(aL,s,aK){O(aL,aK);N(s,aK)},scrollToX:function(aK,s){O(aK,s)},scrollToY:function(s,aK){N(s,aK)},scrollToPercentX:function(aK,s){O(aK*(U-al),s)},scrollToPercentY:function(aK,s){N(aK*(aa-w),s)},scrollBy:function(aK,s,aL){R.scrollByX(aK,aL);R.scrollByY(s,aL)},scrollByX:function(s,aL){var aK=aE()+s,aM=aK/(U-al);X(aM*k,aL)},scrollByY:function(s,aL){var aK=aC()+s,aM=aK/(aa-w);W(aM*j,aL)},positionDragX:function(s,aK){X(s,aK)},positionDragY:function(aK,s){X(aK,s)},animate:function(aK,aN,s,aM){var aL={};aL[aN]=s;aK.animate(aL,{duration:aA.animateDuration,ease:aA.animateEase,queue:false,step:aM})},getContentPositionX:function(){return aE()},getContentPositionY:function(){return aC()},getContentWidth:function(){return U()},getContentHeight:function(){return aa()},getPercentScrolledX:function(){return aE()/(U-al)},getPercentScrolledY:function(){return aC()/(aa-w)},getIsScrollableH:function(){return aG},getIsScrollableV:function(){return aB},getContentPane:function(){return Z},scrollToBottom:function(s){W(j,s)},hijackInternalLinks:function(){n()},destroy:function(){h()}});au(P)}f=b.extend({},b.fn.jScrollPane.defaults,f);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){f[this]=f[this]||f.speed});var e;this.each(function(){var g=b(this),h=g.data("jsp");if(h){h.reinitialise(f)}else{h=new d(g,f);g.data("jsp",h)}e=e?e.add(g):g});return e};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);;
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 * Thanks to: Seamus Leahy for adding deltaX and deltaY
 *
 * Version: 3.0.4
 * 
 * Requires: 1.2.2+
 */

(function($) {

var types = ['DOMMouseScroll', 'mousewheel'];

$.event.special.mousewheel = {
    setup: function() {
        if ( this.addEventListener ) {
            for ( var i=types.length; i; ) {
                this.addEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = handler;
        }
    },
    
    teardown: function() {
        if ( this.removeEventListener ) {
            for ( var i=types.length; i; ) {
                this.removeEventListener( types[--i], handler, false );
            }
        } else {
            this.onmousewheel = null;
        }
    }
};

$.fn.extend({
    mousewheel: function(fn) {
        return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
    },
    
    unmousewheel: function(fn) {
        return this.unbind("mousewheel", fn);
    }
});


function handler(event) {
    var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
    event = $.event.fix(orgEvent);
    event.type = "mousewheel";
    
    // Old school scrollwheel delta
    if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
    if ( event.detail     ) { delta = -event.detail/3; }
    
    // New school multidimensional scroll (touchpads) deltas
    deltaY = delta;
    
    // Gecko
    if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
        deltaY = 0;
        deltaX = -1*delta;
    }
    
    // Webkit
    if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
    if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
    
    // Add event and delta to the front of the arguments
    args.unshift(event, delta, deltaX, deltaY);
    
    return $.event.handle.apply(this, args);
}

})(jQuery);;

