$(function(){
	//noscript
	$("#all").css({"position" : "relative", "top" : "0"});

	//rollover
	var postfix = '_on';
	$('img.imgover').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>').attr('src', src_on);
		img.hover(
			function() {
				img.attr('src', src_on);
			},
			function() {
				img.attr('src', src);
			}
		);
	});
	
	//png
	$("img[src$='.png']").addClass("iepngfix");
	
	//biggerlink
	$('.bl').biggerlink();  
	
	////for SmartPhone
	
	//for Android
	var ua = navigator.userAgent.toLowerCase();
	if( /android/.test(ua) ){
		$("html").addClass("android");
	}
	
	$(".iphone, .android")
		.prepend("<div id='smart'><a href='/?iphone'>スマートフォン版トップページへ移動</a></div>");
		
	//slider
	$('.slider').mobilyslider({
		content: '.sliderContent',
		children: 'p',
		transition: 'fade',
		animationSpeed: 1000,
		autoplay: true,
		autoplaySpeed: 6000,
		pauseOnHover: false,
		bullets: false,
		arrows: false,
		arrowsHide: false,
		prev: 'prev',
		next: 'next',
		animationStart: function(){},
		animationComplete: function(){}
	});
	
	//slider2
	$('.block-event').mobilyslider({
		content: '.block-event2',
		children: 'div.bl',
		transition: 'fade',
		animationSpeed: 500,
		autoplay: false,
		autoplaySpeed: 5000,
		pauseOnHover: false,
		bullets: true,
		arrows: false,
		arrowsHide: false,
		prev: 'prev',
		next: 'next',
		animationStart: function(){},
		animationComplete: function(){
            $(".block-event .bl").each(function(){
                if ($(this).is(':visible')) {
                    var imgWid = $(".f-left img", this).width();
                    $(".f-left", this).width( imgWid );
                    $(".f-right", this).width( 490-imgWid );
                }
            });
        }
	});
	
	
	//lightbox
	$('.item-large a').lightBox();  
	$('.item-work a').lightBox();
	$('.block-figure a').lightBox(); 
	$('.eyecatch a').lightBox(); 
	
	//soroe
	$(".block-list").each(function(){
		$(".item-list", this).autoHeight({column:2, clear:1});
	});
	
	$("#main .block-cont").each(function(){
		$(".item-large", this).autoHeight({column:2, clear:1});
	});
	
	$("#main .block-cont").each(function(){
		$(".item-small", this).autoHeight({column:3, clear:1});
	});
	
	$("#main .block-cont").each(function(){
		$(".item-work", this).autoHeight({column:2, clear:1});
	});
	
	
	//accordion
	$(".block-archive dt").hover(function(){
		$(this).css("cursor","pointer"); 
	},function(){
		$(this).css("cursor","default"); 
		});
	$(".block-archive dd").css("display","none");
	$(".block-archive dt").click(function(){
		$(this).next().slideToggle("normal");
		});
	
	//forie
	$("#contents p:empty").hide();

    //tel
    $('a').each(function() {
        var href = $(this).attr('href');
        if (href.match(/^tel:/)) {
            $(this).replaceWith($(this).html());
        }
    });
	
});

//Smoothscroll
jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
$(function(){
	jQuery('a[href*=#]').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var $target = jQuery(this.hash);
            $target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                jQuery('html,body').animate({ scrollTop: targetOffset }, 1000, 'quart');
                return false;
            }
        }
    });
});

