var VOTECHECK_cancel = false; var vote_submit = false; function VOTECHECK_getName(id) { return 'vform' + id; } function VOTECHECK_getForm(id) { return document.getElementById( VOTECHECK_getName(id) ); } function VOTECHECK_setSubmit(id) { VOTECHECK_cancel = false; VOTECHECK_getForm(id).cancelb.value = ''; } function VOTECHECK_setCancel(id) { VOTECHECK_cancel = true; VOTECHECK_getForm(id).cancelb.value = 'Y'; } function VOTECHECK_checkForm(id) { vote_submit = true; var fm = VOTECHECK_getForm(id); var cnt = document.getElementsByName( VOTECHECK_getName(id) ).length; if( VOTECHECK_cancel ){ VOTECHECK_disabledButton(id, true); return true; } if( cnt == 1 && ! VOTECHECK_checkedRadio(fm.qid) ){ alert("項目が選択されていません。"); vote_submit = false; return false; }else if( cnt == 1 && fm.msg && fm.msg.value.length > 120 ){ alert("コメントは120文字以内で入力してください。"); vote_submit = false; return false; } VOTECHECK_disabledButton(id, true); setTimeout('VOTECHECK_disabledButton(' + id + ', false);', 5000); return true; } function VOTECHECK_disabledButton(id, flg) { var fm = VOTECHECK_getForm(id); if( fm ){ if( ! fm.target ){ if( ! fm.done.value ) document.getElementById('vf-btn-' + id + '-1').disabled = flg; document.getElementById('vf-btn-' + id + '-2').disabled = flg; } } } function VOTECHECK_checkedRadio(sel) { flg = false; for(i = 0; i < sel.length; i++){ if( sel[i].checked ){ flg = true; break; } } return flg; } // default settings function VOTECHECK_loadDefaultValue(id) { var fm = VOTECHECK_getForm(id); //var ck = VOTECHECK_loadVoteCookies(); if( ! fm.sex ){ return false; } // sex for(i = 0; i < fm.sex.length; i++){ if( fm.sex[i].value == "0" ){ fm.sex.selectedIndex = i; break; } } // age for(i = 0; i < fm.age.length; i++){ if( fm.age[i].value == "0" ){ fm.age.selectedIndex = i; break; } } // area for(i = 0; i < fm.area.length; i++){ if( fm.area[i].value == "0" ){ fm.area.selectedIndex = i; break; } } } function VOTECHECK_loadVoteCookies() { var ck = new Array(); var cks = document.cookie.split(';'); var exp = new RegExp('([^ ]+)=([^ ;]+)'); for( i = 0; i < cks.length; i++ ){ var kv = cks[i]; if( kv.match(exp) ){ var k = RegExp.$1; var v = RegExp.$2; if( k == 'VOTE_SAA' ){ v2 = unescape(v); var ary = v2.split(','); ck['sex'] = ary[0]; ck['age'] = ary[1]; ck['area'] = ary[2]; break; } } } return ck; } VOTECHECK_loadDefaultValue(1664);