jQuery.easing.easeOutQuart=function(x,t,b,c,d){return -c*((t=t/d-1)*t*t*t-1)+b;};
var ie = (function(){
var undef,v = 3,div = document.createElement('div'),all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
return v > 4 ? v : undef;
}());

// Apple detection object
var Apple = {};
Apple.UA = navigator.userAgent;
Apple.Device = false;
Apple.Types = ["iPhone", "iPod", "iPad"];
for (var d = 0; d < Apple.Types.length; d++) {
	var t = Apple.Types[d];
	Apple[t] = !!Apple.UA.match(new RegExp(t, "i"));
	Apple.Device = Apple.Device || Apple[t];
}



var cnt = 0;
var prev = 0;
var duration = 5000;
var eT = 1300;
var timer;

var cntB = 0;
var prevB = 0;
var durationB = 3000;
var eTB = 1300;
var timerB;

var cntC = 0;
var prevC = 0;
var durationC = 3000;
var eTC = 1300;
var timerC;

var cntD = 0;
var prevD = 0;
var durationD = 3000;
var eTD = 1300;
var timerD;




$(function(){

		if(Apple.Device){
			$("#footer").css( 'position', 'static !important');
		}


$('a[href*=#]').click(function() {
    var $target=$(this.hash);
    var targetY=$target.offset().top;
    $($.browser.opera ? document.compatMode == 'BackCompat' ? 'body' : 'html' :'html,body').animate({scrollTop: targetY},700,"easeOutQuart");return false;
  });


rollImg();
$('#footer').exFixed();
$("#topImage img").hide();
$("#topImage img:eq(0)").fadeTo(0,0)
$(".churchImg img").hide();
$(".churchImg img:eq(0)").fadeTo(0,0)
$(".churchImg img:eq(3)").fadeTo(0,0)
$(".churchImg img:eq(6)").fadeTo(0,0)
$(".churchImg img:eq(9)").fadeTo(0,0)
$(".churchImg img:eq(12)").fadeTo(0,0)
$(".churchImg img:eq(15)").fadeTo(0,0)
$(".restaurantImg img").hide();
$(".restaurantImg img:eq(0)").fadeTo(0,0)
$(".restaurantImg img:eq(3)").fadeTo(0,0)
$(".restaurantImg img:eq(6)").fadeTo(0,0)
$(".restaurantImg img:eq(8)").fadeTo(0,0)

});


$(window).load(function(){
$("#topImage img:eq(0)").fadeTo(eT,1);
timer = setInterval(changeImg_,duration);

$(".churchImg img:eq(0)").fadeTo(eT,1);
$(".churchImg img:eq(3)").fadeTo(eT,1);
$(".churchImg img:eq(6)").fadeTo(eT,1);
$(".churchImg img:eq(9)").fadeTo(eT,1);
$(".churchImg img:eq(12)").fadeTo(eT,1);
$(".churchImg img:eq(15)").fadeTo(eT,1);
timerB = setInterval(changeImgB_,durationB);

$(".restaurantImg img:eq(0)").fadeTo(eT,1);
$(".restaurantImg img:eq(3)").fadeTo(eT,1);
$(".restaurantImg img:eq(8)").fadeTo(eT,1);
timerC = setInterval(changeImgC_,durationC);

$(".restaurantImg img:eq(6)").fadeTo(eT,1);
timerD = setInterval(changeImgD_,durationD);

});

//top画像変更
function changeImg_(){
cnt++;

var ImgLen = $("#topImage img").length;

if(cnt >= ImgLen) cnt = 0;
$("#topImage img").eq(prev).fadeTo(eT*0.8,0,function(){$(this).hide();});
$("#topImage img").eq(cnt).fadeTo(eT,1);
prev = cnt;
}

//教会画像変更
function changeImgB_(){
cntB++;

if(cntB >= 3) cntB = 0;
$(".churchImg img").eq(prevB).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".churchImg img").eq(cntB).fadeTo(eT,1);

$(".churchImg img").eq(prevB+3).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".churchImg img").eq(cntB+3).fadeTo(eT,1);

$(".churchImg img").eq(prevB+6).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".churchImg img").eq(cntB+6).fadeTo(eT,1);

$(".churchImg img").eq(prevB+9).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".churchImg img").eq(cntB+9).fadeTo(eT,1);

$(".churchImg img").eq(prevB+12).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".churchImg img").eq(cntB+12).fadeTo(eT,1);

$(".churchImg img").eq(prevB+15).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".churchImg img").eq(cntB+15).fadeTo(eT,1);

prevB = cntB;
}

//レストラン画像変更
function changeImgC_(){
cntC++;

if(cntC >= 3) cntC = 0;
$(".restaurantImg img").eq(prevC).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".restaurantImg img").eq(cntC).fadeTo(eT,1);

$(".restaurantImg img").eq(prevC+3).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".restaurantImg img").eq(cntC+3).fadeTo(eT,1);

$(".restaurantImg img").eq(prevC+8).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".restaurantImg img").eq(cntC+8).fadeTo(eT,1);

prevC = cntC;
}


//レストラン画像変更
function changeImgD_(){
cntD++;

if(cntD >= 2) cntD = 0;
$(".restaurantImg img").eq(prevD+6).fadeTo(eTB*0.8,0,function(){$(this).hide();});
$(".restaurantImg img").eq(cntD+6).fadeTo(eT,1);

prevD = cntD;
}



//マウスオーバー
function rollImg(){
	$("#wrapp a img").hover(
		//マウスオーバー 
		function(){
 		$(this).fadeTo(200,0.65);  
		},  
		//マウスアウト
		function(){  
		 $(this).fadeTo(200,1.0);  
		}  
	);  

	$("#footer a img").hover(
		//マウスオーバー 
		function(){
 		$(this).fadeTo(200,0.65);  
		},  
		//マウスアウト
		function(){  
		 $(this).fadeTo(200,1.0);  
		}  
	);  

	$("#SlideMain a img").hover(
		//マウスオーバー 
		function(){
 		$(this).fadeTo(200,0.65);  
		},  
		//マウスアウト
		function(){  
		 $(this).fadeTo(200,1.0);  
		}  
	);  
}  
  

