var reqVersion = '';

//ブラウザのチェック→Flashが可能かのチェック（要client_check.js）
// win = ie4< nav3<
// mac = is5< nav4<
function validBrowser(){
	if(is_win){
		if(is_ie4up || is_nav4up || is_opera5up){
			return validFlash();
		}
	}else if(is_mac){
		if(is_ie5up || is_nav4up || is_opera5up){
			return validFlash();
		}
	}else{
		return false;
	}
}

//Flashが可能かのチェック(Published by Flash)
function validFlash(){
	if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
		var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
		if (plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1))>=reqVersion)
			return true;
	}else if(navigator.appName && navigator.appName.indexOf("Microsoft")!=-1 && 
		  navigator.userAgent.indexOf("Windows")!=-1 && navigator.userAgent.indexOf("Windows 3.1")==-1){
			return true;
	}else{
		return false;
	}
}

//FLASHのタグの書き出し
function writeFlash(){
	var swfValue=getMovieName();
    var flashVersion = reqVersion + ",0,0,0";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write(' codebase=""');
	document.write(' id="' + swfId + '" width="' + swfWidth + '" height="' + swfHeight + '">');
	document.write('<param name="movie" value="' + swfValue + '">');
	document.write('<param name="quality" value="' + swfQuality + '">');
	document.write('<param name="bgcolor" value="' + swfBgcolor + '">');
	document.write('<param name="menu" value="' + swfMenu + '"' + '>');
	document.write('<embed src="' + swfValue + '" width="' + swfWidth + '" height="' + swfHeight + '" menu="' + swfMenu + '" quality="' + swfHeight + '" swLiveConnect="' + swfLiveConnect + '" bgcolor="' + swfBgcolor + '" name="' + swfId + '" type="application/x-shockwave-flash" pluginspage=""></embed>');
	document.write('</object>');
}

//クッキーから得らるSWFムービーの名前を返す
function getMovieName(){
	//***.swf=?count=[回数]&userid=[ユーザー名]"
	return swfFile + "?" + "count=" + jsGetCookie(cookieName1);
}

//保存（FLASHから呼びだし）
function jsSaveCookie(myCookie){
	if( myCookie != null ){
		expiredDay = new Date();
		expiredDay.setTime( expiredDay.getTime() + (1000*60*60*24) );
		expires = expiredDay.toGMTString();
		// クッキーへの書き込み内容チェック↓
		// alert(cookieName1 + "=" + (myCookie) + ";expires=" + expires);
		document.cookie = cookieName1 + "=" + myCookie + ";expires=" + expires;
	}
}

//クッキーの内容を取得
//クッキーが無い場合（＝最初）は、""を返す
function jsGetCookie(cookieName){
	valName = cookieName + "=";
	myCookie = document.cookie + ";";
	start = myCookie.indexOf(valName);
	if(start != -1){
		end = myCookie.indexOf(";", start);
		//クッキーからの取得内容チェック↓
        //alert("Cookie " + cookieName + " = " + myCookie.substring(start + valName.length, end));
		return (myCookie.substring(start + valName.length, end));
	}else{
		return "";
	}
}

//------------------------------------------------------------------------------------
//テスト用
//------------------------------------------------------------------------------------
//両方消去
function clearCookies(){
  var expires = "Fri, 31-Dec-1999 23:59:59 GMT";
  document.cookie = cookieName1 + "=" + ";expires=" + ";expires=" + expires;
}
