index=null;Event.observe(window,"load",function(){index=new AL_index()});AL_index=Class.create({_selected:"ss",_default_keyword:"キーワードを入力してください。",initialize:function(){this.init_first_form();this.init_observer()},init_first_form:function(){$("ss").firstChild.href="javascript:void(0);";$("sm").firstChild.href="javascript:void(0);";$("sj").firstChild.href="javascript:void(0);";$("abcd").firstChild.href="javascript:void(0);"},init_observer:function(){Event.observe($("ss"),"click",function(){this.swap_form("ss","/list.php")}.bind(this));Event.observe($("sm"),"click",function(){this.swap_form("sm","/membo/")}.bind(this));Event.observe($("sj"),"click",function(){this.swap_form("sj","/job/")}.bind(this));Event.observe($("abcd"),"click",function(){this.swap_form("abcd","/store/search.php")}.bind(this));Event.observe($("ai"),"click",function(){this.swap_form("ai","/store/search.php")}.bind(this));Event.observe($("ss_p"),"change",function(){this.init_county_select()}.bind(this));Event.observe($("frm"),"submit",function(){this.do_submit()}.bind(this))},do_submit:function(){if($(this._selected+"_t")!=undefined){if($(this._selected+"_t").value==this._default_keyword){$(this._selected+"_t").value=""}}},swap_form:function(b,a){if(this._selected==b){this.do_submit();$("frm").submit()}else{$("frm").action=a;$(this._selected+"_frm").hide();$(this._selected+"_frm").childElements().each(function(c){if(c.nodeName=="INPUT"||c.nodeName=="SELECT"){c.disabled="disabled"}else{if(c.nodeName=="LABEL"){$(c).childElements().each(function(d){if(d.nodeName=="INPUT"){d.disabled="disabled"}})}}});$(this._selected).className="";$(this._selected).firstChild.href="javascript:void(0);";this._selected=b;$(this._selected).className="active";$(this._selected).firstChild.href="javascript:void(0);";this.init_form(b);$(this._selected+"_frm").childElements().each(function(c){if(c.nodeName=="INPUT"||c.nodeName=="SELECT"){c.disabled=""}else{if(c.nodeName=="LABEL"){$(c).childElements().each(function(d){if(d.nodeName=="INPUT"){d.disabled=""}})}}});$(this._selected+"_frm").show()}},init_form:function(g){if($(g+"_frm")==undefined){var a=this;if(g=="sm"||g=="sj"){var h=new Element("div",{id:g+"_frm"});var e=new Element("input",{name:"t",type:"text",id:g+"_t",value:this._default_keyword,className:"unfocus"});var d=new Element("select",{name:"p",id:g+"_p"});var b=new Element("input",{id:g+"_sb",type:"submit",value:"検索"});Event.observe(e,"focus",function(){if($(g+"_t").value==a._default_keyword){$(g+"_t").value="";$(g+"_t").className="focus"}});Event.observe(e,"blur",function(){if($(g+"_t").value==""){$(g+"_t").value=a._default_keyword;$(g+"_t").className="unfocus"}});this.get_pref(g+"_pref",d);h.insert(e);h.insert(b);h.insert(new Element("br"));h.insert(new Element("span").update("都道府県 :"));h.insert(d);Element.insert($("ss_frm"),{before:h})}else{if(g=="abcd"||g=="ai"){var h=new Element("div",{id:g+"_frm"});var f=new Element("select",{name:"f",id:g+"_f"});var e=new Element("input",{name:"t",type:"text",id:g+"_t",value:this._default_keyword,className:"unfocus"});var b=new Element("input",{id:g+"_sb",type:"submit",value:"検索"});var c=new Element("p",{id:g+"_txt"}).update("※商品検索は只今β版です。キーワードによっては関係の無い商品が表示される場合がございます。");Event.observe(e,"focus",function(){if($(g+"_t").value==a._default_keyword){$(g+"_t").value="";$(g+"_t").className="focus"}});Event.observe(e,"blur",function(){if($(g+"_t").value==""){$(g+"_t").value=a._default_keyword;$(g+"_t").className="unfocus"}});if(g=="abcd"){f.insert(new Element("option",{value:"abcd1",label:"アーティスト名"}).update("アーティスト名"));f.insert(new Element("option",{value:"abcd2",label:"商品名"}).update("商品名"))}else{if(g=="ai"){f.insert(new Element("option",{value:"ai1",label:"商品・ブランド名"}).update("商品・ブランド名"))}}h.insert(f);h.insert(e);h.insert(b);h.insert(c);Element.insert($("ss_frm"),{before:h})}}}},init_county_select:function(){this.update_county($("ss_p").value,$("ss_co"))},update_county:function(b,a){new Ajax.Request("/json.php",{method:"get",parameters:{m:"county",school:null,p:b},onSuccess:function(f){var e=f.responseJSON;a.innerHTML=null;if(e==null){a.insert(new Element("option",{value:"",label:"------"}).update("------"))}else{a.insert(new Element("option",{value:"",label:"▼選択してください"}).update("▼選択してください"));for(var d=0,c=e.length;d<c;d++){a.insert(new Element("option",{value:e[d].c_id,label:e[d].c_name}).update(e[d].c_name))}}},onFailure:function(){}})},get_pref:function(b,a){new Ajax.Request("/json.php",{method:"get",parameters:{m:b},onSuccess:function(d){var c=$H(d.responseJSON)||"no response text";a.innerHTML=null;a.insert(new Element("option",{value:"",label:"▼選択してください"}).update("▼選択してください"));c.each(function(f){var e=new Element("optgroup",{label:f.value.name});$H(f.value.children).each(function(g){e.insert(new Element("option",{value:g.value.id,label:g.value.name}).update(g.value.name))});a.insert(e)})},onFailure:function(){}})}});
