var Recharge=(function(){var A=function(J,G,I){if($(J)){Dom.removeNode($(J));}var H=document.createElement("script");H.id=J;H.onload=H.onreadystatechange=function(){if((H.readyState&&H.readyState=="loaded")||!H.readyState){I&&I();}};document.getElementsByTagName("head")[0].appendChild(H);H.src=G;};var E="http://youa.baidu.com/data/0/mobile_recharge/0/getdata?callback=mobile_card&random="+(+new Date());var D="http://youa.baidu.com/data/0/game_card/0/getdata?callback=net_game&random="+(+new Date());var B=elGame=null;var F=function(I,N,O){if(N[0].value==""){return ;}var K=Dom.getElementsByClassName("price",I)[0];var L=Dom.getElementsByClassName("submit",I)[0];Dom.hide([K,L]);var M=[];for(var J=1;J<N.length;J++){if(N[J].selectedIndex>0){N[J].setAttribute("defText",N[J].options[N[J].selectedIndex].text);}var H=N[J].value.split(":");if(parseInt(H[0])>32){prop=[H[0],H[2]].join(":");}else{prop=[H[0],H[1]].join(":");}if(!N[J].disabled){M.push(prop);}}var G="http://youa.baidu.com/data/0/"+O+"/0/query?callback="+O+"&icid="+N[0].value+"&prop="+M.join(",")+"&random"+(+new Date());A("js_"+O,G);};var C=function(H,G){var I=G.getElementsByTagName("button")[0];var J=Dom.getElementsByClassName("price",G)[0];var K=Dom.getElementsByClassName("submit",G)[0];if(H.err=="ok"){J.innerHTML="折扣价：<strong>"+(H.result.item_price/100).toFixed(2)+"</strong>元";Dom.show(K,"block");I.onclick=function(){window.open("http://youa.baidu.com/order/"+H.result.iid+"/buy/","","");};}else{J.innerHTML='<span class="null">本类卡暂无</span>';}Dom.show(J,"block");};window["mobile_recharge"]=function(G){C(G,B);};window["game_card"]=function(G){C(G,elGame);};window["mobile_card"]=function(M){var G={"移动":{"select":["","移动充值卡地区","移动充值卡价格"]},"联通":{"select":["","","联通充值卡价格"]}};var N=null;var J=B.getElementsByTagName("select");var H=B.getElementsByTagName("li");Dom.getArray(J).each(function(O){BBEvent.observe(O,"change",function(){if(N){clearTimeout(N);}N=setTimeout(function(){F(B,J,"mobile_recharge");},300);});});for(var I in M){var K=new Option(I,M[I].icid);J[0].options[J[0].options.length]=K;J[0].onchange=function(){L(this.options[this.selectedIndex].text);};}function L(Q){var U=G[Q];var V=M[Q]._child_data;for(var S=1;S<U.select.length;S++){var P=U.select;J[S].length=0;if(""==P[S]){J[S].disabled=true;Dom.hide([J[S],H[S]]);}else{J[S].disabled=false;Dom.show([J[S],H[S]]);var R=V[P[S]]._child_data;for(var W in R){var O=R[W];var T=new Option(W,O.item_attr_id+":"+O.item_attr_v1+":"+O.item_attr_v2);if(W==J[S].getAttribute("defText")){T.selected=true;}J[S].options[J[S].options.length]=T;}}}}BBEvent.observe(window,"beforeunload",function(){J[0].selectedIndex=0;});L(J[0].options[0].text);N=setTimeout(function(){F(B,J,"mobile_recharge");},300);};window["net_game"]=function(L){var G=null;var N=elGame.getElementsByTagName("select");var Q=elGame.getElementsByTagName("li");var K=Dom.nextSibling(elGame);var J=Dom.getElementsByClassName("price",elGame)[0];var M=Dom.getElementsByClassName("submit",elGame)[0];var H=function(U,T){for(var S=0;S<U.length;S++){var R=U.options[S];if(R.text==T){R.selected=true;BBEvent.fireEvent(U,"change");break;}}};Dom.getArray(K.getElementsByTagName("a")).each(function(R){BBEvent.observe(R,"click",function(S){BBEvent.preventDefault(S);H(N[0],R.getAttribute("k"));H(N[1],R.getAttribute("v"));});});Dom.getArray(N).each(function(R){BBEvent.observe(R,"change",function(){if(G){clearTimeout(G);}G=setTimeout(function(){F(elGame,N,"game_card");},300);});});for(var O in L){var I=new Option(O,L[O].icid);N[0].options[N[0].options.length]=I;N[0].onchange=function(){P(this.options[this.selectedIndex].text);};}function P(S){if("请选择游戏"==S){if(K){Dom.show([K,J,M]);}N[1].length=0;N[1].options[N[1].options.length]=new Option("请选择面值","");}else{if(K){Dom.hide([K,J,M]);}var W=L[S]._child_data;N[1].length=0;var R=null,U=0;for(var T in W){if(1==U){R=W[T]._child_data;break;}U++;}for(var T in R){var X=R[T];var V=new Option(T.replace("点卡",""),X.item_attr_id+":"+X.item_attr_v1+":"+X.item_attr_v2);N[1].options[N[1].options.length]=V;}}}BBEvent.observe(window,"beforeunload",function(){N[0].selectedIndex=0;});P(N[0].options[0].text);G=setTimeout(function(){F(elGame,N,"game_card");},300);};return{initMobile:function(G){B=$(G);if(!B){return ;}if($("js_recharge_mobile")){return ;}A("js_recharge_mobile",E);},initGame:function(G){elGame=$(G);if(!elGame){return ;}if($("js_recharge_game")){return ;}A("js_recharge_game",D);}};})();