// RollOver
$(function () {
	$.rollover = {
		init: function () {
			// <img>
			$('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();
});

//extension
$(function(){
	$('a[href$=pdf]').addClass('pdf');
	$('a[href$=doc]').addClass('doc');
	$('a[href$=xls]').addClass('xls');
});

//maxImage Propaty（各ページに配置）
$(function(){
	$('img.demo').maxImage({
		isBackground: true,
		slideShow: false,
		position: 'absolute',
		verticalAlign: 'bottom',
		slideShowTitle: false, //タイトルを出すかどうか
		slideDelay:5, //スライド間の秒数
		maxFollows: 'height',
		resizeMsg: {show: false}
	});
});


//PNG fix
if (window.DD_belatedPNG) DD_belatedPNG.fix('img,div,ul,li,h1,h2,a,p.button,p.more');

//navi first_and_last
$(document).ready(function() {
	$('ul.navigation li:first').addClass('first');
	$('ul.navigation li:last').addClass('last');
});


//index accordion
$(document).ready(function() {

	$("div#sub_contents p.button").hover(function(){
		$(this).css("cursor","pointer");
		},function(){
		$(this).css("cursor","default");
	});
	//$("div#sub_contents p.button").addClass('off');
	$("div#sub_contents p.button").addClass('on').removeClass('off');
	$("div#sub_contents p.button").click(function(){
		if($("div#sub_contents div.section").css('display') == 'none'){
			$("div#sub_contents p.button").addClass('on').removeClass('off');
		}else{
			$("div#sub_contents p.button").addClass('off').removeClass('on');
		};
		$("div#sub_contents div.section").animate({width:'toggle'});
	});
});

$(function(){
	//class
	$("div#sub_contents div.news dl.news dt:first").addClass("first");
	$("div#sub_contents div.news dl.news dd:first").addClass("first");

	//default css
	$("div#sub_contents div.news").css("display","block");
	//$("div#sub_contents div.news dl.news dt,div#sub_contents div.news dl.news dd").css("display","none");

	$("div#sub_contents div.news dl.news dt.first,div#sub_contents div.news dl.news dd.first").css("display","block");
//	$("div#sub_contents div.news").css("height","auto");
		$("div#sub_contents div.news").css("height","100%");
$("div#sub_contents div.news dl.news").css("margin","1em 0 20px");
	
	//hover
	$("div#sub_contents div.news p.more img").hover(function(){
		$(this).css("cursor","pointer");
	});

	//click
	$("div#sub_contents div.news p.more").addClass('off').removeClass('on');
	$("div#sub_contents div.news p.more img").click(function(){
		if($("div#sub_contents div.news dl.news dd.first").nextAll().css('display') == 'none'){
			$("div#sub_contents p.more").addClass('on').removeClass('off');
		}else{
			$("div#sub_contents p.more").addClass('off').removeClass('on');
		};
		if($("div#sub_contents div.news dl.news dd.first").nextAll().css('display') == 'none'){
			$("div#sub_contents div.news").css("height","100%");
			$("div#sub_contents div.news dl.news").css("margin","1em 0 100px");
		}else{
			$("div#sub_contents div.news").css("height","auto");
			$("div#sub_contents div.news dl.news").css("margin","1em 0 20px");
			
}
		$("div#sub_contents div.news dl.news dd.first").nextAll().slideToggle("normal");
	});
});



// Accordion
$(document).ready(function() {
	$("div.information h2").hover(function(){
		$(this).css("cursor","pointer");
		$(this).css("text-decoration","underline"); 
	},function(){
		$(this).css("cursor","default");
		$(this).css("text-decoration","none");
		});
	$("div.information div").css("display","none");
	$("div.information h2").click(function(){
		$(this).next().slideToggle("normal");
	});
});



// gallery
$(function(){
    $('div.about ul.gallery li').flatHeights();
});

// toggle on,off

