/**
/* Sample:
/*      $('#tab_wrapper').dsTab();
/*      <div id="tab_wrapper">                                  // wrapper element - can have any attributes
/*          <div class="tabbed_links">                          // link wrapper - div.tabbed_links is default (tabSelector)
/*              <a class="active" href="" rel="one">Tab One</a> // tab link - rel points to tab boxes, put active class on default tab (activeClass and activeSelector)
/*              <a href="" rel="two">Tab Two</a>                //  href is not used
/*          </div>
/*          <div class="tab_box" id="one_box">Box One</div>     // tab box - div.tab_box is default (tabSelector)
/*          <div class="tab_box" id="two_box">Box Two</div>     //  default id is <rel>+'_box' (relPostfix)
/*      </div>
/*
/* Parameters:
/*      truncBox:    'div.tab_box'       // Selector for the tab boxes
/*      appendToken:    'div.tab_box'       // Selector for the tab boxes
 */
jQuery.fn.dsTruncate = function(params) {
    var $ = jQuery;
    var params = params || {};
    var boxHeight = 0;
    var box = $(this);
    params.boxToTruncate = params.boxToTruncate || this;
    params.appendToken = params.appendToken || '&hellip;';
    var tokenLength = params.appendToken.length;
    var truncBox = box.children(params.boxToTruncate);
    boxHeight = box.height();
    var calcHeight = 0;
    box.children().each(function(){
        calcHeight += $(this).outerHeight(true);
    });
    if (calcHeight > boxHeight) {
        truncBox.html(truncBox.html()+params.appendToken);
    }
    while (calcHeight > boxHeight && truncBox.text().length > params.appendToken.length) {
        truncBox.html(truncBox.html().substring(0,truncBox.html().length-tokenLength));
        truncBox.html(truncBox.text().substr(0,truncBox.text().lastIndexOf(' ')));
        truncBox.html(truncBox.html()+params.appendToken);
        calcHeight = 0;
        box.children().each(function(){
            calcHeight += $(this).outerHeight(true);
        });
    }
    return this;
}

