CD.Search=new Class({tabs:{standard:null,extendednded:null},players:{audio:null,video:null},initialize:function(){var D=$("StandardResults");if($defined(D)){this.tabs.standard=D}var B=$("ExtendedResults");if($defined(B)){this.tabs.extended=B}$each(this.tabs,function(F){if($chk(F)){this.processTab(F)}}.bind(this));var E=document.body.getElement(".TabMenu");if($defined(E)){$each(E.getElements("li"),function(F){F.getFirst().addEvent("click",function(G){new Event(G).stop();this.switchSearchMode(F.getProperty("id"))}.bind(this))}.bind(this))}if($defined($("popupBox"))){var C=$("popupBox").getElement(".popupBoxClose").getFirst()}if($defined(C)){C.addEvent("click",function(G){var F=new Event(G).stop();this.closePlayer("flv")}.bind(this))}var A=$$("a.MediaSound");if(A&&A.length){$each(A,function(F){F.addEvent("click",function(I){var G=new Event(I).stop();var H=F.getProperty("class").replace(new RegExp("(^|\\s)MediaSound(?:\\s|$)"),"$1");if(this.players.audio!=null){this.players.audio.close()}this.players.audio=new CD.MediaPlayer({type:"mp3",event:G,source:H});this.players.audio.show()}.bind(this))}.bind(this))}},processTab:function(D){var E=[];var F=D.getElement("#Sound");if($defined(F)){var C=F.getProperty("class").replace(new RegExp("(^|\\s)listen(?:\\s|$)"),"$1");E.push({type:"mp3",source:C,element:F})}var B=D.getElement("#Video");if($defined(B)){var C=B.getProperty("class").replace(new RegExp("(^|\\s)play(?:\\s|$)"),"$1");E.push({type:"flv",source:C,element:B})}$each(E,function(G){G.element.addEvent("click",function(I){var H=new Event(I).stop();G.event=H;this.showPlayer(G)}.bind(this))}.bind(this));var A=D.getElements(".image");if(A&&A.length){$each(A,function(G){G.addEvent("click",function(J){var I=new Event(J).stop();var H=new CD.ImageView(G.href)}.bind(this))}.bind(this))}},switchSearchMode:function(D){$each(this.players,function(F){if(F!=null){F.close()}}.bind(this));if(!D||"string"!=typeof D){D=CD.searchMode}var C,A,E,B;if("standard"==D){C=$("StandardResults");E=$("standard");A=$("ExtendedResults");B=$("extended")}else{if("extended"==D){C=$("ExtendedResults");E=$("extended");A=$("StandardResults");B=$("standard")}}if($defined(E)){if(!E.hasClass("Active")){E.addClass("Active")}}if($defined(B)){B.removeClass("Active")}if($defined(C)){C.setStyle("display","block")}if($defined(A)){A.setStyle("display","none")}new CD.Setting("searchMode",D).save()},showPlayer:function(A){var B=new CD.MediaPlayer(A);if(A.type=="mp3"){if(this.players.audio!=null){this.players.audio.close()}this.players.audio=B}else{if(A.type=="flv"){if(this.players.video!=null){this.players.video.close()}this.players.video=B}}B.show()},closePlayer:function(A){if(A=="mp3"){this.players.audio.close()}else{if(A=="flv"){this.players.video.close()}}}});window.addEvent("onAppReady",function(){CD.AppSearch=new CD.Search()});
