﻿jQuery(document).ready(function(){
var mnuItem = $('.mainMenu').find(".root");
/*Loop through the list*/
$.each(mnuItem, function(j, m)
{	    
    var notBreak = '&amp;';
    var text = $(this).find(".txt").html();
    var newText = '';
    var textItems = text.split(' ');
    var charCounter = 0;
    $.each(textItems, function(c, word)
    {
        charCounter =  charCounter + word.length;
        newText = newText + ' ' + word;
        if (charCounter > 5 && c != textItems.length - 1 && textItems[c + 1].length > 2 && notBreak.indexOf(textItems[c + 1].toLowerCase()) < 0)
        {
            newText = newText + '<br/>';
            charCounter = 0;
        }
    });
    $(this).find(".txt").html(newText);
	$(this).find(".txt").wrapInner("<div class='MenuFixer'></div>");
    $(this).find(".txt").wrapInner("<div class='MenuWrapper'></div>");
	
});
});