var search={paginationCount:20,count:3,start:1,order:"posted",updateStart:function(a){search.start=a;search.update();},update:function(){var a;a=["title","mediaid","duration","downloads_started","rating","thumbnail"];searchphrase=document.getElementById("search-textbox").value;document.getElementById("search_msg_box").style.display="block";document.getElementById("search_msg_box").innerHTML="<div id='search_msg_box_inner'><div class='search-message'><div class='result-for searchtext' id='search-message'>S&ouml;ker efter: "+searchphrase+"</div> <div id='closeSearch'><a href='javascript:playlist.mode=1;playlist.start=1;playlist.update();'></a></div></div></div>";ps.search(searchphrase,{count:search.count,start:search.start,order:search.order,fields:a},function(b){document.getElementById("search-message").innerHTML=b.count+" resultat f&ouml;r: "+document.getElementById("search-textbox").value;search.display(b);});},display:function(c){var d,b,h,a;document.getElementById("video-list-pagination").innerHTML="";var g="";for(d in c.media){b=c.media[d];h=ps.parseDuration(b.duration);var f="<img  src='http://www.aktivitetssida.se/mktv2/starinactive.png'>";var e="<img  src='http://www.aktivitetssida.se/mktv2/staractive.png'>";var j="";for(a=16;a<b.rating;a+=17){j+=e;}for(;a<100;a+=17){j+=f;}g+="<div class='video-list-container'><a href='javascript:ps.activateMedia(\""+b.mediaid+"\")'><div class='video-list-image thumb-blinds' style='width: 124px; height:93px;'><table cellpadding=0 cellspacing=0><tr height=93><td style='vertical-align: middle;'><img src='"+b.thumbnail+"' style='max-width: 124px; max-height: 93px;'></tr></td></table></div><div class='video-list-details'><div class='video-list-heading themecolor'>"+b.title+"</div><p>"+b.description+"</p><span class='clearleft'></span></div></a></div>";}document.getElementById("video-list").innerHTML=g;if(c.count>c.media.length){document.getElementById("video-list-pagination").innerHTML=makePagination(c.count,search.start,search.count,search.paginationCount,"search.updateStart");}}};function makePagination(q,d,f,h,j,p,e){var c="";var a="";c+="<ul>";if(d<=1){a="opacity: 0.3;filter:alpha(opacity=30);";}c+="<li class='page-prev'><a style='"+a+"' class='pag-previous' href='javascript:"+j+"("+Math.max(1,d-f)+', "'+p+"\");'></a></li>";var n=parseInt((q+(f-1))/f);var m=parseInt((d+(f-1))/f);var l=Math.min(n,m+parseInt((h)/2));var k=Math.max(1,l-(h-1));l=Math.min(n,k+(h-1));var o;var g="";var b=1;for(o=k;o<=l;o++){b=1+(o-1)*f;g="";if(b<=d&&b+f>d){g="active";}c+="<li class='pagnum'><a class='"+g+"' href='javascript:"+j+"("+b+', "'+p+"\");'>"+o+"</a></li>";}a="opacity: 0.3;filter:alpha(opacity=30);";if(g==""){b=d+f;a="";}c+="<li class='page-next'><a style='"+a+"' class='pag-next' href='javascript:"+j+"("+b+', "'+p+"\");'></a></li>";c+="</ul>";return c;}var playlist={paginationCount:7,copy:{sortByDate:"Senaste klippen",sortByViews:"Mest visat",sortByRating:"H&ouml;gst betyg",length:"L&auml;ngd",views:"Visningar",rating:"Betyg"},order:"posted",start:1,count:4,mode:1,playlistLink:null,imgcache:[],updateOrder:function(a,b){playlist.order=a;playlist.update(b);},updateStart:function(b,a){playlist.start=b;playlist.update(a);},update:function(b){var a;a=["title","mediaid","duration","downloads_started","rating","thumbnail"];setOpacity("video-list",50);var c=playlists.filters;var d=document.getElementById("search-textbox"+b);if(d){searchphrase=d.value;}if(playlist.mode==2&&searchphrase){document.getElementById("search_msg_box"+b).style.display="block";document.getElementById("search_input"+b).style.display="none";document.getElementById("search_msg_box"+b).innerHTML="<div id='search_msg_box_inner'><div class='search-message'><div class='result-for searchtext' id='search-message'>S&ouml;ker efter: "+searchphrase+"</div> <div id='closeSearch'><a href='javascript:playlist.mode=1;playlist.start=1;playlist.update('"+b+"');'></a></div></div></div>";ps.search(searchphrase,{count:playlist.count,start:playlist.start,order:playlist.order,fields:a},function(e){document.getElementById("search-message").innerHTML=e.count+" resultat f&ouml;r: "+document.getElementById("search-textbox"+b).value;playlist.display(e);});}else{if(d){d.value="";document.getElementById("search_msg_box"+b).style.display="none";document.getElementById("search_input"+b).style.display="block";}ps.listMedia({count:playlist.count,start:playlist.start,order:playlist.order,fields:a,filters:playlists[b].filters},function(e){playlist.display(e,b);});}},display:function(d,k){var f,c,o,a;playlist.media=d.media;var e=document.getElementById("video-list-pagination"+k);if(!e||!d.media){return;}e.innerHTML="";var j="";for(var f=0;f<d.media.length;f++){c=d.media[f];o=ps.parseDuration(c.duration);var h="";var g="<div class='star active'></div>";var p="";for(a=16;a<c.rating;a+=17){p+=g;}for(;a<100;a+=17){p+=h;}var l=playlist.copy;var b="";if(l.length!==0){var b="<span class='video-list-detail-length'>"+l.length+": <b>"+o.timestamp+"</b></span>";}var n="";if(l.views!==0){var n="<span class='video-list-detail-views'>"+l.views+": <b>"+c.downloads_started+"</b></span>";}j+="<div class='video-list-container'><a href='";if(playlist.playlistLink!==null){j+=playlist.playlistLink+"#"+c.mediaid;}else{j+='javascript:ps.activateMedia("'+c.mediaid+'")';}j+="'><div class='video-list-image thumb-blinds' style='width: 124px; height:93px;'><table cellpadding=0 cellspacing=0><tr height=93><td style='vertical-align: middle;'>";j+="<img src='"+c.thumbnail+"' style='max-width: 124px; max-height: 93px;'></tr></td></table></div><div class='video-list-details'><div class='video-list-heading themecolor'>"+c.title+"</div>";if(typeof c.description!=="undefined"){j+="<p>"+c.description+"</p>";}j+="<span class='video-list-info'>"+b+n+"<span class='video-list-detail-grade'><div class='rating-text'>"+l.rating+":</div>"+p+"</span></div></div></a></div>";}document.getElementById("video-list"+k).innerHTML=j;setOpacity("video-list"+k,100);if(d.count>d.media.length){e.innerHTML=makePagination(d.count,playlist.start,playlist.count,playlist.paginationCount,"playlist.updateStart",k);}},activateTab:function(f,a,d){var e=document.getElementById("tab1"+d);if(e){e.className="tab-heading";}var c=document.getElementById("tab2"+d);if(c){c.className="tab-heading";}var b=document.getElementById("tab3"+d);if(b){b.className="tab-heading";}f.className="selected-tab tab-heading-selected";playlist.updateOrder(a,d);},init:function(a){if(typeof a==="undefined"){a="";}playlist.renderHTML(a);var c="";var b={};ps.listCategories({filters:{}},function(j){for(i in j.categories){if(j.categories[i].categoryname==a){c=j.categories[i].categoryid;if(typeof c!=="undefined"){b={categoryid:c};}}}var h=new createPlaylistObj(a);h.filters=b;playlists[a]=h;var g=document.getElementById("tab1"+a);if(g){g.innerHTML=playlist.copy.sortByDate;}var f=document.getElementById("tab2"+a);if(f){f.innerHTML=playlist.copy.sortByViews;}var e=document.getElementById("tab3"+a);if(e){e.innerHTML=playlist.copy.sortByRating;}var d=["title","mediaid","duration","downloads_started","rating","thumbnail"];ps.listMedia({count:playlist.count,start:playlist.start,order:playlist.order,fields:d,filters:b},function(k){playlist.display(k,a);ps.activateMedia(location.hash.substr(1)||findParam("m","")||playlist.media[0].mediaid);});});},renderHTML:function(a){document.write('<div class="tabbed-panel"><ul class="tabs"><li id="tab1'+a+'" class="selected-tab tab-heading-selected" tabindex="0" onclick="playlist.activateTab(this, \'posted\', \''+a+'\')">Senaste klippen</li><li id="tab2'+a+'" class="tab-heading" tabindex="1" onclick="playlist.activateTab(this, \'downloads\', \''+a+'\')">Mest visat</li><li id="tab3'+a+'" class="tab-heading" tabindex="2" onclick="playlist.activateTab(this, \'rating\', \''+a+'\')">H&ouml;gst betyg</li></ul><div  class="tab-content"><div id="video-list'+a+'" class="video-list" ></div><div id="video-list-pagination'+a+'" class="pagination"></div></div></div>');}};function findParam(d,c){d=d.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var a=new RegExp("[\\?&]"+d+"=([^&#]*)");var b=a.exec(window.location.href);if(b==null){return c;}else{return b[1];}}function useHtml5(){return((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPad/i)));}var player={style:0,autoPlayFirst:false,autoPlaySpecific:true,init:function(){ps.addEventListener("mediaActivated",{fields:["mediaid"]},function(b){if(!b){return;}if(location.hash==""){var a=player.autoPlayFirst;}else{var a=player.autoPlaySpecific;}location.hash=b.mediaid;ps.embed({mediaid:b.mediaid,containerId:"mediaplayer",width:620,height:430,autoplay:a,player:"rutile"});});}};var clone=function(d,a){if(!(/array|object/.test(typeof d))){return d;}if(a===undefined){a=[];}for(var c in a){if(a[c][0]===d){return a[c][1];}}var e={};a.push([d,e]);for(var b in d){e[b]=clone(d[b],a);}return e;};var infoPanel={copy:{length:"L&auml;ngd",views:"Visningar",rating:"Betyg",download:"Ladda ner",sendToPhone:0},init:function(){var a=["title","description","duration","rating","downloads_started","downloadlink"];ps.addEventListener("mediaActivated",{fields:a},function(f){var c,l;l=ps.parseDuration(f.duration);var g='ps.assignRating("'+f.mediaid+'", {rating: ';var k="k";var n="l";var k="<div class='star active' onclick='"+g;var n="<div class='star inactive' onclick='"+g;var j="";var h=0;for(c=16;c<f.rating;c+=17){j+=k+h+"});'></div>";h+=25;}for(;c<100;c+=17){j+=n+h+"});'></div>";h+=25;}var d="";var e=infoPanel.copy;if(e.sendToPhone!==0){d="<div class='details-right'><img src='img/send-phone.png' width='21' height='23' class='float-left'><a href='javascript:void(0);'>"+e.sendToPhone+"</a></div>";}var b="";if(e.download!==0){b="<div class='details-right'><img src='img/download-icon.png' width='21' height='23' class='float-left'><a href='"+f.downloadlink+"'>"+e.download+"</div></a></div>";}document.getElementById("metavideo").innerHTML="<div class='descriptionbox'><div class='video-name themecolor'><h1>"+f.title+"</h1></div><p class='video-description'>"+f.description+"</p></div><div class='video-detail'><div class='video-length'>"+e.length+": <b>"+l.timestamp+"</b> </div><div class='video-views'>"+e.views+": <b>"+f.downloads_started+"</b></div><div class='video-rating'><div class='rating-text'>"+e.rating+":</div> "+j+"</div>"+d+b;});}};var recommendedVideos={paginationCount:20,copy:{recommendedVideos:"Rekommenderas",newVideos:"Nya",popularVideos:"Popul&auml;ra",topRated:"B&auml;st betyg",length:"L&auml;ngd",views:"Visningar",rating:"Betyg"},order:"posted",count:3,start:1,media:[],init:function(){document.getElementById("recommended-head").innerHTML=recommendedVideos.copy.recommendedVideos;document.getElementById("recommended-posted").innerHTML="<span></span>"+recommendedVideos.copy.newVideos;document.getElementById("recommended-downloads").innerHTML="<span></span>"+recommendedVideos.copy.popularVideos;document.getElementById("recommended-rating").innerHTML="<span></span>"+recommendedVideos.copy.topRated;recommendedVideos.display();},updateOrder:function(a){document.getElementById("recommended-"+recommendedVideos.order).className=document.getElementById("recommended-"+recommendedVideos.order).className.replace("active","");recommendedVideos.order=a;document.getElementById("recommended-"+recommendedVideos.order).className="active";recommendedVideos.display();},updateStart:function(a){recommendedVideos.start=a;recommendedVideos.display();},display:function(){var a,c,b;if(recommendedVideos.media.length>0){setOpacity("recommended-bottom",50);}a=["title","posted","mediaid","duration","downloads_started","rating","thumbnail"];c={properties:{recommended:"1"}};ps.listMedia({count:recommendedVideos.count,start:recommendedVideos.start,order:recommendedVideos.order,fields:a,filters:c},function(h){var j,g,o;recommendedVideos.media=h.media;var e="";for(var j=0;j<h.media.length;j++){g=h.media[j];o=ps.parseDuration(g.duration);var l="<div class='star inactive'>";var k="<div class='star active'>";var n="";for(r=16;r<g.rating;r+=17){n+=k;}for(;r<100;r+=17){n+=l;}var d=recommendedVideos.copy;var f=g.posted.substr(0,10);e+="<div class='recommended-video-container'><a href='javascript:ps.activateMedia(\""+g.mediaid+"\")'><div class='recommended-video-image'><table cellpadding=0 cellspacing=0 style='display:inline;'><tr height='93' class='thumb-blinds'><td style='vertical-align: middle;'><img src='"+g.thumbnail+"' style='max-width: 165px; max-height: 93px;'></tr></td></table></div><div class='recommended-video-title themecolor'>"+g.title+"</div><div class='recommended-video-date'>"+f+"</div><p>"+g.description+"</p><div class='recommended-video-details'>"+d.length+" "+o.timestamp+" | "+d.views+" "+g.downloads_started+" | "+d.rating+" "+n+"</div></a></div>";}document.getElementById("recommended-bottom").innerHTML=e;setOpacity("recommended-bottom",100);if(h.count>recommendedVideos.count){document.getElementById("recommended-pagination").innerHTML=makePagination(h.count,recommendedVideos.start,recommendedVideos.count,recommendedVideos.paginationCount,"recommendedVideos.updateStart",b);}});}};var pageDetails={logoLink:"http://about.picsearch.com",copy:{copyright:"Copyright PICSEARCH 2009-2010. All Rights Reserved.",title:"Picsearch Image Gallery"},init:function(){document.title=pageDetails.copy.title;document.getElementById("copyright").innerHTML=pageDetails.copy.copyright;document.getElementById("logolink").href=pageDetails.logoLink;}};function setOpacity(b,a){var c=document.getElementById(b);if(c){c.style.opacity=""+a/100;c.style.filter="alpha(opacity="+a+")";}}var playlists={};function createPlaylistObj(a){filters:{}}
