
function addFav4(id,type_fav)
{
	var url = "ajax/js_add_fav.php";
	var data_post = "id=" + id + "&ismusic=" + type_fav;
	
	$.ajax({
		   beforeSend: function(){
		   	//$('#a2_i2').fadeTo("slow",0.1);
			ge("a2_i2").style.display = "none";
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
			ge("addToFavesResult").style.display = "";
	     	$('#addToFavesResult').fadeTo("slow",1);
		   }
		});
}

function sendComment2(type) {
	var bCheck = checkComment();
	if (bCheck) {
		var url = "ajax/send_comment.php";
		var data_post = "id=" + ge("code").value + "&comment=" + ge("textcomment").value+"&section="+type;
		
		$.ajax({
		   beforeSend: function(){
		   	$('#commentmessage').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
			ge("commentmessage").style.display = "";
			ge("textcomment").value = "";
	   	 	$('#commentmessage').children().remove();
	     	$('#commentmessage').html("<img src=\"images/playlist/option_icon2.gif\" width=\"26\" height=\"26\" hspace=\"3\" align=\"absmiddle\" />Cảm nhận của bạn đã được gửi đi.");
	     	$('#commentmessage').fadeTo("slow",1,function(){
				getNewComment2(type);
	     	});
		   }
		});
	}
}
function getNewComment2(type) {
	var url = main_url+"/ajax/get_comment.php";
	var data_post = "id=" + ge("code").value + "&section="+type;
		
		$.ajax({
		   beforeSend: function(){
		   	$('#content_comment_ajax').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
	   	 	$('#content_comment_ajax').children().remove();
	     	$('#content_comment_ajax').html(msg);
	     	$('#content_comment_ajax').fadeTo("slow",1,function(){
	     	});
		   }
		});
}


