$(document).ready(function() {
  if (!(($.browser.version == 'msie') && ($.browser.version <= '6.0'))) {
    $('#slideshow').cycle({
      fx: 'fade',
      height: '310px',
      random: 1,
      timeout: 5000
    });
  }
  
  $('#donate_link_container').click(function() {
    document.location = '/get-involved/donate';
  });
  
  function unitsAreInPixels(value) {
    var result = false;
    
    if (value) {
      result = value.indexOf('px') > 0;
    } else {
      result = true;
    }
    
    return result;
  }
  
  function convertFromPixelsToInt(value) {
    var result = 0;
    
    if (value) {
      value = value.replace('px', '');
      result = parseInt(value);
    }
    
    return result;
  }
  
  function contentHeight(containerId) {
    var heightCss = $(containerId).css('height');
    var paddingTopCss = $(containerId).css('padding-top');
    var paddingBottomCss = $(containerId).css('padding-bottom');
    var marginTopCss = $(containerId).css('margin-top');
    var marginBottomCss = $(containerId).css('marign-bottom'); 
    
    var result = 0;
    
    if (unitsAreInPixels(heightCss) && 
      unitsAreInPixels(paddingTopCss) && 
      unitsAreInPixels(paddingBottomCss) && 
      unitsAreInPixels(marginTopCss) &&
      unitsAreInPixels(marginBottomCss)) {
    
      result = convertFromPixelsToInt(heightCss) - 
        convertFromPixelsToInt(paddingTopCss) - 
        convertFromPixelsToInt(paddingBottomCss) - 
        convertFromPixelsToInt(marginTopCss) - 
        convertFromPixelsToInt(marginBottomCss);
    }
    
    return result;
  }
  
  function contentHeightInPixels(containerId) {
    var height = contentHeight(containerId);
    return height.toString() + 'px';
  }
  
  $('#open_quote').css('padding-bottom', contentHeightInPixels('#quote_box'));
});
