
function fnIsopener(){var ua=navigator.userAgent;if(!!window.opener){if(ua.indexOf('MSIE 4')!=-1&&ua.indexOf('Win')!=-1){return!window.opener.closed;}else{return typeof window.opener.document=='object';}}else{return false;}}
function fnCallAddress(php_url,tagname1,tagname2,input1,input2){zip1=document.form1[tagname1].value;zip2=document.form1[tagname2].value;if(zip1.length==3&&zip2.length==4){$.get(php_url,{zip1:zip1,zip2:zip2,input1:input1,input2:input2},function(data){arrdata=data.split(",");if(arrdata.length>1){fnPutAddress(input1,input2,arrdata[0],arrdata[1],arrdata[2]);}else{alert(data);}});}else{alert("郵便番号を正しく入力して下さい。");}}
function fnPutAddress(input1,input2,state,city,town){if(state!=""){document.form1[input1].selectedIndex=state;document.form1[input2].value=city+town;}}
function fnOpenNoMenu(URL){window.open(URL,"nomenu","scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no");}
function fnOpenWindow(URL,name,width,height){window.open(URL,name,"width="+width+",height="+height+",scrollbars=yes,resizable=no,toolbar=no,location=no,directories=no,status=no");}
function fnSetFocus(name){if(document.form1[name]){document.form1[name].focus();}}
function fnSetSelect(name1,name2,val){sele1=document.form1[name1];sele2=document.form1[name2];if(sele1&&sele2){index=sele1.selectedIndex;count=sele2.options.length
for(i=count;i>=0;i--){sele2.options[i]=null;}
len=lists[index].length
for(i=0;i<len;i++){sele2.options[i]=new Option(lists[index][i],vals[index][i]);if(val!=""&&vals[index][i]==val){sele2.options[i].selected=true;}}}}
function fnCancelEnter()
{if(gCssUA.indexOf("WIN")!=-1&&gCssUA.indexOf("MSIE")!=-1){if(window.event.keyCode==13)
{return false;}}
return true;}
function fnModeSubmit(mode,keyname,keyid){switch(mode){case'delete_category':if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します')){return;}
break;case'delete':if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){return;}
break;case'delete_order':if(!window.confirm('在庫数は手動で戻してください。\n一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){return;}
break;case'confirm':if(!window.confirm('登録しても宜しいですか')){return;}
break;case'delete_all':if(!window.confirm('検索結果をすべて削除しても宜しいですか')){return;}
break;default:break;}
document.form1['mode'].value=mode;if(keyname!=""&&keyid!=""){document.form1[keyname].value=keyid;}
document.form1.submit();}
function fnFormModeSubmit(form,mode,keyname,keyid){switch(mode){case'delete':if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){return;}
break;case'confirm':if(!window.confirm('登録しても宜しいですか')){return;}
break;case'regist':if(!window.confirm('登録しても宜しいですか')){return;}
break;default:break;}
document.forms[form]['mode'].value=mode;if(keyname!=""&&keyid!=""){document.forms[form][keyname].value=keyid;}
document.forms[form].submit();}
function fnSetFormSubmit(form,key,val){document.forms[form][key].value=val;document.forms[form].submit();return false;}
function fnSetFormVal(form,key,val){document.forms[form][key].value=val;}
function fnChangeAction(url){document.form1.action=url;}
function fnNaviPage(pageno){document.form1['pageno'].value=pageno;document.form1.submit();}
function fnSearchPageNavi(pageno){document.form1['pageno'].value=pageno;document.form1['mode'].value='search';document.form1.submit();}
function fnSubmit(){document.form1.submit();}
function fnCheckInputPoint(){if(document.form1['point_check']){list=new Array('use_point');if(!document.form1['point_check'][0].checked){color="#dddddd";flag=true;}else{color="";flag=false;}
len=list.length
for(i=0;i<len;i++){if(document.form1[list[i]]){document.form1[list[i]].disabled=flag;document.form1[list[i]].style.backgroundColor=color;}}}}
function fnCheckInputDeliv(){if(!document.form1){return;}
if(document.form1['deliv_check']){list=new Array('deliv_name01','deliv_name02','deliv_kana01','deliv_kana02','deliv_pref','deliv_zip01','deliv_zip02','deliv_addr01','deliv_addr02','deliv_tel01','deliv_tel02','deliv_tel03');if(!document.form1['deliv_check'].checked){fnChangeDisabled(list,'#dddddd');}else{fnChangeDisabled(list,'');}}}
function fnCheckInputMember(){if(document.form1['member_check']){list=new Array('password','password_confirm','reminder','reminder_answer');if(!document.form1['member_check'].checked){fnChangeDisabled(list,'#dddddd');}else{fnChangeDisabled(list,'');}}}
var g_savecolor=new Array();function fnChangeDisabled(list,color){len=list.length;for(i=0;i<len;i++){if(document.form1[list[i]]){if(color==""){document.form1[list[i]].disabled=false;document.form1[list[i]].style.backgroundColor=g_savecolor[list[i]];}else{document.form1[list[i]].disabled=true;g_savecolor[list[i]]=document.form1[list[i]].style.backgroundColor;document.form1[list[i]].style.backgroundColor=color;}}}}
function fnCheckLogin(formname){var lstitem=new Array();if(formname=='login_mypage'){lstitem[0]='mypage_login_email';lstitem[1]='mypage_login_pass';}else{lstitem[0]='login_email';lstitem[1]='login_pass';}
var max=lstitem.length;var errflg=false;var cnt=0;for(cnt=0;cnt<max;cnt++){if(document.forms[formname][lstitem[cnt]].value==""){errflg=true;break;}}
if(errflg==true){alert('メールアドレス/パスワードを入力して下さい。');return false;}}
function fnPassTime(){end_time=new Date();time=end_time.getTime()-start_time.getTime();alert((time/1000));}
start_time=new Date();function fnUpdateParent(url){if(fnIsopener()){window.opener.location.href=url;}else{window.close();}}
function fnKeySubmit(keyname,keyid){if(keyname!=""&&keyid!=""){document.form1[keyname].value=keyid;}
document.form1.submit();}
function fnCharCount(form,sch,cnt){document.forms[form][cnt].value=document.forms[form][sch].value.length;}
function ChangeSize(button,TextArea,Max,Min,row_tmp){if(TextArea.rows<=Min){TextArea.rows=Max;button.value="小さくする";row_tmp.value=Max;}else{TextArea.rows=Min;button.value="大きくする";row_tmp.value=Min;}}
function fnSetDelivTime(mode,r_key,s_id){var f_key,f_val;var f_cnt=document.form1.length;var f_data="mode="+mode;for(i=0;i<f_cnt;i++){f_key=document.form1[i].name;f_val=document.form1[i].value;if(f_key!="mode"){if(f_key==r_key){if(document.form1[i].checked===true){f_data+="&"+f_key+"="+f_val;}}else{f_data+="&"+f_key+"="+f_val;}}}
$.ajax({type:"POST",url:document.form1.action,data:f_data,dataType:"json",success:function(data){var elm_s="select#"+s_id;var elm_o=elm_s+" option";$(elm_o).remove();$(elm_s).append($('<option>').attr({value:""}).text("指定なし"));for(i=0;i<data.length;i++){if(data[i].time_id>0){$(elm_s).append($('<option>').attr({value:data[i].time_id}).text(data[i].deliv_time));$(elm_s).width();}}}});}