function reportPost(posturl,id){
	
	var url = "js_baocao.php";
	//var url = $('.moi_nhat_path').val();
	//var total = $('.moi_nhat_total_page').val();
		$.ajax({
		   beforeSend: function(){
		   	$('#baocao_div' + id).fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: 'posturl='+ posturl+'&comID='+ id,
		   success: function(msg){
	   	 	$('#baocao_div' + id).children().remove();
	     	$('#baocao_div' + id).html(msg);
	     	$('#baocao_div' + id).fadeTo("slow",1,function(){
				//alert('thanh cong !');
	     	});
		   }
		});
}

function goto_lichdien(contentreport)
{
	var url = main_url+"/ajax/goto_lichdien.php";
	var data_post = "week=" + contentreport;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			
			if ( html != '' )
			{				

				ge("lichdien").innerHTML = html;
			} else alert('Có lỗi, không thể gởi bài !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();		
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}

function saveListOrder(listOrder,type,id){
	var url = main_url+"/ajax/save_panel_position_3.php";
	var data_post = "id="+id+"&list="+listOrder+"&type="+type;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
				//xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
			//xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------
			
			var html = xmlobj.xmlhandler.responseText;
			//alert(html);
			/*if ( html != '' )
			{
				ge("message").style.display = "";
				ge("message").innerHTML = "<em>Cập nhật thành công !</em>";
				//ToolMan.cookies().eraseCookie("list-boxes");
			} else alert('Có lỗi, không thể thực hiện được !');*/
		}
		
		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
function savePanelPosition(username,list,type) {
	var url = main_url+"/ajax/save_panel_position_2.php";
	var data_post = "username="+username+"&list="+list+"&type="+type;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
				//xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
			//xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------
			
			var html = xmlobj.xmlhandler.responseText;
			//alert(html);
			/*if ( html != '' )
			{
				ge("message").style.display = "";
				ge("message").innerHTML = "<em>Cập nhật thành công !</em>";
				//ToolMan.cookies().eraseCookie("list-boxes");
			} else alert('Có lỗi, không thể thực hiện được !');*/
		}
		
		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
function buzz(username) {
	document.getElementById("buzz_"+username).style.display = "none";
	var url = main_url + "/ajax/buzz.php";
	var data_post = "u="+username;	
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
				//xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
			//xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------
			
			var html = xmlobj.xmlhandler.responseText;
			if ( html != '' )
			{				
			} else alert('Có lỗi, không thể gởi bài !');
		}
		
		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
function vote(rank,type) {	
	var url = "";
	var data_post = "";
	if (type == 2) {
		url = main_url+"/ajax/vote_album.php";
		data_post = "rank=" + rank + "&id="+document.getElementById("id").value;
	}
	else if (type == 3) {
		url = main_url+"/ajax/voteplaylist.php";
		data_post = "rank=" + rank + "&id="+document.getElementById("playlistID").value;
	}
	else if (type == 1) {
		url = main_url+"/ajax/vote.php";
		data_post = "rank=" + rank + "&musicID="+document.getElementById("musicID").value+"&singerID="+document.getElementById("singerID").value;	
	}
	else if (type == 4) {
		url = main_url+"/ajax/votesinger.php";
		data_post = "rank=" + rank + "&sid="+document.getElementById("sid").value;	
	}
	else if (type == 5) {
		url = main_url+"/ajax/vote_video.php";
		data_post = "rank=" + rank + "&videoID="+document.getElementById("videoID").value;	
	}
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			if ( html != '' )
			{				
				document.getElementById("votemessage").style.display = "";				
				document.getElementById("votemessage").innerHTML = "Cám ơn bạn đã tham gia đánh giá.";
				document.getElementById("average").innerHTML = html;
						
			} else alert('Có lỗi, không thể đánh giá !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();		
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
function submitenter(e,type) {
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return false;
	if (keycode == 13)
	   {
		   if (type == 1)
			  addtags();
		   else if (type == 2)
		   		addtags_playlist();
		   else if (type == 3)
		   		addToPlayList2('1');
	   		return false;
	   }
	else
	   return false;
}
function addtags() 
{
	if ( document.tagform.tag.value != "thêm tags" && document.tagform.tag.value != "") {
		var url = main_url+"/ajax/js_music_add_tag.php";
		var data_post = "action=update&musicID=" + document.tagform.musicID.value + "&tag=" + document.tagform.tag.value;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
	
				if ( html != '' )
				{
					document.getElementById("content_tag").innerHTML = html;
					document.tagform.tag.value = "thêm tags";
				} else alert('Có lỗi, không thể gởi bài !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
	}
	else {
		alert("Vui lòng nhập từ khóa");
		document.tagform.tag.focus();
		document.tagform.tag.value = "";
		return false;
	}
}

function addtags_jquery() 
{
	if ( document.tagform.tag.value != "thêm tags" && document.tagform.tag.value != "") {
		var url = main_url+"/ajax/js_music_add_tag.php";
		var data_post = "action=update&musicID=" + document.tagform.musicID.value + "&tag=" + document.tagform.tag.value;
		
			$.ajax({
			   beforeSend: function(){
				$('#content_tag').fadeTo("slow",0.1);
			   },
			   type: 'POST',
			   dataType: 'html',
			   url : url,
			   data: data_post,
			   success: function(msg){
				document.tagform.tag.value = "thêm tags";
				$('#content_tag').children().remove();
				$('#content_tag').html(msg);
				$('#content_tag').fadeTo("slow",1,function(){
					//alert('thanh cong !');
				});
			   }
			});
	}
	else {
		alert("Vui lòng nhập từ khóa");
		document.tagform.tag.focus();
		document.tagform.tag.value = "";
		return false;
	}
}

function addtags_playlist() 
{
	if ( document.tagform.tag.value != "thêm tags" && document.tagform.tag.value != "") {
		var url = main_url+"/ajax/js_playlist_add_tag.php";
		var data_post = "action=update&playlistID=" + document.tagform.playlistID.value + "&tag=" + document.tagform.tag.value;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
				if ( html != '' )
				{
					document.getElementById("content_tag").innerHTML = html;
					document.tagform.tag.value = "thêm tags";
				} else alert('Có lỗi, không thể gởi bài !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
	}
	else {
		alert("Vui lòng nhập từ khóa");
		document.tagform.tag.focus();
		document.tagform.tag.value = "";
		return false;	
	}			
}

function addtags_playlist_jquery() 
{
	if ( document.tagform.tag.value != "thêm tags" && document.tagform.tag.value != "") {
		var url = main_url+"/ajax/js_playlist_add_tag.php";
		var data_post = "action=update&playlistID=" + document.tagform.playlistID.value + "&tag=" + document.tagform.tag.value;
	
		var url = main_url+"/ajax/js_playlist_add_tag.php";
	
			$.ajax({
			   beforeSend: function(){
				$('#content_tag').fadeTo("slow",0.1);
			   },
			   type: 'POST',
			   dataType: 'html',
			   url : url,
			   data: data_post,
			   success: function(msg){
				document.tagform.tag.value = "thêm tags";
				$('#content_tag').children().remove();
				$('#content_tag').html(msg);
				$('#content_tag').fadeTo("slow",1,function(){
					//alert('thanh cong !');
				});
			   }
			});
			
	}
	else {
		alert("Vui lòng nhập từ khóa");
		document.tagform.tag.focus();
		document.tagform.tag.value = "";
		return false;	
	}			
}

function add_to_report(contentreport,id,type)
{
	ge("loading2").style.display = "";
	ge("formcontent2").style.display = "none";	
	var url = main_url+"/ajax/add_report.php";
	var data_post = "contentreport=" + contentreport + "&memberID="+ge("memberID").value + "&musicID="+id+"&ismusic="+type;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			
			if ( html != '' )
			{				
				ge("loading2").style.display = "none";
				ge("message2").style.display = "";
				ge("close2").style.display = "";
				ge("contentreport").value = "";
				/*ge("msg_ajax").innerHTML = html;
				hide_div("form_ajax");
				show_div("msg_ajax");
				show_div("close_ajax");*/
				
			} else alert('Có lỗi, không thể gởi bài !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();		
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}

function add_to_quickmix(id,isyanwiki,refreshData)
{
	var url = main_url+"/ajax/add_quickmix.php";
	var data_post = "musicID=" + id;
	if (refreshData) data_post = data_post + "&refresh=true";
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			
			if ( html != '' )
			{				
				//ge("popitmenu").value = html;		
				content_msg = html;
				if (isyanwiki) {
					ge("quick_" + id).style.display = "none";
					ge("quickok_" + id).style.display = "";
					parent.updatePlaylist();
				}
				else {
					ge("span_quickmix").style.color = '#FF0000';
				}
			} else alert('Có lỗi, không thể gởi bài !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		if (!refreshData)
		{
			xmlobj = new ajax_request();		
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
		} else parent.refreshPlaylist(id);
}
function add_toplaylist(playlistname,type,ismusic)
{	
	ge("loading1").style.display = "";
	ge("formcontent1").style.display = "none";
	if (ismusic != 2)
		ismusic = 1;
	var url = main_url+"/ajax/add_playlist.php";
	var data_post = "choosePlayList=" + ge("choosePlayList").value + "&nameplaylist=" + playlistname + "&memberID="+ge("memberID").value + "&type="+type + "&musicID="+ge("addplaylistid").value+"&ismusic="+ismusic;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			
			if ( html != '' )
			{				
				ge("loading1").style.display = "none";
				ge("message1").style.display = "";	
				ge("close1").style.display = "";
				ge("message1").innerHTML = html;
				ge("nameplaylisttext").value = "";
				//ge("msg_addplaylist").innerHTML = html;
				//hide_div("form_addplaylist");
				//show_div("msg_addplaylist");
				//show_div("close_addplaylist");
				
			} else alert('Có lỗi, không thể gởi bài !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();		
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}	
function share_to_friend(receiver,message,type)
{	
	ge("loading3").style.display = "";
	ge("formcontent3").style.display = "none";
	message = message.replace("?","-");
	message = message.replace("&",",");
	var url = main_url+"/ajax/share_to_friend.php";
	var data_post = "receiver="+receiver+"&message=" +message+"&type="+type;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			
			if ( html != '' )
			{
				ge("loading3").style.display = "none";
				ge("message3").style.display = "";
				ge("close3").style.display = "";
				ge("username").value = "";
				ge("yahoousername").value = "";
				ge("email").value = "";
				//ge("msg_ajax").innerHTML = html;
				//hide_div("form_ajax");
				//show_div("msg_ajax");
				//show_div("close_ajax");
				
			} else alert('Có lỗi, không thể thực hiện !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();		
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
if (!win1)
	var win1;
/*function showOneQuickDialog(id,main_url,type,quickmix) {
	var sUrl = main_url+"/dialog/dialog_quickmix.php?musicID="+id;
	var sWinName = "Quick_Mix";
	if (type == 2) {
		sUrl = main_url+"dialog/dialog_quickmix_video.php?musicID="+id;	
		sWinName = "Quick_Mix_Video";
	}
	if (win1) {
		win1.focus();
		var _e = win1.document.getElementById('mp3player');
		if (_e)
			_e.SetVariable("xml", "xmluserquickmix.php?quickmix="+ quickmix +"&id="+id);
			
		else {
			win1 = window.open(sUrl,sWinName,"location=0,menubar=0,resizable=1,titlebar=0,toolbar=0,width=500,height=350,top=0,left=0");
			if (!win1 || win1.closed || !win1.location) {
				show_blockpopup();
			}
		}
	}
	else {
		win1 = window.open(sUrl,sWinName,"location=0,menubar=0,resizable=1,titlebar=0,toolbar=0,width=500,height=350,top=0,left=0");
		if (!win1 || win1.closed || !win1.location) {
			show_blockpopup();
		}
	}
}*/

function showOneQuickDialog(id,main_url,type,quickmix) {
	var sUrl = main_url+"/dialog/dialog_quickmix.php?musicID="+id;
	var sWinName = "Quick_Mix";
	if (type == 2) {
		sUrl = main_url+"dialog/dialog_quickmix_video.php?musicID="+id;	
		sWinName = "Quick_Mix_Video";
	}
	if (win1) {
		win1.focus();
		var _e = win1.document.getElementById('mp3player');
		if (_e)
			_e.SetVariable("xml", "xmluserquickmix.php?quickmix="+ quickmix +"&id="+id);
			
		else {
			win1 = window.open(sUrl,sWinName,"location=0,menubar=0,resizable=1,titlebar=0,toolbar=0,width=500,height=350,top=0,left=0");
			if (!win1 || win1.closed || !win1.location) {
				show_blockpopup();
			}
		}
	}
	else {
		win1 = window.open(sUrl,sWinName,"location=0,menubar=0,resizable=1,titlebar=0,toolbar=0,width=500,height=350,top=0,left=0");
		if (!win1 || win1.closed || !win1.location) {
			show_blockpopup();
		}
	}
}
function showQuickmix() {
	var sUrl = main_url+"/dialog/dialog_quickmix.php";
	var sWinName = "Quick_Mix";
	if (!win1)
	{
		win1 = window.open(sUrl,sWinName,"location=0,menubar=0,resizable=1,titlebar=0,toolbar=0,width=500,height=350,top=0,left=0");
		if (!win1 || win1.closed || !win1.location) {
			show_blockpopup();
		}
	}
}

function showQuickmixDialog(id,quickmix) {
	var sUrl = main_url+"/dialog/dialog_quickmix.php?musicID="+id+"&quickmix=" + quickmix;
	var win = window.open(sUrl, 'YAN_Quickmix', 'status=no,menubar=no,location=no,resizable=yes,scrollbars=no,directories=no,toolbar=no,height=350,width=500,minHeight=350,minWidth=500');
	if (!win || win.closed || !win.location) {
		show_blockpopup();
	}
}
function alertme(str) {
	alert(str);
}
function getMovie(movieName) {
	return document.getElementById(movieName);
}
function addToQuickMix(key, quickmix) {
	var flashMovie=getMovie('QuickMixYAN');
	flashMovie.addToQuickMix(key, quickmix);
}
function show_blockpopup() {
	$('#popup_block_div')
		.jqmShow();
}
function addToReport(id,type) {
	contentreport = ge("contentreport");
	addB = document.getElementById("addButtonReport");
	errorlb = ge("errorlabel");
	if (addB.value == "Gởi thông báo") {
		if (contentreport.value != "") {
			addB.disabled = true;
			add_to_report(contentreport.value,id,type);
		}	
		else {
			alert("Bạn vui lòng chọn nội dung cần gửi");
			contentreport.focus();
		}	
	}
	addB.disabled = false;
}
function changePlayList() {
	choosePlayList = ge("choosePlayList");
	addButton = ge("addButton");	
	ge("errorlabel").innerHTML = "";
	ge("namePlayList");
	if (choosePlayList.value == "0")  {		
		show_div("namePlayList");
		addButton.value = "Tạo mới";
	}
	else {
		hide_div("namePlayList");
		addButton.value = "Thêm vào";
	}
}
function addToPlayList2(ismusic) {
	namepl = ge("nameplaylisttext");
	addB = ge("addButton");
	choosepl = ge("choosePlayList");
	errorlb = ge("errorlabel");
	if (addB.value == "Tạo mới") {
		if (Trim(namepl.value) == "") {
			errorlb.innerHTML = "- Bạn phải nhập tên cho playlist.";
		}
		else  {
			addB.disabled = true;
			add_toplaylist(namepl.value,1,ismusic);
		}	
	}	
	else {
		addB.disabled = true;
		add_toplaylist(choosepl.value,2,ismusic);
	}	
	addB.disabled = false;
}
function shareToFriend(type,ismusic) {
	addB = ge("addButtonShare");
	var receiver = "";
	var message = "";
	if (type == 1) {
		receiver = ge("username");	
		message = ge("message");
	}
	else if (type == 2) {
		receiver = ge("yahoousername");
		message = ge("yahoomessage");
	}
	else if (type == 3) {
		receiver = ge("email");	
		message = ge("emailmessage");
	}	
	if (addB.value == "Gởi đi") {
		if (receiver.value != "") {
			addB.disabled = true;			
			share_to_friend(receiver.value,message.value,type,ismusic);
		}	
		else {
			alert("Bạn vui lòng nhập thông tin người nhận cho phù hợp");
			receiver.focus();
		}	
	}
	addB.disabled = false;
}
function sendplaylist() {
	addB = ge("addButtonSendPlayList");
	var receiver = ge("email");
	var message = ge("sendplaylistmessage");
	var code = ge("code");
	if (addB.value == "Gởi đi") {
		if (receiver.value != "") {
			addB.disabled = true;			
			send_playlist(code.value,receiver.value,message.value);
		}	
		else {
			alert("Bạn vui lòng nhập thông tin người nhận cho phù hợp");
			receiver.focus();
		}	
	}
	addB.disabled = false;
}
function send_playlist(code,receiver,message)
{
	ge("loading1").style.display = "";
	ge("formcontent1").style.display = "none";	
	var url = main_url+"/ajax/send_playlist.php";
	var data_post = "receiver="+receiver+"&message=" +message+"&code="+code;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
			//	xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
		//	xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------

			var html = xmlobj.xmlhandler.responseText;
			
			if ( html != '' )
			{
				ge("loading1").style.display = "none";
				ge("message1").style.display = "";
				ge("close1").style.display = "";
				ge("email").value = "";
				//ge("msg_ajax").innerHTML = html;
				//hide_div("form_ajax");
				//show_div("msg_ajax");
				//show_div("close_ajax");
				
			} else alert('Có lỗi, không thể thực hiện !');
		}

		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();		
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
function sendComment(type) {
	var bCheck = checkComment();
	if (bCheck) {
		var url = main_url+"/ajax/send_comment.php";
		var data_post = "id=" + ge("code").value + "&comment=" + ge("textcomment").value+"&section="+type;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
				if ( html > 0 )
				{
					ge("commentmessage").style.display = "";
					ge("commentmessage").innerHTML = "<img src=\"images/playlist/option_icon2.gif\" width=\"26\" height=\"26\" hspace=\"3\" align=\"absmiddle\" />Cảm nhận của bạn đã được gửi đi.";					
					ge("textcomment").value = "";
					getNewComment(type);
				} else alert('Có lỗi, không thể gửi cảm nhận !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
			ge("commentmessage").style.display = "none";
	}
}

function getNewComment(type) {
	var url = main_url+"/ajax/get_comment.php";
	var data_post = "id=" + ge("code").value + "&section="+type;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
				//xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
			//xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------
			
			var html = xmlobj.xmlhandler.responseText;
			ge("content_comment_ajax").innerHTML = html;
		}
		
		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}

function removemini(miniid) {
		var url = main_url+"/ajax/remove_mini.php";
		var data_post = "id=" + miniid;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
				if ( html != '' )
				{
					if (html==1)
						ge("div_mini_" + miniid).style.display = "none";
				} else alert('Có lỗi, không thể gởi thông tin, bạn hãy thử lại sau !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
			
}
function acceptfriend(friend) {
		ge("acceptbutton").disabled = true;
		ge("noaddbutton").disabled = true;

		var url = main_url+"/ajax/accept_friend.php";
		var data_post = "u=" + friend;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
				if ( html != '' )
				{
					ge("f_" + friend).innerHTML = html;
				} else alert('Có lỗi, không thể gởi thông tin, bạn hãy thử lại sau !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
}

function noaddfriend(friend) {
		//ge("acceptbutton").disabled = true;
		//ge("noaddbutton").disabled = true;
				
		var url = main_url+"/ajax/noadd_friend.php";
		var data_post = "u=" + friend;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
				if ( html != '' )
				{
					ge("f_" + friend).innerHTML = html;
				} else alert('Có lỗi, không thể gởi thông tin, bạn hãy thử lại sau !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
}


function checkComment() {
	var oComment =  ge("textcomment");
	if (oComment.value == "") {
		alert("Vui lòng nhập cảm nhận của bạn.");
		oComment.focus();
		return false;
	}
	return true;
}


function sendGuestbook2(type) {
	var bCheck = checkGuestBook();
	if (bCheck) {
		var url = main_url+"/ajax/send_guestbook.php";
		var data_post = "id=" + ge("code").value + "&guestbook=" + ge("guestbook").value + "&type=" + type;
		
		$.ajax({
		   beforeSend: function(){
		   	$('#guestbookmessage').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
			ge("guestbookmessage").style.display = "";
	   	 	$('#guestbookmessage').children().remove();
	     	$('#guestbookmessage').html("<img src=\"images/playlist/option_icon2.gif\" width=\"26\" height=\"26\" hspace=\"3\" align=\"absmiddle\" />Guestbook của bạn đã được gửi đi.");
	     	$('#guestbookmessage').fadeTo("slow",1,function(){
				getNewLuubut2(type);
	     	});
			ge("guestbook").value = "";
			ge("btnGuestBook").disabled=false;;
		   }
		});
	}
}

function getNewLuubut2(type) {
	
	var url = main_url+"/ajax/get_guestbook.php";
	var data_post = "id=" + ge("code").value + "&type=" + type;
		
		$.ajax({
		   beforeSend: function(){
		   	$('#content_luubut_ajax').fadeTo("slow",0.1);
		   },
		   type: 'POST',
		   dataType: 'html',
		   url : url,
		   data: data_post,
		   success: function(msg){
	   	 	$('#content_luubut_ajax').children().remove();
	     	$('#content_luubut_ajax').html(msg);
	     	$('#content_luubut_ajax').fadeTo("slow",1,function(){
	     	});
		   }
		});
	
}


function sendGuestbook(type) {
	var bCheck = checkGuestBook();
	if (bCheck) {
		var url = main_url+"/ajax/send_guestbook.php";
		var data_post = "id=" + ge("code").value + "&guestbook=" + ge("guestbook").value + "&type=" + type;
			/*--------------------------------------------*/
			// Main function to do on request
			// Must be defined first!!
			/*--------------------------------------------*/
			
			do_request_function = function()
			{
				//----------------------------------
				// Ignore unless we're ready to go
				//----------------------------------
				
				if ( ! xmlobj.readystate_ready_and_ok() )
				{
					// Could do a little loading graphic here?
					//xmlobj.show_loading("Bạn hãy chờ giây lát !");
					return;
				}
				//xmlobj.hide_loading();
				
				//----------------------------------
				// INIT
				//----------------------------------
				
				var html = xmlobj.xmlhandler.responseText;
				//alert(html)
				if ( html > 0 )
				{
					ge("guestbookmessage").style.display = "";
					ge("guestbookmessage").innerHTML = "<img src=\"images/playlist/option_icon2.gif\" width=\"26\" height=\"26\" hspace=\"3\" align=\"absmiddle\" />Lưu bút của bạn đã được gởi thành công !";			
					getNewLuubut(type);
					ge("guestbook").value = "";
					ge("btnGuestBook").disabled=false;;
				} else alert('Có lỗi, không thể gửi lưu bút !');
			}
			
			//----------------------------------
			// LOAD XML
			//----------------------------------
			
			xmlobj = new ajax_request();
			xmlobj.onreadystatechange( do_request_function );
			xmlobj.process( url, "POST", data_post);
	}
}
function getNewLuubut(type) {
	var url = main_url+"/ajax/get_guestbook.php";
	var data_post = "id=" + ge("code").value + "&type=" + type;
		/*--------------------------------------------*/
		// Main function to do on request
		// Must be defined first!!
		/*--------------------------------------------*/
		
		do_request_function = function()
		{
			//----------------------------------
			// Ignore unless we're ready to go
			//----------------------------------
			
			if ( ! xmlobj.readystate_ready_and_ok() )
			{
				// Could do a little loading graphic here?
				//xmlobj.show_loading("Bạn hãy chờ giây lát !");
				return;
			}
			//xmlobj.hide_loading();
			
			//----------------------------------
			// INIT
			//----------------------------------
			
			var html = xmlobj.xmlhandler.responseText;			
			if ( html != "" )
			{
				ge("content_luubut_ajax").innerHTML = html;				
				
			} else alert('Có lỗi, không thể gửi lưu bút !');
		}
		
		//----------------------------------
		// LOAD XML
		//----------------------------------
		
		xmlobj = new ajax_request();
		xmlobj.onreadystatechange( do_request_function );
		xmlobj.process( url, "POST", data_post);
}
function checkGuestBook() {
	var oGuestBook =  ge("guestbook");
	var btnGuestBook =  ge("btnGuestBook");
	if (oGuestBook.value == "") {
		alert("Vui lòng nhập lưu bút.");
		oGuestBook.focus();
		return false;
	} else btnGuestBook.disabled=true;
	return true;
} 
function checkAddTag() {
	var oComment =  ge("tag");
	if (oComment.value == "" || oComment.value == "thêm tags") {
		alert("Vui lòng nhập tag.");
		oComment.focus();
		return false;
	}
	addtags();
	return false;
}

function checkAddTag_playlist() {
	var oComment =  ge("tag");
	if (oComment.value == "" || oComment.value == "thêm tags") {
		alert("Vui lòng nhập tag.");
		oComment.focus();
		return false;
	}
	addtags_playlist();
	return false;
}