var lastDispField;

function getObjectById(id) {
	return (document.all && document.all(id)
		 || document.getElementById && document.getElementById(id));
}

/** textarea の枠を広げる。

 <div id="div-$name">
	<textarea id="$id">
	<a href="javascript:void(0);" onClick="exp($id);">広げる</a>
	<a href="javascript:void(0);" onClick="col($id);">戻す</a>
 </div>

 */
function exp(name) {

	var t = document.getElementById(name).style;
	var d = document.getElementById("div-"+name).style;
	var iw = document.body.clientWidth;
	if(!t) return;
	
	d.position = 'absolute';
	d.width  = (iw - 450) + 'px'; 
	d.height = '200px';
	d.border = '1px solid #999999';
	d.background= '#f0f0f0';
	d.zIndex = 5;
	
	t.width  = (iw - 460) + 'px'; 
	t.height = '180px';
	
	document.getElementById("eb-"+name).style.display='none';
	document.getElementById("cb-"+name).style.display='inline';
	
}

function col(name) {
	var t = document.getElementById(name).style;
	var d = document.getElementById("div-"+name).style;
	var iw = document.body.clientWidth;
	
	t.width = t.height = '';
	
	d.position = 'static';
	d.width = d.height = d.border = d.background= '';

	document.getElementById("eb-"+name).style.display='inline';
	document.getElementById("cb-"+name).style.display='none';

}


/** アップロード画面をポップアップ */
function openUpload(name, sid) {
	w = open("imgup.cgi?name=" + name + "&shopid=" + sid, "upload",
	"width=480,height=200,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes");
	return false;
}

function openProductUpload(name) {
	w = open("imgup_product.cgi?name=" + name + "&shopid=21", "upload",
	"width=480,height=200,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes");
	return false;
}

function preview_product() {
	wnd = window.open('', 'prev', 
		'scrollbars=yes,width=600,height=500');
	fm = document.forms[0];
	vt=fm.target; vm=fm.mode.value;
	fm.target="prev"; fm.mode.value="preview_product"; fm.submit();
	fm.target=vt; fm.mode.value=vm;
	wnd.focus();
}

//* 商品一括削除時使用 */
function item_ikkatu() {
	wFlg = false;
	ob = eval("document.frm_item.elements['delete_list[]']");
	if (ob) {
		if (ob.length) {
			for (i = 0; i < ob.length; i++) {
				if (ob[i].checked == true) {
					wFlg = true;
					break;
				}
			}
		} else {
			if (ob.checked == true) {
				wFlg = true;
			}
		}
	} else {
		alert("削除項目が選択されていません。");
		return;
	}
	if (wFlg == false) { alert("削除項目が選択されていません。"); return; }

	if( !window.confirm("チェックされている項目を一括で削除します。よろしいですか？") ){ return; }

	document.frm_item.action="?mode=item&type=ikkatu";
	document.frm_item.submit();
}


//** 管理画面内の警告 */
function check(){
	if(window.confirm("処理を実行してもよろしいですか？")){
	return true; // 「OK」時は送信を実行 
	}else{
	return false; // 送信を中止 
	}

}


// 商品登録時のフィールド表示切り替え
function showProductField(id) {
  obj = getObjectById("field_" + id);
   
   if (lastDispField) 
   		lastDispField.style.display = 'none';
   
   obj.style.display = 'block';
   lastDispField = obj;
}
