// ロールオーバー
$(function () {
	$.rollover = {
		init: function () {
			// <img>
			$('a img,input[type="image"]')
				.filter('[src*="_off"]')
				.bind('mouseover', this.over)
				.bind('mouseout',  this.out)
				.each(this.preload);
			// <a> with <img>, <shape> with <img> (for DD_belatedPNG.js)
			if ($.browser.msie && $.browser.version <= 6 )	// ie6
			$('shape')
				.filter(function(){return this.firstChild && this.firstChild.src})
				.bind('mouseover', this.overx)
				.bind('mouseout',  this.outx)
				.each(this.preloadx);
		},

		// <img>
		over : function () {
			this.setAttribute('src', this.getAttribute('src').replace('_off', '_on'));
		},
		out : function () {
			this.setAttribute('src', this.getAttribute('src').replace('_on', '_off'));
		},
		preload : function () {
			new Image().src = this.getAttribute('src').replace('_off', '_on');
		},
		// <a> with <img>, <shape> with <img> (for DD_belatedPNG.js)
		overx : function () {
			var img = this.firstChild;
			img.setAttribute('src', img.getAttribute('src').replace('_off', '_on'));
		},
		outx : function () {
			var img = this.firstChild;
			img.setAttribute('src', img.getAttribute('src').replace('_on', '_off'));
		},
		preloadx : function () {
			var img = this.firstChild;
			new Image().src = img.getAttribute('src').replace('_off', '_on');
		}
	};
	$.rollover.init();
});


//flatheight
$(window).bind('load',function(){
    var sets = [], temp = [];
    $('div.section div.navigation').each(function(i) {
        temp.push(this);
        if (i % 2 == 1) {
            sets.push(temp);
            temp = [];
        }
    });
    $('div#contents div.section div.section.category').each(function(i) {
        temp.push(this);
        if (i % 2 == 1) {
            sets.push(temp);
            temp = [];
        }
    });
    if (temp.length) sets.push(temp);
    $.each(sets, function() {
        $(this).flatHeights();
    });
});

$(function(){
    $("div.navigation:even").addClass("odd");
    $("div.navigation:odd").addClass("even");
});

$(function(){
    $("div#contents_navigation ul.navigation li:first").css("border", "none");
    $("div#footer ul.navigation li:first").css("background", "none");
});


// setting 開閉
$(function(){
	if(! $.cookie('akita_mitane_setting')){
	    $.cookie('akita_mitane_setting', 0, {expires:365, path:'/'});
	}
	
	$("#header p.toggle").toggle(
		function () {
			$("#header dl.fontsize, #header dl.color").hide("slow");
			$.cookie('akita_mitane_setting', 1, {expires:365, path:'/'});
		},
		function () {
			$("#header dl.fontsize, #header dl.color").show("slow");
			$.cookie('akita_mitane_setting', 0, {expires:365, path:'/'});
		}
	);
	

	
	if($.cookie('akita_mitane_setting') == 0){
		$("#header dl.fontsize, #header dl.color").show();
	}else{
		$("#header dl.fontsize, #header dl.color").hide();
		$("#header p.toggle").trigger('click');
	}
	

});

//fancybox
$(function () {
 if    ($.fn.fancybox) $("a[href$=jpg],a[href$=gif]").fancybox({
        'hideOnContentClick': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#000000'
    });
});
