/* ---------------------------------------------
初期化
--------------------------------------------- */
/* ---------------------------------------------
サブウィンドウ関連
--------------------------------------------- */
var win01,win02,win03,win04,win05,num;



/* 非表示の要素から内容を表示::WebOS */
function openWindow02() {
	if(!$("window02")) {
		win02 = new Window("window02",{
			className : "window",
			title : "WebOS",
			top : 75,
			left : 350,
			width : 300,
			height : 200,
			showEffect : Effect.BlindDown,
			hideEffect : Effect.BlindUp,
			destroyOnClose : true
		});
		
		win02.getContent().innerHTML = $('link-list02').innerHTML;
		
		win02.show();
		win02.toFront(); 
	} else {
		folderExist(2);
	}
}

/* 表示内容を直接記述::Read Me */
function openWindow03() {
	if(!$("window03")) {
		win03 = new Window("window03",{
			className : "window",
			title : "Read Me",
			top : 250,
			left : 500,
			width : 350,
			height : 225,
			destroyOnClose : true
		});
		
		win03.getContent().innerHTML= "<div>これは、<strong>すぐに使えるCSSデザインテクニック</strong>のサンプルコンテンツです。<br />今回は、Prototype Window Classを利用してサブウィンドウやダイアログボックスを表示させています。右側上部にあるフォルダアイコンをクリックすると、ライブラリの配布元など外部サイトを参照することができますので、よろしければご利用ください。</div>";
		
		win03.show();
		win03.toFront(); 
	} else {
		windowExist(3);
	}
}

/* 外部URLの読み込み::Webブラウザ */
function openWindow04() {
	if(!$("window04")) {
		win04 = new Window("window04",{
			className : "window",
			title : "Webブラウザ",
			//読込先のURL
			url : "http://www.google.com/",
			top : 25,
			left : 50,
			width : 650,
			height : 375,
			destroyOnClose : true
		});
		
		win04.show();
		win04.toFront();
	} else {
		windowExist(4);
	}
}

/* 外部URLの読み込み::Webブラウザ */
//関連サイトのリスト
var newURL1="http://prototype-window.xilinus.com/";
var newURL2="http://www.prototypejs.org/";
var newURL3="http://script.aculo.us/";

//WebOSの参考リスト
var newURL4="https://www.youos.com/";
var newURL5="http://www.startforce.jp/";
var newURL6="http://craythur.com/desktop/";
var newURL7="http://eyeos.org/";

//Webブラウザに表示されるURLのリフレッシュ
function refreshWindow(num) {	
	var nextURL = eval("newURL"+num);
	if(!$("window04")) {
		win04 = new Window("window04",{
			className : "window",
			title : "Webブラウザ",
			width : 740,
			height : 425,
			destroyOnClose : true
		});
		//既存のオブジェクトにsetURL()を実行することで、URLを書き換え
		win04.setURL(nextURL);
		win04.showCenter(); 
	} else {
		win04.toFront();
		//既存のオブジェクトにsetURL()を実行することで、URLを書き換え
		win04.setURL(nextURL);
	}
}


/* ---------------------------------------------

アラート関連

--------------------------------------------- */
/* フォルダの内容を表示している場合のアラート */
function folderExist(num) {
	Dialog.alert("このフォルダは、既に開かれています", {
		className : "alert",
		width:400,
		okLabel: "閉じる",
		//OKボタンをクリック時に、当該ウィンドウを最前面へ移動する関数を実行
		onOk:function(win) { setFront(num); return true; }
	});
}

/* ファイル(コンテンツ)を表示している場合のアラート */
function windowExist(num) {
	Dialog.alert("このウィンドウは、既に開かれています", {
		className : "alert",
		width:400,
		okLabel: "閉じる",
		//OKボタンをクリック時に、当該ウィンドウを最前面へ移動する関数を実行
		onOk:function(win) { setFront(num); return true; }
	});
}


/* ---------------------------------------------

その他

--------------------------------------------- */
/* 表示済みのサブウィンドウを最前面へ */
function setFront(num) {
	target = eval("win0"+num);
	target.toFront();
}
