﻿// JavaScript Document

//////////////////////////////////////////////////////////////////////
// top.js
//////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////
// init 初期化
///////////////////////////////////////////////
function init(){
	
	//画像領域を透明化
	$("#imgDiv").css({'opacity':0});
	
	//画像をロード
	mainimg=null;
	mainimg=new Image();
	mainimg.onload=loadComplete;
	mainimg.src='images/bg.jpg';
	
	//newsPageBG
	$("#newsPageBG").css({'opacity':0.6});
	$("#newsBtn").bind("click",newsOpen);
	$("#newsClose").bind("click",newsClose);
	
	//メールを設定
	mailSet();
}



///////////////////////////////////////////////
// newsOpenClose
///////////////////////////////////////////////
function newsOpen(e){
	$('#newsPage').css({'display':'block'});
}
function newsClose(e){$('#newsPage').css({'display':'none'});}


///////////////////////////////////////////////
// loadComplete
///////////////////////////////////////////////
function loadComplete(){
	//ロード完了	
	$("#wrapper").css({'backgroundImage':'url("images/spacer.gif")'})
	$("#imgDiv").html("<img src='images/bg.jpg' />");
	$("#imgPrint").html("<img src='images/bg.jpg' />");
	
	baseWidth=$("#imgDiv img").width();
	baseHeight=$("#imgDiv img").height();
	
	$(window).bind("resize",windowResize);
	windowResize();
	
	//画像を出す
	$("#imgDiv").animate({'opacity': '1'},2000,'linear', imgAppeared);
	
	$('#titleImg').css({'opacity':0});
	$('#titleImg').animate({'opacity': 1},1500,'linear');
	
	//ニュースを出す
	$('#news').css({'opacity':0});
	$('#news').css({'display':'block'});
	$('#news').animate({'opacity': 1},1500,'linear');
	
	
	$(window).bind("resize",topWindowResize);
	topWindowResize();
	
}


///////////////////////////////////////////////
// imgAppeared
///////////////////////////////////////////////
function imgAppeared(){
	//背景画像が出てきた	
	//ナビオープン＆クローズ＆初期化
	$("#navigation").animate({'top': '-292px'},500,'swing');
	$("#navigation").animate({'top': '-292px'},1500,'swing');
	$("#navigation").animate({'top': '-114px'},500,'swing',function(){navigationInit();});
	
}


///////////////////////////////////////////////
// topWindowResize
///////////////////////////////////////////////
function topWindowResize(event){
	var mainimgHeight=$(window).height()-$("#footer").height();
	var titleImgPositionTop=Math.round(mainimgHeight/8);
	if(titleImgPositionTop<68)titleImgPositionTop=68;
	$('#titleImg').css({'top':titleImgPositionTop+'px'});
}




	
