$(function(){
	//スクロール
	$('a[href*=#]').click(function() {
		if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			
			var targetOffset = 0;
			if ($target.length) {
				if(this.hash.slice(1).length != 0){
					targetOffset = $target.offset().top;
				}
			}
			$('html,body').animate({scrollTop: targetOffset}, 400, 'easeOutSine');
			return false;
		}
	});

	//ホバー
	var postfix = '_a';
	$('#nav a img').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
		img.hover(function() {
			img.attr('src', src_on);
		}, function() {
			img.attr('src', src);
		});
	});
	
	//IEPNG対策
	$("img[src$=png]").pngfix();
});


$(window).scroll(function(){
        var offset = $('body').height() - $('#side_nav').height() -300;

    if ($(window).scrollTop() < 370) {
        $('#side_nav').css({
            top: '0',
            position: 'relative'
        });
    }else if($(window).scrollTop() > offset) {
        $('#side_nav').css({
            top: (offset - 370),
            position: 'relative'
        });
    }else {
        $('#side_nav').css({
            top: '10px',
            position: 'fixed'
        });
    }
});

$(function(){
    $("#home_news > article > h2").click(function () {
        $("+ div",this).slideToggle(350);
    });  
});

//フェード
$(document).ready(function() {
	$('#key').cycle({ 
		fx:    'fade', 
		timeout:   3000 
	});
});
$(document).ready(function() {
	$('.slideshow').cycle({ 
		fx:		'scrollLeft', 
		speed:	500,
		timeout:	3000, 
		random:	1
	});
});





// JavaScript Document

//_____________________________________ setSWF



function setSwf(swf, sn, fv, bgc, boxid, w, h) {
	
	function __construct() {
		var so = new SWFObject(swf, sn, w, h, fv, bgc);
		so.addParam("wmode", "opaque");
		so.addParam("menu", "false");
		so.addParam("scale", "showall");
		so.addParam("salign", "lt");
		so.write(boxid);
	}
	__construct();
	
}




