IndieProfile.Tracks = {
	track_list	: null,
	
	openUploadSnippet : function() {
		var indieUplader = window.open('/pages/snippets/indie_track_upload.php', '', 'width=850, height=375, top=25, left=25, resizable=0,scrollbars=1');
		indieUplader.focus();
	},
	
	RemoveSong : function(params) {
		Marvin.Utilities.CheckCurrentUser();
		//check user login status
		if(typeof(CurrentUser) !='undefined' && CurrentUser.UserID != '0') {
			$.addLoadingBehaviour(params.element, {'text' : ''});
			//request
			var callParameters = {
				id		: 1,
				api		: 'Indie',
				command	: 'removeSong',
				params	: {
					songId: params.songId,
					isOwner: CurrentUser.isOwner
				}
			};
			$.postSK({
				data : {data:JSONstring.make(callParameters)},
				onsuccess : function (data) {
					if (data.error == null && data['1'].error == null) {
						if ($.isFunction(params.onsuccess)) {
							params.onsuccess(data);
						}
						else {
							$.removeLoadingBehaviour(params.element);
							if(params.hideDiv != null){
								$('#'+params.hideDiv).hide();
							}
						}
					}
				}
			});
		}
		return false;
	}
};




// On DOM ready - Start
$(function() {
	IndieProfile.Tracks.lists = new marvinList({ 
		div_id:"indie-tracks-container", 
		api:"Song.list", 
		apiParams:{
			type: 'indie', 
			recordId: IndieID, 
			order:'top',
			limit: 20
		},
		template: Templates.Track.LineListItem,
		templateParameters: {'showPlayCount': true, 'hideArtistName': true, 'isIndie': true, 'isIndieOwner': isOwner},
		header: '<div class="line-list"><ul>',
		footer: '</ul></div>',
		show:true, 
		pagination:true,
		filterBar:true,
		upload: true
	});
	
	$('.indie-upload-button-container').bind('click',IndieProfile.Tracks.openUploadSnippet);
    if ( typeof( autoplay ) != "undefined" && autoplay )
    {
        $('a.icon-big-play').livequery( function() {
            if ( PlayClickBound )
            {
                $(this).click();
                autoplay = null;
            }
        });
    }		
	
});
// On DOM ready - End
