﻿	var req;
	var url;
	function Initialize()
	{
		try
		{
			req=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				req=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(oc)
			{
				req=null;
			}
		}
	
		if(!req&&typeof XMLHttpRequest!="undefined")
		{
			req=new XMLHttpRequest();
		}
	
	}
	function Goi_fun(callbackFunction)
	{}

		function voteloading(name)
	{
		obj = document.getElementById(name);
		obj.innerHTML = '<center><img src="image/loading8.gif"></center>';
	}



		function DisplayHTML(name)
	{
		obj = document.getElementById(name);
		obj.innerHTML = req.responseText;
		
	}

function SendQuery(url,callbackFunction,method,cache,request)
	{
			Initialize();
		if ( (req!=null) )
		{		
			req.onreadystatechange = function()
									{
									// only if req shows "complete"
										if (req.readyState == 4)
									    {
								        // only if "OK"
											if (req.status == 200)
											{
												// Process
												eval(callbackFunction);
											}
										}
									};
					
						
			// Cache data or not , default is yes(1)
	

			if ( cache != 1 )
			{
				url += "&rand="+Math.random()*1000;

			}
			
			// Use POST or GET method , default is GET
			if ( method == 'POST' )
			{
		        req.open("POST", url, true);
		        req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		        req.send(request);
			}
			else
			{										
				req.open("GET", url , true);
				//req.setRequestHeader("Pragma", "no-cache");// xoa cache 
				//req.setRequestHeader("Cache-Control", "must-revalidate");// xoa cache 
				//req.setRequestHeader("If-Modified-Since", document.lastModified);// xoa cache 
				req.send(null);
			}
		}
	}


function ADDVOTE(url)
	{		
			if(url != '' ){
			voteloading('voteresult');
			SendQuery(url,'DisplayHTML("voteresult")');}

}


function PlayMoreNews(url)
	{		
			if(url != '' ){
			voteloading('morenews');
			SendQuery(url,'DisplayHTML("morenews")');}

}

function GRADETHISLESSON(url)
	{		
			if(url != '' ){
			voteloading('rateresult');
			SendQuery(url,'DisplayHTML("rateresult")');}

}


function SETLANGUAGE(url)
	{		
			if(url != '' ){
			voteloading('language');
			SendQuery(url,'DisplayHTML("language")');}
}


function PLAYSINGERBLUM(url)
	{		
			if(url != '' ){
			voteloading('playsingeralbum');
			SendQuery(url,'DisplayHTML("playsingeralbum")');}
}

function PLAYTHISALBUM(url)
	{		
			if(url != '' ){
			voteloading('playalbum');
			SendQuery(url,'DisplayHTML("playalbum")');}
}



function DisplayContent(url)
	{		
			if(url != '' ){
			voteloading('displaycontent');
			SendQuery(url,'DisplayHTML("displaycontent")');}
}

function DisplayBio(url)
	{		
			if(url != '' ){
			voteloading('displaybio');
			SendQuery(url,'DisplayHTML("displaybio")');}
}


function CHECKUSERNAME(url)
	{		
			if(url != '' ){
			resultloading('checkavailability');
			SendQuery(url,'DisplayHTML("checkavailability")');}
}


function CHECKEMAIL(url)
	{		
			if(url != '' ){
			resultloading('useremail');
			SendQuery(url,'DisplayHTML("useremail")');}
}


function SearchMain() {
		var searchby = document.getElementById("searchby");
		var searchinput = document.getElementById("txtSearch").value;
		if (searchinput.length > 3){
		strquery  = "searchby=";
		strquery  += searchby.options[searchby.selectedIndex].value;
		strquery  += "&title=";
		strquery  += encodeURI(searchinput.split(' ').join('+'));
		quicksearch("giaitri_quangnhan1972_quicksearchresult.asp?" + strquery);
		}else {
		alert("Bạn phải nhập vào nội dung tìm kiếm\nHoặc nội dung nhập vào quá ngắn!");
		}
		return true;
	}




function quicksearch(url)
	{		
			if(url != '' ){
			voteloading('quickresult');
			SendQuery(url,'DisplayHTML("quickresult")');}
}







