function modulePlayer(a,d,g){var f=Data.doc[d];var h=$(a+"_media");if(a=="podcast"&&d=="rss"){f={doc_id:"rss",embed_url:"/feed/doc?user_id="+glob_user.user_id+"&only=audio&format=playlist&session"}}if(!f||!h){console.log("modulePlayer : doc or div not found id="+d);return}h.update("");var e=new Element("div",{id:a+"_player"});h.appendChild(e);if(h.getAttribute("showingid")){var c=h.getAttribute("showingid");$(a+"_doc"+c).removeClassName("highlight")}if(f.embed=="flv"){var b={file:f.embed_url,image:f.doc_url+".240.jpg",width:300,height:225,mlink:"/doc/"+Data.doc[d].user_id+"/"+d,autostart:(g)?"true":false};new mediaplayer("flv",a+"_player",b).build()}else{var b={file:f.embed_url,width:300,height:20,showeq:"true",autostart:(g)?"true":"false"};new mediaplayer("mp3",a+"_player",b).build()}h.setAttribute("showingid",d);$(a+"_doc"+d).addClassName("highlight");if(g){IOL.log_visit("doc",d)}}var module_slideshow=Class.create();module_slideshow.prototype.initialize=function(a){this.photos=[];this.speed=3000;this.off=0;this.las=0;this.max=0;this.slide=1;this.last_slide=2;this.preload=document.createElement("img");Event.observe(this.preload,"load",function(d){this.photos[this.off].is_loaded=true;this.is_preloading=false}.bind(this));Event.observe("slideshow_slides","mouseover",function(){$("slideshow_infos").style.display="block"});Event.observe("slideshow_slides","mouseout",function(){$("slideshow_infos").style.display="none"});Event.observe("slideshow_slides","click",function(d){if(this.is_paused){this.is_paused=false;this.play();$("slideshow_paused").style.display="none"}else{this.is_paused=true;this.pause();$("slideshow_paused").style.display="block"}}.bind(this));Event.observe("slideshow_photo_title","click",function(d){Event.stop(d);l=Event.element(d);document.location=l.href});var c={off:0,stp:100,embed:"jpg"};c.user_id=glob_user.user_id;if(a){c.rel=a}var b=this;IOL.API.request("doc.search",c,b)};module_slideshow.prototype.doc_search_onApi=function(f,b,a,e){if(f&&b.docs.length){var d=b.docs;this.max=b.docs.length;this.off=_pi(b.r.off);
for(var c=0;c<d.length;c++){this.photos[c+this.off]=d[c]}this.play()}else{$("module_slideshow").style.display="none"}};module_slideshow.prototype.play=function(){clearTimeout(this.timer);if(this.is_paused){return}if(this.off>=this.max){this.off=0}if(this.off<0){this.off=this.max-1}var a=this.photos[this.off];if(!a.is_loaded&&this.is_preloading&&this.preload_tries<20){this.preload_tries++;setTimeout(function(){this.play()}.bind(this),1000);return}this.preload_tries=0;var e=$("slideshow_slide_"+this.slide);var g=$("slideshow_slide_"+this.last_slide);var j=_pi(a.wh.m[0]);var f=_pi(a.wh.m[1]);var c=_pi((240-j)/2);var b=_pi((240-f)/2);e.src=a.doc_url+".m.jpg";e.width=j;e.height=f;e.style.width=j+"px";e.style.height=f+"px";e.style.left=c+"px";e.style.top=b+"px";Effect.Appear(e,{duration:0.5,afterFinish:function(){this.timer=setTimeout(function(){this.play()}.bind(this),this.speed)}.bind(this)});Effect.Fade(g,{duration:0.5,afterFinish:function(){}.bind(this)});var i=$("slideshow_photo_title");i.href="/doc/"+glob_user.user_id+"/"+a.doc_id;i.innerHTML=a.title;var d=this.last_slide;this.last_slide=this.slide;this.slide=d;this.las=this.off;this.off++;this.prepare()};module_slideshow.prototype.pause=function(){clearTimeout(this.timer)};module_slideshow.prototype.prepare=function(){if(this.photos[this.off]&&!this.photos[this.off].is_loaded){this.is_preloading=true;this.preload.src=this.photos[this.off].doc_url+".m.jpg"}};