//ブラウザのホイールの状態（初期値有効）
var _wheelEnabled = true;

//Flashから呼ばれる関数
function wheelEnabled(flg){
  _wheelEnabled = flg;
}

//ホイールイベントの処理
function wheel(event){
  if(!_wheelEnabled){
    if(!event){
      event = window.event;
    }
    if(event.preventDefault){
      event.preventDefault();
    }
    event.returnValue = false;
  }
}

//イベントリスナーの登録
if(window.addEventListener){
  window.addEventListener('DOMMouseScroll', wheel, false);
}
window.onmousewheel = document.onmousewheel = wheel;

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");
														// 標準モードかどうか

function thisFLASH(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
}


function ShowSize() {

	if (bIE) {
		if (bVer6 && bStd) {
			nWidth = document.documentElement.clientWidth;
			nHeight = document.documentElement.clientHeight;
		} else {
			nWidth = document.body.clientWidth;
			nHeight = document.body.clientHeight;
		}
	} else {
		nWidth = window.innerWidth;
		nHeight = window.innerHeight;
	}
	if (navigator.userAgent.indexOf("Trident/4.0") != -1) {
		nWidth = document.documentElement.clientWidth;
		nHeight = document.documentElement.clientHeight;
	}
	//alert("サイズ　：　幅 " + nWidth + " / 高さ " + nHeight);
	//nHeight = nHeight - 110;

	return nHeight;
}
function ShowSizeW() {
	if (bIE) {
		if (bVer6 && bStd) {
			nWidth = document.documentElement.clientWidth;
		} else {
			nWidth = document.body.clientWidth;
		}
	} else {
		nWidth = window.innerWidth;
	}
	if (navigator.userAgent.indexOf("Trident/4.0") != -1) {
		nWidth = document.documentElement.clientWidth;
	}

	return nWidth;
}
function ShowScroll() {
	var nTop  = document.body.scrollTop  || document.documentElement.scrollTop;
	return nTop;
}


function callSize() {
	//thisFLASH("Photonano").setSize(ShowSize());
	
    if (navigator.appName.indexOf("Microsoft") != -1) {
        window["Photonano"].setSize(ShowSize());
    }
    else {
        document["Photonano"].setSize(ShowSize());
    }

}
function callscrolY() {
	//thisFLASH("Photonano").setscrY(ShowScroll());
	
	if (navigator.appName.indexOf("Microsoft") != -1) {
        window["Photonano"].setscrY(ShowScroll());
    }
    else {
        document["Photonano"].setscrY(ShowScroll());
    }
}

window.onresize = callSize;
window.onscroll = callscrolY;

//スタイルシート動的追加
function applyCSS(doc, cssfile, overwrite) {
  if (typeof overwrite == "undefined")
    overwrite = 0;      // デフォルト:CSSの追加

  // 既存のCSSを削除
  if (overwrite && doc.styleSheets.length >= 1) {
    var links = doc.getElementsByTagName("link");
    for (var i = 0 ; i < links.length ; i++) {
      if (links[i].rel == "stylesheet")
        links[i].parentNode.removeChild(links[i]);
    }
  }

  // CSS追加
  if (document.all) {
    doc.createStyleSheet(cssfile);
  } else {
    var link = doc.createElement("link");
    link.rel = "stylesheet";
    link.href = cssfile;
    link.type = "text/css"
    doc.getElementsByTagName('head')[0].appendChild(link);
  }
}