// ジャバスクリプト
//function GetElementByID(id) {
//	return document.getElementById(id);
//}
//
//function Popup(message) {
//	alert(message);
//}
//
//function Display(on, off) {
//	GetElementByID(on ).style.display = "block";
//	GetElementByID(off).style.display = "none";
//}
//
//function StaticPage() {
//	alert("静的ページ");
//}


// Popup
//var PopupID;

/*
function PopupHTML(url, id) {
	if (id == null) {
		id = "popup";
	}
	if (PopupID != null) {
		var p = $(PopupID);
		p.style.display = "none";
	}
	PopupID = id;
	var p = $(id);
	p.innerText = "now loading...";
	p.style.display = "block";
	p.style.position = "absolute";
	new Ajax.Updater(id, url, {
		method: "get" ,
		onComplete	: function evalResponse(req) {
			var x = req.responseText;
			if (x.substring(0, 1) == "+") {
				p.innerHTML = "";
				eval(x.substring(1));
			}
			return;
		}
	});
	return void(0);
}


function PopupDiv(id) {
	if (id == null) {
		id = "popup";
	}
	if (PopupID != null) {
		var p = $(PopupID);
		p.style.display = "none";
	}
	PopupID = id;
	var p = $(id);
	p.style.display = "block";
	p.style.position = "absolute";
	return void(0);
}


function PopupForm(args) {
	if (args == null) { args = {}; }
	if (args.form	== null) { args.form   = "form" ; }
	if (args.popup	== null) { args.popup  = "popup"; }
	if (args.script	== null) { args.script =  false ; }
	if (PopupID		!= null) { $(PopupID).style.display = "none"; }
	var p = $(PopupID = args.popup);
	var f = $(args.form);
	p.style.display  = "block"	 ;
	p.style.position = "absolute";
	new Ajax.Updater(args.popup, f.action, {
		method		: f.method,
		parameters	: Form.serialize(args.form),
		onComplete	: function evalResponse(req) {
			var x = req.responseText;
			if (x.substring(0, 1) == "+") {
				p.innerHTML = "";
				eval(x.substring(1));
			}
			return;
		}
	});
	return void(0);
}


function PopupForm2(formname) {
	PopupForm({ form: formname });
	return void(0);
}




function ClosePopup() {
	if (PopupID != "") {
		var p = $(PopupID);
		p.style.display = "none";
		p.innerHtml = "";
	}
	return void(0);
}
*/

function Selected(no) {
	return { "selected": no };
}

function LinkSelected(prefix, on) {
	for (var i = 1; ; ++i) {
		var obj = $(prefix + i);
		if (obj == null) break;
		obj.className = (i == on) ? "select" : "";
	}
	return;
}

function LoadIframe(url, id, opts) {
	if (id == null) id = "iframe";
	if (opts.selected != null) LinkSelected("li", opts.selected);
	var obj = $(id);
	if (obj != null) obj.src = url;
	return;
}


function LoadHTML(url, id, opts) {
	if (id == null) id = "load";
	try {
		if (opts.selected != null)
			LinkSelected("li", opts.selected);
	}
	catch (e) { ;}

	var on_complete_end = (opts != null) ? opts.onCompleteEnd : null;
	var p = $(id);
//	p.innerText = "now loading...";

	var q = url.indexOf("?", 0);
	var curl = (q == -1)
			 ? url
			 : url + "&cache=" + (new Date()).getTime();
	new Ajax.Updater(id, curl, {
		method: "get",
		onComplete	: function evalResponse(req) {
			var x = req.responseText;
			if (x.substring(0, 1) == "+") {
				p.innerHTML = "";
				eval(x.substring(1));
			}
			if (on_complete_end != null) {
				on_complete_end(req);
			}
			return;
		}
	});
	return void(0);
}


function AjaxAndReload(url) {
	var p = $("dummy");
//	p.style.display = "none";
	new Ajax.Updater("dummy", url);
	return void(0);
}

function LoadForm(formid, id) {
	if (formid == null) formid = "form";
	if (id == null) id = "load";
	var form = $(formid);
	new Ajax.Updater(id, form.action, {
		method		: form.method,
		parameters	: Form.serialize(form),
		onComplete	: function evalResponse(req) {
			var x = req.responseText;
			if (x.substring(0, 1) == "+") {
				p.innerHTML = "";
				eval(x.substring(1));
			}
			return;
		}
	});
	return void(0);
}

function Display(id, shown) {
	$(id).style.display = shown ? "block" : "none";
	return;
}
