if(!this.JSON){this.JSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+
partial.join(',\n'+gap)+'\n'+
mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
return str('',{'':value});};}
if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('JSON.parse');};}}());;sixTLanguage=new Array();sixTLanguage["nl"]=new Array();sixTLanguage["en"]=new Array();sixTLanguage["nl"][0]="Vriendenlijst van Facebook ophalen";sixTLanguage["nl"][1]="\n\n Er gaat iets mis tijdens de communicatie met Facebook... \n\n Onze excuses voor het ongemak, we proberen het opnieuw binnen Facebook.";sixTLanguage["nl"][2]="Ophalen van mixtapes..";sixTLanguage["nl"][3]="Deze vriend heeft nog geen mixtapes...";sixTLanguage["nl"][4]="Er zitten geen liedjes in deze mixtape...";sixTLanguage["nl"][5]="Maak een nieuwe mixtape:";sixTLanguage["nl"][6]="We kunnen geen liedjes vinden. \n\n Probeer het opnieuw voor een andere artiest...";sixTLanguage["nl"][7]="Liedjes zoeken op Youtube..";sixTLanguage["nl"][8]="Sorry, we konden geen liedjes vinden voor deze artiest.";sixTLanguage["nl"][9]="Een 6tunes mixtape heeft maximaal 6 liedjes!";sixTLanguage["nl"][10]="Selecteer een liedje om aan je mixtape toe te voegen..";sixTLanguage["nl"][11]="Geef je mixtape een naam, EN selecteer liedjes voor je mixtape";sixTLanguage["nl"][12]="Ik heb een mixtape toegevoegd op 6tunes.com. Luister naar mijn mixtape op: http://www.6tunes.com/player.html.";sixTLanguage["nl"][13]="Wil je stoppen zonder deze mixtape op te slaan???";sixTLanguage["nl"][14]="Voeg liedjes toe / verander mixtape: ";sixTLanguage["nl"][15]="Selecteer eerst een mixtape...";sixTLanguage["nl"][16]="Weet je zeker dat je deze mixtape wil aanpassen?";sixTLanguage["nl"][17]="Geef je mixtape een naam, EN selecteer liedjes voor je mixtape";sixTLanguage["nl"][18]="Ik heb een van mijn mixtapes veranderd op 6tunes.com. Luister nu op: http://www.6tunes.com/player.html.";sixTLanguage["nl"][19]="Vrienden";sixTLanguage["nl"][20]="Selecteer een mixtape";sixTLanguage["nl"][21]="Selecteer een vriend:";sixTLanguage["nl"][22]="Vrienden";sixTLanguage["nl"][23]="Mixtape";sixTLanguage["nl"][24]="Selecteer een liedje:";sixTLanguage["nl"][25]="Dit liedje is geselecteerd door:";sixTLanguage["nl"][26]="In mixtape:";sixTLanguage["nl"][27]="Verwijder deze mixtape";sixTLanguage["nl"][28]="Verwijder dit liedje";sixTLanguage["nl"][29]="Koop dit liedje bij ";sixTLanguage["nl"][30]="Verander deze mixtape";sixTLanguage["nl"][31]="Toevoegen aan mixtape";sixTLanguage["nl"][32]="Verwijder dit liedje uit de mixtape";sixTLanguage["nl"][33]="Weet je zeker dat je dit liedje wil verwijderen?";sixTLanguage["nl"][34]="Ophalen van liedjes...";sixTLanguage["nl"][35]="Weet je zeker dat je deze mixtape wil verwijderen?";sixTLanguage["nl"][36]="Zoeken naar artiesten..";sixTLanguage["nl"][37]="Ophalen van mixtapes...";sixTLanguage["nl"][38]="Meldt je aan voor 6Tunes";sixTLanguage["nl"][39]="Mogen we dit plaatsen op je Facebook 'wall'?";sixTLanguage["en"][0]="Retrieving your friends from facebook..";sixTLanguage["en"][1]="\n\n Something is wrong in our communication with Facebook...\n\n Our apologies for the inconvenience. We will try again within Facebook.\n\n";sixTLanguage["en"][2]="Getting your friends mixtapes..";sixTLanguage["en"][3]="This user has no mixtapes yet...";sixTLanguage["en"][4]="There are no songs in this mixtape...";sixTLanguage["en"][5]="Create a new mixtape:";sixTLanguage["en"][6]="We cannot find you any music. \n\n Please fill in a bandname or songname...";sixTLanguage["en"][7]="Searching for videos on Youtube..";sixTLanguage["en"][8]="Sorry, we could not find any songs for this artist.";sixTLanguage["en"][9]="There are no more than 6 tunes allowed in a mixtape!";sixTLanguage["en"][10]="Please select a song to add to your mixtape..";sixTLanguage["en"][11]="Please enter a name for your mixtape AND or select songs for your mixtape";sixTLanguage["en"][12]="I added a new mixtape on 6tunes.com. Come and listen at http://www.6tunes.com/player.html.";sixTLanguage["en"][13]="Do you want to stop without saving???";sixTLanguage["en"][14]="Add songs / edit mixtape: ";sixTLanguage["en"][15]="Please select a mixtape first...";sixTLanguage["en"][16]="Are you sure you want to change this mixtape?";sixTLanguage["en"][17]="Please enter a name for your mixtape AND or select songs for your mixtape";sixTLanguage["en"][18]="I changed one of my mixtapes a 6tunes.com. Come and listen at http://www.6tunes.com/player.html.";sixTLanguage["en"][19]="Friends";sixTLanguage["en"][20]="Select a mixtape";sixTLanguage["en"][21]="Select one of your friends:";sixTLanguage["en"][22]="Friends";sixTLanguage["en"][23]="Mixtape";sixTLanguage["en"][24]="Select a song:";sixTLanguage["en"][25]="This song was selected by:";sixTLanguage["en"][26]="In mixtape:";sixTLanguage["en"][27]="Delete this mixtape";sixTLanguage["en"][28]="Delete this song";sixTLanguage["en"][29]="Purchase at";sixTLanguage["en"][30]="Edit this mixtape";sixTLanguage["en"][31]="Add to mixtape";sixTLanguage["en"][32]="Delete this song from mixtape";sixTLanguage["en"][33]="Are you sure you want to delete this song?";sixTLanguage["en"][34]="Retrieving songs...";sixTLanguage["en"][35]="Are you sure you want to delete this mixtape?";sixTLanguage["en"][36]="Looking for artists..";sixTLanguage["en"][37]="Retrieving mixtapes...";sixTLanguage["en"][38]="Sign up for 6Tunes";sixTLanguage["en"][39]="Can we post the following to your facebook wall?";;function FacebookConnect(){var api_key='e92036ba515f1a728e5d10817c967d7e';var channel_path='js/xd_receiver.html';var features="uid,name,is_app_user";var api;var _userID="";var _userName=false;var _fb_friends=new FriendsList();var errorHandler=false;var eventHandler=false;this._facebookLogin=function(handler,error){errorHandler=error;eventHandler=handler;FB_RequireFeatures(["Api","Connect"],function(){FB.Facebook.init(api_key,channel_path);api=FB.Facebook.apiClient;api.requireLogin(loginResponse);});}
this._postToWall=function(text){var attachment={'media':[{'type':'image','src':'http://www.6tunes.com/img/128.png','href':'http://www.6tunes.com/player.html'}]};var actionLinks=[{"text":""+sixTLanguage[displayLanguage][37]+"","href":"http://www.6tunes.com/player.html"}];FB.Connect.streamPublish(text,attachment,actionLinks,null,sixTLanguage[displayLanguage][38],callback);}
this.getUID=function getUID(){return _userID;}
this.getUName=function getUName(){return _userName;}
function callback(evt){}
function loginResponse(exception){if(exception){errorHandler("LOGIN ERROR:"+exception);}else{_userID=(api.get_session().uid);api.users_getInfo([_userID],[features],userData);}}
function userData(result,exception){if(!exception){_userName=result[0].name;eventHandler();}else{errorHandler("DATA ERROR: "+exception);}}
this._getFriends=function _getFriends(handler,error){errorHandler=error;eventHandler=handler;api.friends_get("",friendsReceived)}
function friendsReceived(result,except){if(except){errorHandler("FRIEND ERROR: "+except);}else{api.users_getInfo(result,[features],getFriendsDetails);}}
function getFriendsDetails(result,except){if(except){var tmp=new Array();eventHandler(tmp);}else{eventHandler(result);}}};var yt=new YoutubePlayer();google.load("swfobject","2.1");function onYouTubePlayerReady(){yt.onready($("youtube_player"),yt);}
function YoutubePlayer(){this.ytplayer;this.onready=function(player,yt){this.ytplayer=player;this.ytplayer.addEventListener("onStateChange","yt_stateChange");this.ytplayer.addEventListener("onError","yt_error");}
this.playSong=function(id){if(this.ytplayer){this.ytplayer.loadVideoById(id,0);}}
this.start=function(){if(this.ytplayer){this.ytplayer.playVideo();}}}
function yt_stateChange(result){if(result==0){playNext();}}
function yt_error(result){$feedaback("SORRY, AN ERROR OCCURED: "+result);};function ServerConnection(){this.url="http://www.6tunes.com/server/"
this.get=function(url,args,fname){if(args==null){args=""};var xmlHttp;xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}
catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){alert("Your browser does not support AJAX!\nThis site will not function properly...");return false;}}}
xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){fname(xmlHttp.responseText);}}
xmlHttp.open("GET",url+"?"+args+"&c="+Math.random().toString(),true);xmlHttp.send(null);}
this.post=function(url,args,fname){if(args==null){args=""};var xmlHttp;xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}
catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){alert("Your browser does not support AJAX!\nThis site will not function properly...");return false;}}}
xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){fname(xmlHttp.responseText);}}
xmlHttp.open("POST",url,true);xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlHttp.setRequestHeader("Content-length",args.length);xmlHttp.setRequestHeader("Connection","close");xmlHttp.send(args);}
this.openURL=function(url,data){window.open(url+"?"+data,"_blank");}}
ServerConnection.prototype.request=function(data,action,type,response){var site="";switch(action){case"GET_MIXTAPES":site="get_mixtape.php";break;case"GET_SONGS":site="get_songs.php";break;case"SEARCH":site="youtube.php";break;case"SAVE_MIXTAPE":site="save_mixtape.php";break;case"DELETE_MIXTAPE":site="delete_mixtape.php";break;case"DELETE_SONG":site="delete_song.php?cache";break;case"PURCHASE_SONG":site="purchase.php";break;case"LOG":site="log_action.php";break;case"NUMBER_OF_MIXTAPES":site="number_of_tapes.php";break;case"EDIT_MIXTAPE":site="edit_mixtape.php";break;case"GET_ADVERTISEMENT":site="get_advertisements.php";break;case"SAVE_FRIENDS":site="save_friends.php";break;case"GET_ALL_FRIENDS":site="get_all_friends.php";break;}
switch(type){case"POST":this.post(this.url+site,data,response);break;case"GET":this.get(this.url+site,data,response);break;case"LINK":this.openURL(this.url+site,data);break;}};function FriendsList(){var stunesID="100000073355342";var stunesName="Six Tunes Player (DEMO)";var callback=false;this.friends=new Array();this.users=new Array();this.previous=0;this.addFriend=function(uid,name,user){this.friends[this.friends.length]=new Friend(uid,name,user);if(user){this.users[this.users.length]=(this.friends.length-1);}}
this.selectUser=function(){var tempArr=new Array();var j=0;for(var i=0;i<this.users.length;i++){if(this.friends[this.users[i]].mixtapes!=0){tempArr[j]=this.users[i];j++;}}
var selected=Math.floor(Math.random()*tempArr.length);this.clickItem(tempArr[selected],true);}
this.numberOfFriends=function(){return this.friends.length;}
this.getFriendAt=function(i){if(i<=this.friends.length){return this.friends[i];}else{false;}}
this.getAllFriends=function(){return this.friends;}
this.clickItem=function(i,rnd){rnd=typeof(rnd)!='undefined'?rnd:false;if($("friend_"+this.previous)){$uncolor($("friend_"+this.previous))}
if($("friend_"+i)){$color($("friend_"+i))};this.previous=i;mixtapeList.userID=this.friends[i].id;moveToMixtapes();userFeedback("html_mixtapesList",true,sixTLanguage[displayLanguage][37]);$html('html_songsList',"");this.friends[i].onClick(rnd);}
this.getMixtapes=function(fname){callback=fname;var list=fb.getUID();for(var i=0;i<this.friends.length;i++){if(this.friends[i].user){list+=","+this.friends[i].id;}}
server.request("friends="+list,"NUMBER_OF_MIXTAPES","POST",this.numberOfMixtapesReceived);}
this.getMixtapes2=function(fname){callback=fname;var list="";for(var i=0;i<this.friends.length;i++){if(this.friends[i].user){list+=this.friends[i].id+",";}}
list=list.slice(0,-1);server.request("friends="+list,"NUMBER_OF_MIXTAPES","POST",this.numberOfMixtapesReceived);}
this.numberOfMixtapesReceived=function(result){result=$decode(result);for(var i in result){friendsList.addNumberOfMixtapes(result[i].uid,result[i].count);}
callback();}
this.addNumberOfMixtapes=function(uid,number){for(var i=0;i<this.friends.length;i++){if(this.friends[i].id==uid){this.friends[i].setNumberOfMixtapes(number);break;}}
return true;}
this.addDemoFriend=function(){if(!this.check6tunes()){this.addFriend(stunesID,stunesName,true);}}
this.check6tunes=function(){for(var i=0;i<this.friends.length;i++){if(this.friends[i].id==stunesID){return true;break;}}
return false;}
this.empty=function(){this.friends.length=0;this.users.length=0;}
this.sortList=function(type){switch(type){case"name":this.friends.sort(this.srtName);break;case"mixtapes":this.friends.sort(this.srtMixtape);break;}
createFriendsList($('users_only').checked);}
this.srtName=function(a,b){a=a.name;b=b.name;return a==b?0:(a<b?-1:1);}
this.srtMixtape=function(a,b){a=a.mixtapes;b=b.mixtapes;return b-a;}};function Friend(id,name,user){this.id=id;this.name=name;this.user=user;this.mixtapes=0;}
Friend.prototype.onClick=function onClick(rnd){if(rnd){server.request("userid="+this.id+"&rnd"+rnd,"GET_MIXTAPES","GET",mixtapesReceivedRandom);}else{server.request("userid="+this.id+"&rnd"+rnd,"GET_MIXTAPES","GET",mixtapesReceived);}}
Friend.prototype.setNumberOfMixtapes=function(mixtapes){this.mixtapes=mixtapes;}
Friend.prototype.getNumberOfMixtapes=function(mixtapes){return this.mixtapes;};function MixtapeList(){this.mixtape=new Array();this.previous=0;this.userID=false;this.addMixtape=function(name,id){this.mixtape[this.mixtape.length]=new Mixtape(name,id);}
this.numberOfMixtapes=function(){return this.mixtape.length;}
this.getRandom=function(){this.clickItem(Math.floor(Math.random()*this.mixtape.length));}
this.getMixtapeAt=function(i){if(i<=this.mixtape.length){return this.mixtape[i];}else{false;}}
this.clickItem=function(i){if($("mixtape_"+this.previous)){$uncolor($("mixtape_"+this.previous))}
$color($("mixtape_"+i));this.previous=i;moveToSongs();userFeedback("html_songsList",true,sixTLanguage[displayLanguage][34]);this.mixtape[i].onClick(i);}
this.deleteItem=function(i){if(confirm(sixTLanguage[displayLanguage][35])){server.request("mixtapeID="+this.mixtape[i].id+"&userID="+fb.getUID(),"DELETE_MIXTAPE","POST",mixtapeDeleted);}}
this.sortList=function(type){switch(type){case"name":this.mixtape.sort(this.srtName);break;}
createMixtapeList();}
this.srtName=function(a,b){a=a.name;b=b.name;return a==b?0:(a<b?-1:1);}
this.empty=function(){this.mixtape.length=0;}};function Mixtape(name,id){this.name=name;this.id=id;}
Mixtape.prototype.onClick=function(i){server.request("mixtapeID="+this.id,"GET_SONGS","GET",songsReceived);};function SongList(){this.songs=new Array();this.currentSong=false;this.previous=0;this.addSong=function(youtube,artist,title,id){this.songs[this.songs.length]=new Song(youtube,artist,title,id);}
this.numberOfSongs=function(){return this.songs.length;}
this.getSongAt=function(i){if(i<=this.songs.length){return this.songs[i];}else{false;}}
this.getCurrent=function(){return this.songs[this.currentSong];}
this.clickItem=function(i,elementPart){elementPart=typeof(elementPart)!='undefined'?elementPart:"newMixtape_";this.currentSong=i;if($(elementPart+this.previous)!=null){$uncolor($(elementPart+this.previous))}
$color($(elementPart+i));this.previous=i;this.songs[i].onClick();}
this.checkSong=function(){if(this.currentSong<(this.songs.length-1)){this.clickItem(this.currentSong+1,"song_");return true;}else{return false;}}
this.empty=function(){this.songs.length=0;this.currentSong=false;}
this.deleteItem=function(i){if(confirm(sixTLanguage[displayLanguage][33])){server.request("mixtapeID="+mixtapeList.mixtape[mixtapeList.previous].id+"&songID="+this.songs[i].id,"DELETE_SONG","POST",songDeleted);}}
this.purchaseSong=function(i,loc){server.request("id="+this.songs[i].id+"&uid="+fb.getUID()+"&shop="+loc,"PURCHASE_SONG","LINK",emptyHandler);}
this.purchaseSong2=function(i,loc){server.request("id="+this.songs[i].id+"&uid="+global_user_id+"&shop="+loc,"PURCHASE_SONG","LINK",emptyHandler);}};function Song(youtube,artist,title,id){this.youtube=youtube;this.artist=artist;this.title=title;this.id=id;}
Song.prototype.onClick=function(){yt.playSong(this.youtube);if(currentState=="LISTEN"){updateBigFeedback();}};function NewMixtape(){this.entries=new Array();this.currentSong=false;this.previous=0;this.addEntry=function(songName,bandName,albumName,time,url,title){this.entries[this.entries.length]=new Entry(songName,bandName,albumName,time,url,title);}
this.full=function(){if(this.entries.length>6){return true;}else{return false;}}
this.getEntryAt=function(i){return this.entries[i];}
this.numberOfEntries=function(){return this.entries.length;}
this.clickItem=function(i,elementPart){this.entries[i].onClick();this.currentSong=i;if($(elementPart+this.previous)!=null){$(elementPart+this.previous).className="newMixtapeItem";}
$(elementPart+i).className="newMixtapeItemSelect";this.previous=i;}
this.deleteItem=function(i){this.entries.splice(i,1);addToMixtapeHTML();}
this.empty=function(){this.entries.length=0;this.currentSong=false;}};function Entry(songName,bandName,albumName,time,url,title){this.songName=songName;this.bandName=bandName;this.albumName=albumName;this.time=time;this.url=url;this.title=title;}
Entry.prototype.onClick=function(){yt.playSong(this.url);};function GetProducts(){var timer=false;var target=null;var callback=null;this.start=function(functie){callback=functie;timer=setTimeout(this.getHTML,200);}
this.resume=function(){timer=setTimeout(this.getHTML,40000);}
this.getHTML=function(){$html('featuredAlbums',"<div id=\"featuredLoader\"><img src=\"img/loader_big.gif\" /><br /><br />"+sixTLanguage[displayLanguage][36]+"</div>");server.request("shop="+shopType,"GET_ADVERTISEMENT","GET",callback);}};function $(id){return document.getElementById(id);}
function $hide(id){$(id).style.display="none";}
function $show(id){$(id).style.display="block";}
function $html(id,html){$(id).innerHTML=html;}
function $htmlp(id,html){$(id).innerHTML+=html;}
function $style(id){$(id).style;}
function $value(id){$(id).value;}
function $debug(txt){if($('debug'))$('debug').innerHTML+=txt;}
function $feedback(txt){if($('html_userFeedback'))$html('html_userFeedback',txt);}
function $decode(data){return eval("("+data+")");}
function $color(element){element.className="listItemSelect";}
function $uncolor(element){element.className="listItem";};var fb=new FacebookConnect();var friendsList=new FriendsList();var server=new ServerConnection();var mixtapeList=new MixtapeList();var songList=new SongList();var searchResultList=new SongList();var newMixtape=new NewMixtape();var getProducts=new GetProducts();var currentState="LISTEN";var shopType="amazon";var displayLanguage="en";function html_loaded(shop,lang){shopType=shop;displayLanguage=lang;userFeedback("html_friendsList",true,sixTLanguage[displayLanguage][0]);fb._facebookLogin(userLoggedIn,fbError);}
function userLoggedIn(){fb._getFriends(friendsDetailsIn,fbError2);}
function fbError(error){alert(error+sixTLanguage[displayLanguage][1]);window.location="http://apps.facebook.com/sixtunes";}
function fbError2(error){alert("E2: "+error+sixTLanguage[displayLanguage][1]);window.location.reload(true);}
function productsReceived(result){$html('featuredAlbums',result);getProducts.resume();}
function friendsDetailsIn(result){friendsList.addFriend(fb.getUID(),fb.getUName(),true);for(var i in result){friendsList.addFriend(result[i].uid,result[i].name,result[i].is_app_user);}
friendsList.addFriend(66,"6tunes Suggestions",true);userFeedback("html_friendsList",true,sixTLanguage[displayLanguage][2]);friendsList.addDemoFriend();friendsList.getMixtapes(friendsMixtapesIn);var jsonobj=JSON.stringify(friendsList.getAllFriends());server.request("data="+jsonobj,"SAVE_FRIENDS","POST",friendsSaved);}
function friendsSaved(result){}
function friendsMixtapesIn(){createFriendsList($('users_only').checked);yt.start();}
function mixtapesReceivedRandom(result){mixtapesReceived(result,true);}
function mixtapesReceived(result,rnd){rnd=typeof(rnd)!='undefined'?rnd:false;mixtapeList.empty();if(result=="null"){userFeedback("html_mixtapesList",false,sixTLanguage[displayLanguage][3]);}else{result=$decode(result)
for(var i in result){mixtapeList.addMixtape(result[i].name,result[i].id);}
createMixtapeList();if(rnd){mixtapeList.getRandom();}}}
function songsReceived(result){$html('html_songsList',"");songList.empty();if(result=="null"){userFeedback("html_songsList",false,sixTLanguage[displayLanguage][4]);}else{result=$decode(result);for(var i in result){songList.addSong(result[i].youtube,result[i].artist,result[i].title,result[i].id);}
createSongList();if($('play_on_click').checked){songList.clickItem(0,"song_");}}}
function playNext(){if(currentState!="SEARCH"){if(!songList.checkSong()&&$('shuffle_finish').checked){friendsList.selectUser();}}}
function hideSearch(){currentState="LISTEN";$('listen_tab').className='tab-selected';$('create_tab').className='tab-unselected';$hide("state_2");$show("state_1");}
function showSearch(){currentState="SEARCH";emptySearch();$html('createNewMixtape',sixTLanguage[displayLanguage][5]);$('state_2').style.backgroundImage="";$('saveMixtapeButton').onclick=newMixtapeSave;$('create_tab').className='tab-selected';$('listen_tab').className='tab-unselected';$hide("state_1");$show("state_2");}
function newMixtapeSearch(band,song,album){if(!band&&!song&&!album){alert(sixTLanguage[displayLanguage][6]);}else{userFeedback("html_searchResult",true,sixTLanguage[displayLanguage][7]);server.request("q="+band+" "+song,"SEARCH","GET",searchResults);}}
function searchResults(result){searchResultList.empty();if($decode(result)==false){userFeedback("html_searchResult",false,sixTLanguage[displayLanguage][8]);}else{result=$decode(result);for(var i in result){searchResultList.addSong(result[i].url,$('html_bandName').value,result[i].title,result[i].time);}
createSearchResultList();}}
function addToNewMixtape(){if(searchResultList.getCurrent()){if(newMixtape.numberOfEntries()<6){var tmp=searchResultList.getCurrent();newMixtape.addEntry($('html_songName').value,$('html_bandName').value,$('html_albumName').value,tmp.id,tmp.youtube,tmp.title);addToMixtapeHTML();}else{alert(sixTLanguage[displayLanguage][9]);}}else{alert(sixTLanguage[displayLanguage][10]);}}
function newMixtapeSave(){if($('html_mixTapeName').value&&(newMixtape.numberOfEntries()>0)){var vars="mixtapeName="+escape($('html_mixTapeName').value)+"&count="+newMixtape.numberOfEntries()+"&userID="+fb.getUID();var piped="";for(var i=0;i<newMixtape.numberOfEntries();i++){piped+=newMixtape.getEntryAt(i).bandName+"||"+newMixtape.getEntryAt(i).songName+"||"+newMixtape.getEntryAt(i).albumName+"||"+newMixtape.getEntryAt(i).time+"||"+newMixtape.getEntryAt(i).url+"||"+newMixtape.getEntryAt(i).title+"##";}
piped=escape(piped.slice(0,-2));vars+="&songInfo="+piped;server.request(vars,"SAVE_MIXTAPE","POST",newMixtapeSaved);}else{alert(sixTLanguage[displayLanguage][11]);}}
function newMixtapeSaved(result){hideSearch();fb._postToWall(sixTLanguage[displayLanguage][12]);friendsList.clickItem(0,true);}
function emptySearch(){searchResultList.empty();newMixtape.empty();$html("html_searchResult","");$html('newMixtapeList',"");$('html_songName').value="";$('html_bandName').value="";$('html_albumName').value="";$('html_mixTapeName').value="";}
function cancelSearch(){if(currentState=="SEARCH"){if(confirm(sixTLanguage[displayLanguage][13])){hideSearch();}}}
function editCurrentMixtape(){if(mixtapeList.mixtape[mixtapeList.previous].name){showSearch();$('saveMixtapeButton').onclick=addSongsToMixtape;$('html_mixTapeName').value=mixtapeList.mixtape[mixtapeList.previous].name;$('state_2').style.backgroundImage="url(img/bckgrnd.png)";$html('createNewMixtape',sixTLanguage[displayLanguage][14]+" "+mixtapeList.mixtape[mixtapeList.previous].name);for(var i=0;i<songList.numberOfSongs();i++){newMixtape.addEntry("",songList.songs[i].artist,"",songList.songs[i].id,songList.songs[i].youtube,songList.songs[i].title);}
addToMixtapeHTML();}else{alert(sixTLanguage[displayLanguage][15]);}}
function addSongsToMixtape(){if(confirm(sixTLanguage[displayLanguage][16])){if($('html_mixTapeName').value&&(newMixtape.numberOfEntries()>0)){var vars="mixtapeName="+escape($('html_mixTapeName').value)+"&count="+newMixtape.numberOfEntries()+"&userID="+fb.getUID()+"&mixtapeID="+mixtapeList.mixtape[mixtapeList.previous].id;var piped="";for(var i=0;i<newMixtape.numberOfEntries();i++){piped+=newMixtape.getEntryAt(i).bandName+"||"+newMixtape.getEntryAt(i).songName+"||"+newMixtape.getEntryAt(i).albumName+"||"+newMixtape.getEntryAt(i).time+"||"+newMixtape.getEntryAt(i).url+"||"+newMixtape.getEntryAt(i).title+"##";}
piped=escape(piped.slice(0,-2));vars+="&songInfo="+piped;server.request(vars,"EDIT_MIXTAPE","POST",mixtapeEdited);}else{alert(sixTLanguage[displayLanguage][17]);}}}
function mixtapeEdited(result){hideSearch();fb._postToWall(sixTLanguage[displayLanguage][18]);friendsList.clickItem(0,true);}
function moveToMixtapes(){$hide('html_friendsList');$hide('html_songsList');$show('html_mixtapesList');$hide('options_1');$hide('options_3');$show('options_2');$html('current_selection',"<a href='#' onclick='moveToFriends(); return false;'>"+sixTLanguage[displayLanguage][19]+" ("+friendsList.friends[friendsList.previous].name+")</a> >> "+sixTLanguage[displayLanguage][20]);}
function moveToFriends(){$hide('html_songsList');$hide('html_mixtapesList');$show('html_friendsList');$hide('options_3');$hide('options_2');$show('options_1');$html('current_selection',sixTLanguage[displayLanguage][21]);}
function moveToSongs(){$hide('html_friendsList');$hide('html_mixtapesList');$show('html_songsList');$hide('options_1');$hide('options_2');$show('options_3');$html('current_selection',"<a href='#' onclick='moveToFriends(); return false;'>"+sixTLanguage[displayLanguage][22]+" ("+friendsList.friends[friendsList.previous].name+")</a> >> <a href='#' onclick='moveToMixtapes(); return false;'>"+sixTLanguage[displayLanguage][23]+" ("+mixtapeList.mixtape[mixtapeList.previous].name+")</a> >> "+sixTLanguage[displayLanguage][24]);}
function updateBigFeedback(){str="You are now listening to: <br>";str+="<span class=\"bigBlack\">"+songList.getSongAt(songList.currentSong).title+"</span><br>";str+="<div class=\"largeFont\">"+sixTLanguage[displayLanguage][25]+" "+friendsList.friends[friendsList.previous].name+"</div>";str+="<div class=\"smallFont\">"+sixTLanguage[displayLanguage][26]+" "+mixtapeList.mixtape[mixtapeList.previous].name+"</div>";$html('bigFeedback',str);}
function purchaseCurrent(){if(songList.currentSong!==false){songList.purchaseSong(songList.currentSong,shopType);}else{server.request("uid="+fb.getUID()+"&shop="+shopType,"PURCHASE_SONG","LINK",emptyHandler);}}
function createFriendsList(usersonly){var htmlString="";$html('html_friendsList',"");usersonly=typeof(usersonly)!='undefined'?usersonly:false;for(var i=0;i<friendsList.numberOfFriends();i++){if(usersonly&&(!friendsList.getFriendAt(i).user)){continue;}
var str="";if(friendsList.getFriendAt(i).user){str="<div class=\"listItem\" id=\"friend_"+i+"\" onclick=\"friendsList.clickItem("+i+");\">";str+="<div class=\"user_image\"><img src=\"img/user.png\" /></div><div class=\"labelr\">";str+=friendsList.getFriendAt(i).name;if(friendsList.getFriendAt(i).getNumberOfMixtapes()>0){str+=" ("+friendsList.getFriendAt(i).getNumberOfMixtapes()+")"}
str+="</div></div>";}else{str="<div class=\"listItemPassive\" id=\"friend_"+i+"\">";str+="<div class=\"user_image\"><img src=\"img/nouser.png\" /></div><div class=\"gray\">";str+=friendsList.getFriendAt(i).name;str+="</div></div>";}
htmlString+=str;}
$html('html_friendsList',htmlString);}
function createMixtapeList(){var htmlString="";$html('html_mixtapesList',"");var clas="label";var opt=false;if(mixtapeList.userID==fb.getUID()){clas="labell";opt=true;}
for(var i=0;i<mixtapeList.numberOfMixtapes();i++){var str="<div class=\"listItem\" id=\"mixtape_"+i+"\" onmouseover=\"$show('options"+i+"');\" onmouseout=\"$hide('options"+i+"');\" onclick=\"mixtapeList.clickItem("+i+");\">";str+="<div class=\""+clas+"\">"+mixtapeList.getMixtapeAt(i).name+"</div><div id='options"+i+"' style='display:none;'>";if(opt){str+="<div class=\"del_image\" onclick=\"mixtapeList.deleteItem("+i+"); event.stopPropagation(); \">";str+="<img title=\""+sixTLanguage[displayLanguage][27]+"\" src=\"img/delete.png\" /></div>";}
str+="</div></div>";htmlString+=str;}
$html('html_mixtapesList',htmlString);}
function createSongList(){var htmlString="";for(var i=0;i<songList.numberOfSongs();i++){var str="<div class=\"listItem\" onmouseover=\"$show('hide_options"+i+"');\" onmouseout=\"$hide('hide_options"+i+"');\" id=\"song_"+i+"\" onclick=\"songList.clickItem("+i+", 'song_');\">";str+="<div class=\"labell\">"+songList.getSongAt(i).title+"</div>";str+="<div id='hide_options"+i+"' style='display:none;'>";if(mixtapeList.userID==fb.getUID()){str+="<div class=\"del_image\" onclick=\"songList.deleteItem("+i+"); event.stopPropagation(); \"><img title=\""+sixTLanguage[displayLanguage][28]+"\" src=\"img/delete.png\" /></div>";}
str+="<div class=\"purchase_image\" onclick=\"songList.purchaseSong("+i+", '"+shopType+"');  event.stopPropagation(); \"><img title=\""+sixTLanguage[displayLanguage][29]+" "+shopType+"\" src=\"img/bol_small.png\" /></div>";str+="</div></div>";htmlString+=str;}
$html('html_songsList',htmlString);if(mixtapeList.userID==fb.getUID()){$htmlp('html_songsList',"<div id=\"editMixtape_Button\" onclick=\"editCurrentMixtape();\"><img title=\""+sixTLanguage[displayLanguage][30]+"\" src=\"img/edit.png\" /></div>");}}
function createSearchResultList(){var htmlString="";$html("html_searchResult","");for(var i=0;i<searchResultList.numberOfSongs();i++){var str="<div class=\"listItem\" id=\"searchResult_"+i+"\" onclick=\"searchResultList.clickItem("+i+", 'searchResult_');\" onmouseover=\"$show('search_options"+i+"');\" onmouseout=\"$hide('search_options"+i+"');\">";str+="<div class=\"labell\">"+searchResultList.getSongAt(i).title+" - ("+searchResultList.getSongAt(i).id+")</div><div id='search_options"+i+"' style='display:none;'>";str+="<div class=\"del_image\" onclick=\"searchResultList.clickItem("+i+", 'searchResult_'); addToNewMixtape();  event.stopPropagation(); \">";str+="<img title=\""+sixTLanguage[displayLanguage][31]+"\" src=\"img/add_small.png\" /></div></div></div>";htmlString+=str;}
$html('html_searchResult',htmlString);}
function addToMixtapeHTML(){var htmlString="";$html('newMixtapeList',"");for(var i=0;i<newMixtape.numberOfEntries();i++){var str="<div class=\"newMixtapeItem\" id=\"newMixtape_"+i+"\" onclick=\"newMixtape.clickItem("+i+", 'newMixtape_');\">";str+="<div class=\"labelNewMixtape\">"+newMixtape.getEntryAt(i).title+"</div>";str+="<div class=\"del_image\" onclick=\"newMixtape.deleteItem("+i+");  event.stopPropagation(); \">";str+="<img title=\""+sixTLanguage[displayLanguage][32]+"\" src=\"img/delete.png\" /></div>";str+="</div>";htmlString+=str;}
$html('newMixtapeList',htmlString);}
function userFeedback(element,loader,message){if(loader){$html(element,"<div class=\"feedback\"><img src=\"img/loader.gif\" /><br>"+message+"</div>");}else{$html(element,"<div class=\"feedback2\">"+message+"</div>");}}
function usersOnly(element){$html("html_friendsList","");if(element.checked){createFriendsList(true);}else{createFriendsList(false);}}
function inviteFriends(){$show('inviteFriends');}
function mixtapeDeleted(resp){server.request("user="+fb.getUID()+"&action=MIXTAPE DELETED: "+mixtapeList.mixtape[mixtapeList.previous].id,"LOG","POST",emptyHandler);friendsList.clickItem(0,true);}
function songDeleted(resp){server.request("user="+fb.getUID()+"&action=SONG DELETED: "+songList.songs[songList.previous].id,"LOG","POST",emptyHandler);mixtapeList.clickItem(mixtapeList.previous);}
function emptyHandler(reps){}
