// 共通処理
function sort(sort) {
	document.form.column.value = sort;
	onSubmit();
}

function pageChange(page) {
	document.form.page.value = page;
	onSubmit('paging');
}

function onSubmit(event,formName)
{
	if(formName == undefined){
		formName = 'form';
	}
	if(event != undefined){
		document.forms[formName].default_event.value = event;
	}
	document.forms[formName].submit();
	return false;
}

function onSubmitSearch(event,formName,comment)
{
	document.getElementById('search_btn').innerHTML = comment;
	onSubmit(event,formName);
	return false;
}

function onKeyPress(event,name,formName){
	event = event || window.event;
	if (event.keyCode == 13) {
		if (event.srcElement) {
			if (event.srcElement.type == 'textarea') {
				return false;
			}
			else{
				event.returnValue = false;
				onSubmit(name,formName);
			}
		}
		else if (event.target) {
			if (event.target.type == 'textarea') {
				return false;
			}
			else{
				event.returnValue = false;
				onSubmit(name,formName);
			}
		}
	}
}

function checkAll(check_flag){
	for(i=0;document.form.length > i;i++){
		if(document.form.elements[i].name.match(/^checkbox\[.*\]$/)){
			document.form.elements[i].checked = check_flag;
		}
	}
}

function goCart(detail_id){
	document.form.detail_id.value = detail_id;
	onSubmit('goCart');
	return false;
}

// ウィンドウオープン
function openWindow(url, name, w, h, closeEvent) {
	if (url == null) return false;
	if (name == null) name="subWin";
	if (w == null) w=800;
	if (h == null) h=600;
	var win =window.open(url, name, 'directories=no,toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,height=' + h + ',width=' + w);
	win.focus();
	if(typeof(closeEvent)=='function'){
		var closeFunc = function(){
			if(win ? win.closed : true) closeEvent();
			else setTimeout(closeFunc, 100);
		}
		setTimeout(closeFunc, 100);
	}
//	return win;
	return false;
}