var mailKey = Os_Cookiess.$Get('skey');var acc = Os_Cookiess.$Get('acn');document.write('<div id="dockingbar">');document.write('<div id="dockingbar_ui">');document.write('<div id="mainmargin">' +'<div id="musicBox">' +'<div class="spanLeft">' +'<span class="icon">' +'<a name="musicbox" title="Box Nhạc"><img name="musicbox" src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/boxnhac.png" width="29" height="25" border="0" alt="Box Nhạc" /></a>' +'<a href="/mp3/nghe-album/box-nhac/index.html" name="playAlbum" title="Nghe nhanh"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/nghenhanh.png" width="29" height="25" border="0" alt="Nghe nhanh" /></a>' +'<a href="/" name="createAlbum" title="Thêm vào Album"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/list.png" width="29" height="25" border="0" alt="Thêm vào Album" /></a>'+'<a href="/" name="remove" title="Xóa Box Nhạc"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/xoa-boxnhac.png" width="29" height="25" border="0" alt="Xóa Box Nhạc" /></a>' +'<a id="login_docking_bar" href="/mp3/nhac-cua-toi/index.html" title="Nhạc của tôi"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/home.png" width="29" height="25" border="0" alt="Nhạc của tôi" /></a>' +'</span>' +'<span class="logo"><a href="/" title="Trang chủ"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/pic-logomp3.png" width="57" height="21" border="0" alt="Trang chủ" /></a></span>' +'</div>');if (mailKey != null && mailKey != '') {document.write('<div class="right">' +'<div class="New"><a href="http://me.zing.vn/' + acc + '" target="_blank"> Tôi có gì mới</a></div>' +'<div class="line"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/line-box.png" width="1" height="21" /></div>  <div id="dockingBarMail" class="mail"><a href="http://mail.zing.vn/cgi-bin/login?V=1060">0 mail</a></div>' +'</div>');}document.write('</div></div>');document.write('</div>');document.write('</div>');/* List */document.write('<div class="db_MusicBox">' +'<div class="topTitle"><span class="left">Box Nhạc</span><span class="iconTitle"><a href="/"><img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/close.png" width="9" height="8" border=0 /></a></span></div>' +'<div class="db_List">'+'</div><div class="marginbtn" id="btnSavePlay"><input type="button" class="btn" onclick="location.href=\'/mp3/nghe-album/box-nhac/index.html\'" value="Nghe tất cả" /> <input name="" type="button" class="btn" onclick="addToAlbum()" value="Lưu album" /></div></div>');var songItem = '<li value="_ID_" style="display: block">' +'<div class="left"><a href="/mp3/nghe-bai-hat/_PLAYSTRING_.html" title="Nghe bài hát _TITLE_">_TITLE_</a></div>' +'<div class="right"><a class="removeCookie" name="_ID_" title="Xóa bài hát ra khỏi Box Nhạc">&nbsp;&nbsp;&nbsp;&nbsp;</a></div>' +'<br class="clr" />' +'</li>';if (Os_Cookiess.$Get('_mBoxStatus') == 1) {musicBoxLoadItem($('span.icon a[name=musicbox]').position().left);}$('span.icon a').click(function() {switch ($(this).attr('name')) {case 'musicbox':musicBoxLoadItem($(this).position().left);break;case 'createAlbum':if (Os_Cookiess.$Get(COOKIE_MBOX_NAME) == '' || Os_Cookiess.$Get(COOKIE_MBOX_NAME) == null) {jAlert('warning', 'Chưa có bài hát nào trong <strong>Box Nhạc</strong>?', 'Thông Báo');} else {if (checkLogin()) {$(this).attr('href', '/mp3/nhac-cua-toi/tao-album/index.html');return true;} else {loadLoginURL('/mp3/nhac-cua-toi/tao-album/index.html');}}break;case 'remove':jConfirm('Bạn thật sự muốn xóa các bài hát trong <strong>Box Nhạc</strong>?', 'Xóa Box Nhạc', function(r) {if (r) {Os_Cookiess.$Set(COOKIE_MBOX_NAME, '', 0, '/', COOKIE_DOMAIN);if (location.pathname.search('tao-album') != -1) {location.href = '/';}if ($('div.db_MusicBox').css('display') == 'block') {listMusicSlide(true);}}});break;case 'playAlbum':if (Os_Cookiess.$Get(COOKIE_MBOX_NAME) == '' || Os_Cookiess.$Get(COOKIE_MBOX_NAME) == null) {jAlert('warning', 'Chưa có bài hát nào trong <strong>Box Nhạc</strong>.', 'Thông Báo');} else {return true;}break;default:return true;break;}return false;});/* change imgage */var mBox = Os_Cookiess.$Get(COOKIE_MBOX_NAME);$("a.nfSong_AddCookies").each(function () {if (('~' + mBox + '~').search('~' + $(this).attr('id') + '~') != -1) {$(this).removeAttr('href');if ($(this).attr('tabindex') == '9999') {$(this).attr('class', 'disableButton');} else {$(this).html('<img src="' + GLOBAL_IMAGE_PATH + 'skins/gentle/images/icon-check.png" width="13px" height="12px" border=0>');}}});var mBoxPos = $('div.spanLeft a[name=musicbox]').position().left;$('span.iconTitle a').click(function(){musicBoxLoadItem(mBoxPos);return false;});$('#login_my_cart').click(function() {musicBoxLoadItem(mBoxPos);return false;});/* load item */function musicBoxLoadItem(position){getMusicBox();$('div.db_MusicBox').css('left', position);listMusicSlide();}/* get music item */function getMusicBox(){if ($('div.db_MusicBox div.db_List').html() == '') {$.getJSON('/includes/getMusicBox/?callback=?', function(items) {var html = '';if (items.length > 0) {for (var i = 0; i < items.length; i++) {html += songItem.replace(/_PLAYSTRING_/g, items[i].PlayString).replace(/_TITLE_/g, decodeURIComponent(items[i].Title)).replace(/\+/g, ' ').replace(/_ID_/g, items[i].SongID);}$('div.db_List').html('<ul>' + html + '</ul>');$('#btnSavePlay').show();removeSongItem();} else {$('div.db_List').html('<ul><li>Chưa có bài hát nào</li></ul>');}});}}/* remove 1 item trong list box */function removeSongItem(){var id = 0;$('a.removeCookie').click(function(){id = $(this).attr('name');var mBox = Os_Cookiess.$Get(COOKIE_MBOX_NAME).replace(id, '').replace(/(^~|~$)/, '').replace(/~~/, '~');Os_Cookiess.$Set(COOKIE_MBOX_NAME, mBox, 24 * 30, '/', COOKIE_DOMAIN);$('li[value=' + $(this).attr('name') + ']').slideToggle(500, function(){if (!Os_Cookiess.$Get(COOKIE_MBOX_NAME)) {listMusicSlide(true);}});});}/* slide list box nhac */function listMusicSlide(clear){$('div.db_MusicBox').css('left', mBoxPos);$('div.db_MusicBox').slideToggle(500, function(){if ($('div.db_MusicBox').css('display') == 'block') {if (Os_Cookiess.$Get(COOKIE_MBOX_NAME) != '' && Os_Cookiess.$Get(COOKIE_MBOX_NAME) != null) {Os_Cookiess.$Set('_mBoxStatus', 1, 0, '/', COOKIE_DOMAIN);} else {Os_Cookiess.$Set('_mBoxStatus', 0, 0, '/', COOKIE_DOMAIN);}$('span.icon img[name=musicbox]').addClass('hover');} else {Os_Cookiess.$Set('_mBoxStatus', 0, 0, '/', COOKIE_DOMAIN);$('span.icon img[name=musicbox]').removeClass();}if (clear == true) {$('div.db_List').html('<ul><li>Chưa có bài hát nào</li></ul>');$('#btnSavePlay').hide();}});}/* add ca khuc vao cookies */function addSongToCart(songID){var mBox = '', str = '', html = '', firstFlag = true, maxSong = false;var arrMBox = new Array();var songTitle = $('#' + songID).attr('name');var playString = $('#' + songID).attr('href').replace(/\/mp3\/nghe-bai-hat\//g, '').replace(/.html/g, '');mBox = Os_Cookiess.$Get(COOKIE_MBOX_NAME);if (mBox) {arrMBox = mBox.split('~');if (('~' + mBox + '~').search('~' + songID + '~') == -1) {if (arrMBox.length >= 20) {jConfirm('Bạn chỉ có thể thêm tối đa 20 bài vào <strong>Box Nhạc</strong><br>Bạn có muốn lưu lại không?', 'Lưu Album', function(r) {if (r) {addToAlbum();}});/*while (arrMBox.length >= 20) {arrMBox.pop();}*/maxSong = true;mBox = arrMBox.join('~');} else {addOneItem(songID, songTitle, playString);/* add song to cookie string */str = songID + '~' + mBox;}} else {return true;}} else {addOneItem(songID, songTitle, playString);str = songID;}if (str) {Os_Cookiess.$Set(COOKIE_MBOX_NAME, str, 24 * 3, '/', COOKIE_DOMAIN);}if (firstFlag) {getMusicBox();}if ($('div.db_MusicBox').css('display') == 'none') {listMusicSlide(false);}if (maxSong) {return false;} else {return true;}}/* add 1 item */function addOneItem(songID, songTitle, playString){if ($('div.db_List').html() != '') {firstFlag = false;html = $('div.db_List').html().replace(/<ul>/i, '').replace(/<\/ul>/i, '').replace(/<li>Chưa có bài hát nào<\/li>/i, '');html = songItem.replace(/_PLAYSTRING_/g, playString).replace(/_TITLE_/g, decodeURIComponent(songTitle)).replace(/\+/g, ' ').replace(/_ID_/g, songID).replace('display: block', 'display: none') + html;$('div.db_List').html('<ul>' + html + '</ul>');$('li[value=' + songID + ']').slideToggle(500);removeSongItem();/* show button add and play */$('#btnSavePlay').show();}}/* Tao album */function addToAlbum(){if (checkLogin()) {location.href = '/mp3/nhac-cua-toi/tao-album/index.html';return true;} else {loadLoginURL('/mp3/nhac-cua-toi/tao-album/index.html');}}

/********************************************************************************************************************/
/* mail box */
function notify_new_mail_mp3(obj)
{
	if (obj) {
		if (obj.unread > 0) {
			$('#zmailLogin').html('<a href="http://mail.zing.vn/cgi-bin/login?V=1060" target="_blank">Mail <strong>(' + obj.unread + ')</strong></a>');
			$('#dockingBarMail').html('<a href="http://mail.zing.vn/cgi-bin/login?V=1060" target="_blank"><strong>' + obj.unread + '</strong> mail</a>');
		} else {
			$('#zmailLogin').html('Mail <strong>(0)</strong>');
			$('#dockingBarMail').html('<a><strong>' + obj.unread + '</strong> mail</a>');
			if ($('#zmailActivate')) {
				$('#zmailActivate').hide();
			}
		}
	}
}
/*
var mailKey = Os_Cookiess.$Get('skey');
if (mailKey != null && mailKey != '') {
	var script = document.createElement("script");
	script.setAttribute("src","http://data.mail.zing.vn/cgi-bin/unreadnum?callback=notify_new_mail_mp3");
	script.setAttribute("type","text/javascript");
	document.getElementsByTagName('head')[0].appendChild(script);
}
*/
/********************************************************************************************************************/

