/* ************************************************************************

Site: ピースフル優祐悠
File: peaceful.js
---
Last Update: 2011/11/25
Create Date: 2011/11/14

************************************************************************ */

var _ua;
$(document).ready(function(){
	if($.browser.msie && $.browser.version<7){
		$("div#mainimageArea").css({'text-align':'center'});
		//flash
		//safariのユーザーエージェントをIEにしてみると背景が透過されない。
		//実機の方では問題ない。
		var flashvars = {};
		var params = {scale:"noscale", salign:"T", menu:"false", allowScriptAccess:"samedomain", allowFullScreen:"true",wmode:"transparent" };
		var attributes = {};
		swfobject.embedSWF("./images/visual.swf", "mainImg", "100%", "451", "9.0.0", "#ffffff", flashvars, params, attributes);
	} else {
		//CSS3
		$("ul#topEventList li:last-child span.event").css({'background':'none','padding-bottom':'0'});
		//
		$("div#circle01,div#circle02,div#circle03,div#circle04").hide();
		//ユーザエージェント条件分岐
		_ua = (function(){
			return {
			ltIE6:typeof window.addEventListener == "undefined" && typeof document.documentElement.style.maxHeight == "undefined",
			ltIE7:typeof window.addEventListener == "undefined" && typeof document.querySelectorAll == "undefined",
			ltIE8:typeof window.addEventListener == "undefined" && typeof document.getElementsByClassName == "undefined"
		}
		})();
		//
		if(_ua.ltIE8){ //IE8以下対象
			changeImage(); //画像URL変更
		}
	}
});

//Setting
$(window).bind("load", function() {
	if(!($.browser.msie && $.browser.version<7)){
		opAnime();
	}
});

/* --------------------------------------------------------------------- */
/* メインアニメーション */
/* --------------------------------------------------------------------- */
//画像URL変更
function changeImage() {
	$("div#outwardImg img").attr("src","images/img_outward2.png");
	$("p#topCopyTxt img").attr("src","images/txt_copy.gif");
	$("p#topLeadTxt img").attr("src","images/txt_lead2.gif");
}

function opAnime(){
	//1
	function mainImg02() {
		$('p#topCopyTxt').animate({
			left: '135px',
			opacity: 1.0
		}, 1000);
	}
	//2
	function mainImg03() {
		$('p#topLeadTxt').animate({
			top: '60px',
			opacity: 1.0
		}, 1000)
	}
	//3
	setTimeout(circleDelay, 1600);
	function circleDelay () {
		$('div#circle01').innerfade({
			speed: 1200,
			timeout: 5000,
			containerheight: '69px'
		}).css({'position':'absolute'}).fadeIn(2300);
		var int=setInterval("circleImgAnime(i)",300);
	}
	//アニメーション起動タイミング						
	if(_ua.ltIE6){ //IE6以下対象
		$("div#circle03").css({'background':'url(images/bg_circle03.gif) no-repeat left top;'});
		$("div#circle04").css({'background':'url(images/bg_circle04.gif) no-repeat left top;'});
		
		$("div#outwardImg").css({'opacity':'1.0;','-moz-opacity':'1.0'});
		$("p#topCopyTxt").css({'opacity':'1.0;','-moz-opacity':'1.0'});
		$("p#topLeadTxt").css({'opacity':'1.0;','-moz-opacity':'1.0'});
	} else if(_ua.ltIE8){ //IE8以下対象
		$("div#circle03").css({'background':'url(images/bg_circle03.gif) no-repeat left top;'});
		$("div#circle04").css({'background':'url(images/bg_circle04.gif) no-repeat left top;'});
		$('div#outwardImg').animate({
			top: '145px',
			opacity: 1.0
		}, 1200);
		setTimeout(mainImg02, 670);
		setTimeout(mainImg03, 1100);
	} else { //IE8以下を除くその他のブラウザ
		$('div#outwardImg').animate({
			top: '145px',
			opacity: 1.0
		}, 1200);
		setTimeout(mainImg02, 670);
		setTimeout(mainImg03, 1100);
	}
}


/* --------------------------------------------------------------------- */
/* 円形領域アニメーション */
/* --------------------------------------------------------------------- */
var i = 0;
var int = 0;
function circleImgAnime() {
    if (i >= 2) {
        clearInterval(int); // setIntervalの解除
    }
    if (i == 0) {
		$('div#circle02').fadeIn(1600).innerfade({
			speed: 1200,
			timeout: 5000,
			containerheight: '101px'
		}).css({'position':'absolute'}); // step2
    }
    if (i == 1) {
        $('div#circle03').fadeIn(1600).innerfade({
			speed: 1200,
			timeout: 5000,
			containerheight: '219px'
		}).css({'position':'absolute'}); // step3
    }
	 if (i == 2) {
		$('div#circle04').fadeIn(1600).innerfade({
			speed: 1200,
			timeout: 5000,
			containerheight: '121px'
		}).css({'position':'absolute'}); // step4
    }
    i++;
}

