// 日本語 UTF-8N LF
//-------------------------------------------------------------
// JavaScript
// jQuery プラグイン
//-------------------------------------------------------------
// Landwarf / Takayuki Onodera
//-------------------------------------------------------------
//
//-------------------------------------------------------------
// プラグイン
//-------------------------------------------------------------
(function($) {
    //---------------------------------------------------------
    // 指定要素内のブロックの高さを揃える
    //---------------------------------------------------------
    $.fn.setHeight = function() {
        if (this.length > 1) {
            var maxHeight = 0;
            this.each(function() {
                var height = $(this).height();
                if (height > maxHeight) maxHeight = height;
            });
            $(this).height(maxHeight);
        //  $(this).height(maxHeight).css("overflow","auto");
        //  $(this).css({'height':strHight + 'px'});
        //  $(this).css({'min-height':strHight + 'px'});
        }
        return this;
    };
    //---------------------------------------------------------
    // 指定要素内の文章に word-break 効果を適用する
    // Usage: $('[search]').breakWords();
    //---------------------------------------------------------
    $.fn.breakWords = function() {
        this.each(function() {
            if (this.nodeType !== 1) { return; }
            if (this.currentStyle && typeof this.currentStyle.wordBreak === 'string') {
                // Lazy Function Definition Pattern, Peter's Blog
                // From http://peter.michaux.ca/article/3556
                this.runtimeStyle.wordBreak = 'break-all';
            } else if(document.createTreeWalker) {
                // Faster Trim in Javascript, Flagrant Badassery
                // http://blog.stevenlevithan.com/archives/faster-trim-javascript
                var trim = function(str) {
                    str = str.replace(/^\s\s*/, '');
                    var ws = /\s/,
                    i = str.length;
                    while (ws.test(str.charAt(--i)));
                    return str.slice(0, i + 1);
                };
                // Lazy Function Definition Pattern, Peter's Blog
                // From http://peter.michaux.ca/article/3556
                // For Opera, Safari, and Firefox
                var dWalker = document.createTreeWalker(this, NodeFilter.SHOW_TEXT, null, false);
                var node,s,c = String.fromCharCode('8203');
                while (dWalker.nextNode()) {
                    node = dWalker.currentNode;
                    // we need to trim String otherwise Firefox will display
                    // incorect text-indent with space characters
                    s = trim( node.nodeValue ).split('').join(c);
                    node.nodeValue = s;
                }
            }
        });
        return this;
    };
})(jQuery);
//-------------------------------------------------------------
// Copyright(C)Landwarf All right reserved.
//-------------------------------------------------------------
