// JavaScript Document
function openwin(url, title, w, h)
{
	var win = new Window(Application.getNewId(), {
		className: "dialog",  
		width:  w, 
		height: h, 
//		zIndex: 99, 
		resizable: true, 
		title: title, 
		url: url,
//		showEffect: Effect.BlindDown, 
//		hideEffect: Effect.SwitchOff, 
//		minimizable: false,
//		maximizable: false,
		draggable:true
		});
		
	var editorOnEndMove = { 
		onEndMove: function(eventName, win) { 
			if (win.element.offsetTop<0) {
				win.setLocation(10, win.element.offsetLeft);
			}
			return;
		} 
	}

	Windows.addObserver(editorOnEndMove);     
	win.showCenter(); 
}

function getBrowser(){
	var ua = navigator.userAgent;

	if (ua.match(/Opera[\/\s](\d\.\d+)/)) {
		return("Opera " + RegExp.$1);
	}
	else if (ua.match(/MSIE (\d\.\d+)/)) {
		return("Internet Explorer " + RegExp.$1);
	}
	else if (ua.match(/Mozilla\/(4\.[5678]\d?)/)) {
		return("Netscape Communicator " + RegExp.$1);
	}
	else if (ua.match(/Netscape6?\/([\.\d]+)/)) {
		return("Netscape " + RegExp.$1);
	}
	else if (ua.match(/Safari\/([\.\d]+)/)) {
		return("Safari " + RegExp.$1);
	}
	else if (ua.match(/Gecko/)) {
		if (ua.match(/(Firebird|Firefox)\/([\.\d]+)/)) {
			return("Mozilla " + RegExp.$1 + " " + RegExp.$2);
		}
		else if (ua.match(/Thunderbird\/([\.\d]+)/)) {
			return("Mozilla Thunderbird " + RegExp.$1);
		}
		else if (ua.match(/rv:([\.\d]+)/)) {
			return("Mozilla " + RegExp.$1);
		}
		else {
			return("Mozilla");
		}
	}
	return("N/A");
}


function TopFunc(){
	if (window.screen) {
		var aw = (screen.Width-550)  / 2;
		var ah = (screen.Height-428) / 2;
	}

	window.open("index_flash2.html" 
				, null
				, "width=550, height=428"
				+ ",toolbar=0, location=0, directories=0, status=0"
				+ ",menubar=0, scrollbars=0,resizable=yes"
				+ ",left=" + aw
				+ ",top=" + ah);
}

function BikesFunc(url){

	title = "Bikes";
	w = 450;
	h = 350;
	theme = "darkX";
	
	if (getBrowser().indexOf("N/A")>-1){
		return;
	}else if (getBrowser().indexOf("Internet")>-1){
		showeff = Effect.Grow;
		hideeff = Effect.Puff;
	}else{
		showeff = Effect.Appear;
		hideeff = Effect.Fade;
	}

	var win = new Window(Application.getNewId(), {
		className: theme,  
		width:  w, 
		height: h, 
//		zIndex: 99, 
		resizable: true, 
		title: title, 
		url: url,
		showEffect: showeff,//Grow,	//Appear,Grow,BlindDown, 
		hideEffect: hideeff,//Puff, 	//BlindUp,DropOut,Fade,Fold,Puff,Shrink,Squish,SwitchOff
//		minimizable: false,
//		maximizable: false,
		draggable:true
		});

	var editorOnEndMove = { 
		onEndMove: function(eventName, win) { 
			if (win.element.offsetTop<0) {
				win.setLocation(10, win.element.offsetLeft);
			}
			return;
		} 
	}

	Windows.addObserver(editorOnEndMove);     
	win.showCenter(); 
}

function LinksFunc(){
	bwser = getBrowser();
	if (bwser.indexOf("N/A")>-1){
		return;
	}else if (bwser.indexOf("Internet")>-1){

/*		
		Dialog.alert({url: "./link_flash.html", options: {method: 'get'}}, 
    	        {windowParameters: {className: "alphacube",width:400}, okLabel: "Close"	
		});
*/
		
		var win = new Window(Application.getNewId(), {
			className: "darkX",  
			width:  400, 
			height: 350, 
			resizable: true, 
			title: "Link", 
			url: "link_flash.html",
			showEffect: Effect.Appear,	//Appear,Grow,BlindDown, 
			hideEffect: Effect.Fade, 	//BlindUp,DropOut,Fade,Fold,Puff,Shrink,Squish,SwitchOff
			draggable:true
			});

		var editorOnEndMove = { 
			onEndMove: function(eventName, win) { 
				if (win.element.offsetTop<0) {
					win.setLocation(10, win.element.offsetLeft);
				}
				return;
			} 
		}

		Windows.addObserver(editorOnEndMove);     
		win.showCenter(); 


	}else if (bwser.indexOf("Netscape")>-1 || bwser.indexOf("Mozilla")>-1 || bwser.indexOf("Safari")>-1){
		window.open("./link_flash.html" 
					, ""
					, "width=400, height=300"
					+ ",toolbar=0, location=0, directories=0, status=0"
					+ ",menubar=0, scrollbars=0,resizable=yes"
					);
		return;
		
	}
		
}



function MenuFunc(frameno){

	//javascriptでフレーム番号が1なら0とするので１をひく
	if (navigator.appName == "Netscape"){
		window.document["eirin550"].GotoFrame(frameno-1);
	}else{
		window["eirin550"].GotoFrame(frameno-1);
	}

}









//クッキーの有効期限
//var nExpTime = 10*24*60*60*1000; //（ここでは10日間となっています。）
var nExpTime = 1*60*1000; //（ここでは10分間となっています。）




//クッキーを取得する関数です。引数にはクッキーから検索する文字列を指定します。
function GetCookie(strName)
{
	var nReturn = 0;
	var nLoop = 0;
	var nLength = 0;
	var strNameEx = strName + "=";
	var strTemp = "";
	//ループで引数の値が存在するかどうかをチェックします。
	while (nLoop < document.cookie.length)
	{
		nLength = nLoop + strNameEx.length;
		//存在すればその値を判断し戻します。
		if (document.cookie.substring(nLoop, nLength) == strNameEx)
		{
			strTemp = document.cookie.indexOf(";", nLength);
			if (strTemp == -1)
			{
				nReturn = document.cookie.substring(nLength, document.cookie.length);
			}
			else
			{
				nReturn = document.cookie.substring(nLength, strTemp);
			}
			break;
		}
		//存在しなければ次へ、なければ終了
		nLoop = document.cookie.indexOf(" ", nLoop) + 1;
		if (nLoop == 0)
		{
			break;
		}
	}
	return nReturn;
}
//クッキーをセットする関数です。引数にはクッキーの名前と値を指定します。
function SetCookie(strName, strValue)
{
	//有効期限の計算
	var dtExpire = new Date();
	dtExpire.setTime(dtExpire.getTime() + nExpTime);
	//クッキーをセット
	document.cookie = strName + "=" + strValue + "; expires=" + dtExpire.toGMTString();
}




//クッキーの値を加工して戻す関数です。
function GetValue()
{
	var strCount;
	strCount = GetCookie("FlashLoadCheck");			//値を取得
	SetCookie("FlashLoadCheck", parseInt(strCount) + 1);	//次のためにプラス1をセット
	return (parseInt(strCount) + 1);
}
//ページを移動する関数です
function CheckPage()
{
	//もしも、訪問回数が２回目以降であれば、別のページへ移動する
	if (GetValue() > 1)
	{
		location.href=strNextUrl;
	}
}
