var docbao_xmlHttp
var playlist_xmlHttp
var menu_xmlHttp
var header_xmlHttp
var topnew_xmlHttp
var topnewalbum_xmlHttp
var topsongs_xmlHttp
var statics_xmlHttp
var chat_xmlHttp
var download_xmlHttp
var footer_xmlHttp
var search_xmlHttp

function GetXmlHttpObject(handler){ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This example doesn't work in Opera") 
		return 
	}
	
	if (navigator.userAgent.indexOf("MSIE")>=0){ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0){
			strName="Microsoft.XMLHTTP"
		} try { 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} catch(e) { 
			alert("Error. Scripting for ActiveX might be disabled") 
			return
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}

function docbao_changed_header(){ 
	if (header_xmlHttp.readyState==4 || header_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtheader").innerHTML=header_xmlHttp.responseText 
	}
}

function docbao_changed_menu(){ 
	if (menu_xmlHttp.readyState==4 || menu_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtmenu").innerHTML=menu_xmlHttp.responseText 
	}
}

function docbao_changed_playlist(){ 
	if (playlist_xmlHttp.readyState==4 || playlist_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtplaylist").innerHTML=playlist_xmlHttp.responseText 
	}
}

function docbao_changed_topnew(){ 
	if (topnew_xmlHttp.readyState==4 || topnew_xmlHttp.readyState=="complete"){ 
		document.getElementById("txttopnew").innerHTML=topnew_xmlHttp.responseText 
	}
}

function docbao_changed_topnewalbum(){ 
	if (topnewalbum_xmlHttp.readyState==4 || topnewalbum_xmlHttp.readyState=="complete"){ 
		document.getElementById("txttopnewalbum").innerHTML=topnewalbum_xmlHttp.responseText 
	}
}

function docbao_changed_topsongs(){ 
	if (topsongs_xmlHttp.readyState==4 || topsongs_xmlHttp.readyState=="complete"){ 
		document.getElementById("txttopsongs").innerHTML=topsongs_xmlHttp.responseText 
	}
}

function docbao_changed_statics(){ 
	if (statics_xmlHttp.readyState==4 || statics_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtstatics").innerHTML=statics_xmlHttp.responseText 
	}
}

function docbao_changed_footer(){ 
	if (footer_xmlHttp.readyState==4 || footer_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtfooter").innerHTML=footer_xmlHttp.responseText 
	}
}

function docbao_changed_search(){ 
	if (search_xmlHttp.readyState==4 || search_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtsearch").innerHTML=search_xmlHttp.responseText 
	}
}

function docbao_changed_chat(){ 
	if (chat_xmlHttp.readyState==4 || chat_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtchat").innerHTML=chat_xmlHttp.responseText 
	}
}

function docbao_changed_download(){ 
	if (download_xmlHttp.readyState==4 || download_xmlHttp.readyState=="complete"){ 
		document.getElementById("txtdownload").innerHTML=download_xmlHttp.responseText 
	}
}

function docbao_changed_songs(){
	if(docbao_xmlHttp.readyState == 1){
		var loading_mess = '<table width="618" border="0" cellpadding="0" cellspacing="0">'
			+ '<tr align="center"><td width="35%" valign="middle" align="right" height="150">'
			+ '<img src="/music/images/load.gif" border="0"></td>'
			+ '<td valign="middle" align="left">&nbsp;&nbsp;&nbsp;'
			+ '<font size="1" color="#666666">&#272;ang t&#7843;i d&#7919; li&#7879;u, please wait'
			+ '...</font>'
			+ '</td></tr></table>'
		document.getElementById('txtdocbao').innerHTML = loading_mess;
	} else {
		if (docbao_xmlHttp.readyState==4 || docbao_xmlHttp.readyState=="complete"){

			document.getElementById("txtdocbao").innerHTML=docbao_xmlHttp.responseText 
		}
	}
}

