PARAMS={CATEGORY:{},tagwordUndefinedFromRange:50000000};PARAMS.CATEGORY={PAL:50,FRIEND:51,COMPUTER_SEARCH:69,LOCAL:20000000,PALS_MIX:20000001};PARAMS.SIZE={LEFT_PANEL_FRIENDS:4,SHOWCASE_SHARE:5,RESOLUTION_YOUTUBE_CONCURRANT_REQUEST:10,PLAYLIST_MORE_SONGS:12,PLAYLIST_START_SONGS:15,RANDOM_CACHE_SONGS:700};PARAMS.USER_PROGRESS={SHOWCASE:10};ENUM={READY:"ready",NOT_READY:"not_ready",LOADING:"loading"};PARAMS.ACHIEVEMENTS={SHOWCASE_N:7};function HashTable(c,b){this.length=0;this.items={};if(c){for(var a=0;a<c.length;a++){this.items[c[a][b]]=c[a];this.length++}}this.remove=function(d){if(this.items[d]!=undefined){this.length--;delete this.items[d]}};this.get=function(d){return this.items[d]};this.set=function(d,e){if(this.items[d]==undefined){this.length++}this.items[d]=e};this.sets=function(f,e){for(var d=0;d<f.length;d++){this.set(f[d][e],f[d])}};this.has=function(d){return(this.items[d]!=undefined)};this.clear=function(){for(var d in this.items){delete this.items[d]}this.length=0};this.each=function(d){var f=arguments[1];for(var e in this.items){d.call(f,e,this.items[e])}};this.copy=function(){var d=new HashTable();this.each(function(e,f){d.set(e,f)});return d};this.shift=function(){for(var d in this.items){var e=this.items[d];this.remove(d);return e}};this.keyToArray=function(){var d=[];this.each(function(e,f){d.push(e)});return d};this.valueToArray=function(){var d=[];this.each(function(e,f){d.push(f)});return d}}OrderHashTable=function(){this.array=new Array();this.items=new HashTable();this.length=0;this.push=function(a,b){this.array.push(a);this.items.set(a,b);this.length++};this.remove=function(a){}};function SortedArray(a,b){this.a=new Array();this.length=0;this.add=function(d){var e=this.getCloserIndex(d);if(e==-1){this.a.splice(0,0,d)}else{var c=e;while(c>0&&a(d,this.a[c])==0){if(b(d,this.a[c--])){return 0}}c=e+1;while(c<this.length&&a(d,this.a[c])==0){if(b(d,this.a[c++])){return 0}}this.a.splice(e,0,d)}this.length=this.a.length};this.getCloserIndex=function(e){var c=0;var f=this.length-1;while(f>=c){var d=Math.floor((c+f)/2);switch(a(e,this.a[d])){case 1:f=d-1;break;case 0:return d;break;case -1:c=d+1;break}}return Math.min(c,f)}}Utils={durationFormat:function(d){var b=new Date(d*1000);var a=b.getUTCHours();var c=b.getUTCMinutes();var e=b.getUTCSeconds();c=(c<10)?"0"+c:c;e=(e<10)?"0"+e:e;return(a==0)?c+":"+e:a+":"+c+":"+e},removeFromArray:function(d,a,c){for(var b=0;b<d.length;b++){if(d[b][a]==c){d.splice(b,1);break}}},isInArray:function(d,a,c){for(var b=0;b<d.length;b++){if(d[b][a]==c){return true}}return false},getArrayOfProperty:function(d,b){var a=new Array();for(var c=0;c<d.length;c++){a.push(d[c][b])}return a},removeDiacritics:function(d){if(d!=undefined){var c=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g,];var b=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"];for(var a=0;a<c.length;a++){d=d.replace(c[a],b[a])}}return d},log:function(a){if(typeof console!="undefined"){console.log(a)}},os:function(){var a="Unknown";if(navigator.appVersion.indexOf("Win")!=-1){a="Windows"}else{if(navigator.appVersion.indexOf("Mac")!=-1){a="Mac"}else{if(navigator.appVersion.indexOf("X11")!=-1){a="UNIX"}else{if(navigator.appVersion.indexOf("Linux")!=-1){a="Linux"}}}}return a},getDate:function(c){if(c!=undefined){var d=new RegExp("([0-9]+)-([0-9]+)-([0-9]+).([0-9]+):([0-9]+):([0-9]+)");var a=d.exec(c);var b=new Date();if(a&&a.length==7){return new Date(a[1],a[2]-1,a[3],a[4],a[5]-b.getTimezoneOffset(),a[6])}}return undefined}};Utils.ui={filter:function(a,b,e,g){var d="<li class='vux-filter data-tag body vux-hover-parent'>";d+="<ul class='vux-filter-actions vux-hover-child rightCol contentWidth clearFix'>";for(var c=0;c<e.length;c++){d+="<li class='element-float'>";d+="<button class='vux-control "+e[c]+"'";d+="<img src='/images/transparent.gif' class='vux-control-content' alt='"+e[c]+"'/>";d+="</button>";d+="</li>"}d+="</ul>";d+="<div class='main'>";d+="<span class='vux-filter-link "+b+"'>";d+=g;d+="</span>";d+="</div>";d+="</li>";var f=$(d);Data.insert(Data.types.tag,f,a);return f},tag:function(b,a){b.find(".vux-tag-content").html(a.content);b.find(".vux-category-content").html(a.category.content);Data.insert(Data.types.tag,b,a)},parentsOrChildren:function(b,a){b=b.closest(a);if(b.size()==0){b=b.find(a)}return(b.size()==0)?undefined:b},loadImage:function(a,e,c,b){a.attr("src","/images/transparent.gif");a.addClass(e);var d=function(f){a.removeClass(e);a.attr("src",f)};b(function(g){if(g!=null&&g!=""){var f=new Image();$(f).load(function(){d(g)}).error(function(i,h){d(c)}).attr("src",g)}else{d(c)}})},getFBImageSource:function(a){return"http://graph.facebook.com/"+a+"/picture"},getYoutubeThumbnailSource:function(a){return"http://i2.ytimg.com/vi/"+a+"/default.jpg"}};Utils.url={get:function(d){var c=window.location.hash.substring(1);var e=c.split("&");for(var b=0;b<e.length;b++){var a=e[b].split("=");if(a[0]==d){return(a[1]!=undefined)?a[1]:""}}return undefined}};function upperFirst(a){var b=a.substr(0,1);return b.toUpperCase()+a.substr(1)}function getPreNoun(b){var a=b.substr(0,1);if(a.toUpperCase()=="A"||a.toUpperCase()=="E"||a.toUpperCase()=="I"||a.toUpperCase()=="O"||a.toUpperCase()=="U"){return"an"}return"a"}function Observer(){this.fns=[]}Observer.prototype={subscribe:function(a){this.fns.push(a)},unsubscribe:function(a){this.fns=this.fns.filter(function(b){if(b!==a){return b}})},fire:function(e,d){var c=e||window;for(var a=0;a<this.fns.length;a++){var b=this.fns[a];b.call(c,d)}}};if(!Array.prototype.filter){Array.prototype.filter=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var e=new Array();var d=arguments[1];for(var c=0;c<a;c++){if(c in this){var f=this[c];if(b.call(d,f,c,this)){e.push(f)}}}return e}}if(!Array.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}}Array.prototype.shuffle=function(){var a;var c;for(var b=0;b!=this.length;b++){c=Math.floor(Math.random()*this.length);a=this[b];this[b]=this[c];this[c]=a}};if(!Array.prototype.forEach){Array.prototype.forEach=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var d=arguments[1];for(var c=0;c<a;c++){if(c in this){b.call(d,this[c],c,this)}}}}JSON={encode:function(b){switch(b.constructor){case String:return'"'+b+'"';case Number:return b.toString();case Array:var c=[];for(var d=0;d<b.length;d++){c.push(JSON.encode(b[d]))}return"["+c.join(",")+"]";case Object:var c=[];for(var a in b){c.push('"'+a+'": '+JSON.encode(b[a]))}return"{"+c.join(",")+"} ";default:return"null"}}};Log={url:"data/log",search:"?debug",active:false,popUp:undefined,init:function(){if(window.location.search==this.search){this.active=true;this.popUp=window.open("","name","height=400,width=500");this.popUp.document.write("<html><head><title>Voxound Debug console</title>");this.popUp.document.write('</head><body><div style="overflow:scroll; height:100%;">');this.popUp.document.write('<table id="trace"></table>');this.popUp.document.write("</div></body></html>");this.popUp.document.close()}},trace:function(h,a,d){if(this.active){var i=new Date();var j=this.popUp.document.getElementById("trace");var k=document.createElement("TR");var g=document.createElement("TD");var f=document.createElement("TD");var c=document.createElement("TD");var b=document.createElement("TD");g.appendChild(document.createTextNode(i.getMinutes()+":"+i.getSeconds()+":"+i.getMilliseconds()));f.appendChild(document.createTextNode(h));c.appendChild(document.createTextNode(a));b.appendChild(document.createTextNode(d));k.appendChild(g);k.appendChild(f);k.appendChild(c);k.appendChild(b);j.appendChild(k)}else{if(typeof console!="undefined"){var i=new Date();var e=i.getMinutes()+":"+i.getSeconds()+":"+i.getMilliseconds();console.log(e+" - "+h+" - "+a+" - "+d)}}}};function Song(a){this.id=a.id;this.vxRecognized=true;this.releaseId=a.releaseId;this.artist=a.artist;this.album=a.album;this.title=a.title;this.track=a.track;this.disc=a.disc;this.official=a.official;this.tags=new HashTable();this.isBookmarked=Showcase.hasSong(this.id);this.audio=new HashTable();this.lyric=undefined;this.friendId=a.friend;this.dateAdded=a.dateAdded;if(this.id<1){this.vxRecognized=false}}Song.prototype.getSongInfo=function(){var a=this;if(!this.lyric){Frontera.lyrics(a,function(b){a.lyric=b;SongUtils.onSongChange.fire(a,"lyric")})}};Song.prototype.setAudioResource=function(c,a,b){this.audio.set(c,{type:a,resource:b});if(b!=null){SongUtils.onSongChange.fire(this,"newAudioSource")}};Song.prototype.editTagwords=function(e){if(this.vxRecognized){var a=this;var d=this.tags.copy();var c=new HashTable();for(var b=0;b<e.length;b++){if(this.tags.has(e[b])){d.remove(e[b])}else{c.set(e[b],Tagwords.get(e[b]))}}if(c.length>0){Facelib.doWithPermission("",function(){Frontera.link(a,c.keyToArray(),true,function(){})});c.each(function(f,g){a.tags.set(f,g)})}if(d.length>0){Facelib.doWithPermission("",function(){Frontera.link(a,d.keyToArray(),false,function(){})});d.each(function(f,g){a.tags.remove(f)})}}};Song.prototype.getAudioResourceByType=function(a){var b=undefined;this.audio.each(function(c,d){if(d.type==a){b=d.resource}});return b};SongOwnerContainer=function(a){this.song=a.song;this.owner=a.owner;this.dateAdded=a.dateAdded};SongUtils={onSongChange:new Observer(),passSongThroughFilter:function(b,d){if(b.artist&&b.artist.id!=d.artist.id){return false}if(b.album&&b.album.id!=d.album.id){return false}if(b.title&&b.title.id!=d.title.id){return false}for(var a=0;a<b.tagwords_all.length;a++){var c=Math.abs(b.tagwords_all[a]);var e=d.tags.has(c);if((b.tagwords_all[a]<0&&e)||(b.tagwords_all[a]>0&&!e)){return false}}return true},serverDataToSongList:function(e){var h=new Array();if(e){for(var f=0;f<e.length;f++){var d=new Song({id:parseInt(e[f][0]),release_id:parseInt(e[f][1]),artist:new Tag({id:parseInt(e[f][5]),content:e[f][2],category:Categories.get(1)}),album:new Tag({id:parseInt(e[f][7]),content:e[f][4],category:Categories.get(3)}),title:new Tag({id:parseInt(e[f][6]),content:e[f][3],category:Categories.get(2)}),track:e[f][10],disc:e[f][9],official:(e[f][11]==1)?true:false,friend:(e[f][12])?e[f][12]:undefined});d.releaseId=-1;if(!d.vxRecognized){d.id=Math.round(Math.random()*1000000)+10000000}var a=e[f][8]||[];if(typeof a==="string"){a=a.split(",")}for(var b=0;b<a.length;b++){var m=a[b];if(m&&m!=""){var o=Tagwords.get(m);if(o!=undefined){d.tags.set(o.id,o)}else{alert("Ocurrió el error del tag desconocido. ¡Avísale a los desarroladores!")}}}if(e[f][13]!=undefined){for(var c=0;c<e[f][13].length;c++){var l=e[f][13][c];if(l[2]&&l[2]!=""&&l[2]!="0"){d.audio.set(l[0],{type:l[1],resource:l[2]})}}}if(e[f][14]!=undefined){var n=new RegExp("([0-9]+)-([0-9]+)-([0-9]+).([0-9]+):([0-9]+):([0-9]+)");var g=n.exec(e[f][14]);if(g&&g.length==7){d.dateAdded=new Date(g[1],g[2]-1,g[3],g[4],g[5],g[6])}}h.push(d)}}return h},getParameters:function(b,c,d){if(!d){var a=new Object();a.limit=c;if(b.isFixedInfoSelected){a.info=[];a.info[0]=(b.artist==undefined)?0:b.artist.id;a.info[1]=(b.title==undefined)?0:b.title.id;a.info[2]=(b.album==undefined)?0:b.album.id}if(b.tagwords_all.length>0){a.tags=b.tagwords_all}if(b.users.length>0){a.users=b.users}return{params:a}}else{var a=[[],[],[],c];if(b.isFixedInfoSelected){a[0][0]=(b.artist==undefined)?0:b.artist.id;a[0][1]=(b.title==undefined)?0:b.title.id;a[0][2]=(b.album==undefined)?0:b.album.id}a[1]=b.tagwords_all;a[2]=b.users;return{data:a}}}};function Category(a){this.id=a.id;this.content=a.content}function Tag(a){this.id=(typeof(a.id)=="string")?parseInt(a.id):a.id;this.vxRecognized=(this.id<PARAMS.tagwordUndefinedFromRange)?true:false;this.content=a.content;this.category=a.category;this.tagslate=a.tagslate}Tag.prototype.compare=function(a){return(a==undefined||a.id==undefined||a.id!=this.id)?false:true};function Selection(){this.elements=new Array();this.isRandom=undefined;this.pseudoId=undefined;this.isEmpty=true;this.vxRecognized=true;this.isFixedInfoSelected=false;this.isUserSelected=false;this.isComputerSelected=false;this.isTagwordSelected=false;this.isAllFriendsSelected=false;this.artist=undefined;this.album=undefined;this.title=undefined;this.tagwords_all=new Array();this.tagwords_pos=new Array();this.tagwords_all_unsigned=new Array();this.users=new Array();this.fbUserId=undefined}Selection.prototype.addElement=function(c){var a;if(c.tag.category.id<=3){for(var b=0;b<this.elements.length;b++){if(c.tag.category.id==this.elements[b].tag.category.id){a=this.elements.splice(b,1);break}}}this.elements.push(c);return(a)?a[0]:undefined};Selection.prototype.removeElement=function(b){for(var a=0;a<this.elements.length;a++){if(this.elements[a].tag.id==b){this.elements.splice(a,1)}}};Selection.prototype.copy=function(){var a=new Selection();a.elements=this.elements.slice(0);a.isRandom=this.isRandom;return a};Selection.prototype.getPseudoId=function(){if(!this.isEmpty){var b=new Array();for(var a=0;a<this.elements.length;a++){if(this.elements[a].sign){b.push(this.elements[a].tag.id)}else{b.push(-this.elements[a].tag.id)}}return b.sort(function(d,c){return d-c}).toString()}return""};Selection.prototype.toggleRandom=function(){this.isRandom=!this.isRandom};Selection.prototype.getDescription=function(){var b="";if(!this.isEmpty){b=(this.elements[0].sign)?"+ ":"- ";b+=this.elements[0].tag.content;for(var a=1;a<this.elements.length;a++){b+=((this.elements[a].sign)?" + ":" - ")+this.elements[a].tag.content}}return b};Selection.prototype.updateProperties=function(){if(this.elements.length!=0){this.isEmpty=false}for(var c=0;c<this.elements.length;c++){var a=this.elements[c].tag;var b=this.elements[c].sign;if(!a.vxRecognized){this.vxRecognized=false}if(a.id==PARAMS.CATEGORY.LOCAL){this.isComputerSelected=true}else{if(a.id==PARAMS.CATEGORY.PALS_MIX){this.isAllFriendsSelected=true}else{if(a.category.id==PARAMS.CATEGORY.PAL){this.users.push(a.id);if(Showcase.tag&&a.id==Showcase.tag.id){this.isUserSelected=true}}else{if(a.category.id==PARAMS.CATEGORY.FRIEND){this.users.push(a.id);this.fbUserId=a.id}else{if(a.category.id==PARAMS.CATEGORY.COMPUTER_SEARCH||a.category.id>500){this.isTagwordSelected=true;this.tagwords_all.push(((b)?1:-1)*a.id);this.tagwords_all_unsigned.push(a.id);if(b){this.tagwords_pos.push(a.id)}}else{this.isFixedInfoSelected=true;if(a.category.id==1){this.artist=a}if(a.category.id==2){this.title=a}if(a.category.id==3){this.album=a}}}}}}}if(this.isAllFriendsSelected){if(this.isRandom==undefined){this.isRandom=false}}else{if((this.artist!=undefined&&this.album!=undefined)){this.isRandom=false}else{this.isRandom=true}}this.pseudoId=this.getPseudoId()};Selection.prototype.getLink=function(){var e="http://"+window.location.host+"/#";if(!this.isEmpty){var d=(Showcase.tag&&Showcase.tag.id==this.elements[0].tag.id)?Facelib.user.name:this.elements[0].tag.content;var c=this.elements[0].tag.id;var a=this.elements[0].tag.category.id;for(var b=1;b<this.elements.length;b++){c+=","+this.elements[b].tag.id;a+=","+this.elements[b].tag.category.id;d+="/"+(Showcase.tag&&Showcase.tag.id==this.elements[b].tag.id)?Facelib.user.name:this.elements[0].tag.content}e+="songs/"+d+"?id="+c+"&cat="+a}return e};function property(c){this.value=c;this._thriggers=[];var b=[];var a=this;function d(f){var e=(jQuery.isFunction(f.value))?f.value(a.value):a.value==f.value;$("#"+f.domId).toggleClass(f.className,e)}this.classTemp=function(){for(var e=0;e<b.length;e++){d(b[e])}};this.addClass=function(h,f,g){var e={domId:h,className:f,value:g};b.push(e);d(e)};this.observer=new Observer();this.onChange=function(e){this.observer.subscribe(e)}}property.prototype.bind=function(b,a,e,d){var c=this;$(b).live("click",function(){c.set($(this).attr(a))});this.onChange(function(f){if(f.newValue==e){$(b).attr(a,d)}else{$(b).removeAttr(a)}})};property.prototype.addTrigger=function(b){var a=arguments[1]||window;if(b.constructor!=Array){b=[b]}b.forEach(function(c){this._thriggers.push([c.callback,c.value||c.comparer,a])},this)};property.prototype.set=function(b){var a=this.value;if(this.value!=b){this.value=b;this._thriggers.forEach(function(c){if(typeof c[1]==="function"){if(c[1](this.value)){c[0].call(c[2])}}else{if(c[1]==this.value){c[0].call(c[2])}}},this);this.observer.fire(this,{oldValue:a,newValue:b});this.classTemp()}};property.prototype.bindClass=function(a,b){if(b.constructor!=Array){b=[b]}b.forEach(function(c){this.addTrigger({comparer:function(){return true},callback:function(){var d=(c.comparer)?c.comparer(this.value):(c.value==this.value);a.toggleClass(c.className,d)}},this)},this)};function fbInfo(a){this.id;this.name;this.picture;this.fillData({})}fbInfo.prototype.fillData=function(a){this.id=a.id;this.name=a.name;this.picture=a.picture};jQuery.fn.balloonTip=function(a){a=jQuery.extend({htmlContent:"<div>Here goes the tip content</div>",position:"bottom",startHidden:false},a);var c=function(f,d,e){switch(e){case"top":d.css("top",f.offset().top-d.outerHeight());d.css("left",f.offset().left);break;case"right":d.css("top",f.offset().top);d.css("left",f.offset().left+f.outerWidth());break;case"bottom":d.css("top",f.offset().top+f.outerHeight());d.css("left",f.offset().left);break;case"left":d.css("top",f.offset().top);d.css("right",$("body").width()-f.offset().left);break;default:break}};var b=function(d){d.hide()};this.each(function(){var d=$(this);var g=$("<div class='balloon'></div>");var e=$("<div class='balloonArrow'></div>");var h=$("<div class='balloonContentWrapper'></div>");if(a.customClass){g.addClass(a.customClass)}if(a.startHidden){g.css("display","none")}if(a.timeDelay){g.css("display","none");setTimeout("$('#"+$(this).attr("id")+"').showBalloonTip();",a.timeDelay)}if(a.onClick){g.bind("click",function(i){a.onClick(i)})}var f=$("<div class='close'>x</div>");h.append(f);c($(this),g,a.position);h.append(a.htmlContent);g.append(h);switch(a.position){case"top":g.addClass("arrowBottom");g.append(e);break;case"right":g.addClass("arrowLeft");g.prepend(e);break;case"bottom":g.addClass("arrowTop");g.prepend(e);break;case"left":g.addClass("arrowRight");g.append(e);break;default:break}$("body").append(g);$(window).resize(function(){c(d,g,a.position)});f.click(function(){b(g);if(a.onClose){a.onClose()}});$(this).bind("showBalloonTip",function(){c($(this),g,a.position);g.fadeIn(200)});$(this).bind("hideBalloonTip",function(){g.fadeOut(200)})})};jQuery.fn.showBalloonTip=function(){return this.trigger("showBalloonTip")};jQuery.fn.hideBalloonTip=function(){return this.trigger("hideBalloonTip")};EnableTooltips={isWaitingTooltip:false,isShowingTooltip:false,jqTooltipedElement:undefined,tooltipContent:undefined,tooltipTimer:undefined,isTooltipDown:false,jqTooltipWrapper:$("<div class='tooltip'><div class='tooltipArrow'></div></div>"),jqTooltipContent:$("<div class='tooltipContent'>Tooltip Content</div>"),init:function(){this.jqTooltipWrapper.css("position","absolute");this.jqTooltipWrapper.css("z-index","55000");$(".hasTooltip").live("mouseover mouseout mousedown",function(a){if(a.type=="mouseover"){if(!EnableTooltips.isWaitingTooltip){EnableTooltips.jqTooltipedElement=$(this);EnableTooltips.jqTooltipedElement.attr("title","");if(EnableTooltips.jqTooltipedElement.attr("data-tooltip-title")!==undefined){EnableTooltips.tooltipContent=EnableTooltips.jqTooltipedElement.attr("data-tooltip-title")}EnableTooltips.isWaitingTooltip=true;EnableTooltips.tooltipTimer=setTimeout("EnableTooltips.showTooltip();",250)}}else{if(a.type=="mouseout"||a.type=="mousedown"){if(EnableTooltips.isWaitingTooltip){clearTimeout(EnableTooltips.tooltipTimer);EnableTooltips.isWaitingTooltip=false;EnableTooltips.tooltipContent=undefined}else{if(EnableTooltips.isShowingTooltip){$(".tooltip").remove();EnableTooltips.jqTooltipedElement.attr("title",EnableTooltips.tooltipContent);EnableTooltips.isShowingTooltip=false}}}}})},showTooltip:function(){var a=(this.jqTooltipedElement.offset().top>this.jqTooltipedElement.outerHeight()+5)?false:true;this.jqTooltipContent.html(this.tooltipContent);if(a){this.jqTooltipWrapper.append(this.jqTooltipContent);this.jqTooltipWrapper.toggleClass("down",true);this.jqTooltipWrapper.toggleClass("up",false)}else{this.jqTooltipWrapper.prepend(this.jqTooltipContent);this.jqTooltipWrapper.toggleClass("down",false);this.jqTooltipWrapper.toggleClass("up",true)}$("body").append(this.jqTooltipWrapper);if(a){this.jqTooltipWrapper.css("top",this.jqTooltipedElement.offset().top+this.jqTooltipWrapper.outerHeight()-12)}else{this.jqTooltipWrapper.css("top",this.jqTooltipedElement.offset().top-this.jqTooltipWrapper.outerHeight()-5)}this.jqTooltipWrapper.css("left",this.jqTooltipedElement.offset().left-this.jqTooltipWrapper.outerWidth()/2+this.jqTooltipedElement.outerWidth()/2);this.jqTooltipWrapper.hide();this.jqTooltipWrapper.fadeIn(200);this.isWaitingTooltip=false;this.isShowingTooltip=true}};jQuery.fn.labeledInput=function(a){a=jQuery.extend({label:"Here goes the label content"},a);this.each(function(){var d=$(this);var c=$("<div class='labeledInput'></div>");var b=$("<label class='labeledInputLabel'></label>");b.attr("for",d.attr("id"));var e=$("<span></span>");d.addClass("labeledInputInput");if(a.customClass){c.addClass(a.customClass)}e.html(a.label);d.after(c);b.append(e);c.append(b);c.append(d);$(d).focus(function(){if($(this).val()==""){$(b).animate({opacity:0.5},500)}});$(d).blur(function(){if($(this).val()==""){$(b).animate({opacity:1},500)}});$(d).keyup(function(){if($(this).val()!=""){$(b).animate({opacity:0},0)}if($(this).val()==""){$(b).animate({opacity:0.5},0)}});$(d).click(function(){$(this).focus()})})};Animations={};Animations.bounceAndRotate=function(a){this.jq=a;this.interval=undefined;if(Modernizr.cssanimations){this.jq.toggleClass("vux-animation-bounce-n-rotate",true)}else{this.interval=window.setInterval(function(){a.effect("bounce",{},500)},5000);this.jq.toggleClass("vux-highlight-shadow",true)}};Animations.bounceAndRotate.prototype.stop=function(){if(Modernizr.cssanimations){this.jq.toggleClass("vux-animation-bounce-n-rotate",false)}else{window.clearInterval(this.interval);this.jq.toggleClass("vux-highlight-shadow",false)}};CurrentSelection={onChange:new Observer(),selection:new Selection(),init:function(){},setSelection:function(a){if(a.constructor===Array){var b=new Selection();a.forEach(function(c){b.addElement({tag:c,sign:true})});b.updateProperties();a=b}this.selection=a;this.onChange.fire(this,{})},addItem:function(a,b){var e=false;for(var c=0;c<this.selection.elements.length;c++){if(this.selection.elements[c].tag.id==a.id){e=true}}if(!e){var d=this.selection.copy();d.addElement({tag:a,sign:b});d.updateProperties();this.setSelection(d)}},removeItem:function(b){var a=this.selection.copy();a.removeElement(b);a.updateProperties();this.setSelection(a)},clear:function(){var a=new Selection();a.updateProperties();this.setSelection(a)},loadFromUrl:function(){if(Url.type=="songs"&&Url.obj){this.setSelection([Url.obj])}}};Player={player:undefined,song:undefined,audioType:undefined,volume:80,status:new property(),_seekTo:0,_solvingError:false,resources:{youtube:undefined,url:undefined},songChanged:new Observer(),audioChanged:new Observer(),init:function(){Players.onStoped.subscribe(function(){if(Player.song){Poke.songEnds(Player.song)}Player.next()});Players.onError.subscribe(function(){if(Player.audioType=="youtube"&&!Player._solvingError){Player._solvingError=true;Resolvers.youtube.getIds(Player.song,function(b,a){if(a.length>0){Player.changeResource("youtube",a[0])}},Player)}});SongUtils.onSongChange.subscribe(function(a){if(a=="newAudioSource"&&Player.song&&Player.song.id==this.id){if(!Player.resources.url&&Player._getResource("url")){Player._loadResource("url",Player._getResource("url"))}if(!Player.resources.youtube&&Player._getResource("youtube")){Player._loadResource("youtube",Player._getResource("youtube"))}}})},_securePlay:function(){var a=true;if(this.status.value==this.E_status.play){if(this.resources[this.audioType]&&this.player.isReady()){this._stopEverything();if(this.player.play()){Poke.songStarts(this.song);this.player.volume(this.volume);this.player.position(this._seekTo)}else{a=false}}else{a=false}}if(!a){setTimeout("Player._securePlay();",500)}},_loadResource:function(b,c){var d=true;if(b&&c){var a=(b=="url")?Players.soundManager:Players.youtube;if(a.isReady()&&a.load(c)){this.resources[b]=c}else{d=false}}if(!d){setTimeout("Player._loadResource('"+b+"', '"+c+"');",500)}},_stopEverything:function(){if(Players.soundManager.isReady()){Players.soundManager.stop()}if(Players.youtube.isReady()){Players.youtube.stop()}},_getResource:function(a){var b;this.song.audio.each(function(c,d){if(a==d.type){b=d.resource}});return b},_setAudioType:function(a){if(a=="url"){this.player=Players.soundManager;this.audioType="url"}else{this.player=Players.youtube;this.audioType="youtube"}},play:function(b){if(this.player&&this.player.isReady()&&Account.status.value==ENUM.READY){Frontera.played(this.song.id,this.player.duration(),this.player.position())}this.status.set(this.E_status.play);if(b!=undefined){this.song=b;this.player=undefined;this.audioType=undefined;this._solvingError=false;var c=this._getResource("url");var a=this._getResource("youtube");if(c||a){this._setAudioType((c)?"url":"youtube");this._seekTo=0;if(c){this._loadResource("url",c)}if(a){this._loadResource("youtube",a)}this.songChanged.fire(this,this.song)}this._securePlay()}else{if(this.player.isReady()&&this.resources[this.audioType]){this.player.play()}}},changeResource:function(a,b){if(a){if((b==undefined&&this.audioType==a)||(b&&this.audioType[a]==b)){return}this._seekTo=(this.player)?this.player.position():0;this._setAudioType(a);if(b!=undefined){this._loadResource(a,b)}this._securePlay();this.audioChanged.fire(this,{})}},next:function(){Playlist.getSong("next")},prev:function(){if(this.player.position()<3){Playlist.getSong("prev")}else{this.player.position(0)}},pause:function(){if(this.player&&this.status.value==this.E_status.play){this.player.pause();this.status.set(this.E_status.pause)}},togglePlay:function(){if(this.status.value==this.E_status.play){this.pause()}else{this.play()}},jumpTo:function(a){if(this.player){this.player.position(a)}},setVolume:function(a){if(this.player){this.player.volume(a)}this.volume=a}};Player.E_status={play:"play",pause:"pause"};Extension={tag:undefined,isLoading:new property(),installStatus:new property(),onStatsChange:new Observer(),onCometResolution:new Observer(),init:function(){this.tag=Tagwords.special.computer;if(Utils.os()=="Windows"||Utils.os()=="Mac"){this.searchInstallation(function(){})}ContentManager.isAppStarted.onChange(function(a){if(a.newValue==true){if(Extension.installStatus.value==Extension.E_Status.notInstalled){$(document).keydown(function(b){if(b.keyCode==176){Player.next()}if(b.keyCode==177){Player.prev()}if(b.keyCode==179){Player.togglePlay()}})}}});this.installStatus.onChange(function(a){Log.trace("Extension","installStatus",a.newValue)})},searchInstallation:function(){var a=this;if(a.installStatus.value==a.E_Status.notInstalled){a.installStatus.set(a.E_Status.installing)}else{if(a.installStatus.value==a.E_Status.launcherUpdateNeeded){a.installStatus.set(a.E_Status.updating)}}PeWon.status(function(b){if(b!=undefined){PeWon.version(function(c){if(Extension.isUpdate(c,"launcher")){if(!Extension.isUpdate(c,"pack")){if(a.installStatus.value==undefined){PeWon.restart();a.installStatus.set(a.E_Status.updating)}setTimeout("Extension.searchInstallation();",2000)}else{if(a.installStatus.value==a.E_Status.installing){a.installStatus.set(a.E_Status.fakeLoading)}else{a.installStatus.set(a.E_Status.installed);a.stats.processStats(b);PeWon.comet(-1)}}}else{if(a.installStatus.value==a.E_Status.updating){setTimeout("Extension.searchInstallation();",2000)}else{a.installStatus.set(a.E_Status.launcherUpdateNeeded);Log.trace("extension","version","current: "+c.launcher)}}})}else{a.isLoading.set(false);if(a.installStatus.value==undefined){a.installStatus.set(a.E_Status.notInstalled)}else{if(a.installStatus.value==a.E_Status.installing||a.installStatus.value==a.E_Status.updating){setTimeout("Extension.searchInstallation();",2000)}else{alert("Error tipo: "+a.installStatus.value+". Por favor refrescar voxound")}}}})},isUpdate:function(a,b){if(window.location.search=="?oaxaca"){return true}if(a==undefined){return false}var c;switch(Utils.os()){case"Windows":c="win32";break;case"Mac":c="mac";break}if(c){return(jsVersions[b][c]="0.0.0.0"||jsVersions[b][c]==a[b])}return true},cometHandler:function(c){var a=this;if(c==undefined){setTimeout("PeWon.comet(-1);",300)}else{for(var b=0;b<c.msg.length;b++){switch(c.msg[b][0]){case"media_key":switch(c.msg[b][1]){case"play":Player.togglePlay();break;case"rwnd":Player.prev();break;case"frwd":Player.next();break}break;case"state":a.stats.processStats(c.msg[b][1]);break;default:a.onCometResolution.fire(a,c.msg[b]);break}}setTimeout("PeWon.comet("+(c.id)+");",0)}}};Extension.E_Status={installing:"installing",installed:"installed",notInstalled:"notInstalled",fakeLoading:"fakeLoading",launcherUpdateNeeded:"launcherUpdateNeeded",updating:"updating"};Extension.stats={recognized:0,pending:0,notRecognized:0,processStats:function(a){this.pending=a.synch_st.pend+a.synch_st.qued+a.synch_st.quef;this.recognized=a.synch_st.reco;this.notRecognized=a.synch_st.notr;Extension.isLoading.set((a.search||a.scan>0||this.pending>0));Extension.onStatsChange.fire(Extension,{})}};Tagwords={hash:new HashTable(),array:new Array(),fixed:new Array(),radios:[],init:function(){if(jsTags){for(var b in jsTags){var a=new Tag({id:parseInt(b),content:jsTags[b][0],category:Categories.get(jsTags[b][1]),tagslate:(jsTags[b][2])?jsTags[b][2]:jsTags[b][0]});this.hash.set(a.id,a);this.array.push(a);if(a.category.id>1000){this.fixed.push(a)}else{if(a.category.id==666){this.radios.push(a)}}}delete jsTags}this.special.computer.category=Categories.get(50);this.special.allFriends.category=Categories.get(50);this.special.therapy.category=Categories.get(50);this.hash.set(this.special.computer.id,this.special.computer);this.hash.set(this.special.allFriends.id,this.special.allFriends);this.hash.set(this.special.therapy.id,this.special.therapy)},get:function(a){return this.hash.get(a)},getRange:function(c){var a=new Array();for(var b=0;b<c.length;b++){a.push(this.hash.get(c[b]))}return a}};Tagwords.special={computer:new Tag({id:PARAMS.CATEGORY.LOCAL,content:jsLang.computer}),allFriends:new Tag({id:PARAMS.CATEGORY.PALS_MIX,content:jsLang.all_friends}),therapy:new Tag({id:4584070,content:jsLang.therapy})};Categories={hash:new HashTable(),init:function(){for(var a=0;a<jsCategories.length;a++){this.hash.set(parseInt(jsCategories[a].id),new Category({id:parseInt(jsCategories[a].id),content:jsCategories[a].content}))}delete jsCategories;this.hash.set(PARAMS.CATEGORY.PAL,new Category({id:PARAMS.CATEGORY.PAL,content:"user"}));this.hash.set(PARAMS.CATEGORY.FRIEND,new Category({id:PARAMS.CATEGORY.FRIEND,content:"friend"}));this.hash.set(PARAMS.CATEGORY.COMPUTER_SEARCH,new Category({id:PARAMS.CATEGORY.COMPUTER_SEARCH,content:"asdf"}))},get:function(a){return this.hash.get(a)}};Showcase={_songsTemp:[],songOwners:new HashTable(),tag:new Tag({}),ready:new property(),onChange:new Observer(),init:function(){Showcase.ready.set(false);Account.status.addTrigger([{value:ENUM.READY,callback:function(){this.tag.id=Facelib.user.name_id;this.tag.content=jsLang.showcase;this.tag.category=Categories.get(50);this.tag.vxRecognized=true;Account.rawData.songs.forEach(function(a){var b=new SongOwnerContainer({song:SongUtils.serverDataToSongList([a])[0],dateAdded:Utils.getDate(a[14]),owner:this.tag});b.song.isBookmarked=true;this.songOwners.set(b.song.id,b)},this);Tagwords.hash.set(this.tag.id,this.tag);this._songsTemp.forEach(function(a){this._addSong(a)},this);this._songsTemp=[];this.ready.set(true)}},{value:ENUM.NOT_READY,callback:function(){this.tag=new Tag({});this.songOwners.clear();this.ready.set(false);this._songsTemp=[]}}],this)},hasSong:function(a){return this.songOwners.has(a)},totalSongs:function(){return this.songOwners.length},removeSong:function(b){var a=this.songOwners.get(b.id);if(a){Frontera.bookmark({song:b,sign:-1,callback:function(c){if(!c){Facelib.logout();Facelib.login()}}});this.songOwners.remove(b.id);b.isBookmarked=false;this.onChange.fire(this,b)}},addSong:function(b,a){if(Player.song.id==b.id&&Player.resources.youtube){b.audio.each(function(c,d){if(d.type=="youtube"){d.resource=Player.resources.youtube}})}if(b.vxRecognized&&!this.hasSong(b.id)){if(this.ready.value){this._addSong(b);this.onChange.fire(this,b)}else{Showcase._songsTemp.push(b)}Facelib.secureAction(function(c){Frontera.bookmark({song:b,sign:1,inspirer:a,callback:c})},function(){},function(){},this)}},updateAudioResource:function(c,a,b){if(this.songOwners.has(c.id)){var d=this.songOwners.get(c.id).song;if(d){d.audio.each(function(e,f){if(f.type==a){f.resource=b}});Frontera.updateAudioResource(d,b,function(){})}}},_addSong:function(b){var a=new SongOwnerContainer({song:b,dateAdded:new Date(),owner:this.tag});b.isBookmarked=true;this.songOwners.set(b.id,a)}};Friends={songOwners:new HashTable(),tag:undefined,songs:[],hash:new HashTable(),fb:new HashTable(),vx:new HashTable(),ready:new property(),alone:new property(),mixPals:new HashTable(),init:function(){this.tag=Tagwords.special.allFriends;this.reset();Account.status.addTrigger([{value:ENUM.NOT_READY,callback:function(){this.reset()}}],this);Showcase.ready.onChange(function(a){if(a.newValue){Facelib.rawData.pals.forEach(function(c,b){this.fb.set(c.name_id,c.fb_id);this.vx.set(c.fb_id,c.name_id)},Friends);Friends.extendTagwords();Facelib.rawData.pal_songs.forEach(function(b){var c=new SongOwnerContainer({song:SongUtils.serverDataToSongList([b])[0],dateAdded:Utils.getDate(b[14]),owner:Tagwords.get(b[12])});if(c.owner&&!this.songOwners.has(c.song.id)){this.songOwners.set(c.song.id,c);this.songs.push(c.song)}},Friends);Friends.fixSongs();Friends.fb.each(function(c,b){this.mixPals.set(c,Tagwords.get(c))},Friends);Friends.excludePal(Showcase.tag);Friends.ready.set(true);Friends.alone.set((Friends.vx.length==1&&Friends.vx.has(1)))}})},reset:function(){this.ready.set(false);this.alone.set(undefined);this.songs=[];this.songOwners.clear();this.fb.clear();this.hash.clear()},extendTagwords:function(){var a=new HashTable();Facelib.friends.forEach(function(b){a.set(b.id,b.name)});this.fb.each(function(b,c){Tagwords.hash.set(b,new Tag({id:b,content:a.get(c),category:Categories.get(50)}))})},fixSongs:function(){var a=new HashTable();var b=new HashTable();var c=[];this.songs.forEach(function(e,d){if(!b.has(e.id)){var f=this.songOwners.get(e.id).owner.id;if(!a.has(f)){a.set(f,0)}var g=a.get(f);if(g<25){a.set(f,++g);b.set(e.id,e);c.push(e)}}},this);this.songs=c},includePal:function(a){this.mixPals.set(a.id,a)},excludePal:function(a){this.mixPals.remove(a.id)}};Friends.pals=new HashTable();Friends.fbFriends=new HashTable();Facelib={rawData:undefined,user:undefined,friends:[],friendsHash:new HashTable(),sessionId:undefined,perms:undefined,loginStatus:new property(-1),userStatus:new property(-1),init:function(){var a=this;this.loginStatus.onChange(function(b){if(b.newValue==1){Facelib.userStatus.set(0);a.userInit()}else{if(b.newValue==-1){a.rawData=undefined;a.user=undefined;a.friends=[];a.friendsHash.clear();Facelib.userStatus.set(-1)}else{if(b.newValue==0){Facelib.userStatus.set(0)}}}Log.trace("facelib","loginStatus",b.newValue)});this.userStatus.onChange(function(b){Log.trace("facelib","userStatus",b.newValue)});Facelib.loginStatus.set(0);this._checkFbStatus()},_checkFbStatus:function(){if(this.loginStatus.value==0){Log.trace("Facelib","_checkFbStatus","true");FB.getLoginStatus(function(a){Facelib.loginStatus.set((a.session)?1:-1)})}},userInit:function(){Frontera.userInit(function(b){if(true){if(b==null){alert("ooops..Houston!!\n                    no pudimos conectarnos, por favor trata de nuevo");Facelib.logout();Poke.wrongInit()}else{Facelib.rawData=b;Facelib.user=b.user;b.friends.forEach(function(d,c){if(d.uid!=null&&d.name!=null){var e={id:d.uid,name:d.name,picture:d.pic_square};Facelib.friends.push(e);Facelib.friendsHash.set(e.id,e)}},Facelib);if(b.pals.length==1&&b.pals[0].fb_id==1){var a={id:1,name:jsLang.therapy,picture:"/images/leftpanel/therapy-buddy.jpg"};Facelib.friends.push(a);Facelib.friendsHash.set(a.id,a)}Facelib.userStatus.set(1)}}})},logout:function(a){FB.logout(function(b){Facelib.loginStatus.set(-1);if(a){a()}})},login:function(b,a){Facelib.loginStatus.set(0);FB.login(function(c){if(c.session){Facelib.loginStatus.set(1);if(b){b()}}else{if(c.status==="connected"){FB.init({appId:FBAppid,status:true,cookie:true,xfbml:true});var d=window.setInterval(function(){var e=$.cookie("fbs_"+FBAppid);if(e!==null){window.clearInterval(d);Facelib.loginStatus.set(1)}},200)}else{Facelib.loginStatus.set(-1);Poke.notAllowed();if(a){a()}}}},{perms:"email"})},askPublish:function(e,a,c,d,b){FB.login(function(g){if(g.session){if(g.perms){if(g.perms.indexOf("publish_stream")>-1){if(c==null){c="me"}var f=e;FB.api({method:"stream.publish",message:e,attachment:a,target_id:c},function(h){if(h){d()}else{alert("Sorry, an error ocurred and the post was not published.")}})}else{alert("Nothing was published.")}}else{alert("Nothing was published.")}}else{}},{perms:"publish_stream"})},publish:function(f,b,d,e,c){if(d==null){d="me"}var a=f;FB.api({method:"stream.publish",message:f,attachment:b,target_id:d},function(g){if(g){e()}else{c()}})},doWithPermission:function(a,c,b){FB.login(function(d){if(d.session){if(d.perms||a==""){if(a==""||d.perms.indexOf(a)>-1){c()}else{if(b){b()}}}else{if(b){b()}}}else{if(b){b()}}},{perms:a})},secureAction:function(d,a,b){var c=arguments[2];FB.login(function(e){if(e.session){Facelib.loginStatus.set(true);d(function(f){if(!f){Facelib.logout(function(){Facelib.login(function(){Facelib.secureAction(d,a,b,c)},function(){b.call(c)})})}else{a.call(c)}})}else{Facelib.loginStatus.set(false);b.call(c)}},{perms:""})},getYoutubeVideoAttachment:function(a){if(a!=undefined){return{name:jsLang.message,href:"http://apps.facebook.com/voxound/",description:jsLang.how,media:[{type:"flash",swfsrc:"http://www.youtube.com/v/"+a+"&fs=1",imgsrc:"http://i2.ytimg.com/vi/"+a+"/default.jpg",width:"90",height:"80",expanded_width:"425",expanded_height:"344"}]}}return undefined},getListLink:function(a){return{message:a+" "+encodeURI(Utils.ui.getMyUrl())}},getStandardLink:function(a){return{message:a+" www.voxound.com"}}};Account={status:new property(),fbInfo:new fbInfo(),user_id:undefined,inspirations:undefined,rawData:undefined,init:function(){Facelib.userStatus.onChange(function(a){if(a.newValue==1){Account._processUserInfo(Facelib.rawData)}if(a.newValue==0){Account.status.set(ENUM.LOADING)}if(a.newValue==-1){Account.logout()}})},login:function(){this.status.set(undefined);FB.login(function(a){if(a.session){Account._getUserInfo()}else{Poke.notAllowed();Account.status.set(ENUM.NOT_READY)}},{perms:"email"})},logout:function(){this.fbInfo.fillData({});this.inspirations=undefined;this.status.set(ENUM.NOT_READY)},doWithFbPermission:function(a,c,b){FB.login(function(d){if(d.session){if(d.perms||a==""){if(a==""||d.perms.indexOf(a)>-1){c()}else{if(b){b()}}}else{if(b){b()}}}else{if(b){b()}}},{perms:a})},secureAction:function(d,a,b){var c=arguments[2];FB.login(function(e){if(e.session){Facelib.loginStatus.set(true);d(function(f){if(!f){Facelib.logout(function(){Facelib.login(function(){Facelib.secureAction(d,a,b,c)},function(){b.call(c)})})}else{a.call(c)}})}else{Facelib.loginStatus.set(false);b.call(c)}},{perms:""})},_getUserInfo:function(){Frontera.userInit(function(a){if(a==null){alert("ooops..Houston!!\n                no pudimos conectarnos, por favor trata de nuevo");Account.logout();Poke.wrongInit()}else{Account._processUserInfo(a)}})},_processUserInfo:function(a){this.rawData=a;this.fbInfo.fillData(a.user);this.user_id=a.user.name_id;this.inspirations=a.user.inspirations;this.achievements.fill(a.user.achievements);this.status.set(ENUM.READY)}};Account.achievements={_list:[],fill:function(a){if(a){var b=a.split(",");b.forEach(function(c){if(c&&c.length>0){this._list.push(parseInt(c))}},this)}else{this._list=[]}},set:function(a){a=parseInt(a);if(!this.has(a)){this._list.push(a);Poke.achievement(a);Frontera.updateAchievements()}},has:function(a){a=parseInt(a);return(this._list.indexOf(a)!=-1)},get:function(){return this._list.join(",")},isEmpty:function(){return(this._list.length==0?true:false)}};Playlist={_CACHE_SIZE:15,_debt:0,_uiSongs:new HashTable(),_cache:[],_noMoreSongsToGet:false,_firstSearch:false,_listeners:{added:undefined,updated:undefined,no_more:undefined},_methods:{next:undefined,prev:undefined},_songOwnersContainers:[],type:new property(),init:function(){this.setListener(this.resolution,"added",function(a){a.forEach(function(b){this._cache.push(b)},this);this._balance()},this);this.setListener(this.resolution,"updated",function(a){if(this._uiSongs.has(a.id)){this.runListener(this._listeners.updated,a)}},this);this.setListener(this.resolution,"no_more",function(){this._noMoreSongsToGet=true;this.runListener(this._listeners.no_more)},this);this.setSongContainer(function(a){return Playlist.metadata.hash.get(a)});this.resolution.init()},start:function(){this._clear();this.type.set((CurrentSelection.selection.artist!=undefined&&CurrentSelection.selection.album!=undefined)?"album":"normal");this.get((this.type.value=="album"||CurrentSelection.selection.isUserSelected)?1000:PARAMS.SIZE.PLAYLIST_START_SONGS)},refresh:function(){var b=new HashTable();var a=this._cache;a.forEach(function(c){b.set(c.id,this.metadata.hash.get(c.id))},this);this._clear();this.metadata.hash=b;this._cache=a},get:function(a){Log.trace("Playlist","get",a);this._debt+=a;if(!this._noMoreSongsToGet){if(!this._firstSearch){this._firstSearch=true;this.resolution.get(a+this._CACHE_SIZE-this._cache.length)}else{this.resolution.get(a)}}this._balance()},getSong:function(a){this._methods[a].call(this)},getSongOwnerContainer:function(c){var a;for(var b=0;b<this._songOwnersContainers.length&&a==undefined;b++){a=this._songOwnersContainers[b].call(window,c)}return a},setMethod:function(b,a){this._methods[b]=a},setSongContainer:function(a){this._songOwnersContainers.push(a)},setListener:function(a,c,d,b){a._listeners[c]={callback:d,scope:b}},runListener:function(a,b){a.callback.call(a.scope,b)},_clear:function(){this._debt=0;this._uiSongs.clear();this._cache=[];this._noMoreSongsToGet=false;this._firstSearch=false;this.resolution.clear();this.metadata.clear()},_balance:function(){var a=[];while(this._debt>0&&this._cache.length>0){this._debt--;var b=this._cache.shift();this._uiSongs.set(b.id,b);a.push(this.metadata.hash.get(b.id))}if(a.length>0){this.runListener(this._listeners.added,a)}}};Playlist.resolution={_MIN_METADATA_REQUEST:50,_RESOLVERS_THRESHOLD:15,_metadataStatus:undefined,_resolversStatus:undefined,_listeners:{added:undefined,updated:undefined,no_more:undefined},_metadataGet:0,init:function(){Resolvers.onSongResolved.subscribe(function(c){var b=Playlist.metadata.hash.get(c.songId);if(b){var a=b.song.audio.length;if(!b.song.getAudioResourceByType(c.type)){b.song.setAudioResource(c.source,c.type,c.resource)}if(CurrentSelection.selection.isRandom&&a==0){Playlist.runListener(Playlist.resolution._listeners.added,[b.song])}else{Playlist.runListener(Playlist.resolution._listeners.updated,b.song)}}});Resolvers.threshold.subscribe(function(){Log.trace("Playlist.resolution","resolvers","threshold");Playlist.resolution._resolversStatus="warning";Playlist.resolution._balance()});Resolvers.noSongs.subscribe(function(){Log.trace("Playlist.resolution","resolvers","no_more_songs");Playlist.resolution._resolversStatus="no_songs";Playlist.resolution._balance()});Playlist.setListener(Playlist.metadata,"added",function(b){this._metadataStatus="ok";this._resolversStatus="feeded";var a=[];if(!CurrentSelection.selection.isRandom){a=b}else{b.forEach(function(c){if(c.audio.length>0){a.push(c)}})}if(a.length>0){Playlist.runListener(Playlist.resolution._listeners.added,a)}Resolvers.feed(b);this._balance()},this);Playlist.setListener(Playlist.metadata,"no_more",function(){Log.trace("Playlist.resolution","metadata","no_more_songs");this._metadataStatus="no_songs";this._balance()},this)},get:function(a){Log.trace("Playlist.resolution","get",a);Resolvers.feed(undefined,a);this._metadataGet=a;this._balance()},clear:function(){this._metadataStatus="ok";this._resolversStatus="not_started";this._debt=0;Resolvers.clear()},_balance:function(){if(this._metadataStatus=="no_songs"&&(this._resolversStatus=="no_songs"||this._resolversStatus=="not_started")){Playlist.runListener(this._listeners.no_more)}else{if(this._metadataGet>0&&this._resolversStatus!="feeded"&&this._metadataStatus=="ok"){this._metadataStatus="waiting";Playlist.metadata.get(Math.max(this._MIN_METADATA_REQUEST,this._metadataGet));this._metadataGet=0}}}};Playlist.metadata={noMoreSongs:false,_MIN_REQUEST:20,_source:undefined,_globalSongHash:undefined,_listeners:{added:undefined,no_more:undefined},hash:new HashTable(),get:function(b){var a=Math.max(this._MIN_REQUEST,b);Log.trace("Playlist.metadata","get",a);this._betterSourceGet(CurrentSelection.selection,a,function(d,e,c){Log.trace("Playlist.metadata","get","callback: "+e.length);if(d.pseudoId==CurrentSelection.selection.pseudoId){var f=[];e.forEach(function(g){if(!this.hash.has(g.id)){f.push(g);this.hash.set(g.id,this._getSongOwner(d,g))}},this);if(c==true&&f.length==0){Playlist.runListener(this._listeners.no_more)}else{Playlist.runListener(this._listeners.added,f)}if(c==true&&e.length<a){this.noMoreSongs=true;Playlist.runListener(this._listeners.no_more)}}},this)},clear:function(){this.hash.clear();this.noMoreSongs=false;this._source=this._getMetadataSource();this._source.reset()},_getSongOwner:function(a,c){if(a.isUserSelected){return Showcase.songOwners.get(c.id)}else{if(a.isAllFriendsSelected){return Friends.songOwners.get(c.id)}else{if(a.users.length>0){return new SongOwnerContainer({song:c,owner:Tagwords.get(c.friendId),dateAdded:c.dateAdded})}else{var b=Friends.songOwners.get(c.id);if(b){return b}return new SongOwnerContainer({song:c})}}}},_betterSourceGet:function(b,c,d,a){this._source.get(c,function(f,e){d.call(a,b,f,e)})},_getMetadataSource:function(){var a=CurrentSelection.selection;if(a.isComputerSelected||!a.vxRecognized){return Metadata.extension}if(a.isAllFriendsSelected&&a.users.length==0){return Metadata.friends}if(a.isUserSelected&&a.users.length==1){return Metadata.showcase}return Metadata.world}};Players={onStoped:new Observer(),onError:new Observer(),init:function(){Players.youtube.init();Players.soundManager.init()}};function onYouTubePlayerReady(a){Players.youtube.ytplayer=document.getElementById("youtubeContainer");Players.youtube.ytplayer.addEventListener("onStateChange","Players.youtube.onPlayerChanged");Players.youtube.ytplayer.addEventListener("onError","Players.youtube.onError")}Players.youtube={ytplayer:undefined,onPlayerChanged:function(a){switch(a){case 0:Players.onStoped.fire(this,{});break;case 1:Player.changeResource("youtube");break;case 2:break;case 3:break;default:break}},onError:function(a){Log.trace("player","error",a);if(a==2){Players.onError.fire(this,{})}},key:"youtube",isReady:function(){return(this.ytplayer!=undefined&&typeof this.ytplayer.getDuration=="function")},init:function(){var a={allowScriptAccess:"always",wmode:"transparent"};var b={id:"youtubeContainer"};swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer","youtubeContainer","600","325","8",null,null,a,b)},load:function(b){try{this.ytplayer.cueVideoById(b,1);return true}catch(a){Log.trace("Players->youtube","load","error"+a);return false}},play:function(){try{this.ytplayer.playVideo();return true}catch(a){Log.trace("Players->youtube","play","error"+a);return false}},pause:function(){try{if(this.isReady()){this.ytplayer.pauseVideo()}}catch(a){Log.trace("Players->youtube","play","error"+a)}},stop:function(){try{if(this.isReady()){this.ytplayer.stopVideo()}}catch(a){Log.trace("Players->youtube","play","error"+a)}},volume:function(b){try{if(b!=undefined){this.ytplayer.setVolume(b)}return this.ytplayer.getVolume()}catch(a){Log.trace("Players->youtube","play","error"+a)}return 0},duration:function(){try{return this.ytplayer.getDuration()}catch(a){Log.trace("Players->youtube","play","error"+a)}return 0},position:function(b){try{if(b!=undefined){this.ytplayer.seekTo(b,true)}return this.ytplayer.getCurrentTime()}catch(a){Log.trace("Players->youtube","play","error"+a)}return 0},buffered:function(){try{return this.ytplayer.getVideoBytesLoaded()/(this.ytplayer.getVideoBytesTotal()-this.ytplayer.getVideoStartBytes())}catch(a){Log.trace("Players->youtube","play","error"+a)}return 0}};Players.soundManager={sound:undefined,ready:false,key:"soundManager",isReady:function(){return this.ready},init:function(){soundManager.url="/swf/";soundManager.debugMode=false;soundManager.onready(function(a){Players.soundManager.ready=(a.success)?true:false})},load:function(b){try{if(this.sound!=undefined){this.sound.destruct()}this.sound=soundManager.createSound({id:"mySound1",bufferTime:1,url:b,onfinish:function(){Players.onStoped.fire(this,{})}});return true}catch(a){Log.trace("Players->soundmanager","load","error"+a);return false}},play:function(){try{this.sound.play();return true}catch(a){Log.trace("Players->soundmanager","play","error"+a);return false}},pause:function(){try{if(this.isReady()){this.sound.pause()}}catch(a){Log.trace("Players->soundmanager","pause","error"+a)}},stop:function(){try{if(this.isReady()){this.sound.stop()}}catch(a){Log.trace("Players->soundmanager","stop","error"+a)}},volume:function(b){try{if(b!=undefined){this.sound.setVolume(b)}return this.sound.volume}catch(a){Log.trace("Players->soundmanager","volume","error"+a)}return 0},duration:function(){try{return parseInt(this.sound.durationEstimate/1000)}catch(a){Log.trace("Players->soundmanager","duration","error"+a)}return 0},position:function(b){try{if(b!=undefined){this.sound.setPosition((b*1000))}return this.sound.position/1000}catch(a){Log.trace("Players->soundmanager","position","error"+a)}return 0},buffered:function(){try{return this.sound.bytesLoaded/this.sound.bytesTotal}catch(a){Log.trace("Players->soundmanager","buffered","error"+a)}return 0}};Resolvers={threshold:new Observer(),noSongs:new Observer(),error:new Observer(),onSongResolved:new Observer(),init:function(){this.vx_extension.init()},clear:function(){if(Extension.installStatus.value==Extension.E_Status.installed){this.vx_extension.clear()}else{this.youtube.clear()}},feed:function(b,a){if(CurrentSelection.selection.vxRecognized){if(Extension.installStatus.value==Extension.E_Status.installed){this.vx_extension.feed(b,a)}else{this.youtube.feed(b,a)}}}};Resolvers.vx_extension={init:function(){Extension.installStatus.onChange(function(a){if(a.newValue==Extension.E_Status.installed){Extension.onCometResolution.subscribe(function(b){Resolvers.vx_extension.handleCometResolution(b)})}})},feed:function(b,a){if(b){while(b.length>0){PeWon.feed(b.splice(0,Math.min(20,b.length)),function(){Resolvers.error.fire(this)})}}if(a){PeWon.resolve(a)}},clear:function(){this.songsToResolve=0;this.songsQueueLength=0;PeWon.clear(15)},handleCometResolution:function(a){switch(a[0]){case"resolved":Resolvers.onSongResolved.fire(this,{songId:a[2][0],source:a[1],type:a[3][0],resource:a[3][1]});break;case"below_t":Resolvers.threshold.fire(this,{});break;case"empty":Resolvers.noSongs.fire(this,{});break}}};Resolvers.youtube={_songs:[],_debt:0,_threshold:99,_resolving:0,_sequenceId:0,feed:function(b,a){if(b){this._feed(b)}if(a){this._get(a)}this._runResolutionsThreads(this._sequenceId)},clear:function(){this._debt=0;this._resolving=0;this._songs=[];this._threshold=100;this._sequenceId++},getIds:function(b,c){var a=arguments[1]||window;this._resolve(b,8,function(f,e,d){c.call(a,f,e,d)},a)},_get:function(a){this._debt+=a},_feed:function(a){a.forEach(function(b){this._songs.push(b)},this);this._threshold=Math.min(15,Math.round(this._songs.length/2))},_runResolutionsThreads:function(a){while(this._resolving<PARAMS.SIZE.RESOLUTION_YOUTUBE_CONCURRANT_REQUEST&&this._resolving<this._debt&&this._songs.length>0){var b=this._songs.shift();if(this._songs.length==this._threshold){Resolvers.threshold.fire(this,{})}this._resolving++;this._resolve(b,1,function(d,c){if(this._sequenceId==a){this._resolving--;if(c.length>0){this._debt--;Resolvers.onSongResolved.fire(this,{songId:d.id,source:"youtube",type:"youtube",resource:c[0]})}if(this._songs.length>0){this._runResolutionsThreads(a)}else{if(this._resolving==0){Resolvers.noSongs.fire(this,{})}}}},this)}},_resolve:function(c,a,d,b){$.getJSON("http://gdata.youtube.com/feeds/videos?alt=json-in-script&callback=?",{"max-results":a,format:"5",orderby:"relevance",vq:c.artist.content+' "'+c.title.content+'"'},function(f){var e=[];var g=[];if(f.feed.entry!=undefined){$.each(f.feed.entry,function(h,j){e.push(j.id.$t.substr(38,20));g.push(j.title.$t)})}d.call(b,c,e,g)})}};Metadata={init:function(){this.world.init()}};Metadata.extension={name:"extension",get:function(a,b){PeWon.songs(CurrentSelection.selection,a,function(c){b.call(arguments[2],c,true)})},reset:function(){}};Metadata.friends={name:"friends",get:function(b,d){if(!this.filteredSongs){this.setFilteredSongs()}var a=Math.min(this.filteredSongs.length,this.index+b);var c=this.filteredSongs.slice(this.index,a);this.index=a;d.call(arguments[2],c,true)},reset:function(){this.index=0;this.filteredSongs=undefined},getRandomSongs:function(a){if(CurrentSelection.selection.pseudoId!=this.selectionId){this.selectionId=CurrentSelection.selection.pseudoId;this.setFilteredSongs()}var c=[];if(this.filteredSongs){for(var b=0;b<a&&b<this.filteredSongs.length;b++){if(Math.random()<0.1){c.push(this.filteredSongs[Math.floor(Math.random()*this.filteredSongs.length)])}}}return c},filteredSongs:undefined,index:0,selectionId:undefined,setFilteredSongs:function(){this.filteredSongs=new Array();Friends.songs.forEach(function(b,a){if(Friends.mixPals.has(b.friendId)&&SongUtils.passSongThroughFilter(CurrentSelection.selection,b)){this.filteredSongs.push(b)}},this);if(CurrentSelection.selection.isRandom){this.filteredSongs.shuffle()}}};Metadata.showcase={name:"showcase",filteredSongs:undefined,index:0,get:function(b,d){if(!this.filteredSongs){this.filterSongs()}var a=Math.min(this.filteredSongs.length,this.index+b);var c=this.filteredSongs.slice(this.index,a);this.index=a;d.call(arguments[2],c,true)},filterSongs:function(){var a=new Array();if(CurrentSelection.selection.elements.length>1){Showcase.songOwners.each(function(c,b){if(SongUtils.passSongThroughFilter(CurrentSelection.selection,b.song)){a.push(b.song)}})}else{Showcase.songOwners.each(function(c,b){a.push(b.song)})}a.shuffle();this.filteredSongs=a},reset:function(){this.filteredSongs=undefined;this.index=0}};Metadata.world={name:"world",randomSongs:new Array(),init:function(){Account.status.addTrigger({comparer:function(a){return(a!=ENUM.LOADING)},callback:function(){this.checkRandomSongs()}},this)},get:function(d,e){var c=CurrentSelection.selection;var b=new Array();if(c.users.length==0){for(var a=0;a<this.randomSongs.length&&b.length<d;a++){if(SongUtils.passSongThroughFilter(CurrentSelection.selection,this.randomSongs[a])){b.push(this.randomSongs.splice(a--,1)[0])}}}if(b.length>0){Log.trace("md_world","get",b.length+" cache");e.call(arguments[2],b,(b.length==d));this.checkRandomSongs()}if(b.length<d){Frontera.songs(CurrentSelection.selection,d-b.length,function(f){if(c.pseudoId==CurrentSelection.selection.pseudoId){e.call(arguments[2],f,(b.length==0))}})}},reset:function(){},checkRandomSongs:function(){if(this.randomSongs.length<PARAMS.SIZE.RANDOM_CACHE_SONGS/2){Frontera.songs(new Selection(),PARAMS.SIZE.RANDOM_CACHE_SONGS,function(a){Metadata.world.randomSongs=a})}}};ServerMethod=function(a){this.url=a.url;this.type=a.type;this.allowCache=(a.allowCache&&a.allowCache==true)?true:false;this.allowConcurrentConnections=(a.allowConcurrentConnections&&a.allowConcurrentConnections==true)?true:false;this.cacheData=a.cacheData;this.abort=(a.abort&&a.abort==true)?true:false;this.dataProcess=a.dataProcess;this.cachedAnswers=new HashTable();this.currentConnection=undefined};ServerMethod.prototype.go=function(e,g){var d=arguments[2]||window;var a=(this.allowCache)?this.cachedAnswers.get(e[this.cacheData]):null;if(a!=null){if(g){g.call(d,a)}}else{var f={};for(var c in e){f[c]=JSON.encode(e[c])}if(this.abort&&this.currentConnection!=undefined){this.currentConnection.abort()}var b=this;if(this.allowConcurrentConnections||this.currentConnection==undefined){if(this.type=="ajax"){this.currentConnection=$.ajax({url:this.url,dataType:"json",data:f,cache:false,success:function(i){b.currentConnection=undefined;var h=b.dataProcess(i);if(b.allowCache){b.cachedAnswers.set(e[b.cacheData],h)}if(g){g.call(d,h)}},error:function(){b.currentConnection=undefined;if(g){g.call(d,b.dataProcess(null))}}})}else{this.currentConnection=$.jsonp({callbackParameter:"_callback",url:this.url,data:f,success:function(i){b.currentConnection=undefined;var h=b.dataProcess(i);if(b.allowCache){b.cachedAnswers.set(e[b.cacheData],h)}if(g){g.call(d,h)}},error:function(i,h){b.currentConnection=undefined;if(g){g.call(d,b.dataProcess(null))}}})}}}};Frontera={url:"http://"+window.location.host+"/",poke:function(a,f,d){try{var g=(Account.status.value==ENUM.READY)?Account.user_id:-1;var b={id:g,type:a,message:f,parameter:d};this.methods.poke.go({params:b},function(){})}catch(c){}},userInit:function(a){Log.trace("frontera","userInit","start");if(this.userInitAjax!=undefined){this.userInitAjax.abort()}this.userInitAjax=$.ajax({url:"data/users/init/",dataType:"json",cache:false,success:function(b){a(b)},error:function(){a(null)}})},songs:function(a,b,c){this.methods.songs.go(SongUtils.getParameters(a,b),c,arguments[3])},relatedInfo:function(a,d){var b=(a.category.id==1)?"albums":"artists";var c={data:JSON.encode([a.id,a.category.content]),method:"data/meta/"+b};$.getJSON(this.url+"ajax/do.php",c,function(f){var e=[];if(f){f.forEach(function(h){var g=new Tag({id:h[0],content:h[1]});if(b=="albums"){g.year=h[2]}e.push(g)})}d(e)})},relatedTags:function(a,c,d){var b="method=data/tagword/related&data=[["+a.tagwords_all_unsigned.join(",")+"],"+c+"]";$.getJSON(this.url+"ajax/do.php",b,function(f){var e=new Array();if(f!=null){f.forEach(function(g){e.push(Tagwords.get(g))})}d(e,a)})},link:function(d,c,a,e){var b=JSON.encode([(a)?1:-1,[d.id],c]);$.getJSON(this.url+"data/link",{data:b},function(f){e()})},bookmark:function(b){var a={weight:b.sign,song_id:b.song.id};if(b.sign==1&&b.inspirer!=undefined){a.inspirer=b.inspirer.id}if(b.sign==1&&Player.song.id==b.song.id&&Player.audioType=="youtube"){a.youtube_id=Player.resources.youtube}this.methods.bookmark.go({params:a},b.callback,b.scope)},updateAudioResource:function(b,d,c){var a={song_id:b.id,resource_id:d};this.methods.updateResource.go({params:a},c,arguments[3])},updateAchievements:function(){if(Account.status.value==ENUM.READY){this.methods.updateAchievements.go({data:[Account.user_id,Account.achievements.get()]},undefined)}},coverSrc:function(b,c){if(this.converSrcAjax!=undefined){this.converSrcAjax.abort()}var a=[b.artist.content,b.album.content];this.converSrcAjax=$.ajax({url:"ajax/do.php",dataType:"json",data:{method:"data/meta/album_art",data:JSON.encode(a)},success:function(d){c(d)},error:function(){c(null)}})},lyrics:function(a,b){if(this.lyricsAjax!=undefined){this.lyricsAjax.abort()}this.lyricsAjax=$.ajax({url:"data/lyrics",dataType:"json",data:{artist:a.artist.content,title:a.title.content},success:function(c){b((c&&c.lyric)?c.lyric:jsLang.no_lyrics)},error:function(){b(jsLang.no_lyrics)}})},pointSummary:function(){$("#vux-user-points-summary .thickbox-content").load("/points")},autocomplete:function(a,b){this.methods.autocomplete.go({key:a},b,arguments[2])},played:function(a,f,b){try{var c=new Object();c.user_id=(Account.status.value==ENUM.READY)?Account.user_id:-1;c.song_id=a;c.duration=f;c.stop=b;this.methods.played.go({params:c},function(){},arguments[4])}catch(d){}}};Frontera.methods={updateAchievements:new ServerMethod({url:"/data/users/achieve",type:"ajax",allowCache:false,allowConcurrentConnections:true,dataProcess:function(a){return(a==null)?false:a}})};Frontera.methods.autocomplete=new ServerMethod({url:"acmage/autocp",type:"ajax",allowCache:true,cacheData:"key",dataProcess:function(c){var b=[[],[]];if(c!=null){for(var a=0;a<c[0].length;a++){b[0].push(new Tag({id:parseInt(c[0][a][0]),category:Categories.get(c[0][a][2]),content:c[0][a][1]}))}for(var a=0;a<c[1].length;a++){b[1].push(new Tag({id:parseInt(c[1][a][0]),category:Categories.get(c[1][a][2]),content:c[1][a][1]}))}}return b}});Frontera.methods.songs=new ServerMethod({url:"/data/music",type:"ajax",allowCache:false,allowConcurrentConnections:true,abort:false,dataProcess:function(a){return(a==null)?[]:SongUtils.serverDataToSongList(a)}});Frontera.methods.bookmark=new ServerMethod({url:"/data/music/bookmark",type:"ajax",allowCache:false,allowConcurrentConnections:true,dataProcess:function(a){return(a==null)?false:a}});Frontera.methods.poke=new ServerMethod({url:"/stats/poke",type:"ajax",allowCache:false,allowConcurrentConnections:true,dataProcess:function(a){return(a==null)?false:a}});Frontera.methods.updateResource=new ServerMethod({url:"/data/music/update_video",type:"ajax",allowCache:false,allowConcurrentConnections:true,dataProcess:function(a){return(a==null)?false:a}});Frontera.methods.played=new ServerMethod({url:"/stats/played",type:"ajax",allowCache:false,allowConcurrentConnections:true,dataProcess:function(a){return true}});PeWon={url:"http://127.0.0.1:5050/",urlComet:"http://127.0.0.1:5051/",songs:function(a,b,c){this.methods.songs.go(SongUtils.getParameters(a,b,true),c,arguments[3])},relatedInfo:function(a,d){var c={input:a.id,type:a.category.content.toLowerCase()};var b=(a.category.id==1)?"getAlbums/":"getArtists/";$.jsonp({callbackParameter:"_callback",url:this.url+b,data:c,success:function(e){d(e)},error:function(f,e){Log.trace("PeWon","relatedInfo","error: "+f.toString()+" - "+e.toString());d([])}})},relatedTags:function(a,c,d){var b="input="+a.tagwords_all_unsigned.join(",")+"&limit="+c;$.jsonp({callbackParameter:"_callback",url:this.url+"getRelatedTags",data:b,success:function(g){var e=new Array();if(g!=null){for(var f=0;f<g.length;f++){e.push(Tagwords.get(g[f]))}}d(e,a)},error:function(f,e){Log.trace("PeWon","relatedTags","error: "+f.toString()+" - "+e.toString());d([])}})},suggestedTags:function(b,c){var a=[this.methods.cleanText(b.artist.content),this.methods.cleanText(b.title.content),this.methods.cleanText(b.album.content)];$.jsonp({callbackParameter:"_callback",url:this.url+"resolve/tags",data:{data:JSON.encode(a)},success:function(f){var d=new Array();if(f!=null){for(var e=0;e<f.length;e++){d.push(Tagwords.get(f[e]))}}c(d)},error:function(e,d){Log.trace("PeWon","suggestedTags","error: "+e.toString()+" - "+d.toString());c([])}})},feed:function(c,b){var d=new Array();for(var a=0;a<c.length;a++){d.push([c[a].id,c[a].releaseId,this.methods.cleanText(c[a].artist.content),this.methods.cleanText(c[a].title.content),this.methods.cleanText(c[a].album.content)])}Log.trace("peWon","feed",c.length);$.jsonp({callbackParameter:"_callback",url:this.url+"resolve/feed",data:{new_data:JSON.encode(d)},error:function(f,e){Log.trace("PeWon","feed","error: "+f.data.new_data);b()}})},resolve:function(a){Log.trace("peWon","resolve",a+" - "+CurrentSelection.selection.getDescription());$.jsonp({callbackParameter:"_callback",url:this.url+"resolve/req",data:{number:a},error:function(d,c){Log.trace("peWon","resolve","error: "+d.toString()+" - "+c.toString())}})},clear:function(a){Log.trace("peWon","clear","yeah");$.jsonp({callbackParameter:"_callback",url:this.url+"resolve/reset",data:{thresh:a},error:function(c,b){Log.trace("peWon","clear","error")}})},status:function(a){$.jsonp({callbackParameter:"_callback",url:this.url+"stats/global",success:function(b){a(b)},error:function(c,b){Log.trace("peWon","status","error");a(undefined)}})},version:function(a){$.jsonp({callbackParameter:"_callback",url:this.url+"stats/versions",success:function(b){a({launcher:b[0],pack:b[1]})},error:function(c,b){Log.trace("peWon","version","error");a(undefined)}})},comet:function(a){$.jsonp({callbackParameter:"_callback",url:this.urlComet,data:{id:a,_timeout:"40"},timeout:50000,success:function(c,b){Extension.cometHandler(c)},error:function(b,d,c){Extension.cometHandler()}})},restart:function(){$.jsonp({callbackParameter:"_callback",url:this.url+"control/restart",error:function(b,a){Log.trace("peWon","restart","error")}})},autocomplete:function(a,b){this.methods.autocomplete.go({key:a},b,arguments[2])}};PeWon.methods={cleanText:function(a){return Utils.removeDiacritics(a.replace(/["&]/g,""))},autocomplete:new ServerMethod({url:PeWon.url+"data/temp_tags",type:"jsonp",allowCache:false,dataProcess:function(c){var b=[[],[]];if(c!=null){for(var a=0;a<c[0].length;a++){b[0].push(new Tag({id:parseInt(c[0][a][0]),category:Categories.get(c[0][a][2]),content:c[0][a][1]}))}for(var a=0;a<c[1].length;a++){b[1].push(new Tag({id:parseInt(c[1][a][0]),category:Categories.get(c[1][a][2]),content:c[1][a][1]}))}}return b}}),songs:new ServerMethod({url:PeWon.url+"data/songs",type:"jsonp",allowCache:false,allowConcurrentConnections:false,abort:true,dataProcess:function(a){return(a==null)?[]:SongUtils.serverDataToSongList(a)}})};$(document).ready(function(){});function isValidEmailAddress(b){var a=new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);return a.test(b)}function validateEmail(){var a=$("#FT_talkInput").val();if(a!=0){if(isValidEmailAddress(a)){$("#FT_talkInput").addClass("valid");$("#FT_talkInput").removeClass("invalid");$("#FT_talkSend").removeAttr("disabled");$("#FT_talkSend").removeClass("disabled")}else{$("#FT_talkInput").removeClass("valid");$("#FT_talkInput").addClass("invalid");$("#FT_talkSend").attr({disabled:"disabled"});$("#FT_talkSend").addClass("disabled")}}else{$("#validEmail").css({"background-image":"none"})}}LeftPanel={sections:{},init:function(){this.dom.init();for(var a in LeftPanel.sections){LeftPanel.sections[a].init()}CurrentSelection.onChange.subscribe(function(){for(var b in LeftPanel.sections){LeftPanel.sections[b].update()}})}};LeftPanel.dom={init:function(){$("#leftPanel .vux-section-expander").each(function(){if($(this).hasClass("state-collapsed")){$(this).find(".vux-section-content-wrapper").hide()}else{$(this).find(".vux-section-content-wrapper").show()}});$(".vux-section-expander .vux-section-header").live("click",function(){LeftPanel.dom.toggleCollapse($(this).closest(".vux-section-expander"))});$(".vux-section-action.state-notready .vux-filter-link").live("click",function(){$(this).closest(".vux-section-action").find(".vux-section-content-wrapper").slideDown("fast")});$(".vux-section-action").bind("clickoutside",function(){$(this).find(".vux-section-content-wrapper").slideUp("fast")})},toggleCollapse:function(a,b){if(b==undefined){a.toggleClass("state-collapsed")}else{a.toggleClass("state-collapsed",b)}if(a.hasClass("state-collapsed")){a.find(".vux-section-content-wrapper").slideUp("fast")}else{a.find(".vux-section-content-wrapper").slideDown("fast")}}};LeftPanel.sections.computer={init:function(){Extension.installStatus.onChange(function(a){if(a.newValue==Extension.E_Status.installed){Actions.searchBar.unabort($("#lp_computer"));Data.insert(Data.types.tag,$("#lp_computer"),Extension.tag)}else{if(a.newValue==Extension.E_Status.notInstalled){Actions.searchBar.abort($("#lp_computer"));Data.remove(Data.types.tag,$("#lp_computer"))}}});Extension.onStatsChange.subscribe(function(){$("#lp_cp_totalSongs").html(Extension.stats.recognized)});Extension.installStatus.addClass("lp_computer","state-notready",Extension.E_Status.notInstalled);Extension.installStatus.addClass("lp_computer","state-ready",Extension.E_Status.installed);Extension.isLoading.addClass("lp_computer","state-loading",true)},update:function(){}};LeftPanel.sections.showcase={ready:new property(),loading:new property(),init:function(){var a=this;this.ready.addClass("lp_showcase","state-ready",true);this.ready.addClass("lp_showcase","state-notready",false);this.loading.addClass("lp_showcase","state-loading",true);Showcase.onChange.subscribe(function(b){$("#lp_sc_totalSongs").html(Showcase.totalSongs());a.ready.set(Showcase.totalSongs()>0)});Showcase.ready.onChange(function(b){if(b.newValue){$("#lp_sc_totalSongs").html(Showcase.totalSongs());a.ready.set(Showcase.totalSongs()>0);a.loading.set(false)}});this.ready.onChange(function(b){if(b.newValue){Data.insert(Data.types.tag,$("#lp_showcase.data-tag"),Showcase.tag)}else{Data.remove(Data.types.tag,$("#lp_showcase.data-tag"))}});Account.status.addTrigger([{comparer:function(b){return(b!=ENUM.NOT_READY)},callback:function(){this.loading.set(true)}},{value:ENUM.NOT_READY,callback:function(){this.loading.set(false);this.ready.set(false)}}],this)},update:function(){}};LeftPanel.sections.friends={pals:[],status:new property(),init:function(){var a=this;Friends.ready.onChange(function(b){if(b.newValue){a.status.set(1);Friends.fb.each(function(c,d){a.pals.push(Tagwords.get(c))})}});Account.status.addTrigger([{value:ENUM.READY,callback:function(){this.status.set(0)}},{value:ENUM.LOADING,callback:function(){this.status.set(0)}},{value:ENUM.NOT_READY,callback:function(){this.pals=[];this.status.set(-1);this.update()}}],this);Friends.alone.onChange(function(b){a.update(true)});Friends.alone.addClass("lp_friends","state-therapy",true);this.status.addClass("lp_friends","state-loading",0);this.status.addClass("lp_friends","state-ready",1);this.status.addClass("lp_friends","state-notready",-1)},update:function(b){if(this.status.value==-1||b||Math.random()<0.5){this.pals.shuffle();$(".vux-friends-list").empty();var a=0;if(!Friends.alone.value){$(".vux-friends-list").append(this.format.all())}else{$(".vux-friends-list").append(this.format.therapy());a=1}for(a;a<PARAMS.SIZE.LEFT_PANEL_FRIENDS;a++){if(a<this.pals.length){$(".vux-friends-list").append(this.format.friend(this.pals[a]))}else{$(".vux-friends-list").append(this.format.ghost())}}}}};LeftPanel.sections.friends.format={friend:function(b){var a="<img src='"+Utils.ui.userPictureSrc(b.id)+"' class='vux-filter-friend-img' width='35' height='35'/>";a+="<span class='vux-filter-friend-name'>"+b.content+"</span>";return Utils.ui.filter(b,"action-searchbar-replace",["action-searchbar-add"],a)},therapy:function(){var a="<img src='/images/leftpanel/therapy-buddy.jpg' class='vux-filter-friend-img' width='35' height='35'/>";a+="<span class='vux-filter-friend-name'>"+Tagwords.special.therapy.content+"</span>";return Utils.ui.filter(Tagwords.special.therapy,"action-searchbar-replace",["action-searchbar-add"],a)},ghost:function(){var a="<li class='vux-filter data-tag body'>";a+="<div class='vux-filter-link action-share-invite'>";a+="<img src='/images/leftpanel/invite-friend.png' class='vux-filter-friend-img' width='35' height='35'/>";a+="<span class='vux-filter-friend-name'>"+jsLang.invite+"</span>";a+="</div>";a+="</li>";return a},all:function(){var a="<span class='vux-filter-friend-name'>"+jsLang.all_friends+"</span>";var b=Utils.ui.filter(Friends.tag,"action-searchbar-replace",["action-searchbar-add"],a);b.addClass("vux-filter-friend-noimg");return b}};LeftPanel.sections.tagwords={hash:new HashTable(),loading:new property(),init:function(){this.loading.addClass("lp_tagwords","state-loading",true)},update:function(){if(!CurrentSelection.selection.isFixedInfoSelected){$("#lp_tagwords").show();var b=CurrentSelection.selection.pseudoId;if(!this.hash.has(b)){var a=this;this.loading.set(true);Frontera.relatedTags(CurrentSelection.selection,8,function(c){a.loading.set(false);a.hash.set(b,c);if(b==CurrentSelection.selection.pseudoId){a.refreshDom()}})}else{this.refreshDom()}}else{$("#lp_tagwords").hide()}},refreshDom:function(){var c=this.hash.get(CurrentSelection.selection.pseudoId);$("#lp_tagwords .vux-section-content").empty();for(var b=0;b<c.length;b++){var a=c[b];$("#lp_tagwords .vux-section-content").append(Utils.ui.filter(a,"action-searchbar-replace",["action-searchbar-add","action-searchbar-negate"],a.content+"<span class='vux-filter-tagword-category color-black-gray'> "+a.category.content+"</span>"))}}};LeftPanel.sections.radios={SIZE:4,radios:[],init:function(){this.chooseRadios();this.refreshDom()},update:function(){if(!CurrentSelection.selection.isFixedInfoSelected){$("#lp_radios").show();if(this.radios.lenght==0||Math.random()<0.4){this.chooseRadios();this.refreshDom()}}else{$("#lp_radios").hide()}},chooseRadios:function(){this.radios=Tagwords.radios;this.radios.shuffle();this.radios.splice(0,Math.max(0,this.radios.length-this.SIZE))},refreshDom:function(){$("#lp_radios .vux-section-content").empty();for(var b=0;b<this.radios.length;b++){var a=this.radios[b];$("#lp_radios .vux-section-content").append(Utils.ui.filter(a,"action-searchbar-replace",["action-searchbar-add","action-searchbar-negate"],a.content))}}};LeftPanel.sections.artists={hash:new HashTable(),loading:new property(),init:function(){this.loading.addClass("lp_artists","state-loading",true)},update:function(){var c=CurrentSelection.selection;if(c.isFixedInfoSelected&&!c.artist){$("#lp_artists").show();$("#lp_artists .vux-section-content").empty();var b=(c.album)?c.album:c.title;if(!this.hash.has(b.id)){var a=this;this.loading.set(true);Frontera.relatedInfo(b,function(d){a.loading.set(false);for(var e=0;e<d.length;e++){d[e].category=Categories.get(1)}a.hash.set(b.id,d);a.refreshDom(b)})}else{this.refreshDom(b)}}else{$("#lp_artists").hide()}},refreshDom:function(c){var a=this.hash.get(c.id);$("#lp_artists .vux-section-content").empty();for(var b=0;b<a.length;b++){$("#lp_artists .vux-section-content").append(this.formatArtist(a[b]))}},formatArtist:function(a){return Utils.ui.filter(a,"action-searchbar-add",["action-searchbar-replace"],a.content)}};LeftPanel.sections.albums={hash:new HashTable(),loading:new property(),init:function(){this.loading.addClass("lp_albums","state-loading",true)},update:function(){var b=CurrentSelection.selection;if(b.isFixedInfoSelected&&b.artist){$("#lp_albums").show();$("#lp_albums .vux-section-content").empty();if(!this.hash.has(b.artist.id)){var a=this;this.loading.set(true);Frontera.relatedInfo(b.artist,function(e){a.loading.set(false);var c=[];var d=new HashTable();for(var f=0;f<e.length;f++){if(e[f].year>1000&&!d.has(e[f].content)){d.set(e[f].content,e[f].content);e[f].category=Categories.get(3);c.push(e[f])}}a.hash.set(b.artist.id,c);a.refreshDom(b.artist)})}else{this.refreshDom(b.artist)}}else{$("#lp_albums").hide()}},refreshDom:function(c){var a=this.hash.get(c.id);$("#lp_albums .vux-section-content").empty();for(var b=0;b<a.length;b++){$("#lp_albums .vux-section-content").append(this.formatAlbum(a[b]))}},formatAlbum:function(a){var b=a.content+"<span class='vux-filter-tagword-category color-black-gray'> ("+a.year+")</span>";return Utils.ui.filter(a,"action-searchbar-add",["action-searchbar-replace"],b)}};SearchHistory={MAX_ELEMENTS:10,items:new Array(),hash:new HashTable(),init:function(){$("#PL_searchHistoryBrowse").click(function(a){SearchHistory.domShowSearchHistory()});$("#PL_searchHistoryList").bind("click",function(b){var a=$(b.target).data("pseudoId");CurrentSelection.setSelection(SearchHistory.hash.get(a))});$(document).bind("click",function(a){if($(a.target).attr("id")!="PL_searchHistoryBrowse"){SearchHistory.domHideSearchHistory()}});Player.songChanged.subscribe(function(){var a=SearchHistory.items;var c=SearchHistory.hash;var b=CurrentSelection.selection.pseudoId;if(a.length==0||(a.length>0&&a[a.length-1].pseudoId!=b)){if(c.has(b)){Utils.removeFromArray(a,"selectionId",b)}else{c.set(b,CurrentSelection.selection)}a.push(CurrentSelection.selection);if(a.length>SearchHistory.MAX_ELEMENTS){c.remove(a[0].pseudoId);a.splice(0,1)}}})},domShowSearchHistory:function(){$("#PL_searchHistoryList").empty();var b=this.items.length;while(b>0){var c="<li>";c+=this.items[--b].getDescription();c+="</li>";var a=$(c);a.data("pseudoId",this.items[b].pseudoId);$("#PL_searchHistoryList").append(a)}$("#PL_searchHistoryBrowse").toggleClass("PL_searchHistoryBrowseOpen",true);$("#PL_searchHistoryList").show()},domHideSearchHistory:function(){$("#PL_searchHistoryList").hide()}};ContentManager={isAppStarted:new property(),onAppStarted:new Observer(),init:function(){ContentManager.resizeContent();$(window).bind("resize",function(){ContentManager.resizeContent()});if(window.location.pathname.indexOf("songs")>=0){$("#transporter").show()}this.dom.init();this.isAppStarted.set(false)},resizeContent:function(){$(".vux-app-control-content").css("height",Math.max(250,$(window).height()-277)+"px");$("#songContent").css("height",Math.max(390,$(window).height()-225)+"px")},startApp:function(){if(!this.isAppStarted.value){var a=[];if(Account.status.value==ENUM.READY&&Account.achievements.isEmpty()){CurrentSelection.clear()}else{if(Showcase.totalSongs()>0){a.push(Showcase.tag)}if(Friends.alone.value==false){a.push(Tagwords.special.allFriends)}if(Extension.installStatus.value==Extension.E_Status.installed&&Extension.stats.recognized>0){a.push(Tagwords.special.computer)}if(a.length>0){CurrentSelection.addItem(a[Math.floor(Math.random()*a.length)],true)}else{CurrentSelection.clear()}}if(Friends.alone.value==true){$("#lp_friends .rightCol sectionExpanderColumn").click()}}}};ContentManager.dom={init:function(){$("#contentWrapper").addClass("inTutorial")}};Thickbox={domId:"thickbox-wrapper",frameWrapperId:"thickbox-frame-wrapper",active:false,onClose:undefined,content:undefined,frame:undefined,jqPositionReference:undefined,displayContent:function(b){var a=b.attr("class").split(" ");a.forEach(function(c){if(c.indexOf("thickbox-customclass-")>-1){$("#"+this.domId).addClass(c)}},this);$("#"+this.domId).find(".thickbox-content").html(b)},show:function(a){if(this.active){this.hide()}this.active=true;this.jqPositionReference=a.where;this.onClose=a.close;$("#"+this.domId).removeClass();this.frame=(a.frame)?a.frame:$("<div><div class='thickbox-content'></div></div>");$("#"+this.frameWrapperId).html(this.frame);if(a.classes){a.classes.forEach(function(b){this.frame.addClass(b)},this)}$("#"+this.frameWrapperId).css("height",this.frame.css("height"));$("#"+this.frameWrapperId).css("width",this.frame.css("width"));if(a.content){this.content=a.content;this.displayContent(a.content)}else{if(a.url){$.ajax({url:a.url,dataType:"html",cache:true,success:function(b){$("#"+Thickbox.domId).find(".thickbox-content").html(b);Thickbox.fixPosition()},error:function(){$("#"+Thickbox.domId).find(".thickbox-content").html("oooops");Thickbox.fixPosition()}})}}$("#"+this.domId).show();this.fixPosition()},hide:function(){$("#"+this.domId).hide();if(this.onClose){this.onClose.call(this)}if(this.content){$("#thickbox-garbage").append(this.content)}$("#thickbox-garbage").append(this.frame);this.onClose=undefined;this.jqPositionReference=undefined;this.content=undefined;this.active=false},fixPosition:function(){var a=$("#"+this.domId).find("#"+this.frameWrapperId);if(this.jqPositionReference){a.css("top",this.jqPositionReference.offset().top);a.css("left",this.jqPositionReference.offset().left)}else{a.css("top",($(window).height()-a.outerHeight())/2);a.css("left",($(window).width()-a.outerWidth())/2)}}};$(document).ready(function(){$(".thickbox-close").live("click",function(){Thickbox.hide()});$(window).bind("resize",function(){Thickbox.fixPosition()});var a="";a+="<div id='"+Thickbox.domId+"'>";a+="<div id='"+Thickbox.frameWrapperId+"' class='vux-animation-thickbox'></div>";a+="<div id='thickbox-garbage' style='display: none'></div>";a+="</div>";$("body").append(a)});General={skipExtension:new property(),firstSearchDone:new property(),init:function(){this.classes_def();General.skipExtension.set(Url.originalHash.length>1);$(".action-extension-skip").live("click",function(){General.skipExtension.set(true)});Poke.init();Extension.installStatus.onChange(function(a){if(a.newValue==Extension.E_Status.fakeLoading){General.fakeWelcomeLoading(ContentManager.isAppStarted.value?100:0)}});Friends.ready.onChange(function(a){if(a.newValue){$("#user-info-name").html(Facelib.user.name);$("#user-info-points").html(Facelib.user.inspirations+" "+jsLang.points);Utils.ui.loadImage($("#user-info-picture"),"vux-image-loading","",function(b){b(Facelib.user.picture)});if(ContentManager.isAppStarted.value==false&&!Account.achievements.isEmpty()){ContentManager.startApp()}if(Url.type=="msg"&&Url.obj){if(Url.obj.message_id==4){$("#user-info-points").click()}}}else{$("#user-info-name").html("");$("#user-info-points").html("");$("#user-info-picture").attr("src","")}});this.firstSearchDone.set(false);CurrentSelection.onChange.subscribe(function(){ContentManager.isAppStarted.set(true);if(CurrentSelection.selection.isEmpty==false){General.firstSearchDone.set(true)}})},classes_def:function(){Facelib.userStatus.addClass("contentWrapper","fb_loggedOut",-1);Facelib.userStatus.addClass("contentWrapper","fb_checking",0);Facelib.userStatus.addClass("contentWrapper","fb_loggedIn",1);ContentManager.isAppStarted.addClass("contentWrapper","appIsStarted",true);ContentManager.isAppStarted.addClass("contentWrapper","appIsNotStarted",false);Extension.installStatus.bindClass($("#contentWrapper"),[{className:"vx_installed",value:Extension.E_Status.installed},{className:"vx_notInstalled",value:Extension.E_Status.notInstalled},{className:"vx_installing",value:Extension.E_Status.installing},{className:"vx_loading",value:Extension.E_Status.fakeLoading},{className:"vx_updating",value:Extension.E_Status.updating},{className:"vx_needsUpdate",value:Extension.E_Status.launcherUpdateNeeded},]);this.skipExtension.bindClass($("#contentWrapper"),[{className:"tu_extensionSkipped",value:true},{className:"tu_extensionNotSkipped",value:false},]);Friends.alone.bindClass($("#contentWrapper"),[{className:"fr_isLonely",value:true},{className:"fr_hasFriends",value:false},]);this.firstSearchDone.bindClass($("#contentWrapper"),[{className:"app_firstSearchDone",value:true},{className:"app_firstSearchNotDone",value:false},])},fakeWelcomeLoading:function(a){$(".vux-welcome-detectpercent").html(a+"%");if(a<100){setTimeout("General.fakeWelcomeLoading("+(a+1)+");",100)}else{Extension.searchInstallation();ContentManager.startApp()}}};Url={originalHash:undefined,originalUrl:undefined,type:undefined,obj:undefined,init:function(){try{this.originalHash=window.location.hash;this.originalUrl=window.location.href;var a=window.location.hash.match(/^#([^\/]*)\/?(.*)$/);if(a){this.type=a[1];var c;if(this.type=="songs"&&a[2]){c=a[2].match(/([^\?]*)\?id=([0-9]+)&cat=([0-9]+)/);if(c[1]&&c[2]&&c[3]){this.obj=new Tag({id:c[2],content:decodeURI(c[1]),category:Categories.get(c[3])})}}else{if(this.type=="msg"&&a[2]){c=a[2].match(/([0-9]+)-([0-9]+)-([0-9]+)/);if(c[1]&&c[2]&&c[3]){this.obj=new Object();this.obj.message_id=c[1];this.obj.user_id=c[3]}}else{if(this.type=="fake"&&a[2]){c=a[2].match(/([0-9]+)/);if(c[1]){this.obj=new Object();this.obj.user_id=c[1]}}}}}}catch(b){}window.location.href="http://"+window.location.host+"/#"}};Actions={init:function(){this.searchBar.init();this.showcase.init();this.facebook.init();this.start.init();this.extension.init();this.share.init()}};Actions.searchBar={init:function(){this.add_def();this.replace_def();this.negate_def()},abort:function(a){a.find(".action-searchbar-add").addClass("action-searchbar-abort");a.find(".action-searchbar-replace").addClass("action-searchbar-abort");a.find(".action-searchbar-negate").addClass("action-searchbar-abort")},unabort:function(a){a.find(".action-searchbar-add").removeClass("action-searchbar-abort");a.find(".action-searchbar-replace").removeClass("action-searchbar-abort");a.find(".action-searchbar-negate").removeClass("action-searchbar-abort")},add_def:function(){$(".action-searchbar-add").live("click",function(){if(!$(this).hasClass("action-searchbar-abort")){var a=Data.get(Data.types.tag,$(this));for(var b=0;b<a.length;b++){CurrentSelection.addItem(a[b],true)}}})},replace_def:function(){$(".action-searchbar-replace").live("click",function(){if(!$(this).hasClass("action-searchbar-abort")){var a=Data.get(Data.types.tag,$(this));if(a.length>0){CurrentSelection.setSelection(a)}}})},negate_def:function(){$(".action-searchbar-negate").live("click",function(){if(!$(this).hasClass("action-searchbar-abort")){var a=Data.get(Data.types.tag,$(this));for(var b=0;b<a.length;b++){CurrentSelection.addItem(a[b],false)}}})}};Actions.showcase={init:function(){Showcase.onChange.subscribe(function(a){$(".action-showcase").each(function(){Actions.showcase.check($(this))})});$(".action-showcase").live("click",function(){var c=$(this);var b=Data.get(Data.types.song,c);if(b!=undefined&&b.length>0){var a=Playlist.getSongOwnerContainer(b[0]);if(Showcase.hasSong(a.song.id)){Showcase.removeSong(a.song)}else{Showcase.addSong(a.song,a.owner)}Actions.showcase.check(c)}})},check:function(b){var a=Data.get(Data.types.song,b);if(a!=undefined&&a.length>0){b.closest(".action-showcase").each(function(){$(this).toggleClass("state-showcase-in",Showcase.hasSong(a[0]));$(this).toggleClass("state-showcase-out",!Showcase.hasSong(a[0]));if(Showcase.hasSong(a[0])){$(this).attr("data-tooltip-title","Sacar de mis canciones")}if(!Showcase.hasSong(a[0])){$(this).attr("data-tooltip-title","Agregar a mis canciones")}});b.find(".action-showcase").each(function(){$(this).toggleClass("state-showcase-in",Showcase.hasSong(a[0]));$(this).toggleClass("state-showcase-out",!Showcase.hasSong(a[0]));if(!Showcase.hasSong(a[0])){$(this).attr("data-tooltip-title","Sacar de mis canciones")}if(!Showcase.hasSong(a[0])){$(this).attr("data-tooltip-title","Agregar a mis canciones")}})}}};Actions.facebook={init:function(){$(".state-facebook-login").live("click",function(){if(Facelib.loginStatus.value==-1){Facelib.login()}});$(".state-facebook-logout").live("click",function(){if(Facelib.loginStatus.value==1){Facelib.logout()}})}};Actions.start={init:function(){$(".action-startapp").live("click",function(){ContentManager.startApp()})}};Actions.extension={init:function(){$(".action-extension-download").live("click",function(){setTimeout("Extension.searchInstallation();",5000)})}};Actions.share={init:function(){$(".action-share-song").live("click",function(){var b=Data.get(Data.types.song,$(this));if(b&&b.length>0){var a=Playlist.getSongOwnerContainer(b[0]);Share.song(a.song)}});$(".action-share-invite").live("click",function(){Share.invite()})}};Data={insert:function(d,h,f,e){var a=Utils.ui.parentsOrChildren(h,".data-"+d);for(var c in Data[d].objToData){var g=a.data(c);var b=Data[d].objToData[c](f);a.data(c,(e&&g!=undefined)?g+","+b:b)}},get:function(f,h){var c=Utils.ui.parentsOrChildren(h,".data-"+f);var a=[];for(var e in Data[f].objToData){var d=c.data(e);if(d!=undefined){var b=(d.constructor==String)?d.split(","):[d];b.forEach(function(i,k){if(a[k]==undefined){a[k]={}}a[k][e]=i})}}var g=[];a.forEach(function(j){g.push(Data[f].dataToObj(j))});return g},remove:function(c,d){var a=Utils.ui.parentsOrChildren(d,".data-"+c);for(var b in Data[c].objToData){a.removeData(b)}}};Data.tag={objToData:{tagId:function(a){return a.id},catId:function(a){return a.category.id},content:function(a){return a.content}},dataToObj:function(a){return new Tag({id:a.tagId,content:a.content,category:Categories.get(a.catId)})}};Data.song={objToData:{songId:function(a){return a.id}},dataToObj:function(a){return a.songId}};Data.types={tag:"tag",song:"song"};SearchBar={$items:new HashTable(),init:function(){CurrentSelection.onChange.subscribe(function(){var b=CurrentSelection.selection.elements;var a=new HashTable();b.forEach(function(c){var d=this.$items.get(c.tag.id);if(!d){d=this.$.item(c);$("#SB_elementsWrapper").append(d);a.set(c.tag.id,d)}else{a.set(c.tag.id,d)}},SearchBar);SearchBar.$items.each(function(c,d){if(!a.has(c)){d.remove()}});SearchBar.$items=a;SearchBar.htmlRefreshExtras()});$("#SB_clearAll").click(function(){CurrentSelection.clear()});this.manageHiddenInputEvents();this.manageSearchBarEvents();this.manageElementWrapperEvents();this.manageInputEvents();Autocomplete.init()},manageHiddenInputEvents:function(){$("#SB_searchHiddenInput").keydown(function(c){if(c.keyCode==37){SearchBar.selectElement($("#SB_elementsWrapper .selected:first").prev())}else{if(c.keyCode==39){SearchBar.selectElement($("#SB_elementsWrapper .selected:first").next())}else{if(c.keyCode==8){var b=$("#SB_elementsWrapper .selected:first");var a=b.prev();CurrentSelection.removeItem(b.data("tagId"));SearchBar.selectElement(a)}else{if(c.keyCode==46){var b=$("#SB_elementsWrapper .selected:first");var a=b.next();CurrentSelection.removeItem(b.data("tagId"));SearchBar.selectElement(a)}}}}});$("#SB_searchHiddenInput").blur(function(){$("#SB_elementsWrapper li").removeClass("selected")});$("#SB_searchInput").focus()},manageSearchBarEvents:function(){$("#SB_searchBarWrapper").bind("mouseenter",function(a){$(this).addClass("remove")});$("#SB_searchBarWrapper").bind("mouseleave",function(a){$(this).removeClass("remove")})},manageElementWrapperEvents:function(){$(".searchRemoveButton").live("click",function(){var a=Data.get(Data.types.tag,$(this));CurrentSelection.removeItem(a[0].id)})},manageInputEvents:function(){$("#SB_searchInput").keydown(function(a){if((a.keyCode==8||a.keyCode==37)&&$(this).val()==""){SearchBar.selectElement($("#SB_elementsWrapper li:last"))}else{if(a.keyCode==27){$(this).val("")}}});$("#SB_searchInput").labeledInput({label:jsLang.search_bar_text,customClass:"searchBar"})},selectElement:function(a){if(a.length==0){$("#SB_searchHiddenInput").blur();$("#SB_searchInput").focus()}else{$("#SB_elementsWrapper li").removeClass("selected");a.addClass("selected");$("#SB_searchHiddenInput").focus()}},htmlRefreshExtras:function(){if(CurrentSelection.selection.isEmpty){$("#SB_inputLabel").html(jsLang.start_);$("#SB_searchBarWrapper").toggleClass("removeAll",false)}else{$("#SB_inputLabel").html(jsLang.type_);$("#SB_searchBarWrapper").toggleClass("removeAll",true)}}};SearchBar.$={item:function(c){var b="<li class='searchElement data-tag'>";b+="<span class='searchElementContent'>";b+="<span class='searchElementCat'/>";b+="<span class='searchElementText'>"+c.tag.content+"</span>";b+="</span>";b+="<span class='searchRemoveButton hasTooltip' data-tooltip-title='"+jsLang.remove_tag+"'></span>";b+="</li>";var a=$(b);Data.insert(Data.types.tag,a,c.tag);if(c.tag.category.id==50&&Extension.tag&&Extension.tag.id==c.tag.id){a.addClass("cat-computer")}else{if(c.tag.category.id==50&&Showcase.tag&&Showcase.tag.id==c.tag.id){a.addClass("cat-user")}else{if(c.tag.category.id==50){a.addClass("cat-friend")}else{if(c.tag.category.id<=3){a.addClass("cat-"+c.tag.category.content.toLowerCase())}else{if(!c.sign){a.addClass("cat-negativeTagword")}else{a.addClass("cat-tagword")}}}}}return a}};domPlaylist={items:new HashTable(),bang:new property(),loading:new property(),$song:undefined,$discHead:undefined,noMoreSongs:false,init:function(){this.$song=$("#music .vux-playlist-song").clone();$("#music .vux-playlist-song").remove();this.$discHead=$("#music .vux-playlist-album").clone();$("#music .vux-playlist-album").remove();Playlist.setMethod("next",function(){var a=$("#playlist .vux-playlist-song.hasAudioSource").index($("#playlist .vux-playlist-song.state-now-playing"));var b=$("#playlist .vux-playlist-song.hasAudioSource").get(a+1);if(b==undefined){b=$("#playlist .vux-playlist-song.hasAudioSource").get(0)}domPlaylist.selectSong($(b),(Player.status.value==Player.E_status.play))});Playlist.setMethod("prev",function(){var a=$("#playlist .vux-playlist-song.hasAudioSource").index($("#playlist .vux-playlist-song.state-now-playing"));var b=$("#playlist .vux-playlist-song.hasAudioSource").get(Math.max(a-1,0));domPlaylist.selectSong($(b),(Player.status.value==Player.E_status.play))});Playlist.setSongContainer(function(b){var a=domPlaylist.items.get(b);return(a)?a.songOwnerContainer:undefined});Playlist.setListener(Playlist,"added",function(a){var b=[];this.loading.set(false);if(Playlist.type.value=="album"){a=this.utils.sortSongs(a)}a.forEach(function(c){var d=this.$.song(c);this.utils.addItem(c,d);var e=(c.song.official)?c.song.disc:"notOficial";if(Playlist.type.value=="album"&&b.indexOf(e)==-1){$("#playlist #playlist-last-search-list").append(this.$.discHead(c.song));b.push(e)}this.checkAudioSource(c.song);$("#playlist #playlist-last-search-list").append(d);Actions.showcase.check(d)},this);$("#playlist-last-search-list").toggleClass("multidisc-album",$(".vux-playlist-album-official").length>1);$("#playlist-last-search-list").toggleClass("hasNotOfficialSongs",$(".vux-playlist-album-notofficial").length==1);if(Player.song==undefined){$("#playlist .vux-playlist-song.hasAudioSource").first().click()}},this);Playlist.setListener(Playlist,"updated",function(a){this.checkAudioSource(a)},this);Playlist.setListener(Playlist,"no_more",function(){domPlaylist.noMoreSongs=true;domPlaylist.loading.set(false);if($("#playlist-last-search-list").children().size()==0){this.$.bang();this.bang.set(true)}},this);CurrentSelection.onChange.subscribe(function(){if(!CurrentSelection.selection.isEmpty){domPlaylist.start()}});Account.status.addTrigger([{value:ENUM.READY,callback:function(){this.$song.find(".vux-playlist-song-showcase-me .vux-image-placeholder").attr("src",Utils.ui.userPictureSrc(Account.user_id))}},{value:ENUM.NOT_READY,callback:function(){this.$song.find(".vux-playlist-song-showcase-me .vux-image-placeholder").attr("src",Utils.ui.userPictureSrc())}}],this);$("#playlist-remix-songs","#playlist").live("click",function(a){CurrentSelection.selection.isRandom=true;domPlaylist.start()});$("#PL_searchHistoryBack").live("click",function(a){if(!CurrentSelection.selection.isEmpty){domPlaylist.clear();Playlist.refresh();Playlist.get(15)}});$("#music .vux-app-control-content").bind("scroll",function(){if(!domPlaylist.loading.value&&Playlist.type.value!="album"&&$("#playlist").height()-$("#music .vux-app-control-content").scrollTop()-$("#music .vux-app-control-content").height()<10){if(domPlaylist.noMoreSongs==false&&!domPlaylist.loading.value){domPlaylist.loading.set(true);setTimeout("Playlist.get(15); if(Playlist.metadata.noMoreSongs) domPlaylist.loading.set(false);",150)}}});$(".vux-playlist-song","#playlist").live("click",function(a){if($(a.target).closest(".action-showcase").length){}else{if($(this).hasClass("hasAudioSource")){domPlaylist.selectSong($(this),true)}}});this.loading.bindClass($("#music"),{value:true,className:"state-loading"});this.bang.bindClass($("#music"),{value:true,className:"state-bang"});Playlist.type.bindClass($("#playlist-last-search-list"),{value:"album",className:"isAlbum"})},start:function(){this.clear();this.$.header();this.fetchProperties();Playlist.start()},fetchProperties:function(){$("#playlist").toggleClass("prop-isRandom",CurrentSelection.selection.isRandom);$("#playlist").toggleClass("prop-isAllFriends",CurrentSelection.selection.isAllFriendsSelected);$("#playlist").toggleClass("prop-isUser",CurrentSelection.selection.isUserSelected)},clear:function(){this.bang.set(false);this.loading.set(true);this.noMoreSongs=false;this.discHeadCount=[];$("#playlist .vux-playlist-song").not(".state-now-playing, .state-locked").remove();$("#playlist .vux-playlist-album").remove();$("#playlist-last-search-list .state-locked, #playlist-last-search-list .state-now-playing").each(function(){$("#playlist-locked-list").append($(this))});var a=new HashTable();$("#playlist .vux-playlist-song").each(function(){var b=Data.get(Data.types.song,$(this))[0];a.set(b,domPlaylist.items.get(b))});this.items=a},checkAudioSource:function(b){if(b.audio.length){var a=this.items.get(b.id);if(a){a.$.forEach(function(c){c.toggleClass("hasAudioSource",true)},this)}}},selectSong:function(b,d){var a=domPlaylist.items.get(Data.get("song",b)[0]).songOwnerContainer;Player.play(a.song);if(d!=true){Player.pause()}this.$.nowPlaying().removeClass("state-now-playing");b.addClass("state-now-playing");var e=$("#music .vux-app-control-content .state-now-playing").offset().top-$("#music .vux-app-control-content").offset().top;var c=$("#music .vux-app-control-content").height();if(e/c>0.5&&e<c){$("#music .vux-app-control-content").scrollTop($("#music .vux-app-control-content").scrollTop()+$("#music .vux-app-control-content .state-now-playing").outerHeight())}if(e<0){$("#music .vux-app-control-content").scrollTop($("#music .vux-app-control-content").scrollTop()-$("#music .vux-app-control-content .state-now-playing").outerHeight())}}};domPlaylist.$={song:function(g){var d=domPlaylist.$song.clone();var e=g.song;var b=g.owner;Data.insert(Data.types.song,d,e);if(b){d.addClass("state-withfriend");Utils.ui.loadImage(d.find(".vux-playlist-song-friend .vux-image-placeholder"),"vux-image-loading","/images/songinfo/image-cover-nocover.png",function(k){k(Utils.ui.userPictureSrc(b.id))});d.find(".vux-playlist-song-friend").attr("data-tooltip-title",b.content);if(g.dateAdded){d.addClass("hasDate");var i;var a=new Date();var j=Math.floor((a-g.dateAdded)/1000/60);var c=Math.floor(j/60);var h=Math.floor(c/24);var f=Math.floor(h/7);if(j<60){i="la agregó hace "+j+" minuto";if(j!=1){i+="s"}}else{if(1<=c&&c<24){i="la agregó hace "+c+" hora";if(c!=1){i+="s"}}else{if(1<=h&&h<7){i="la agregó hace "+h+" día";if(h!=1){i+="s"}}else{if(1<=f&&f<2){i="la agregó esta semana"}else{if(2<=f&&f<5){i="la agregó este mes"}else{if(5<=f){i="la agregó hace más de un mes"}}}}}}d.find(".vux-playlist-song-info-date").html(i)}}if(Playlist.type.value=="album"){d.find(".vux-playlist-song-album-info-track").html(e.track)}d.find(".vux-playlist-song-info-title").html(e.title.content);d.find(".vux-playlist-song-info-artist").html(e.artist.content);d.find(".vux-playlist-lock-toggle").attr("data-tooltip-title",jsLang.add_list);if(e.official){d.addClass("official")}d.addClass((e.vxRecognized)?"isVxRecognized":"isNotVxRecognized");return d},discHead:function(c){var a=domPlaylist.$discHead.clone();var b;if(c.official){b="Disc "+c.disc;a.addClass("vux-playlist-album-official")}else{b="No official songs";a.addClass("vux-playlist-album-notofficial")}a.find(".vux-playlist-album-content").html(b);return a},header:function(){$(".vux-playlist-filter-header-content").html(CurrentSelection.selection.getDescription())},bang:function(){$(".vux-playlist-bang-tagwords").html(CurrentSelection.selection.getDescription())},nowPlaying:function(){return $("#playlist .vux-playlist-song.state-now-playing")}};domPlaylist.utils={addItem:function(a,b){var c=domPlaylist.items.get(a.song.id);if(!c){domPlaylist.items.set(a.song.id,{songOwnerContainer:a,$:[b]})}else{c.$.push(b)}},sortSongs:function(e){var f=0;var b=[[],[]];e.forEach(function(g){var i=g.song;if(!b[i.disc]){b[i.disc]=[]}var h=b[i.disc][i.track];if(!h&&(i.disc>1||i.official)){b[i.disc][i.track]=g}else{if(!b[0][i.track]){b[0][i.track]=[]}b[0][i.track].push(g)}});if(b[1].length==0){b[1][20]=undefined}var a=[];for(var d=1;d<b.length;d++){for(var c=1;c<b[d].length;c++){if(!b[d][c]&&b[0][c]&&b[0][c].length>0){b[d][c]=b[0][c].shift()}if(b[d][c]){b[d][c].song.official=true;a.push(b[d][c])}}}b[0].forEach(function(g){if(g){g.forEach(function(h){h.song.official=false;a.push(h)})}});return a}};SongInfo={editing:new property(),hasInspierer:new property(),init:function(){this.tags.init();this.categories.init();this.editing.set(false);SongInfo.editing.addClass("vux-songinfo","state-editing",true);SongInfo.editing.addClass("vux-songinfo","state-notediting",false);SongInfo.hasInspierer.addClass("vux-songinfo","state-inspired",true);$("#songinfo-edit").live("click",function(){SongInfo.editing.set(!SongInfo.editing.value)});$("#songinfo-confirm-ok").live("click",function(){var a=SongInfo.tags.get();Player.song.editTagwords(a);SongInfo.endEdition()});$("#songinfo-confirm-cancel").live("click",function(){SongInfo.endEdition()});Player.songChanged.subscribe(function(){SongInfo.editing.set(false);Data.insert(Data.types.song,$("#vux-songinfo"),Player.song);Actions.showcase.check($("#vux-songinfo"));SongInfo.refresh()});$("#songinfo-add-input").labeledInput({label:jsLang.search_for_tags})},refresh:function(){this.cortesy.refresh();this.fixed.refresh();this.tags.refresh()},endEdition:function(){this.editing.set(false);this.tags.refresh()}};SongInfo.cortesy={refresh:function(){SongInfo.hasInspierer.set((Player.song.friendId!=undefined));if(Player.song.friendId){var a=Tagwords.get(Player.song.friendId);if(a){$("#songinfo-cortesy-friend-name").html(a.content);Utils.ui.loadImage($("#songinfo-cortesy-friend-img .vux-image-placeholder"),"vux-image-loading-cover","/images/songinfo/image-cover-nocover.png",function(b){b(Utils.ui.userPictureSrc(a.id))})}}}};SongInfo.fixed={refresh:function(){this.refreshCover();Data.insert(Data.types.tag,$("#vux-songinfo .vux-songinfo-cover"),Player.song.artist);Data.insert(Data.types.tag,$("#vux-songinfo .vux-songinfo-cover"),Player.song.album,true);$("#vux-songinfo .vux-songinfo-title").html(Player.song.title.content);Data.insert(Data.types.tag,$("#vux-songinfo .vux-songinfo-title"),Player.song.title);$("#vux-songinfo .vux-songinfo-artist").html(Player.song.artist.content);Data.insert(Data.types.tag,$("#vux-songinfo .vux-songinfo-artist"),Player.song.artist)},refreshCover:function(){var a=Player.song;Utils.ui.loadImage($(".vux-songinfo-cover .vux-image-placeholder"),"vux-image-loading-cover","/images/songinfo/image-cover-nocover.png",function(b){Frontera.coverSrc(a,function(c){b((c==null)?null:c.small)})})}};SongInfo.tags={suggestedTagsStatus:new property(),suggestedTagJq:undefined,init:function(){$("#vux-songinfo .vux-filter input[type = checkbox]").live("change",function(){$(this).closest("li").toggleClass("state-removed",!($(this).attr("checked")))});$("#songinfo-add-input").autocomplete(Tagwords.fixed,{formatItem:function(a){return a.content+" - "+a.category.content},formatMatch:function(c,b,a){return c.tagslate},formatResult:function(a){return""},matchContains:"word",selectFirst:true,autoFill:false,minChars:2});$("#songinfo-add-input").result(function(a,c,b){if(c&&!SongInfo.tags.contains(c)){SongInfo.tags.add(c);SongInfo.categories.adjustWidths();$(this).val("")}});this.suggestedTagsStatus.set(-1);this.suggestedTagsStatus.addClass("vux-songinfo","state-suggestedtags-loading",0);this.suggestedTagsStatus.addClass("vux-songinfo","state-suggestedtags-ready",function(a){return a!=0});this.suggestedTagsStatus.addClass("vux-songinfo","state-suggestedtags-noresults",-1);this.suggestedTagsStatus.addClass("vux-songinfo","state-suggestedtags-hasresults",1);SongInfo.editing.onChange(function(a){if(a.newValue){$("#vux-songinfo .data-tag").each(function(){Actions.searchBar.abort($(this))});SongInfo.tags.loadSuggested()}})},refresh:function(){$("#vux-songinfo .vux-songinfo-tags-list").empty();Player.song.tags.each(function(b,a){SongInfo.tags.add(a)});SongInfo.categories.adjustWidths()},loadSuggested:function(){this.suggestedTagsStatus.set(0);$("#songinfo-suggestedtags-list").empty();var a=Player.song;PeWon.suggestedTags(Player.song,function(b){if(a.id==Player.song.id){SongInfo.tags.suggestedTagsStatus.set(-1);for(var c=0;c<b.length;c++){if(!Player.song.tags.has(b[c].id)){SongInfo.tags.suggestedTagsStatus.set(1);SongInfo.tags.add(b[c],"suggested")}}}})},get:function(){var a=[];$("#vux-songinfo .vux-filter input:checked").each(function(){a.push($(this).closest(".data-tag").data("tagId"))});return a},contains:function(a){var b=false;$("#vux-songinfo .vux-filter").each(function(){if($(this).data("tagId")==a.id){b=true}});return b},add:function(a,c){var b=Utils.ui.filter(a,"action-searchbar-replace",["action-searchbar-add","action-searchbar-negate"],"<input type='checkbox' /><span>"+a.content+"</span>");if(c=="suggested"){b.addClass("state-source-suggested")}else{b.addClass("state-source-normal");b.find("input[type = checkbox]").attr("checked",true)}if(SongInfo.editing.value){Actions.searchBar.abort(b)}SongInfo.categories.hash.get(a.category.id).find(".vux-songinfo-tags-list").append(b);if(c=="suggested"){SongInfo.categories.adjustWidths()}}};SongInfo.categories={hash:new HashTable(),init:function(){var a=this;var b=$("#vux-songinfo .vux-songinfo-category").clone();$("#songinfo-category-list").empty();Categories.hash.each(function(c,e){if(c>500){var d=b.clone();a.hash.set(c,d);d.find(".vux-songinfo-category-name").html(e.content);$("#songinfo-category-list").append(d)}});this.adjustWidths()},adjustWidths:function(){var b=100;var a=3;$("#vux-songinfo .vux-songinfo-category").each(function(){var c=$(this).find(".vux-songinfo-tags-list").children().size();if(c==0){$(this).hide()}else{$(this).show();$(this).width(Math.ceil(c/a)*b)}})}};Autocomplete={cleanInput:undefined,jqItem:undefined,results:new HashTable(),active:new property(),noResults:new property(),loading:new property(),init:function(){this.active.addClass("SB_autocomplete","state-active",true);this.loading.addClass("SB_searchBarWrapper","state-loading",true);this.noResults.addClass("SB_autocomplete","state-noresults",true);this.noResults.addClass("SB_autocomplete","state-withresults",false);$(this.dom.inputId).keydown(function(a){if(a.keyCode==38){Autocomplete.dom_moveSelection("previous")}else{if(a.keyCode==40){Autocomplete.dom_moveSelection("next")}}});$(this.dom.inputId).keyup(function(a){if(a.keyCode==13){var b=$(Autocomplete.dom.resultsId+" .sacGroupResults").children(".sacElementKeyHover").first();if(b.size()>0){Autocomplete.selectResult(b.data("tagId"))}else{Poke.wrongEnter();if(Facelib.loginStatus.value==-1){Thickbox.show({frame:$("#thickbox-frame-usefull"),content:$("#achievement-2"),where:$("#SB_elementsWrapper"),classes:["vux-animation-thickbox"]})}}}else{if(a.keyCode!=38&&a.keyCode!=40){if($(this).val().length>1){Autocomplete.noResults.set(false);clearTimeout(this.timer);this.timer=setTimeout("Autocomplete.findResults()",100)}else{Autocomplete.active.set(false)}}}});$("#SB_searchBarWrapper").bind("clickoutside",function(){if($("#SB_searchInput:focus").size()==0){Autocomplete.active.set(false)}});$(this.dom.inputId).bind("focus",function(){if($(this).val().length>1){Autocomplete.active.set(true)}});this.active.onChange(function(a){if(a.newValue==false){Autocomplete.loading.set(false)}else{Autocomplete.noResults.set(false)}});this.loading.onChange(function(a){if(a.newValue==false&&Autocomplete.active.value==true&&Autocomplete.results.length==0){Autocomplete.noResults.set(true)}});$(".sacElement").live("click",function(a){Autocomplete.selectResult($(this).data("tagId"))});this.friends.init();this.extras.init();this.dom_defineItem()},selectResult:function(a){CurrentSelection.addItem(this.results.get(a).tag,true);$(this.dom.inputId).val("");this.active.set(false)},findResults:function(){this.cleanInput=this.cleanText($(this.dom.inputId).val());if(this.cleanInput.length>1){this.active.set(true);this.results.each(function(a,b){if(!this.isValidResult(b.tag)){this.dom_removeResult(b.jq);this.results.remove(a)}},Autocomplete);this.extras.add();this.tagwords.add();this.friends.add();this.server.add();this.dom_refreshAdorners()}else{this.active.set(false)}},addResults:function(a,d,c){if(d==undefined){d=true}if(c==undefined){c=false}for(var b=0;b<a.length;b++){if(!this.results.has(a[b].id)&&(c||this.results.length<this.param.MAX_RESULTS)&&(!d||Autocomplete.isValidResult(a[b]))){this.results.set(a[b].id,{tag:a[b],jq:this.dom_addResult(a[b])})}}},cleanText:function(a){return Utils.removeDiacritics(a).toLowerCase()},isValidResult:function(a){var b=this.cleanText(a.content);return(b.indexOf(this.cleanInput)==0||b.indexOf(" "+this.cleanInput)!=-1)},dom_defineItem:function(){var a="";a+="<li class='sacElement'>";a+="<div class='sacContent'>";a+="<span class='sacItemContent'></span>";a+="<span class='sacFriendUserC hidden'> (usuario de voxound)</span>";a+="</div>";a+="<div class='sacTagwordCategory hidden'></div>";a+="</li>";this.jqItem=$(a)},dom_moveSelection:function(e){var d=$(this.dom.resultsId+" .sacGroupResults").children(".sacElementKeyHover");d=(d.length==0)?undefined:d.first();var a=undefined;if(!d){a=(e=="next")?$(this.dom.resultsId+" .sacGroupResults").children().first():$(this.dom.resultsId+" .sacGroupResults").children().last()}if(!a){var b=undefined;var c=false;$(this.dom.resultsId+" li").each(function(f){if(!a){if(c){a=$(this)}if($(this).hasClass("sacElementKeyHover")){if(e=="next"){c=true}else{if(b){a=b}}$(this).toggleClass("sacElementKeyHover",false)}b=$(this)}})}if(a){a.toggleClass("sacElementKeyHover",true)}},dom_addResult:function(b){var a=this.jqItem.clone();var c=undefined;if(b.category.id==1){c="artists"}else{if(b.category.id==2){c="titles"}else{if(b.category.id==3){c="albums"}else{if(b.category.id<=51){c="people"}else{if(b.category.id==PARAMS.CATEGORY.COMPUTER_SEARCH){c="computer"}else{c="tagwords"}}}}}$(this.dom.resultsId+" #"+c+" .sacGroupResults").append(a);a.data("tagId",b.id);a.find(".sacItemContent").html(b.content);if(b.category.id>1000){a.find(".sacTagwordCategory").html(b.category.content).show()}if(b.category.id==PARAMS.CATEGORY.PAL){a.find(".sacFriendUserC").show()}return a},dom_removeResult:function(a){a.remove()},dom_clear:function(){$(this.dom.resultsId+" .sacGroupResults").empty()},dom_refreshAdorners:function(){$("#SB_autocompleteResults .sacGroup").each(function(){if($(this).find(".sacGroupResults").children().size()==0){$(this).hide()}else{$(this).show()}});$(this.dom.wrapperId+" .sacGroup:visible:odd").toggleClass("alternate",true);$(this.dom.wrapperId+" .sacGroup:visible:even").toggleClass("alternate",false)}};Autocomplete.dom={wrapperId:"#SB_autocomplete",resultsId:"#SB_autocompleteResults",inputId:"#SB_searchInput"};Autocomplete.param={MAX_RESULTS:10,CACHE_RESULTS:30,MIN_CHARACTERS:3};Autocomplete.friends={array:[],init:function(){Friends.ready.onChange(function(a){if(a.newValue){Facelib.friends.forEach(function(c,b){if(!Friends.vx.has(c.id)){this.array.push(new Tag({id:c.id,content:c.name,category:Categories.get(51)}))}else{this.array.push(new Tag({id:Friends.vx.get(c.id),content:c.name,category:Categories.get(50)}))}},Autocomplete.friends)}})},add:function(){Autocomplete.addResults(this.array)}};Autocomplete.tagwords={add:function(){Autocomplete.addResults(Tagwords.array)}};Autocomplete.server={add:function(){var a=Autocomplete.cleanInput;if(a.length>1){Autocomplete.loading.set(true);Frontera.autocomplete(a,function(b){if(this.cleanInput==a){this.addResults(b[0],false,true);this.addResults(b[1],false,false);this.loading.set(false)}else{this.addResults(b[1],true,false);this.server.add(this.cleanInput)}this.dom_refreshAdorners()},Autocomplete)}}};Autocomplete.extension={add:function(){var a=Autocomplete.cleanInput;if(a.length>1){PeWon.autocomplete(a,function(b){if(this.cleanInput==a){this.addResults(b[0],false,true);this.addResults(b[1],false,false);this.dom_refreshAdorners()}else{this.addResults(b[1],true,false);this.extension.add(this.cleanInput)}},Autocomplete)}}};Autocomplete.extras={items:[],init:function(){this.checkItems();Extension.installStatus.onChange(function(){Autocomplete.extras.checkItems()});Showcase.ready.onChange(function(){Autocomplete.extras.checkItems()})},add:function(){Autocomplete.addResults(this.items)},checkItems:function(){this.items=[];if(Showcase.ready.value==true){this.items.push(new Tag({id:Showcase.tag.id,content:Account.fbInfo.name,category:Showcase.tag.category}))}}};Transporter={init:function(){var a=this;$("#soundcontrol-rew").live("click",function(){Player.prev()});$("#soundcontrol-play-pause").live("click",function(){Player.togglePlay()});$("#soundcontrol-ff").live("click",function(){Player.next()});$(".mandon-obediente").bind("clickoutside",function(){$(this).toggleClass("active",false)});$(".mandon").live("click",function(b){$(this).closest(".mandon-obediente").addClass("active")});$("#volume-slider").slider({orientation:"vertical",min:0,max:100,value:80,slide:function(b,c){Player.setVolume(c.value)}});$("#transporter-source-selector-video").live("click",function(){Player.changeResource("youtube");$(this).closest(".mandon-obediente").removeClass("active")});$("#transporter-source-selector-audio").live("click",function(){Player.changeResource("url");$(this).closest(".mandon-obediente").removeClass("active")});Player.songChanged.subscribe(function(){$("#transporter-source-current").toggleClass("state-audio",(Player.player.key!="youtube"));$("#transporter-source-current").toggleClass("state-video",(Player.player.key=="youtube"));$("#transporter-source-selector").removeClass("state-audio");$("#transporter-source-selector").removeClass("state-video");Transporter.setSourcesSelector()});Player.audioChanged.subscribe(function(){$("#transporter-source-current").toggleClass("state-audio",(Player.player.key!="youtube"));$("#transporter-source-current").toggleClass("state-video",(Player.player.key=="youtube"));$("#transporter-source-selector").removeClass("state-audio");$("#transporter-source-selector").removeClass("state-video");Transporter.setSourcesSelector()});SongUtils.onSongChange.subscribe(function(b){if(b=="newAudioSource"&&Player.song&&Player.song.id==this.id){Transporter.setSourcesSelector()}});Player.status.addClass("transporter","playing",Player.E_status.play);$("#progress").live("click",function(c){var b=(Player.player.duration()*(c.pageX-$(this).offset().left))/$(this).width();Player.jumpTo(Math.round(b))});this.refreshTimer()},setSourcesSelector:function(){Player.song.audio.each(function(a,b){if(b.type=="url"){$("#transporter-source-selector").toggleClass("state-audio",true)}else{$("#transporter-source-selector").toggleClass("state-video",true)}})},refreshTimer:function(){if(Player.player&&Player.player.isReady()){var d=Player.player.duration();var c=Player.player.position();if(d>0){var a=Math.round(c/d*100);var b=Math.max(0,Math.round(Player.player.buffered()*100)-a);$("#progress-elapsed").css("width",a+"%");$("#progress-buffered").css("width",b+"%");$("#progress-time").html(Utils.durationFormat(c)+" / "+Utils.durationFormat(d))}}else{$("#progress-elapsed").css("width","0%");$("#progress-buffered").css("width","0%");$("#progress-time").empty()}setTimeout("Transporter.refreshTimer();",300)}};VideoAndLyrics={loadingLyrics:new property(),bookmarkedVideo:undefined,currentSongBookmarked:new property(),moreVideos:new property(),$altVideo:undefined,init:function(){Player.songChanged.subscribe(function(a){VideoAndLyrics.setLyric(a.lyric==undefined?"":a.lyric);if(Player.song.lyric==undefined){Player.song.getSongInfo()}if(Player.song.isBookmarked){VideoAndLyrics.bookmarkedVideo=a.getAudioResourceByType("youtube");VideoAndLyrics.currentSongBookmarked.set(true)}else{VideoAndLyrics.currentSongBookmarked.set(false)}VideoAndLyrics.moreVideos.set(false);$("#youtube-more-videos-button .button-content").html($("#youtube-more-videos-button .button-content").data("oldContent"))});Showcase.onChange.subscribe(function(a){VideoAndLyrics.bookmarkedVideo=Player.resources.youtube;if(a.isBookmarked){VideoAndLyrics.currentSongBookmarked.set(true)}else{VideoAndLyrics.currentSongBookmarked.set(false)}VideoAndLyrics.checkVideos()});SongUtils.onSongChange.subscribe(function(a){if(a=="lyric"&&this.id==Player.song.id){VideoAndLyrics.setLyric(this.lyric)}});this.loadingLyrics.bindClass($("#sc_lyric"),[{className:"state-loading",value:true}]);this.moreVideos.bindClass($("#sc_youtube"),[{className:"state-morevideos",value:true}]);this.currentSongBookmarked.bindClass($("#sc_youtube"),[{className:"state-bookmarked",value:true}]);$("#youtube-more-videos-button .button-content").data("oldContent",$("#youtube-more-videos-button .button-content").html());$("#youtube-more-videos-button").bind("click",function(){if(VideoAndLyrics.moreVideos.value){$("#youtube-more-videos-button .button-content").html($("#youtube-more-videos-button .button-content").data("oldContent"));VideoAndLyrics.moreVideos.set(false)}else{$("#youtube-more-videos").html(jsLang.searching_videos);$("#youtube-more-videos-button .button-content").html(jsLang.agrandar_video);Resolvers.youtube.getIds(Player.song,function(b,c,a){if(Player.song.id==b.id&&c.length!=0){$("#youtube-more-videos").html("");c.forEach(function(e,d){$("#youtube-more-videos").append(VideoAndLyrics.$.altVideo(e,a[d]))});VideoAndLyrics.checkVideos()}else{$("#youtube-more-videos").html(jsLang.searching_videos_not_found)}});VideoAndLyrics.moreVideos.set(true)}});VideoAndLyrics.$altVideo=$("#youtube-more-videos .vux-youtube-altVideo").clone();$("#youtube-more-videos .vux-youtube-altVideo").html(jsLang.searching_videos);$(".vux-youtube-altVideo").live("click",function(){VideoAndLyrics.playAltVideo($(this).data("ytid"))});$(".vux-youtube-bookmark-flag",".vux-youtube-altVideo").live("click",function(){VideoAndLyrics.bookmarkedVideo=$(this).parent().data("ytid");Showcase.updateAudioResource(Player.song,"youtube",VideoAndLyrics.bookmarkedVideo);VideoAndLyrics.checkVideos()})},setLyric:function(a){VideoAndLyrics.loadingLyrics.set((a==""));$("#lyricContent").html(a.replace(/\n/g,"<br>"))},checkVideos:function(){$("#youtube-more-videos .vux-youtube-altVideo").each(function(){$(this).toggleClass("state-playing",false);$(this).toggleClass("state-bookmarked",false);if(Player.resources.youtube==$(this).data("ytid")){$(this).toggleClass("state-playing",true)}if(VideoAndLyrics.currentSongBookmarked.value){if(VideoAndLyrics.bookmarkedVideo==$(this).data("ytid")){$(this).toggleClass("state-bookmarked",true)}}})},playAltVideo:function(a){Player.changeResource("youtube",a);VideoAndLyrics.checkVideos()}},VideoAndLyrics.$={altVideo:function(b,a){var c=VideoAndLyrics.$altVideo.clone();c.data("ytid",b);if(a){c.addClass("hasTooltip").attr("data-tooltip-title",a)}Utils.ui.loadImage(c.find(".vux-thumb-container .vux-image-placeholder"),"vux-image-loading","/images/songinfo/image-cover-nocover.png",function(d){d(Utils.ui.getYoutubeThumbnailSource(b))});return c}};Achievements={active:new property(),userAchievements:new HashTable(),currentThickbox:undefined,init:function(){Account.status.addTrigger([{value:ENUM.READY,callback:function(){if(Utils.url.get("achievements")==undefined){var a=Facelib.user.achievements.split(",");a.forEach(function(c,b){if(c!=""){this.userAchievements.set(c,true)}},this)}this.active.set(!this.userAchievements.has(0));if(this.active.value){this.reactions.bind();this.treasures.bind()}}},{value:ENUM.NOT_READY,callback:function(){this.userAchievements=new HashTable();this.active.set(false);this.firstLog=false;this.treasures.unbind();this.reactions.unbind()}}],this);$(".achievement-quit").live("click",function(){Achievements.achievementComplete(0);Achievements.active.set(false);Achievements.treasures.unbind();Achievements.reactions.unbind()});$(".thickbox-close").live("mouseup",function(){if(!Achievements.active.value||Achievements.currentThickbox==2){$("#SB_searchInput").focus();Log.trace("caca","caca","caca");Autocomplete.active.set(true)}})},achievementComplete:function(c){c=parseInt(c);if(c>0){var a;switch(c){case 1:a=$("#SB_elementsWrapper");break;case 2:a=$("#SB_elementsWrapper");break;case 3:a=$("#SB_elementsWrapper");break;case 5:a=$("#lp_showcase");break}this.currentThickbox=c;Thickbox.show({frame:$("#thickbox-frame-usefull"),content:$("#achievement-"+c),where:a,classes:["vux-animation-thickbox"]});if(c==3){var b=$("#achievement-3-specific").html();b=b.replace("tag_1",CurrentSelection.selection.elements[0].tag.content);b=b.replace("tag_2",CurrentSelection.selection.elements[1].tag.content);$("#achievement-3-specific").html(b)}}else{this.active.set(false)}if(!this.userAchievements.has(c)){this.userAchievements.set(c,true);Frontera.achievement(this.userAchievements.keyToArray())}}};Achievements.treasures={binded:false,currentTreasure:{},where:{5:"#vux-songinfo #songinfo-outshowcase",7:"#vux-songinfo .action-share-song"},when:{4:function(){return true},5:function(){return Achievements.userAchievements.has(4)},6:function(){return Achievements.userAchievements.has(5)},7:function(){return Achievements.userAchievements.has(6)}},bind:function(){if(!this.binded){for(var a in this.where){this.bindAchievement(a)}}this.binded=true;this.coordinator()},bindAchievement:function(b){var a=this;$(this.where[b]).live("click",function(){if(Achievements.active.value&&b==a.currentTreasure.id){Achievements.achievementComplete(b);a.disableCurrentTreasure();a.checkTreasures()}});$(this.where[b]).css("position","relative")},unbind:function(){this.currentAchievementId=undefined;this.disableCurrentTreasure()},coordinator:function(){if(Achievements.active.value){if(this.checkTreasures()){setTimeout("Achievements.treasures.coordinator();",1000)}}},checkTreasures:function(){var c=undefined;var a=false;for(var b in this.where){if(!Achievements.userAchievements.has(b)){a=true;if(this.when[b]()){c=parseInt(b)}}}if(c!=undefined&&c!=this.currentTreasure.id){this.disableCurrentTreasure();this.currentTreasure.id=c;this.currentTreasure.animation=new Animations.bounceAndRotate($(this.where[c]))}return a},disableCurrentTreasure:function(){if(this.currentTreasure.id!=undefined){this.currentTreasure.animation.stop();this.currentTreasure.id=undefined}}};Achievements.reactions={bind:function(){if(!Achievements.userAchievements.has(1)){$(".action-searchbar-add, .action-searchbar-replace, .action-searchbar-negate").live("click",Achievements.reactions.what[1])}$("#SB_searchInput").keyup(Achievements.reactions.what[2]);if(!Achievements.userAchievements.has(3)){CurrentSelection.onChange.subscribe(Achievements.reactions.what[3])}},unbind:function(){$(".action-searchbar-add, .action-searchbar-replace, .action-searchbar-negate").die("click",Achievements.reactions.what[1]);$("#SB_searchInput").unbind("keyup",Achievements.reactions.what[2]);CurrentSelection.onChange.unsubscribe(Achievements.reactions.what[3])},what:{1:function(){if(!Achievements.userAchievements.has(1)&&!$(this).hasClass("action-searchbar-abort")&&$(this).closest("#lp_radios").size()==0&&$(this).closest("#lp_showcase").size()==0){Achievements.achievementComplete(1)}},2:function(a){if(a.keyCode==13&&$(".sacElementKeyHover").size()==0){Achievements.achievementComplete(2)}},3:function(){if(!Achievements.userAchievements.has(3)){var a=CurrentSelection.selection;if(a.elements.length>1&&(a.isUserSelected||a.isComputerSelected||a.isTagwordSelected||a.isAllFriendsSelected)){Achievements.achievementComplete(3)}}}}};Share={objectToShare:undefined,type:new property(),friend:undefined,sending:new property(),publishToMyWall:new property(),publishToFriend:new property(),publishReady:new property(),init:function(){Share.type.addClass("thickbox-action","prop-invite-search",Share.E_types.invite_search);Share.type.addClass("thickbox-action","prop-invite",Share.E_types.invite);Share.type.addClass("thickbox-action","prop-song",Share.E_types.song);Share.type.addClass("thickbox-action","prop-request",Share.E_types.request);Share.type.addClass("thickbox-default","prop-showcase",Share.E_types.showcase);Share.sending.addClass("thickbox-action","state-sending",true);Share.sending.addClass("thickbox-default","state-sending2",true);Share.publishToFriend.bind('#share-content-to input[type="checkbox"]',"checked",true,"checked");Share.publishToMyWall.bind('#share-content-mywall input[type="checkbox"]',"checked",true,"checked");Share.publishReady.bind("#thickbox-action-ok","disabled",false,"disabled");Share.publishToFriend.onChange(function(a){if(!a.newValue&&!Share.publishToMyWall.value){Share.publishReady.set(false)}else{Share.publishReady.set(true)}});Share.publishToMyWall.onChange(function(a){if(!a.newValue&&!Share.publishToFriend.value){Share.publishReady.set(false)}else{Share.publishReady.set(true)}});$("#thickbox-action-ok").live("click",function(){Share.publish()});$("#share-showcase-friend").live("click",function(){Share.publishToFriend.set(true);Share.publishToMyWall.set(false);Share.publish()});$("#share-showcase-wall").live("click",function(){Share.friend=undefined;Share.publishToFriend.set(false);Share.publishToMyWall.set(true);Share.publish()});$("#share-content-friend-remove").live("click",function(){Share.friend=undefined;Share.publishToFriend.set(false);Share.checkFriend()});$("#share-showcase-friend-reload").live("click",function(){Share.inviteRandomFriend()});CurrentSelection.onChange.subscribe(function(){if(CurrentSelection.selection.fbUserId){Share.invite(Facelib.friendsHash.get(CurrentSelection.selection.fbUserId))}});Friends.ready.onChange(function(a){Share.setAutocomplete()})},setAutocomplete:function(){$("#share-content-autocomplete").unbind();$("#share-content-autocomplete").autocomplete(Facelib.friends,{formatItem:function(a){var b="<img src='"+a.picture+"' class='vux-image-placeholder' width='32' height='32'/>"+a.name;return b},formatMatch:function(c,b,a){return c.name},matchContains:"word",selectFirst:true,autoFill:false,minChars:2});$("#share-content-autocomplete").result(function(a,c,b){if(c){Share.friend=c;Share.checkFriend();Share.publishToFriend.set(true);$("#share-content-autocomplete").val("")}})},reset:function(){Share.type.set(undefined);this.friend=undefined;this.sending.set(false);this.publishToMyWall.set(false);this.publishToFriend.set(false);$("#share-content-autocomplete").val("");this.checkFriend()},message:function(b){if(b){$(".share-content-message").html(b);$(".share-content-message").val(b);return b}var a=$(".share-content-message:visible").val();return a},song:function(a){if(a!=undefined){Facelib.doWithPermission("",function(){Share.reset();$("#thickbox-action-ok").html(jsLang.share_go);Share.objectToShare=a;Share.type.set(Share.E_types.song);Share.publishToMyWall.set(true);Share.message(jsLang.sample_message);$("#share-song-title").html(Share.objectToShare.title.content);$("#share-song-artist").html(Share.objectToShare.artist.content);Utils.ui.loadImage($("#share-song-video .vux-image-placeholder"),"vux-image-loading","/images/songinfo/image-cover-nocover.png",function(b){b(Utils.ui.getYoutubeThumbnailSource(Share.objectToShare.getAudioResourceByType("youtube")))});Thickbox.show({frame:$("#thickbox-frame-action"),content:$("#share")})})}},invite:function(a){Share.reset();$("#thickbox-action-ok").html(jsLang.share_ok);if(a){Share.type.set(Share.E_types.invite_search);Share.message(jsLang.sample_invite_search);$("#share-friend-name").html(a.name);Share.friend=a;Share.checkFriend();Share.publishToFriend.set(true);Share.publishToMyWall.set(false);Utils.ui.loadImage($("#share-friend-picture .vux-image-placeholder"),"vux-image-loading","/images/songinfo/image-cover-nocover.png",function(b){b(Utils.ui.getFBImageSource(a.id))})}else{Share.type.set(Share.E_types.invite);Share.message(jsLang.sample_invitation);Share.publishToMyWall.set(true)}Thickbox.show({frame:$("#thickbox-frame-action"),content:$("#share")})},showcase:function(){Facelib.doWithPermission("",function(){Share.reset();Share.type.set(Share.E_types.showcase);Share.message(jsLang.share_showcase_message);Share.inviteRandomFriend();Thickbox.show({frame:$("#thickbox-frame-default"),content:$("#share-showcase")})})},Oldpublish:function(){$("thickbox-action-error").hide();if(this.type.value==this.E_types.song){var a=this.objectToShare.getAudioResourceByType("youtube")}Facelib.doWithPermission("publish_stream",function(){Share.sending.set(true);$("#thickbox-action-ok").html(jsLang.share_publishing);if(Share.publishToMyWall.value){Facelib.publish(Share.message(),Facelib.getYoutubeVideoAttachment(a),Facelib.user.id,function(){Share.publishToMyWall.set(false);Share.checkPublished()},function(){$("#thickbox-action-error").html(jsLang.share_error);$("#thickbox-action-error").show()})}if(Share.publishToFriend.value&&Share.friend!=undefined){Facelib.publish(Share.message(),Facelib.getYoutubeVideoAttachment(a),Share.friend.id,function(){Share.publishToFriend.set(false);Share.checkPublished()},function(){$("#thickbox-action-error").html(jsLang.share_error);$("#thickbox-action-error").show()})}})},publish:function(){$("thickbox-action-error").hide();Share.sending.set(true);Share.publishReady.set(false);if(this.type.value==this.E_types.song){var a=Player.resources.youtube;if(Share.publishToMyWall.value){Facelib.doWithPermission("publish_stream",function(){Facelib.publish(Share.message(),Facelib.getYoutubeVideoAttachment(a),Facelib.user.id,function(){Share.publishToMyWall.set(false);Share.checkPublished()},Share.shareError)},function(){Share.shareError();alert("No permission to publish!")})}if(Share.publishToFriend.value&&Share.friend!=undefined){Facelib.doWithPermission("publish_stream",function(){Facelib.publish(Share.message(),Facelib.getYoutubeVideoAttachment(a),Share.friend.id,function(){Share.publishToFriend.set(false);Share.checkPublished()},Share.shareError)},function(){Share.shareError()})}}else{if(this.type.value==this.E_types.invite){if(Share.publishToMyWall.value){Facelib.doWithPermission("publish_stream",function(){FB.api("/me/feed","post",Facelib.getStandardLink(Share.message()),function(b){if(b){Share.publishToMyWall.set(false);Share.checkPublished()}else{Share.shareError()}})},function(){Share.shareError();alert("No permission to publish!")})}if(Share.publishToFriend.value&&Share.friend!=undefined){Facelib.doWithPermission("publish_stream",function(){FB.api("/"+Share.friend+"/feed","post",Facelib.getStandardLink(Share.message()),function(b){if(b){Share.publishToFriend.set(false);Share.checkPublished()}else{Share.shareError()}})},function(){Share.shareError();alert("No permission to publish!")})}}else{if(Share.publishToMyWall.value){Facelib.doWithPermission("publish_stream",function(){FB.api("/me/feed","post",Facelib.getListLink(Share.message()),function(b){if(b){Share.publishToMyWall.set(false);Share.checkPublished()}else{Share.shareError()}})},function(){Share.shareError();alert("No permission to publish!")})}if(Share.publishToFriend.value&&Share.friend!=undefined){Facelib.doWithPermission("publish_stream",function(){FB.api("/"+Share.friend+"/feed","post",Facelib.getListLink(Share.message()),function(b){if(b){Share.publishToFriend.set(false);Share.checkPublished()}else{Share.shareError()}})},function(){Share.shareError();alert("No permission to publish!")})}}}},shareError:function(){$("#thickbox-action-error").html(jsLang.share_error);$("#thickbox-action-error").show()},checkPublished:function(){if(!Share.publishToMyWall.value&&!Share.publishToFriend.value){Share.sending.set(false);Thickbox.hide()}},checkFriend:function(){if(Share.friend!=undefined){$("#share-content-friend").show();$("#share-content-autocomplete").hide();Utils.ui.loadImage($("#share-content-friend-image .vux-image-placeholder"),"vux-image-loading","/images/songinfo/image-cover-nocover.png",function(a){a(Utils.ui.getFBImageSource(Share.friend.id))});$("#share-content-friend-name").html(Share.friend.name)}else{$("#share-content-friend").hide();$("#share-content-autocomplete").show()}},inviteRandomFriend:function(){var a=0;var b=Facelib.friends[Math.floor(Math.random()*Facelib.friends.length)];while(b.id==1&&a<100){b=Facelib.friends[Math.floor(Math.random()*Facelib.friends.length)];a++}$("#share-showcase-friend-name").html(b.name);Share.friend=b.id;Utils.ui.loadImage($("#share-showcase-friend .vux-image-placeholder"),"vux-image-loading","/images/songinfo/image-cover-nocover.png",function(c){c(b.picture)})}};Share.E_types={song:"song",invite:"invite",invite_search:"invite_search",request:"request",showcase:"showcase"};Poke={cookieId:$.cookie("session_id"),init:function(){if(this.cookieId==null){this.cookieId=Math.round(Math.random()*2000000000);$.cookie("session_id",this.cookieId,{path:"/",expires:1000})}$(".action-poke").live("click",function(){Frontera.poke($(this).attr("data-poke"),"click","")});this._pokeInDom($(".action-extension-skip"),"SKIP_EXTENSION");this._pokeInDom($("#lp_computer"),"COMPUTER");this._pokeInDom($(".action-extension-download"),"DOWNLOAD");this._pokeInDom($(".state-facebook-login"),"LOGIN_CLICK");this._pokeInDom($(".state-facebook-logout"),"LOGOUT_CLICK");this._pokeInDom($(".state-facebook-invite"),"INVITE");this._pokeInDom($("#user-info-points"),"POINTS");this._pokeInDom($("#lp_computer-moreinfo"),"EXTENSION_MORE_INFO");$("#thickbox-wrapper button").live("click",function(){Frontera.poke("THICKBOX",$(this).attr("id"),"")});$(".thickbox-close").live("click",function(){Frontera.poke("THICKBOX","close","")});CurrentSelection.onChange.subscribe(function(){var a=[];CurrentSelection.selection.elements.forEach(function(c,b){a.push(c.tag.id)});Frontera.poke("SEARCH",CurrentSelection.selection.getDescription(),a.join(","))});Extension.installStatus.onChange(function(a){if(a.oldValue!=undefined&&a.newValue==Extension.E_Status.installed){Frontera.poke("INSTALLED","instaló","")}});$("#SB_searchInput").bind("click",function(){if($(this).val()==""){Frontera.poke("SEARCH_INIT","","")}});$("#vux-welcome-first-user-buttons a").live("click",function(){var a=$(this).html();a=a.replace(/^\s*/,"").replace(/\s*$/,"");Frontera.poke("WELCOME",a,"")});Autocomplete.noResults.onChange(function(a){if(a.newValue){Frontera.poke("NO_RESULTS",$("#SB_searchInput").val(),"")}});$(window).unload(function(){Frontera.poke("EXIT",$("#contentWrapper").attr("class"),"")});$(window).keydown(function(a){if(a.keyCode==116){Frontera.poke("RELOAD",$("#contentWrapper").attr("class"),"")}});$("body").ajaxError(function(c,b,a){Log.trace("frontera",a.url,"ajax error: "+b.responseText)});Frontera.poke("URL",Url.originalUrl,"")},_pokeInDom:function(a,b){a.addClass(".action-poke");a.attr("data-poke",b)},songStarts:function(a){Frontera.poke("PLAY_BEGIN",a.artist.content+" - "+a.title.content,a.id)},songEnds:function(a){Frontera.poke("PLAY_END",a.artist.content+" - "+a.title.content,a.id)},notAllowed:function(){Frontera.poke("WONT_ALLOW",window.location.search,"")},wrongEnter:function(){Frontera.poke("WRONG_ENTER",$("#SB_searchInput").val(),"")},wrongInit:function(){Frontera.poke("WRONG_INIT","houston!","")},achievement:function(a){Frontera.poke("ACHIEVEMENT",a,"")}};Utils.ui.userPictureSrc=function(b){var d;if(b!=undefined){if(b==Account.user_id){d=Facelib.user.picture}else{var c=Friends.fb.get(b);if(!c){c=b}var a=Facelib.friendsHash.get(c);if(a){d=a.picture}}}if(d==null||d==""||d==undefined){return"http://static.ak.fbcdn.net/rsrc.php/z5HB7/hash/ecyu2wwn.gif"}return d};Utils.ui.getMyUrl=function(){var a=new Selection();a.addElement({tag:Showcase.tag,sign:true});a.updateProperties();return a.getLink()};UserHelper={init:function(){this.reactions.init()}};UserHelper.reactions={init:function(){$(".action-searchbar-add, .action-searchbar-replace, .action-searchbar-negate").live("click",function(){if(Account.status.value==ENUM.READY&&!Account.achievements.has(0)&&!Account.achievements.has(1)&&!$(this).hasClass("action-searchbar-abort")&&$(this).closest("#lp_radios").size()==0&&$(this).closest("#lp_showcase").size()==0){Account.achievements.set(1);Thickbox.show({frame:$("#thickbox-frame-usefull"),content:$("#achievement-1"),where:$("#SB_elementsWrapper"),classes:["vux-animation-thickbox"]})}});$("#SB_searchInput").keyup(function(a){if(!Account.achievements.has(0)&&a.keyCode==13&&$(".sacElementKeyHover").size()==0){Account.achievements.set(2);Thickbox.show({frame:$("#thickbox-frame-usefull"),content:$("#achievement-2"),where:$("#SB_elementsWrapper"),classes:["vux-animation-thickbox"]})}});CurrentSelection.onChange.subscribe(function(){if(Account.status.value==ENUM.READY&&!Account.achievements.has(0)&&!Account.achievements.has(3)){var a=CurrentSelection.selection;if(a.elements.length>1&&(a.isUserSelected||a.isComputerSelected||a.isTagwordSelected||a.isAllFriendsSelected)){Account.achievements.set(3);Thickbox.show({frame:$("#thickbox-frame-usefull"),content:$("#achievement-3"),where:$("#SB_elementsWrapper"),classes:["vux-animation-thickbox"]});var b=$("#achievement-3-specific").html();b=b.replace("tag_1",CurrentSelection.selection.elements[0].tag.content);b=b.replace("tag_2",CurrentSelection.selection.elements[1].tag.content);$("#achievement-3-specific").html(b)}}});$("#lp_computer-moreinfo").bind("click",function(){alert("Ooops, todavía no terminamos esta explicación. \n\nPero bueno...lo que te puedo contar rápidamente es que si lo instalas podrás ver las canciones de tu computador acá!! \n\nEs buenísimo tener las canciones de tu computador, de tus amigos y del mundo en un sólo lugar. ¡¡Haz la prueba!! ;)")});Showcase.onChange.subscribe(function(a){if(Showcase.totalSongs()==PARAMS.SIZE.SHOWCASE_SHARE){Share.showcase()}});$("#user-info-points").bind("click",function(){Thickbox.show({frame:$("#thickbox-frame-loading"),url:"/points/user/"+Showcase.tag.id})})}};UserHelper.progress={active:new property(),_current:undefined,_items:{10:{isDone:function(){return(Showcase.totalSongs()<PARAMS.USER_PROGRESS.SHOWCASE)},set:function(){this._eventHandler();Showcase.onChange.subscribe(this._eventHandler)},unset:function(){Showcase.onChange.unsubscribe(this._eventHandler)},_eventHandler:function(){if(!this.isDone()){}else{this.unset();UserHelper.progress.check()}}}},setTitle:function(a){},setContent:function(a){},setProgress:function(a){},check:function(){this._current=undefined;for(var a in this._items){if(!Account.achievements.has(a)){if(this._items[a].isDone()){Account.achievements.set(a)}else{this._current=a;this._items[this.current].set();break}}}this.active.set((this._current==undefined)?false:true)},unset:function(){this.current=undefined;var a=this.items[this.current];if(a&&typeof a.unset=="function"){a.unset()}this.active.set(false)}};UserHelper.clicks={binded:false,actives:[],items:[{id:5,selector:"#vux-songinfo #songinfo-outshowcase",condition:function(){return(Showcase.totalSongs()==0)},reaction:function(){},animation:true},{id:7,selector:"#vux-songinfo .action-share-song",animation:true}],reset:function(){},check:function(){}};$(document).ready(function(){if($.cookie("session_id")==null){$.cookie("session_id",Math.round(Math.random()*2000000000),{path:"/",expires:1000})}HTML={};$(".html-object-definition").each(function(){HTML[$(this).attr("id")]=$(this).clone();HTML[$(this).attr("id")].removeAttr("id");HTML[$(this).attr("id")].removeClass("html-object-definition");$(this).remove()});Log.init();Categories.init();Tagwords.init();Url.init();General.init();SearchBar.init();SearchHistory.init();domPlaylist.init();SongInfo.init();LeftPanel.init();Share.init();ContentManager.init();VideoAndLyrics.init();Actions.init();UserHelper.init();EnableTooltips.init();Metadata.init();Resolvers.init();Players.init();CurrentSelection.init();Playlist.init();Showcase.init();Friends.init();Transporter.init();Player.init();Extension.init();Facelib.init();Account.init();CurrentSelection.loadFromUrl()});