//コンテンツサイズの変更（ウインドウサイズ変更時）
//===================================================
function ShowSize() 
{
     var ua = navigator.userAgent;       // ユーザーエージェント
     var nWidth, nHeight;                   // サイズ
     var nHit = ua.indexOf("MSIE");     // 合致した部分の先頭文字の添え字
     var bIE = (nHit >=  0);                 // IE かどうか
     var bVer6 = (bIE && ua.substr(nHit+5, 1) == "6");  // バージョンが 6 かどうか
     var bStd = (document.compatMode && document.compatMode=="CSS1Compat");
                                                                           // 標準モードかどうか
     if (bIE) {
          if (bVer6 && bStd) {
               nWidth = document.documentElement.clientWidth;
          } else {
               nWidth = document.body.clientWidth;
          }
     } else {
          nWidth = window.innerWidth;
     }
if(nWidth>1000){
	document.getElementById("wrapper").style.width="1048px";
	document.getElementById("container").style.width="1028px";
	document.getElementById("contents").style.width="756px";
	document.getElementsByTagName("h1")[0].style.width="1038px";
	document.getElementsByTagName("h2")[0].style.width="1038px";
	document.getElementById("subH2New").style.width="242px";
	document.getElementById("wrapper").style.backgroundImage="url(./images/wrapperBackB.jpg)";
	document.getElementById("subH2New").style.backgroundImage="url(./images/subH2NewB.jpg)";

	  var P= document.getElementsByTagName("div");
	  for(var i=0;i<P.length;i++){
	    if((P[i].getAttribute("className")|| P[i].getAttribute("class"))=="floatBox"){
	      P[i].style.height="auto";
	    }
	  }
}else{
	document.getElementById("wrapper").style.width="820px";
	document.getElementById("container").style.width="800px";
	document.getElementById("contents").style.width="528px";
	document.getElementsByTagName("h1")[0].style.width="810px";
	document.getElementsByTagName("h2")[0].style.width="810px";
	document.getElementById("subH2New").style.width="508px";
	document.getElementById("wrapper").style.backgroundImage="url(./images/wrapperBackA.jpg)";
	document.getElementById("subH2New").style.backgroundImage="url(./images/subH2NewA.jpg)";


	  var P= document.getElementsByTagName("div");
	  for(var i=0;i<P.length;i++){
	    if((P[i].getAttribute("className")|| P[i].getAttribute("class"))=="floatBox"){
	      P[i].style.height="250px";
	    }
	  }
}
}





//文字サイズ変更
//===================================================
function fSizeCookie(){
	//cookieから読み出し
	var temp=document.cookie+';';
	var p1=temp.indexOf("FS");
	if(p1==-1){
	FS1="80%";
	}else{
	var p2=temp.indexOf('=',p1)+1;
	var p3=temp.indexOf(';',p2);
	FS1=unescape(temp.substring(p2,p3));
	}
	bodyObj=document.getElementsByTagName("body");
	bodyObj[0].style.fontSize=FS1;

}

function fSize(SIZE){
	//cookieへの書き込み
	var tmp="FS="+SIZE;
	document.cookie=tmp;
	fSizeCookie()
}

//メニューの位置
HEADSIZE= 273;


//フォントサイズ変更ボックスの位置変更
//===================================================
function SCR() {
//スクロールバーの位置
var scroll_y=document.body.scrollTop || document.documentElement.scrollTop;
//メニューの位置
POSI=document.getElementById("font").style.top;
if(scroll_y > HEADSIZE){
Y=parseInt(Number(POSI.slice(0,POSI.length-2))+(scroll_y-Number(POSI.slice(0,POSI.length-2))));
document.getElementById("font").style.top=Y+"px";
}else{
document.getElementById("font").style.top=HEADSIZE+"px";
}
}




OPEN=0

//ページ内移動ボックスの大きさ変更
//===================================================
function PageHeight(){
	H=document.getElementById('page').style.height
	pageH=parseInt(Number(H.slice(0,H.length-2))+(HX-Number(H.slice(0,H.length-2)))/3);
	document.getElementById('page').style.height=pageH+"px";
	if(OPEN!=1){
		if(pageH>=(HX-1) ){
			clearInterval(pageTIMER)
		}
	}else{
		if(pageH<=(HX+1) ){
			clearInterval(pageTIMER)
		}
	}
}

