﻿function ReadCookie(key) {
     var sCookie = document.cookie;    // Cookie文字列
     var aData = sCookie.split(";");       // ";"で区切って"キー=値"の配列にする
     var oExp = new RegExp(" ", "g");   // すべての半角スペースを表す正規表現
     key = key.replace(oExp, "");          // 引数keyから半角スペースを除去

     var i = 0;
     while (aData[i]) {                           /* 語句ごとの処理 : マッチする要素を探す */
          var aWord = aData[i].split("=");                         // さらに"="で区切る
          aWord[0] = aWord[0].replace(oExp, "");              // 半角スペース除去
          if (key == aWord[0]) return unescape(aWord[1]); // マッチしたら値を返す
          if (++i >= aData.length) break;                          // 要素数を超えたら抜ける
     }
     return "";                                   // 見つからない時は空文字を返す
}

function WriteCookie(key, value, days) {
     var str = key + "=" + escape(value) + ";";         // 書き出す値１ : key=value
     if (days != 0) {                                                 /* 日数 0 の時は省略 */
          var dt = new Date();                                   // 現在の日時
          dt.setDate(dt.getDate() + days);                   // days日後の日時
          str += "expires=" + dt.toGMTString() + ";"; // 書き出す値２ : 有効期限
     }
     document.cookie = str;                                   // Cookie に書き出し
}

function getBrowserWidth() {

        if ( window.innerWidth ) {
                return window.innerWidth;
        }
        else if ( document.documentElement && document.documentElement.clientWidth != 0 ) {
                return document.documentElement.clientWidth;
        }
        else if ( document.body ) {
                return document.body.clientWidth;
        }
        return 0;
}

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;
}

var ie = (function(){
    var undef, v = 3, div = document.createElement('div');
 
    while (
        div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
        div.getElementsByTagName('i')[0]
    );
 
    return v> 4 ? v : undef;

}());


function initflash(){
	dc=document.getElementById("opflash");
	bf=document.getElementById("bigframe");

	wd=getBrowserWidth();
	ht=getBrowserHeight();
	var h = Math.max.apply( null, [document.body.clientHeight , document.body.scrollHeight, document.documentElement.scrollHeight, document.documentElement.clientHeight] );
	dc.style.height=h+"px";
	var so = new SWFObject("flash/flash_op.swf", "externalopflash", "100%","100%", "8");  
	so.addParam("wmode","transparent");
	so.addParam("scale","noscale");
	so.addParam('allowScriptAccess', 'always');
	so.addParam('align', 'top');
	so.addParam('salign', '');

	so.write("opflash");  

	
	bd=document.getElementById("bodyid");
	


}

function getScrollPosition() {
var obj = new Object();
obj.x = document.documentElement.scrollLeft || document.body.scrollLeft;
obj.y = document.documentElement.scrollTop || document.body.scrollTop;
return obj;
}

function initnoflash(){

	dc=document.getElementById("opflash");
	dc.style.display="none";
	bf=document.getElementById("bigframe");
	bf.style.visibility="visible";

}

function flashstart(){
var tid=setInterval(timeloop,66);
	bf.style.visibility="visible";

}
function swfName(str) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[str];
	}else {
		return document[str];
	}
}

tlm=0;

function timeloop(){
	if(tlm==1)return;
	ypos=getScrollPosition().y;
	ysz=getBrowserHeight();

	swfName("externalopflash").setlogopos(ypos+ysz/2-240-110);

}
function fadestart(){
bf=document.getElementById("bigframe");
}
function fadeend(){
	dc=document.getElementById("opflash_frame");
	bf=document.getElementById("bigframe");
	bd=document.getElementById("bodyid");
	tlm=1;
	
	bf.style.overflow="visible";
	if(!(ie==6||ie==7)){
		//bf.style.height="auto";
	}
	bf.style.width="auto";
	bf.style.height="auto";

	bd.style.backgroundImage="url(images/common/bg_footer.jpg)";

	dc.style.display="none";
	dc.style.width="0px";


}

function startsc(){
	if(ReadCookie("firsttime")==""){
		initflash();
	}else initnoflash();
	WriteCookie("firsttime","1",0);
}

