jQuery(function() {
    jQuery('a').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var target = jQuery(this).attr("href");
target = target.split("#");
target = "#"+target[1];

            target = jQuery(target);

            target = target.length && target;

            if (target.length) {
                var sclpos = 30;
                var scldurat = 1200;
                var targetOffset = target.offset().top - sclpos;
                jQuery('html,body')
                    .animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
                return false;
            }
        }
    });
});

jQuery.auto = {
    init: function() {
        for (module in jQuery.auto) {
            if (jQuery.auto[module].init)
                jQuery.auto[module].init();
        }
    }
};

jQuery(document).ready(jQuery.auto.init);

jQuery.auto.hide = {
    init: function() {
        jQuery('.Hide').hide();
    }
};

jQuery.auto.hover = {

    init: function() {
        jQuery('IMG.Hover,input.Hover')
            .bind('mouseover', this.enter)
            .bind('mouseout', this.exit)
            .each(this.preload);
    },

    preload: function() {
        this.preloaded = new Image;
        this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
    },

    enter: function() {
        this.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
    },

    exit: function() {
        this.src = this.src.replace(/^(.+)_over(\.[a-z]+)$/, "$1$2");
    }
};

jQuery.auto.submit = {
    init: function() {
        jQuery('SELECT.Submit').bind('change', this.on_change);
    },

    on_change: function() {
        if (this.value) this.form.submit();
    }
};

jQuery.auto.select = {
    init: function() {
        jQuery('LABEL.Select').each(this.label_action);
        jQuery('INPUT.Select').bind('click', function(){ this.select(); });
    },

    label_action: function() {
        var field = jQuery('#'+this.htmlFor).get(0);
        if (field && field.focus && field.select) {
            jQuery(this).bind('click', function(){ field.focus(); field.select(); });
        }
    }
};

jQuery.auto.tabs = {

    init: function() {

        jQuery('.Tabs').each(function(){
            var f = jQuery.auto.tabs.click;
            var group = this;
            jQuery('.Tab', group).each(function(){
                this.group = group;
                jQuery(this).click(f);
                jQuery('#'+this.id+'_body').hide();
            }).filter(':first').trigger('click');
        });

    },

    click: function() {
        var tab = jQuery('#'+this.id+'_body').get(0);
        jQuery('.Tab', this.group).each(function(){
            jQuery(this).removeClass('Active');
            jQuery('#'+this.id+'_body').hide();
        });

        jQuery(this).addClass('Active');
        jQuery(tab).show();
        this.blur();

        return false;
    }

};

jQuery(function(){
jQuery('.popup').click(function(){

var myid = jQuery(this).parent().attr('id');
//alert(myid);
var url = jQuery(this).parent().get(0).action;
var windownames = "win"+myid;

window.open(url,windownames,"width=700,height=500, menubar=no, toolbar=no, scrollbars=yes");
return false;
});
});

jQuery(function(){
jQuery('.close').click(function(){
    window.close();
});
});


jQuery(document).ready(function(){
    var name = "fontsize";
    if(jQuery.cookie(name))
    {
        
        if (jQuery.cookie(name) == "l")
        {
            jQuery("#contents").animate({ fontSize: "16px" }, 50 );
        }
        else if (jQuery.cookie(name) == "m")
        {
            jQuery("#contents").animate({ fontSize: "14px" }, 50 );
        }
        else if (jQuery.cookie(name) == "s")
        {
            jQuery("#contents").animate({ fontSize: "12px" }, 50 );
        }
    }
});
jQuery(function() {
    jQuery('#head .fontsize span').click(function() {
        if (jQuery(this).attr("class") == "l")
        {
            jQuery("#contents").animate({ fontSize: "16px" }, 50 );
        }
        else if (jQuery(this).attr("class") == "m")
        {
            jQuery("#contents").animate({ fontSize: "14px" }, 50 );
        }
        else if (jQuery(this).attr("class") == "s")
        {
            jQuery("#contents").animate({ fontSize: "12px" }, 50 );
        }
        var name = "fontsize";
        if(jQuery.cookie(name))
        {
            jQuery.cookie(name, '', { expires: -1 });//クッキーを削除
        }
        else
        {
            jQuery.cookie(name,jQuery(this).attr("class"),{expires:7});//クッキーをセット
        }
    });
});

/**
 * 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;
    }
};


function mainmenu(){
jQuery("#ajaxmenu li").hover(function(){
        jQuery(this).find('ul:first').show(400);
        },function(){
        jQuery(this).find('ul:first').hide(400);
        });
}

 
 
jQuery(document).ready(function(){                  
    mainmenu();
});