// 日本語 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 (PNG Fix) v1.2
     * Microsoft Internet Explorer 24bit PNG Fix
     *
     * The MIT License
     *
     * Copyright (c) 2007 Paul Campbell (pauljamescampbell.co.uk)
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in
     * all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     * THE SOFTWARE.
     *
     * @param       Object
     * @return      Array
     */
    //---------------------------------------------------------
    $.fn.pngfix = function(options) {
        // Review the Microsoft IE developer library for AlphaImageLoader reference
        // http://msdn2.microsoft.com/en-us/library/ms532969(VS.85).aspx
        // ECMA scope fix
        var elements    = this;
        var settings    = $.extend({
            imageFixSrc:    false,
            sizingMethod:   false
        }, options);
        if(!$.browser.msie || ($.browser.msie &&  $.browser.version >= 7)) {
            return(elements);
        }
        function setFilter(el, path, mode) {
            var fs = el.attr("filters");
            var alpha = "DXImageTransform.Microsoft.AlphaImageLoader";
            if (fs[alpha]) {
                fs[alpha].enabled = true;
                fs[alpha].src = path;
                fs[alpha].sizingMethod = mode;
            } else {
                el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');
            }
        }
        function setDOMElementWidth(el) {
            if(el.css("width") == "auto" & el.css("height") == "auto") {
                el.css("width", el.attr("offsetWidth") + "px");
            }
        }
        return(
            elements.each(function() {
                // Scope
                var el = $(this);
                if(el.attr("tagName").toUpperCase() == "IMG" && (/\.png/i).test(el.attr("src"))) {
                    if(!settings.imageFixSrc) {
                        // Wrap the <img> in a <span> then apply style/filters,
                        // removing the <img> tag from the final render
                        el.wrap("<span></span>");
                        var par = el.parent();
                        par.css({
                            height:     el.height(),
                            width:      el.width(),
                            display:    "inline-block"
                        });
                        setFilter(par, el.attr("src"), "scale");
                        el.remove();
                    } else if((/\.gif/i).test(settings.imageFixSrc)) {
                        // Replace the current image with a transparent GIF
                        // and apply the filter to the background of the
                        // <img> tag (not the preferred route)
                        setDOMElementWidth(el);
                        setFilter(el, el.attr("src"), "image");
                        el.attr("src", settings.imageFixSrc);
                    }
                } else {
                    var bg = new String(el.css("backgroundImage"));
                    var matches = bg.match(/^url\("(.*)"\)$/);
                    if(matches && matches.length) {
                        // Elements with a PNG as a backgroundImage have the
                        // filter applied with a sizing method relevant to the
                        // background repeat type
                        setDOMElementWidth(el);
                        el.css("backgroundImage", "none");
                        // Restrict scaling methods to valid MSDN defintions (or one custom)
                        var sc = "crop";
                        if(settings.sizingMethod) {
                            sc = settings.sizingMethod;
                        }
                        setFilter(el, matches[1], sc);
                        // Fix IE peek-a-boo bug for internal links
                        // within that DOM element
                        el.find("a").each(function() {
                            $(this).css("position", "relative");
                        });
                    }
                }
            })
        );
    };
})(jQuery);
//-------------------------------------------------------------
// プラグイン
//-------------------------------------------------------------
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
//-------------------------------------------------------------
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
//-------------------------------------------------------------
// Copyright(C)Landwarf All right reserved.
//-------------------------------------------------------------

