var isOpera;
var uAgent  = navigator.userAgent.toUpperCase();
var isMac	= ( (uAgent.indexOf("MAC") >= 0) ? true : false ) ;
var isWin	= ( (uAgent.indexOf("WIN") >= 0) ? true : false ) ;
var isUnix	= ( (uAgent.indexOf("X11") >= 0) ? true : false ) ;
var isNav	= ( document.layers ? true : false ) ;
var isIE	= ( document.all ? true : false ) ;
var isGecko	= ( document.getElementById ? true : false ) ;
if ( uAgent.indexOf("OPERA") >= 0 ) {
	var isOpera = true ;
	isIE = false ;
	isOpera = true;
}
var isIE5;
var isIE4;
if (isIE) {
	var escapeVer = 0;
	var version = "";
	var s = 0;
	var e = 0;
	var appVer  = navigator.userAgent;
	s = appVer.indexOf("MSIE ",0) + 5;
	e = appVer.indexOf(";",s);
	brVer = appVer.substring(s,e);
	if (4.0 <= brVer) {
		isIE4 = true;
	} else {
		isIE5 = false;
	}
	if (5.0 <= brVer) {
		isIE5 = true;
	} else {
		isIE5 = false;
	}
}
	var fsc = (isWin && isIE) ? "1" : "0";

	var contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var PluginVersion = words[i]; 
	    }
	var FlashCanPlay = PluginVersion >= contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}

if ((FlashCanPlay)&&(isWin)&&(isIE)&&(!isOpera)){
	envStatus=1;
}else{
	envStatus=0;
}
//alert("envStatus = " + envStatus);

//フローティングを作成-----------------------------------------------------------------------------------

//レイヤーおよびFlashの最小サイズを設定
var minwidth = 700;
var minheight = 260;

//ドキュメントのデフォルトの幅
var defwidth;
//レイヤーのデフォルトのクリッピング座標
var defclip = "rect(70px,3000px,170px,0px)"; //top, right, bottom, left
//リサイズを許可するフラグ
var Resizeflag = 0;

function printGif01(){
	if(envStatus){
		document.write (
			'<img src="spacer.gif" border=0 width="728" height="90">'
		);
	} else {
		document.write (
			'<a href="http://www.asahi.com/ad/clients/fumakilla/products.html" target="_blank">' +
			'<img src="kafun1.gif" border=0 width="468" height="60"></a>'
		);
	}
}

function printMovie01(){
	if(envStatus){
		//WinIE5,Flash6の場合
		newLayer();
		//ドキュメントのデフォルトの幅を取得
		defwidth = document.body.scrollWidth;
		adhandler();
	}
}

//フローティングレイヤーを作成
function newLayer(){

	var swfiniwidth = (document.body.clientWidth > 700)? document.body.clientWidth:700;

	document.write (
			'<div id="fLayer" style="position:absolute; clip:'+ defclip +
			//'; background-color: #0000FF; layer-background-color: #0000FF; border: 1px none #000000' +
			'; width:100%; height:100%; top:0px; left:0px; visibility:visible; z-index:2"><div align="center">' +
			'<object id=kafun1 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
			' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ' +
			'width='+swfiniwidth+' height='+ document.body.scrollHeight +'>' +
			//'width="100%" height="100%">' +
			'<param name=movie value="kafun1.swf?clickTAG=http://www.asahi.com/ad/clients/fumakilla/top.html&clicktarget=_blank&clickTAG2=http://www.asahi.com/ad/clients/fumakilla/products.html&clicktarget2=_blank">' +
			'<param name="menu" value="false">' +
			'<param name="scale" value="noscale">' +
			'<param name="salign" value="T">' +
			//'<param name=quality value=autohigh>' +
			//'<param name=quality value=high>' +
			//'<param name=quality value=low>' +
			'<param name="loop" value="false">' +
			'<param name="wmode" value="transparent">' +
			'</object>' +
			'</div></div>'
	);
}

//イベントハンドラを設定
function adhandler(){
	attachEvent("onresize",ReLayer);
}

//ウィンドウリサイズ時用のファンクション
function ReLayer(){
	if(Resizeflag == 1){
		LayerCh("on");
	}else{
		LayerCh("off");
	}
}

//フローティングレイヤーの開閉
function LayerCh(num){
	switch(num){
		case "on":
			//レイヤーをオープン
			//flashの横幅リサイズ
			if(document.body.clientWidth > 700){
				document.kafun1.style.width = document.body.clientWidth;
			}else{
				document.kafun1.style.width = 700;
			}
			//flashの縦幅リサイズ
			document.kafun1.style.height = document.body.scrollHeight;
			//レイヤーのリサイズ
			//document.all.fLayer.style.pixelWidth = document.kafun1.style.width;
			//document.all.fLayer.style.pixelHeight = document.body.scrollHeight;
			//レイヤーのクリッピング
			document.all.fLayer.style.clip = "rect(0px,"+document.body.scrollWidth+"px,"+document.body.scrollHeight+"px,0px)";
			break;
		case "off":
			//レイヤーをクローズ
			//flashのリサイズ
			document.kafun1.style.width = document.body.clientWidth
			
			if(document.body.clientWidth > 700){
				document.kafun1.style.width = document.body.clientWidth;
			}else{
				document.kafun1.style.width = 700; //minwidth;
			}
			//flashの縦幅リサイズ
			document.kafun1.style.height = document.body.scrollHeight;
			//レイヤーのリサイズ
			//document.all.fLayer.style.pixelWidth = document.body.clientWidth;
			//document.all.fLayer.style.pixelHeight = minheight;
			//レイヤーのクリッピング
			document.all.fLayer.style.clip = defclip;
			break;
	}
}

//以下fscommand受け取り用

function kafun1_DoFSCommand(cmd, arg){
	if(arg == "on"){
		Resizeflag = 1;
	}else{
		Resizeflag = 0;
	}
	LayerCh(arg);
}