pageOPEN=0
function PAGE(){
	if(pageOPEN !=1){
		HX=200
		pageOPEN=1
		document.getElementById('pageH2').style.backgroundImage="url(./images/pageH2Over.jpg)";
	}else{
		HX=53
		pageOPEN=0
		document.getElementById('pageH2').style.backgroundImage="url(./images/pageH2.jpg)";
	}
pageTIMER=setInterval("PageHeight()",50); 
}



//目的位置へのスクロールさせる
//===================================================
function scroll(Y){

	if(winLoad==1){
	H=getBrowserHeight()
	CH=getConHeight()

	ID1=parseInt(document.getElementById(Y).offsetTop);
		if(ID1>CH-H){
			ID1=CH-H
		}
	GO=setInterval("SC('" + ID1 + "')",50); 
document.getElementById('page').style.visibility="hidden";
document.getElementById('font').style.visibility="hidden";
	}
}


//目的位置へのスクロール（setIntervalで実行）
function SC(ID1){
//DOCTYPE宣言の有り、無しによってスクロール位置の取得方法が異なる
var scroll_y=document.body.scrollTop || document.documentElement.scrollTop;
SCY=(ID1-scroll_y)/3
window.scrollBy(0,SCY)

	if(Math.abs(SCY)<=2){
	clearInterval(GO)
document.getElementById('page').style.visibility="visible";
document.getElementById('font').style.visibility="visible";
	}
}

//ウインドウ高さ取得
function getBrowserHeight() {   
    if ( window.innerHeight) { return window.innerHeight; }   
    else if ( document.documentElement && document.documentElement.clientHeight != 0 ) { return document.documentElement.clientHeight; }   
    else if ( document.body ) { return document.body.clientHeight; }   
    return 0;   
}  
//コンテンツの高さ取得
function getConHeight(){
	if(document.body.scrollHeight){return document.body.scrollHeight;}
	else if(document.height){return document.height;}
    return 0; 
} 

//スクロール位置の取得
function getScroll(){
	if(document.body.scrollTop){return document.body.scrollTop}
	else if(document.documentElement.scrollTop){return document.documentElement.scrollTop}
	return 0;
}
//IE6以下で#pageを最下部に固定
function pagePosi(){
BOT=getConHeight()-getBrowserHeight()-getScroll()
document.getElementById('page').style.bottom=BOT+"px";
}


//フォーム送信
//===================================================
flag=0;
function ONSUBMIT(F){
	if (flag==0){
		 document.getElementById(F).submit();
		 flag = 1;
	}
}


function OPEN(ID){
	document.getElementById(ID).style.display="block";
}

function CLOSE(ID){
	document.getElementById(ID).style.display="none";
}


//表示非表示の切り替え
//===================================================
function showHide(ID){
DOC=document.getElementById(ID).style
	if(DOC.display!="block"){
	DOC.display="block";
	}else{
	DOC.display="none"
	}
}







//ウインドウリサイズ時に実行
//===================================================
window.onresize = ShowSize;

//ページ読み込み時に実行
//===================================================
window.onload=function(){

	//メールアドレスチェック 
	new Spry.Widget.ValidationTextField("checkMail", "email", {validateOn:["change"]});
	//フォームチェック用(sply)入力チェック
	new Spry.Widget.ValidationTextField("checkText1", "none");
	//テキストエリアチェック
	var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");

	//フォントサイズの設定
	fSizeCookie();

	//フォントのトップ位置
	document.getElementById("font").style.top=HEADSIZE+"px";

	//Wrapperサイズ変更
	ShowSize();
	
//ブラウザ判別(IE6以下)
	UA=navigator.userAgent;
POS=UA.indexOf("MSIE",0)
if(POS!=-1){
	VER=UA.slice(POS+5,POS+6)
	if(VER<=6){
	IE=6
	}else{
	IE=7
	}
}else{
IE=0
}
document.getElementsByTagName("html")[0].onscroll = function(){
//フォントサイズ変更ボックスの位置
	SCR();

//IE6以下の場合だけ実行（#pageを最下部に固定）
	if(IE==6){
	pagePosi();
	}

}

	winLoad=1
}


