﻿var req;
	var email_OK = false;
	var name_OK = false;
	function loadXMLDoc(url) 
	{
		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send(null);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = processReqChange;
				req.open("GET", url, true);
				req.send();
			}
		}
	}
	
	
	function processReqChange() 
	{
		if (req.readyState == 4) // only if req shows "complete"
		{
			if (req.status == 200) // only if "OK"
			{
				response  = req.responseXML.documentElement;
				A_Method  =	response.getElementsByTagName('method')[0].firstChild.data;
				A_Result    = response.getElementsByTagName('result')[0].firstChild.data;
				if (A_Method!='addNew')
				{
					eval(A_Method + '(\'\', A_Result)');
				}
				else
				{
					eval(A_Method + '(\'\',\'\', A_Result)');
				}
			} 
			else 
			{
				alert("There was a problem retrieving the XML data:\n" + req.statusText);
			}
		}
	}
	
	
	function loading(show, type) {
 xmlhttp.open("GET", show, true);
 if(type=='main'){
 xmlhttp.onreadystatechange = T2HnS;
  } else if(type=='ds'){
 xmlhttp.onreadystatechange = DS;
   } else if(type=='if'){
 xmlhttp.onreadystatechange = IF;
  }else if(type=='play'){
 xmlhttp.onreadystatechange = PLAY;
 }
 
  xmlhttp.send(null);
}
function T2MCreateObject()
{
 var http;
 var browser = navigator.appName; 
 if(browser == "Microsoft Internet Explorer"){
	http = new ActiveXObject("Microsoft.XMLHTTP");
 }else{
	http = new XMLHttpRequest();
	}
  return http;
}

var xmlhttp = T2MCreateObject();

if(!xmlhttp) alert('Sorry we can not creat an ActiveX on your browser');

function T2HnS() {
   if(xmlhttp.readyState == 1 || xmlhttp.readyState == 2)
   {
	   document.getElementById("T2M").innerHTML = '<center><br><img src="images/load.gif" border=0><br><br>';
	
   }
   else if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
      document.getElementById("T2M").innerHTML = xmlhttp.responseText;
     window.status="Đã tải xong dữ liệu ";
   }   
}
function DS() {
   if(xmlhttp.readyState == 1 || xmlhttp.readyState == 2)
   {
	   document.getElementById("ds").innerHTML = '<center><br><img src="images/load.gif" border=0><br><br>';

   }
   else if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
      document.getElementById("ds").innerHTML = xmlhttp.responseText;
        
   }   
}
function IF() {
   if(xmlhttp.readyState == 1 || xmlhttp.readyState == 2)
   {
	   document.getElementById("if").innerHTML = '<center><br><img src="images/load.gif" border=0><br><br>';
   }
   else if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
      document.getElementById("if").innerHTML = xmlhttp.responseText;
        
   }   
}
function PLAY() {
   if(xmlhttp.readyState == 1 || xmlhttp.readyState == 2)
   {
	   document.getElementById("play").innerHTML = '<center><br><img src="images/load.gif" border=0><br><br>';
	
   }
   else if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
      document.getElementById("play").innerHTML = xmlhttp.responseText;
     window.status="Playing H ...";
        
   }   
}

//////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
function play(id)
{  
  loading('./?cat=11&id='+id+'','play');
  	  window.status="Đang tải bài hát...";
}
function cat()
{  
  loading('./?','play');
  	  window.status="Đang tải du liệu...";
}


function playalbum(id)
{  
  loading('./?h=26&id='+id+'','play');
      window.status="Playing Album nhạc... ";
}
function playsg(id)
{  
  loading('./?h=27&id='+id+'','play');
      window.status="Playing các bài hát của ca sĩ ... ";
}
function showoze(oze,id,page)//////Load main her
{ 
	if(id=="0"){
	 if(oze=="0")
	{loading('./?cat=4&page='+page+'','main');
      window.status="Đang tải dữ liệu... ";
      }
      
    
      else{
	loading('./?cat='+oze+'&page='+page+'','main');
     window.status="Đang tải dữ liệu... ";
} 
}else
	{loading('./?cat='+oze+'&id='+encodeURI(id)+'&page='+page+'','main');
	
     window.status="Đang tải dữ liệu... ";
	
	}

}
function ss(id,page)
{ 
	loading('./?cat=21&name='+encodeURI(id)+'&page='+page+'','main');
	
     window.status="Đang tải dữ liệu... ";
	

}
function showcat(ms)
{
	loading('./?cat='+ms+'','main');
	window.status="Đang tải dữ liệu... ";
}
function mes(id)
{
	loading('./?cat=17&action=del&id='+id+'','main');
	window.status="Đang tải dữ liệu... ";
}
function vmes(id)
{
	loading('./?cat=18&id='+id+'','main');
	window.status="Đang tải dữ liệu... ";
}
function showsing(ms)
{
	loading('./?cat=13&id='+ms+'','main');
	window.status="Đang tải dữ liệu... ";
}
function showgen(id)
{
	loading('./?cat=12&id='+id+'','main');
	window.status="Đang tải dữ liệu... ";
}
function search(kwd,p)
{  
	  var kwd = document.getElementById("kwd").value;
	  var ad  = document.getElementById("advanced").value;

	if(ad=='')
     {
  loading('./?cat=21&srch=all&name='+encodeURI(kwd)+'','main');
        window.status="Đang tìm bài hát... ";
       }  else  {
  loading('./?cat=21&srch=all&name='+encodeURI(kwd)+'','main');
          window.status="Đang tìm ca sĩ... ";
  	 }  
}

function sig(singer,p)
{
	loading('./?cat=21&id='+encodeURI(singer)+'&page='+p+'','main');
	document.getElementById('kwd').value = singer;
	          window.status="Đang tải dữ liệu về ca sĩ ";
}
function sog(song,p)
{
	loading('./?cat=21&name='+encodeURI(song)+'&type=0&page='+p+'','main');
	document.getElementById('kwd').value = song;
	window.status="Đang tải dữ liệu về bài hát";
}


function sg(id,p)
{
	loading('./?h=12&casi='+id+'&page='+p+'','main');
	window.status="Đang tải dữ liệu ...";
}

function showalbum(album,page)
{
  loading('./?h=17&ab='+album+'&page='+page+'&#','main');
  	window.status="Đang tải dữ liệu Album...";
  
}
function loai(l,p)
{
	loading('./?h=25&ex='+l+'&page='+p+'','main');
	document.getElementById('kwd').value = l;
		window.status="Đang tìm các bài hát theo loại nhạc yêu cầu...";
}