function getRightLstGenre(type) {
	var url = root_url + '/modules/music/category.php?type=' + type;
	$.ajax({
		url: url,
		dataType: 'text',
		error: function(xhr, ajaxOptions, thrownError){
		//	alert(xhr.status);
        //    alert(thrownError);
			return false;
		},
		success: function(data){
			if (type == 1) {
				$('#right_music_lst_genre_vn').html(data);
			} else if (type == 2) {
				$('#right_music_lst_genre_asia').html(data);
			} else if (type == 3) {
				$('#right_music_lst_genre_eu_us').html(data);
			}
		}
	});
}

function getFeatureAlbum() {
	var url = root_url + '/modules/music/featured_album.php';
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#hompage_featured_album').html(stringdata);
			$('a.tooltip').tipsy({gravity: 'sw'});
		}
	});
}

function getLstHomepageHotSongs(page) {
	var url = root_url + '/modules/music/lst_hot_song.php?page=' + page;
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#muisc_lst_song_main').html(stringdata);
			$('a.tooltip').tipsy({gravity: 'sw'});
		}
	});
}

function getLstHomepageNewSongs(page) {
	var url = root_url + '/modules/music/lst_new_song.php?page=' + page;
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#muisc_lst_song_main').html(stringdata);
			$('a.tooltip').tipsy({gravity: 'sw'});
		}
	});
}

function getLstHomepageMostListen(page) {
	var url = root_url + '/modules/music/lst_most_listen_song.php?page=' + page;
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#muisc_lst_song_main').html(stringdata);
		}
	});
}

function getTypeSong(type) {
	if (type == 'hot-song') {
		getLstHomepageHotSongs(1);
	} else if (type == 'new-song') {
		getLstHomepageNewSongs(1);
	} else if (type == 'most-listen') {
		getLstHomepageMostListen(1);
	}
}

function getLstHomepageNewPlaylist(page) {
	var url = root_url + '/modules/music/lst_new_album.php?page=' + page;
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#muisc_lst_album_main').html(stringdata);
			$('a.tooltip').tipsy({gravity: 'sw'});
		}
	});
}

function getLstHomepageHotPlaylist(page) {
	var url = root_url + '/modules/music/lst_hot_album.php?page=' + page;
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#muisc_lst_album_main').html(stringdata);
			$('a.tooltip').tipsy({gravity: 'sw'});
		}
	});
}

function getTypeAlbum(type) {
	if (type == 'album-new') {
		getLstHomepageNewPlaylist(1);
	} else if (type == 'album-hot') {
		getLstHomepageHotPlaylist(1);
	}
}

function scrollPageMusic(jsContainer) {
	var viewportTop = self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
 	var viewportHeight = self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	if (viewportTop > jsContainer.offset().top + jsContainer.height()) $('html,body').animate({scrollTop: jsContainer.offset().top - 50}, 500);
	if (viewportTop + viewportHeight < jsContainer.offset().top) $('html,body').animate({scrollTop: jsContainer.offset().top - 50}, 500);
}

function getLocationSongs(location, page) {
	var url = root_url + '/modules/music/music_genre_detail.php?location='+ location +'&page=' + page;
	$.ajax({
		url: url,
		type: 'GET',
		dataType: 'text',
		cache: false,
		timeout: 100000,
		error: function(){
			return false;
		},
		success: function(stringdata){
			$('#muisc_lst_song_main').html(stringdata);	
			var jsContainer = $('#anchor_genre_detail');
			scrollPageMusic(jsContainer);
		}
	});
}
