﻿$(document).ready(function() {
    $(".txtDescription").each(function() {
        var a = new Array();
        var maxLength = 30;
        jQuery.each($(this).html().split(" "), function() {
            if (this.length > maxLength) {
                a.push(this.split("").join("<wbr/>"));
            }
            else {
                a.push(this);
            }
        });
    });

    $('.productMoreButton').click(function() {
        var maxLength = 30;
        var a = new Array();
        var itemContainer = $(this).parents('#itemContainer');
        var descriptionPlace = itemContainer.find('.txtDescription');
        var html = itemContainer.find('.txtDescriptionFull').html();
        jQuery.each(html.split(" "), function() {
            if (this.length > maxLength) {
                a.push(this.split("").join("<wbr/>"));
            }
            else {
                a.push(this);
            }
        });
        descriptionPlace.html(html);
        $(this).hide();
        return false;
    });
});