/*////////////////////////////////////////////////

  colopla
	Copyright (c)COLOPL, Inc. All Rights Reserved.
	CreationDate: 2010-8
	
////////////////////////////////////////////////*/
$(function(){
					 $(".fontsize").html('<dl>'+
	'<dt><img src="/common/image/txt_size.png" alt="文字のサイズ" width="75" height="12"></dt>'+
	'<dd id="fontS"><img src="/common/image/btn_small.png" alt="小さく" width="24"  height="24" class="on"></dd>'+
	'<dd id="fontL"><img src="/common/image/btn_large.png" alt="大きく" width="26" height="26" class="on"></dd>'+
	'</dl>');
});		 
/**
 * 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
 *
 */
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(){
					 
		var minValue=66;
		var maxValue=126;
    $(function(){
			var ChildElements=$('body');
			var fontSizeSet =75;
			if($.cookie('fontSize') == null) { $('body').css('font-size',fontSizeSet+"%");}		 
			if($.cookie('fontSize')){
			fontSizeSet = $.cookie('fontSize');
			$('body').css('font-size',fontSizeSet+"%");
			}
			$('#fontL').click(function(){
				if(fontSizeSet<maxValue){	fontSizeSet=(fontSizeSet-0)+17;}
				$('body').css('font-size',fontSizeSet+"%");
				$.cookie('fontSize', fontSizeSet,{ expires: 7 , path:'/'}); 
			});
			$('#fontS').click(function(){
				if(fontSizeSet>minValue){fontSizeSet -= 17;}
				$('body').css('font-size',fontSizeSet+"%");
				$.cookie('fontSize', fontSizeSet,{ expires: 7 , path:'/'}); 
			});
		});
/*------------------------------
roll over
------------------------------*/
    $.fn.rollover = function(postfix) {
        postfix = postfix || '_on';
        return this.not('[src*="'+ postfix +'."]').each(function() {
            var img = $(this);
            var src = img.attr('src');
            var src_on = [
                src.substr(0, src.lastIndexOf('.')),
                src.substring(src.lastIndexOf('.'))
            ].join(postfix);
            $('<img>').attr('src', src_on);
            img.hover(
                function() {
                    img.attr('src', src_on);
                },
                function() {
                    img.attr('src', src);
                }
            );
        });
    };
	$('img.on').rollover();
/*----------------------------
 * add class
----------------------------*/
var lastchild = [
		"article:last-child",
		".sitemap ul:last-child"
		];
for(i=0; i<lastchild.length; i++){
$($(lastchild)[i]).addClass('lastChild'); 
}

var firstchild = [
		"p:first-child",
		"table.schedule th:first-child"
	];
for(i=0; i<firstchild.length; i++){
$($(firstchild)[i]).addClass('firstChild'); 
}

var odd = [
		"table.event tr:nth-child(odd)"
		];
for(i=0; i<odd.length; i++){
$($(odd)[i]).addClass('odd'); 
}
/*------------------------------
scrollto
------------------------------*/
	$('a[href*=#pagetop]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var target = $(this.hash);
			target = target.length && target;
			if (target.length) {
				var sclpos = 30;
				var scldurat = 1200;
				var targetOffset = target.offset().top - sclpos;
				$('html,body')
					.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
				return false;
			}
		}
	});
/*------------------------------
toggle
------------------------------*/
$('.sitemap ul').hide();
$('.sitemap h3').click(function() {
		$('.sitemap ul').toggle('normal');
		$('.sitemap div').toggleClass('open');
});
/*------------------------------
target
------------------------------*/
$(".modal a").removeAttr("href");

$(".thum").each(function() {
		$(this).hover(function() {
						$(this).css({
						"-webkit-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1.05)',
						"-moz-transform": 'rotate(' + (Math.floor(Math.random()*10)-5) + 'deg) scale(1.05)'
						})
				}, function() {
						$(this).css({
						"-webkit-transform": 'none',
						"-moz-transform": 'none'
						})
				});
});

$(".thum").click(function() {
		$(this).parent().next().addClass("target");
		});

$(".modal div").click(function() {
		$(this).removeClass("target");
		});


});