function init(){ 
	var url_menu="module/media_com.asp?menu_act=view_menu"
	menu_xmlHttp=GetXmlHttpObject(docbao_changed_menu)
	menu_xmlHttp.open("GET", url_menu , true)
	menu_xmlHttp.send(null)

	
	var url_header="module/media_com.asp?header_act=view_header"
	header_xmlHttp=GetXmlHttpObject(docbao_changed_header)
	header_xmlHttp.open("GET", url_header , true)
	header_xmlHttp.send(null)
	
	var url_playlist="module/media_com.asp?playlist_act=view_playlist"
	playlist_xmlHttp=GetXmlHttpObject(docbao_changed_playlist)
	playlist_xmlHttp.open("GET", url_playlist , true)
	playlist_xmlHttp.send(null)
	
	var url_topnew="module/media_com.asp?topnew_act=view_topnew"
	topnew_xmlHttp=GetXmlHttpObject(docbao_changed_topnew)
	topnew_xmlHttp.open("GET", url_topnew , true)
	topnew_xmlHttp.send(null)
	
	var url_topnewalbum="module/media_com.asp?topnewalbum_act=view_topnewalbum"
	topnewalbum_xmlHttp=GetXmlHttpObject(docbao_changed_topnewalbum)
	topnewalbum_xmlHttp.open("GET", url_topnewalbum , true)
	topnewalbum_xmlHttp.send(null)

	var url_topsongs="module/media_com.asp?topsongs_act=view_topsongs"
	topsongs_xmlHttp=GetXmlHttpObject(docbao_changed_topsongs)
	topsongs_xmlHttp.open("GET", url_topsongs , true)
	topsongs_xmlHttp.send(null)
	
	var url_statics="module/media_com.asp?statics_act=view_statics"
	statics_xmlHttp=GetXmlHttpObject(docbao_changed_statics)
	statics_xmlHttp.open("GET", url_statics , true)
	statics_xmlHttp.send(null)
	
	var url_chat="module/media_com.asp?chat_act=view_chat"
	chat_xmlHttp=GetXmlHttpObject(docbao_changed_chat)
	chat_xmlHttp.open("GET", url_chat , true)
	chat_xmlHttp.send(null)
	
	var url_download="module/media_com.asp?download_act=view_download"
	download_xmlHttp=GetXmlHttpObject(docbao_changed_download)
	download_xmlHttp.open("GET", url_download , true)
	download_xmlHttp.send(null)
	
	var url_footer="module/media_com.asp?footer_act=view_footer"
	footer_xmlHttp=GetXmlHttpObject(docbao_changed_footer)
	footer_xmlHttp.open("GET", url_footer , true)
	footer_xmlHttp.send(null)
	
	var url_search="module/media_com.asp?search_act=view_search"
	search_xmlHttp=GetXmlHttpObject(docbao_changed_search)
	search_xmlHttp.open("GET", url_search , true)
	search_xmlHttp.send(null)
	
	var url_songs="module/media_com.asp?song_act=init_docbao"
	docbao_xmlHttp=GetXmlHttpObject(docbao_changed_songs)
	docbao_xmlHttp.open("GET", url_songs , true)
	docbao_xmlHttp.send(null)
}

function view_song(song_act,fid,page){ 
	var songs_url="module/media_com.asp?song_act=" + song_act
	if(fid!=null){
		songs_url+="&fid=" + fid
	}
	if(page!=null){
		songs_url+="&p=" + page
	}
	docbao_xmlHttp=GetXmlHttpObject(docbao_changed_songs)
	docbao_xmlHttp.open("GET", songs_url , true)
	docbao_xmlHttp.send(null)
}

function act_playlist(playlist_act,fid){
	var url="module/media_com.asp?playlist_act=" + playlist_act
	if(fid!=null){
		url+="&fid=" + fid
	}
	if(playlist_act!="playlist_detail"){
		playlist_xmlHttp=GetXmlHttpObject(docbao_changed_playlist)
		playlist_xmlHttp.open("GET", url , true)
		playlist_xmlHttp.send(null)
	}else{
		docbao_xmlHttp=GetXmlHttpObject(docbao_changed_songs)
		docbao_xmlHttp.open("GET", url , true)
		docbao_xmlHttp.send(null)
		}
}

function delete_playlist(del_act,playlist_act,fid){ 
	var url="module/media_com.asp?del_act=" + del_act
	if(fid!=null){
		url+="&fid=" + fid
	}
	playlist_xmlHttp=GetXmlHttpObject(docbao_changed_playlist)
	playlist_xmlHttp.open("GET", url , true)
	playlist_xmlHttp.send(null)
	
	var url_okie="module/media_com.asp?playlist_act=" + playlist_act
	docbao_xmlHttp=GetXmlHttpObject(docbao_changed_songs)
	docbao_xmlHttp.open("GET", url_okie , true)
	docbao_xmlHttp.send(null)
}

function search_f(fs_act,text,by,fid){ 
	var url="module/media_com.asp?fs_act=" + fs_act
	if(text!=null){
		url+="&text=" + encodeURI(text)
	}
	if(by!=null){
		url+="&by=" + by
	}
	if(fid!=null){
		url+="&p=" + fid
	}
	docbao_xmlHttp=GetXmlHttpObject(docbao_changed_songs)
	docbao_xmlHttp.open("GET", url , true)
	docbao_xmlHttp.send(null)
}