YUI.add("key-aevents",function(a){a.namespace("KEY");a.KEY.AppletEvents=function(b){a.KEY.AppletEvents.superclass.constructor.call(this,b)};a.KEY.AppletEvents.NAME="appletEvents";a.KEY.AppletEvents.CATSTYLE=new Array(["flirt",{width:"125px",height:"87px"}],["over20",{width:"97px",height:"91px",bottom:"-12px"}],["under18",{width:"158px",height:"90px",bottom:"-10px"}],["local",{width:"123px",height:"89px"}],["games",{width:"135px",height:"118px",bottom:"-15px"}],["classic",{width:"128px",height:"73px"}],["themes",{width:"145px",height:"90px"}],["poker",{width:"143px",height:"98px"}],["iPhone",{}],["topmychannels",{width:"140px",height:"98px",bottom:"-16px"}]);a.KEY.AppletEvents.instance=null;a.KEY.AppletEvents.ATTRS={applet:{value:null},container:{value:null},queue:{value:[]}};a.KEY.AppletEvents.available=function(){var b=a.get("#chatjavanote");if(b!=null){b.setStyle("display","none")}};a.KEY.AppletEvents.categorySwitch=function(e){var f=a.get(".catimg");if(f==null||a.KEY.AppletEvents.CATSTYLE[e]==undefined){return}var d=f.getStyle("backgroundImage");if(d!=null){if(d!="none"){d=d.replace(/(.*cat_\D*)\d(.*)/,"$1"+e+"$2");f.setStyle("backgroundImage",d)}else{d=f.getStyle("filter");d=d.replace(/(.*cat_\D*)\d(.*)/,"$1"+e+"$2");f.setStyle("filter",d)}f.setStyle("bottom","");for(var c in a.KEY.AppletEvents.CATSTYLE[e][1]){f.setStyle(c,a.KEY.AppletEvents.CATSTYLE[e][1][c])}}for(var b=0;b<a.KEY.AppletEvents.CATSTYLE.length;b++){f.removeClass(a.KEY.AppletEvents.CATSTYLE[b][0])}f.addClass(a.KEY.AppletEvents.CATSTYLE[e][0])};a.KEY.AppletEvents.loginSuccess=function(e,b){var d=window.K.auth.Info.getInstance().setAI(b)};a.KEY.AppletEvents.loadAdvertAsync=function(d,c){var b=a.KEY.AppletEvents.getInstance();b.handle(d,c);return"ok"};a.KEY.AppletEvents.loadAdTimeout=function(b){a.KEY.AppletEvents.getInstance().receiveAdvertAsync("")};if(window.sendToApplet==undefined){window.sendToApplet=function(b){a.KEY.AppletEvents.getInstance().receiveAdvertAsync(b)}}a.KEY.AppletEvents.getInstance=function(b){if(a.KEY.AppletEvents.instance==null){a.KEY.AppletEvents.instance=new a.KEY.AppletEvents(b)}return a.KEY.AppletEvents.instance};a.extend(a.KEY.AppletEvents,a.Base,{initializer:function(b){try{this.set("applet",a.Node.getDOMNode(a.one("#chatapplet")))}catch(d){a.log("Applet not found","info","AppletEvents")}var f=this.get("container");if(f==null){this.set("container",a.Node.create('<div id="'+a.guid("adkld")+'" style="position:absolute; visibility:hidden; height: 0px; width:0px;"></div>'));a.get("body").append(this.get("container"))}},destructor:function(){var b=this.get("container");if(b!=null){b.remove();this.set("container",null)}},handle:function(d,b){var c=this.get("queue");c.push([d,b,a.guid("if")]);if(c.length==1){this.notify()}a.log("Got Ad for loading id "+d+" url "+b,"debug","AppletEvents")},notify:function(){var d=this.get("queue");if(d.length>0){var b=d[0];var e=this.get("container");e.append(a.Node.create('<iframe src="'+b[1]+'" width="0" height="0" border="0" id="'+b[2]+'" style="visibility:hidden;"></iframe>'));b.push(window.setTimeout(function(){a.KEY.AppletEvents.loadAdTimeout(b[0])},10000))}},receiveAdvertAsync:function(f){try{if(window.location.search.indexOf("IAMTest")>-1){alert("Result:"+f)}}catch(g){}a.log("Callback incoming","debug","AppletEvents");var d=this.get("queue");if(!(d.length>0)){return}var c=d[0];var b=a.one("#"+c[2]);if(b){b.remove();c=d.shift();window.clearTimeout(c[3])}else{f=""}try{a.log("Calling Applet for id "+c[0],"debug","AppletEvents");this.get("applet").receiveAdvertAsync(""+c[0],f)}catch(g){a.log("Appletcall for id "+c[0]+" failed. "+g,"warn","AppletEvents")}if(d.length>0){this.notify()}}})},"1.0",{requires:["base","dom","node"],skinnable:false});if(typeof Y=="undefined"||!Y){Y={}}if(typeof Y.KEY=="undefined"||!Y.KEY){Y.KEY={}}if(typeof Y.KEY.AppletEvents=="undefined"||!Y.KEY.AppletEvents){KYUI().use("key-aevents",function(a){Y.KEY.AppletEvents=a.KEY.AppletEvents})};