function constrain(text, ideal_width, strStyle)
{
    var temp_item = ('<span id="testWidth" style="'+strStyle+'" style="display:none;">'+ text +'</span>');
    jQuery(temp_item).appendTo('body');
    var item_width = jQuery('#testWidth').width();
    var ideal = parseInt(ideal_width);
    var smaller_text = text;

    if (item_width>ideal_width)
    {
        while (item_width > ideal)
        {
            smaller_text = smaller_text.substr(0, (smaller_text.length-1));
            jQuery('#testWidth').html(smaller_text);
            item_width = jQuery('#testWidth').width();
        }
        smaller_text = smaller_text + '&hellip;'
    }
    jQuery('#testWidth').remove();
    return smaller_text;
}
