﻿var http = createRequestObject();
var lastUrl = '';
var current_url = '';
var field = '';
var interval = '';
var loading=0;
function PlayGame(id) {
        html='<html>';
        html+='<head>';
        html+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
        html+='<title>WwW.Vkool.Net - Game & Karaoke Online</title>';
        html+='<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">';
        html+='<table cellpadding="0" cellspacing="0" border="0">';
        html+='<tr>';
        html+='<td align="center" style="font-size:10pt; color:#0000CC; font-family:tahoma"><b>Bạn Vui Lòng Chờ Chút Để Dữ Liệu Được Tải Về!</b></td>';
        html+='</tr>';
        html+='<tr>';
        html+='    <td align="center">';
        html+='<object id="fplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" type="application/x-shockwave-flash" width="620" height="520">';
        html+='        <param name="movie" value="' + id + '">';
        html+='        <param name="quality" value="high">';
        html+='        <param name="autoStart" value="-1">';
        html+='        <param name="Menu" value="0">';
        html+='        <param name="AllowScriptAccess" value="always">';
        html+='        <param name="DeviceFont" value="0">';
        html+='        <param name="EmbedMovie" value="-1">';
        html+='        <param name="SWRemote" value="">';
        html+='        <param name="MovieData" value="">';
        html+='        <param name="SeamlessTabbing" value="1">';
        html+='<embed src="' + id + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="620" height="520"></embed></object>    ';
        html+='    </td>';
        html+='</tr>';
        html+='<tr>';
        html+='    <td align="center" style="font-size:9pt; color:#330099; font-family:tahoma">Chúc Các Bạn Thư Giãn Vui Vẻ Nhé<br><a href="" onClick="window.close(); return false;"><i>Đóng Cửa Sổ Này</i></a></td>';
        html+='</tr>';
        html+='</table>';
        html+='</body>';
        html+='</html>';
    winDef = 'height=580,width=620';
    newwin = window.open('', '_blank', winDef);
    newwin.document.writeln(html);
}var br_s = navigator.userAgent.toLowerCase();
if (br_s.indexOf('opera')!= -1)
browser='op';
else if (br_s.indexOf('netscape')!= -1)
browser='ns';
else if (br_s.indexOf('firefox')!= -1)
browser='ff';
else
browser='ie';

var update = '001';

function createRequestObject() {
	var xmlhttp;
	try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e) {
    try { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
	catch(f) { xmlhttp=null; }
  }
  if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
	xmlhttp=new XMLHttpRequest();
  }
	return  xmlhttp;
}

function sendRequest(current_url,act) {
	try{
		if (act == 'Play' ||act == 'NSplay'|| act == 'Esplay' ||act == 'Zplay' || act == 'Yplay' || act == 'Cplay' || act == 'Nplay'|| act == 'Bplay'|| act == 'CCplay'|| act == 'play_videoz' || act == 'Gift' || act == 'Play_Album' || act == 'Play_Singer' || act == 'Play_Playlist' || act == 'Truyen_Hinh'){
			//self.scrollTo(0, 650);
			field = document.getElementById("playing_field");
			var vitri_top = document.getElementById("playing_field").offsetTop + 200;
			//alert(vitri_top);
			self.scrollTo(0, vitri_top);
		}
		else if (act == 'Download')
			field = document.getElementById("download_field");
		else if (act !== 'Home') {
			field = document.getElementById("data_field");
			//self.scrollTo(0, 400);
			var vitri_top = document.getElementById("data_field").offsetTop + 200;
			//alert(vitri_top);
			self.scrollTo(0, vitri_top);
		}
		else field = document.getElementById("data_field");
		//document.getElementById("loading").innerHTML = loadingText;
		//document.getElementById("loading").style.display = "block";
		if (loading==0) {
			loading=1;
			show_Loading();
		}
		current_url = encodeURIComponent(current_url);
		http.open('POST',  'index.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = handleResponse;
		http.send('url='+current_url);
	}
	catch(e){}
	finally{}
}

function handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			//document.getElementById("loading").style.display = "none";
			hide_Loading();
			loading=0;
			response = http.responseText;
			if (current_url.indexOf('Play') != -1 || current_url.indexOf('Gift') != -1) {
				field.style.marginBottom = "10";
				/*document.getElementById("show_hide").style.display = "block";*/
			}
			field.innerHTML = response;
			field.style.display = "";
		}
  	}
	catch(e){}
	finally{}
}

// NDK Loading
var ie45,ns6,ns4,dom;
if (navigator.appName=="Microsoft Internet Explorer") ie45=parseInt(navigator.appVersion)>=4;
else if (navigator.appName=="Netscape"){  ns6=parseInt(navigator.appVersion)>=5;  ns4=parseInt(navigator.appVersion)<5;}
dom=ie45 || ns6;

var timershow=false;
var curx=-200;
var cury=350;
var win_w=window.innerWidth ? window.innerWidth : document.body.offsetWidth;
var mid_w=win_w/2;
var timershow1=window.setInterval("stayMiddle()",1);

function getobj(id) {
el = document.all ? document.all[id] :   dom ? document.getElementById(id) :   document.layers[id];
return el;
}

function show_Loading() {
	obj = getobj('LoadingDiv');
	if (timershow) window.clearTimeout(timershow);
	timershow=window.setInterval("nshow()",1);
}

function hide_Loading() {
	obj = getobj('LoadingDiv');
	if (timershow) window.clearTimeout(timershow);
	timershow=window.setInterval("nhide()",1);
}

function moveobj(obj,x,y) {
	obj.style.left=x + "px";
	obj.style.top=y+ "px";
	curx=x;
	cury=y;
}

function stayMiddle() {
	if (document.documentElement && document.documentElement.scrollTop)
		var pY =  document.documentElement.scrollTop;
	else if (document.body)
		var pY =  document.body.scrollTop;

	obj = getobj('LoadingDiv');
	newy = cury+((pY-cury)/16)+12;
	moveobj(obj,curx,newy);
}

function nshow() {
	obj = getobj('LoadingDiv');
	newx = curx+((mid_w-curx)/16)-7;
	moveobj(obj,newx,cury);
}
function nhide() {
	obj = getobj('LoadingDiv');
	newx = curx+((0-curx)/16)-15;
	moveobj(obj,newx,cury);
}
// End

function getVar(url,cnt)
{
	url=url+'#';
	url=url.split('#');
	if (!url[1]) window.location.href = '#Home';
	url=url[1];
	url=url+',';
	url=url.split(',');
	if (url[0] == 'Logout')
		window.location.href = '?refresh=1';
	if (cnt != -1) {
		url=url[cnt];
		if (!url) return '';
	}
	return url;
}

function loadPage() {
	act = getVar(window.location.href,0);
	if (act) {
		current_url=window.location.href;
		current_url=current_url+'#';
		current_url=current_url.split('#');
		current_url=current_url[1];
		if (current_url) sendRequest(current_url,act);
	}
}

function urlCheck()
{
url=window.location.href;
if (url.indexOf('?') != -1 ) {
url_temp = url.split('?');
clearInterval(interval);
window.location.href = url_temp[0];

}
if (url != '' && url!=lastUrl)
{
loadPage();
url_hs = window.location.href;
url_hs = url_hs.split('#');
url_hs = url_hs[1];
if (browser=='ie') document.getElementById("ieHistory").src='history.php?history='+url_hs;
lastUrl=url;
}

}

function startLoad() {
	interval = setInterval('urlCheck()',100);
}

function alertBrokenLink(id) {
	if (confirm("Báo Link nhạc này đã hỏng ?")) {
		try{
			http.open('POST',  'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = BrokenResponse;
			http.send('url=Broken,'+id);
		}
		catch(e){}
		finally{}
	}
}

function BrokenResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			response = http.responseText;
			if (response == 1) alert("Thông báo đã được gởi đi. Cám ơn bạn đã báo cho chúng tôi.");
			else alert("Thông báo đã được gởi đi. Cám ơn bạn đã báo cho chúng tôi.");
		}
  	}
	catch(e){
		alert("Lỗi. Mong bạn thử lại.");
	}
	finally{}
}

function do_search() {
	kw = document.getElementById("keyword").value;
	if (!kw) alert('Bạn chưa nhập từ khóa');
	else {
		kw = encodeURIComponent(kw);
		s = document.getElementsByName("searchType");
		if (s[0].checked) type = 999;
		if (s[1].checked) type = 1;
		if (s[2].checked) type = 2;
		if (s[3].checked) type = 3;
		if (s[4].checked) type = 7;
		if (s[5].checked) type = 5;
		if (s[6].checked) type = 6;
		if (s[7].checked) type = 4;
		if (s[8].checked) type = 15;
		if (s[9].checked) type = 10;
		if (s[10].checked) type = 17;
		if (s[11].checked) type = 8;
		if (s[12].checked) type = 13;
		if (s[13].checked) type = 9;
		if (s[14].checked) type = 11;
		if (s[15].checked) type = 12;
		if (s[16].checked) type = 14;
		if (s[17].checked) type = 18;
		last_url = '';
		if (type==8) 
		window.location.href = '#Zget,'+kw;
		else if (type==9)
        window.location.href = '#Esget,'+kw;
		else if (type==10) 
        window.location.href = '#NSget,'+kw;
		else if (type==11) 
		window.location.href = '#Yget,'+kw;
		else if (type==12) 
		window.location.href = '#Cget,'+kw;
		else if (type==13)
		window.location.href = '#Nget,'+kw;
		else if (type==14)
		window.location.href = '#Bget,'+kw;
		else if (type==17)
		window.location.href = '#CCget,'+kw;
		else if (type==18)
		window.location.href = '#search_videoz,'+kw;
	else
		window.location.href = '#Search,'+type+','+kw;
	}
	return false;

}
// + ---------------------- +
// |        PLAYLIST        |
// + ---------------------- +

function reloadPlaylist(add_id,remove_id) {
	try{
		document.getElementById("playlist_field").innerHTML = loadingText;
		http.open('POST',  'index.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = playlist_handleResponse;
		http.send('reloadPlaylist=1&add_id='+add_id+'&remove_id='+remove_id);
	}
	catch(e){}
	finally{}
}

function playlist_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			var response = http.responseText;
			document.getElementById("playlist_field").innerHTML = response;
		}
  	}
	catch(e){}
	finally{}
}

function addToPlaylist(song_id)
{
	reloadPlaylist(song_id,0);
}
function removeFromPlaylist(song_id)
{
	reloadPlaylist(0,song_id);
}

/*------------------------------------------------------*/


function trim(a) {
	return a.replace(/^s*(S*(s+S+)*)s*$/, "$1");
}

// + ------------------- +
// |        LOGIN        |
// + ------------------- +

function login_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("login_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("login_loading").innerHTML = response;
				document.getElementById("login_loading").style.display = "block";
			}
			else window.location.href = '?refresh=1';
		}
  	}
	catch(e){}
	finally{}
}

function login(form) {
	name = eval('encodeURIComponent('+form+'.name.value);');
	pwd = eval('encodeURIComponent('+form+'.pwd.value);');
	if(	trim(name) == "" ||	trim(pwd) == "")
		alert("Bạn chưa nhập đầy đủ thông tin");
	else {
		try{
			document.getElementById("login_loading").innerHTML = loadingText;
			document.getElementById("login_loading").style.display = "block";
			http.open('POST',  'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = login_handleResponse;
			http.send('login=1&name='+name+'&pwd='+pwd);
			
		}
		catch(e){}
		finally{}
	}
	return false;
}

// + ---------------------- +
// |        REGISTER        |
// + ---------------------- +

function reg_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("reg_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("reg_loading").innerHTML = response;
				document.getElementById("reg_loading").style.display = "block";
			}
			else {
				window.location.href = '#Login';
			}
		}
  	}
	catch(e){}
	finally{}
}

function request_check_values() {
    ok = false;
    title_request = encodeURIComponent(document.getElementById("title_request").value);
    singer_request = encodeURIComponent(document.getElementById("singer_request").value);
    author_request = encodeURIComponent(document.getElementById("author_request").value);
    ym_request = encodeURIComponent(document.getElementById("ym_request").value);
    email_request = encodeURIComponent(document.getElementById("email_request").value);
    info_request = encodeURIComponent(document.getElementById("info_request").value);
   
    if(    trim(title_request) == "" ||    trim(email_request) == "" )
        alert("Bạn chưa nhập đầy đủ thông tin");
    else {
        try{
            document.getElementById("reg_loading").innerHTML = loadingText;
            document.getElementById("reg_loading").style.display = "block";
            http.open('POST',  'index.php');
            http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            http.onreadystatechange = reg_handleResponse;
            http.send('request=1&title_request='+title_request+'&author_request='+author_request+'&singer_request='+singer_request+'&ym_request='+ym_request+'&email_request='+email_request+'&info_request='+info_request);
           
        }
        catch(e){}
        finally{}
    }
    return ok;
}

function reg_check_values() {
	ok = false;
	name = encodeURIComponent(document.getElementById("reg_name").value);
	pwd = encodeURIComponent(document.getElementById("reg_pwd").value);
	pwd2 = encodeURIComponent(document.getElementById("reg_pwd2").value);
	email = encodeURIComponent(document.getElementById("reg_email").value);
	bday = encodeURIComponent(document.getElementById("reg_bday").value);
	bmonth = encodeURIComponent(document.getElementById("reg_bmonth").value);
	byear = encodeURIComponent(document.getElementById("reg_byear").value);
	fullname = encodeURIComponent(document.getElementById("reg_fullname").value);
	yahoo = encodeURIComponent(document.getElementById("reg_yahoo").value);
	signature = encodeURIComponent(document.getElementById("u_sig").value);
	avatar_input = encodeURIComponent(document.getElementById("u_avatar_input").value);
    avatar_local = encodeURIComponent(document.getElementById("u_avatar_local").value);

	u_area = document.getElementById("u_area");
	area = u_area.options[u_area.selectedIndex].value;
	agree = document.getElementById("agree").checked;
	sec_num = document.getElementById("sec_num").value;  
	 
	s = document.getElementsByName("reg_sex");
	if (s[0].checked) sex = s[0].value;
	if (s[1].checked) sex = s[1].value;
	
	if(	trim(name) == "" ||	trim(pwd) == "" ||	trim(pwd2) == "" ||	trim(email) == "" || trim(bday) == "" ||	trim(bmonth) == "" ||	trim(byear) == "" || trim(fullname) == "" || trim(yahoo) == "" )
		alert("Bạn chưa nhập đầy đủ thông tin");
	else
		if (pwd != pwd2) alert("Xác nhận mật khẩu không chính xác");
		else if (!agree) alert("Bạn chưa đồng ý với các quy định của trang Web");
		else {
			try{
				document.getElementById("reg_loading").innerHTML = loadingText;
				document.getElementById("reg_loading").style.display = "block";
				http.open('POST',  'index.php');
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = reg_handleResponse;
				http.send('reg=1&name='+name+'&pwd='+pwd+'&email='+email+'&bday='+bday+'&bmonth='+bmonth+'&byear='+byear+'&fullname='+fullname +'&yahoo='+yahoo+'&area='+area+'&sex='+sex+'&avatar_input='+avatar_input+'&avatar_local='+avatar_local+'&u_sig='+signature+'&sec_num='+sec_num);
			}
			catch(e){}
			finally{}
		}
	return ok;
}

// + ------------------------- +
// |        CHANGE INFO        |
// + ------------------------- +

function change_info_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("change_info_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("change_info_loading").innerHTML = response;
				document.getElementById("change_info_loading").style.display = "block";
			}
			else window.location.href = '?refresh=1';
		}
  	}
	catch(e){}
	finally{}
}

function change_info() {
	email = encodeURIComponent(document.getElementById("u_email").value);
	oldpwd = encodeURIComponent(document.getElementById("u_oldpwd").value);
	newpwd_1 = encodeURIComponent(document.getElementById("u_newpwd_1").value);
	newpwd_2 = encodeURIComponent(document.getElementById("u_newpwd_2").value);
	avatar_input = encodeURIComponent(document.getElementById("u_avatar_input").value);
    avatar_local = encodeURIComponent(document.getElementById("u_avatar_local").value);
	yahoo = encodeURIComponent(document.getElementById("u_yahoo").value);
	fullname = encodeURIComponent(document.getElementById("fullname").value);
	signature = encodeURIComponent(document.getElementById("u_sig").value);
	bday = encodeURIComponent(document.getElementById("u_day").value);
	bmonth = encodeURIComponent(document.getElementById("u_month").value);
	byear = encodeURIComponent(document.getElementById("u_year").value);
	h_sex = document.getElementById("hide_sex").checked;
	h_email = document.getElementById("hide_email").checked;
	u_area = document.getElementById("u_area");
	area = u_area.options[u_area.selectedIndex].value;
	s = document.getElementsByName("u_sex");
	if (s[0].checked) sex = s[0].value;
	if (s[1].checked) sex = s[1].value;
	if(	trim(email) == "" )
		alert("Bạn chưa nhập đầy đủ thông tin");
	else if (newpwd_1 != newpwd_2)
		alert("Xác nhận mật khẩu không đúng");
	else {
		try{
			document.getElementById("change_info_loading").innerHTML = loadingText;
			document.getElementById("change_info_loading").style.display = "block";
			http.open('POST',  'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = change_info_handleResponse;
			http.send('change_info=1&email='+email+'&oldpwd='+oldpwd+'&newpwd='+newpwd_1+'&sex='+sex+'&hide_sex='+h_sex+'&hide_email='+h_email+'&u_area='+area+'&bday='+bday+'&bmonth='+bmonth+'&byear='+byear+'&yahoo='+yahoo+'&avatar_input='+avatar_input+'&avatar_local='+avatar_local+'&fullname='+fullname+'&u_sig='+signature);  }
		catch(e){}
		finally{}
	}
	return false;
}

// + ----------------------------- +
// |        FORGOT PASSWORD        |
// + ----------------------------- +

function forgot_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("forgot_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("forgot_loading").innerHTML = response;
				document.getElementById("forgot_loading").style.display = "block";
			}
		}
  	}
	catch(e){}
	finally{}
}

function forgot() {
	email = encodeURIComponent(document.getElementById("u_email").value);
	if(	trim(email) == "" )	alert("Bạn chưa nhập email");
	else {
		try{
			document.getElementById("forgot_loading").innerHTML = loadingText;
			document.getElementById("forgot_loading").style.display = "block";
			http.open('POST',  'index.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = forgot_handleResponse;
			http.send('forgot=1&email='+email);
		}
		catch(e){}
		finally{}
	}
	return false;
}

function popup(url,wdname,width,height)
{
	if (width == null)  { width  = 200; }   // default width
	if (height == null) { height = 400; }   // default height
	newwin=window.open(url,wdname,'fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+width+',height='+height);
	if (document.all)
	{
		newwin.moveTo(0,0);
		newwin.focus();
	}
}

function gift(id,width,height) {
	popup('gift.php?id='+id,'gift',width,height);
}

function comment(id,width,height) {
	popup('comment.php?id='+id,'comment',width,height);
}

function receive_gift(id) {
	window.location.href = '#Gift,'+id;
}

function showComment(media_id) {
	try {
		document.getElementById("comment_field").innerHTML = loadingText;
		document.getElementById("comment_field").style.display = "block";
		http.open('POST',  'comment.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			if((http.readyState == 4)&&(http.status == 200)){
				document.getElementById("comment_field").innerHTML = http.responseText;
			}
		}
		http.send('showcomment=1&media_id='+media_id);
	}
	catch(e){}
	finally{}
	return false;
}

function comment_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			var response = http.responseText;
			if (response == 'OK') {
				media_id = encodeURIComponent(document.getElementById("media_id").value);
				showComment(media_id);
			}
			else document.getElementById("comment_loading").innerHTML = response;

		}
  	}
	catch(e){}
	finally{}
}

function comment_check_values() {
	media_id = encodeURIComponent(document.getElementById("media_id").value);
	comment_content = encodeURIComponent(document.getElementById("comment_content").value);
	if(trim(comment_content) == "")
		alert("Bạn chưa nhập cảm nhận");
	//else if (comment_content.length > 255)
	//	alert("Nội dung cảm nhận quá 255 ký tự.");
	else {
		try {
			document.getElementById("comment_loading").innerHTML = loadingText;
			document.getElementById("comment_loading").style.display = "block";
			http.open('POST',  'comment.php');
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			http.onreadystatechange = comment_handleResponse;
			http.send('comment=1&media_id='+media_id+'&comment_content='+comment_content);
		}
		catch(e){}
		finally{}
	}
	return false;
}

function comment_delete(media_id,comment_id) {
	if (confirm("Bạn có muốn xóa cảm nhận này không ?")) {
		document.getElementById("comment_loading").innerHTML = loadingText;
		document.getElementById("comment_loading").style.display = "block";
		http.open('POST',  'comment.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = comment_handleResponse;
		http.send('delete=1&media_id='+media_id+'&comment_id='+comment_id);
	}
	return false;
}

// BEGIN RATING
function Rating(media_id,star) {
	try {
		document.getElementById("rate_s").innerHTML = loadingText;
		document.getElementById("rate_s").style.display = "block";
		hide_rating_process();
		http.open('POST',  'rating.php');
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			if((http.readyState == 4)&&(http.status == 200)){
				document.getElementById("rating_field").innerHTML = http.responseText;
			}
		}
		http.send('rating=1&media_id='+media_id+'&star='+star);
	}
	catch(e){}
	finally{}
	return false;
}


	// pre-fetch image
	(new Image()).src = RATE_OBJECT_IMG;
	(new Image()).src = RATE_OBJECT_IMG_HALF;
	(new Image()).src = RATE_OBJECT_IMG_BG;

	function show_star(starNum) {
		remove_star();
		full_star(starNum);
	}
	
	function full_star(starNum) {
		for (var i=0; i < starNum; i++)
			document.getElementById('star'+ (i+1)).src = RATE_OBJECT_IMG;
	}
	function remove_star() {
		for (var i=0; i < 5; i++)
			document.getElementById('star' + (i+1)).src = RATE_OBJECT_IMG_BG; // RATE_OBJECT_IMG_REMOVED;
	}
	function show_rating_process() {
		document.getElementById("rating_process").style.display = "block";
	}
	function hide_rating_process() {
		document.getElementById("rating_process").style.display = "none";
	}
// END RATING

function ntxNext()
{
    if(document.getElementById("current_id"))
    n = document.getElementById("current_id").value;
  	window.location.href = '#Play,'+n+',LVP-Auto-Play';
}
function user_post_check_values() {
    ok = false;
    title_post = encodeURIComponent(document.getElementById("title_post").value);
    link_post = encodeURIComponent(document.getElementById("link_post").value);
    lyric_post = encodeURIComponent(document.getElementById("lyric_post").value);
    cat_post = encodeURIComponent(document.getElementById("cat_post").value);
    album_post = encodeURIComponent(document.getElementById("album_post").value);
    singer_post = encodeURIComponent(document.getElementById("singer_post").value);
    new_singer_post = encodeURIComponent(document.getElementById("new_singer_post").value);
    singer_type_post = encodeURIComponent(document.getElementById("singer_type_post").value);
    new_album_post = encodeURIComponent(document.getElementById("new_album_post").value);
   
    if(    trim(title_post) == "" ||    trim(link_post) == "")
        alert("Bạn chưa nhập đầy đủ thông tin");
    else {
        try{
            document.getElementById("reg_loading").innerHTML = loadingText;
            document.getElementById("reg_loading").style.display = "block";
            http.open('POST',  'index.php');
            http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            http.onreadystatechange = reg_handleResponse;
            http.send('user_post=1&title_post='+title_post+'&link_post='+link_post+'&new_album_post='+new_album_post+'&new_singer_post='+new_singer_post+'&singer_type_post='+singer_type_post+'&singer_post='+singer_post+'&cat_post='+cat_post+'&album_post='+album_post+'&lyric_post='+lyric_post);
           
        }
        catch(e){}
        finally{}
    }
    return ok;
}

function media_edit_handleResponse() { 
    try { 
        if((http.readyState == 4)&&(http.status == 200)){ 
            document.getElementById("edit_loading").style.display = "none"; 
            var response = http.responseText; 
            if (response){     
                document.getElementById("edit_loading").innerHTML = response; 
                document.getElementById("edit_loading").style.display = "block"; 
                document.getElementById("submit").disabled=false;document.getElementById("submit").value="Đăng lại"; 
            }else window.location.href = '?refresh=1';     
        } 
    } 
    catch(e){} 
        finally{} 
} 

function media_edit(id) { 
    song = encodeURIComponent(document.getElementById("edit_song").value); 
    artist = encodeURIComponent(document.getElementById("edit_artist").value); 
    album = encodeURIComponent(document.getElementById("edit_album").value); 
    cat = encodeURIComponent(document.getElementById("edit_cat").value); 
    lyric = encodeURIComponent(document.getElementById("edit_lyric").value); 
    url = encodeURIComponent(document.getElementById("edit_url").value); 
    //nhacsi = encodeURIComponent(document.getElementById("edit_nhacsi").value); 
    if(    trim(song) == "" || trim(url) == "") 
        alert("Bạn chưa nhập đầy đủ thông tin (*)"); 
    else { 
        try{ 
            document.getElementById("edit_loading").innerHTML = loadingText; 
            document.getElementById("edit_loading").style.display = "block"; 
            http.open('POST',  'index.php'); 
            http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
            http.onreadystatechange = media_edit_handleResponse; 
            http.send('media_edit=1&song='+song+'&artist='+artist+'&cat='+cat+'&lyric='+lyric+'&url='+url+'&media_id='+id+'&album='+album); //+'&nhacsi='+nhacsi 
            document.getElementById("submit").disabled=true;document.getElementById("submit").value="Wait..."; 
        } 
        catch(e){} 
        finally{} 
    } 
    return false; 
} 
function m_del_handleResponse() { 
    try { 
        if((http.readyState == 4)&&(http.status == 200)){ 
            var response = http.responseText; 
            if (response == 1) { 
                alert("Media đã được xoá."); 
                window.location.href = '?refresh=1'; 
            } 
        } 
      } 
    catch(e){} 
    finally{} 
} 
function media_delete(media_id) { 
    if (confirm("Bạn có chắc chắn muốn xóa ca khúc này không ?")) { 
        http.open('POST',  'index.php'); 
        http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
        http.onreadystatechange = m_del_handleResponse; 
        http.send('media_delete=1&media_id='+media_id); 
    } 
    return false; 
}  
function get_comic(){
id = document.getElementById("comic").value;
if (id != '0')
window.location.href='#comic,'+id+'0';
}
function get_Gallery(){
id = document.getElementById("Gallery").value;
if (id != '0')
window.location.href='#Gallery,'+id+'0';
}
function email_handleResponse() {
 try {
  if((http.readyState == 4)&&(http.status == 200)){
   document.getElementById("email_loading").style.display = "none";
   var response = http.responseText;
   if (response) {
    document.getElementById("email_loading").innerHTML = response;
    document.getElementById("email_loading").style.display = "block";
   }else window.location.href = '#List_Message';
  }
   }
 catch(e){}
  finally{}
}
function email(to) {
 title = encodeURIComponent(document.getElementById("email_title").value);
 content = encodeURIComponent(document.getElementById("email_content").value);
 if( trim(title) == "" || trim(content) == "")
  alert("Bạn chưa nhập đầy đủ thông tin");
 else {
  try{
   document.getElementById("email_loading").innerHTML = loadingText;
   document.getElementById("email_loading").style.display = "block";
   http.open('POST',  'index.php');
   http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
   http.onreadystatechange = email_handleResponse;
   http.send('email=1&title='+title+'&content='+content+'&emailto='+to);
   document.getElementById("submit").disabled=true;document.getElementById("submit").value="Wait...";
  }
  catch(e){}
  finally{}
 }
 return false;
}
function pm_handleResponse() {
 try {
  if((http.readyState == 4)&&(http.status == 200)){
   document.getElementById("pm_loading").style.display = "none";
   var response = http.responseText;
   if (response == 1 ) {
    alert("Tin nhắn đã được gửi đi.");
    window.location.href = '#List_Message';
   }else {
   alert("Không có thành viên này!");
   document.getElementById("submit").disabled=false;document.getElementById("submit").value="Gửi lại";
   }
  }
   }
 catch(e){
 alert("Không có thành viên này!");
 }
  finally{}
}
function pm() {
 title = encodeURIComponent(document.getElementById("pm_title").value);
 content = encodeURIComponent(document.getElementById("pm_content").value);
 name = encodeURIComponent(document.getElementById("pm_name").value);
 if( trim(title) == "" || trim(content) == "" || trim(name) == "")
  alert("Bạn chưa nhập đầy đủ thông tin");
 else if (content.length > 1000)
  alert("Nội dung tin nhắn quá 1000 ký tự.");
 else {
  try{
   document.getElementById("pm_loading").innerHTML = loadingText;
   document.getElementById("pm_loading").style.display = "block";
   http.open('POST',  'index.php');
   http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
   http.onreadystatechange = pm_handleResponse;
   http.send('pm=1&title='+title+'&content='+content+'&name='+name);
   document.getElementById("submit").disabled=true;document.getElementById("submit").value="Wait...";
  }
  catch(e){}
  finally{}
 }
 return false;
}
function pm_del_handleResponse() {
 try {
  if((http.readyState == 4)&&(http.status == 200)){
   document.getElementById("list_message_loading").style.display = "none";
   var response = http.responseText;
   if (response == 1) window.location.href = '#Home';
   else alert("Warning!");
  }
   }
 catch(e){
 alert("Warning!");
 }
 finally{}
}
function pm_delete(pm_id) {
 if (confirm("Bạn có chắc chắn muốn xóa tin nhắn này không ?")) {
 try{ 
  document.getElementById("list_message_loading").innerHTML = loadingText;
  document.getElementById("list_message_loading").style.display = "block";
  http.open('POST',  'index.php');
  http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http.onreadystatechange = pm_del_handleResponse;
  http.send('pm_delete=1&pm_id='+pm_id);
 }
 catch(e){}
 finally{}
 }
 return false;
}  

function Title(song,sing)
{
  document.title ='––– [ Vkool.Net ] –––» Bài hát: '+Replaces(song)+' - Ca sỹ: '+Replaces(sing);
}
function TitleSong(title)
{
  document.title ='––– [ Vkool.Net ] –––» Bài hát: '+Replaces(title);
}
function TitleSing(title)
{
  document.title ='––– [ Vkool.Net ] –––» Ca sỹ: '+Replaces(title);
}
function TitleAlbum(title)
{
  document.title ='––– [ Vkool.Net ] –––» Album: '+Replaces(title);
}
function TitlePlaylist(title)
{
  document.title ='––– [ Vkool.Net ] –––» '+Replaces(title)+' \'s Playlist';
}
function TitleCatalog(title)
{
  document.title ='––– [ Vkool.Net ] –––» Catalog: '+Replaces(title);
}
function TitleUser(title)
{
  document.title ='––– [ Vkool.Net ] –––» User: '+Replaces(title);
}
function TitleChannel(title)
{
  document.title ='––– [ Vkool.Net ] –––» Channel: '+Replaces(title);
}
function TitleNews(title)
{
  document.title ='––– [ Vkool.Net ] –––» News: '+Replaces(title);
}

function  Replaces(string) {
string=string.replace(/'/g,"\'");
return string
}

function winSizer(){
	windowWidth = window.screen.availWidth;
	windowHeight = window.screen.availHeight;
	window.moveTo(0,0);
	window.resizeTo(windowWidth,windowHeight);
}
winSizer();

<!--
/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}
function QPlay(media_id) {
    try {
        document.getElementById("quick_play_"+media_id).innerHTML = loadingText;
        document.getElementById("quick_play_"+media_id).style.display = "block";
        http.open('POST',  'qplay.php');
        http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http.onreadystatechange = function() {
            if((http.readyState == 4)&&(http.status == 200)){
                document.getElementById("quick_play_field_"+media_id).innerHTML = http.responseText;
                document.getElementById("control_quick_play_"+media_id).innerHTML = '<a href=# onclick="return CQPlay(\''+media_id+'\');"><img src="img/qplaycol.gif" border="0"></a>';
            }
        }
    http.send('qplay=1&media_id='+media_id);
    }
    catch(e){}
    finally{}
    return false;
}

function CQPlay(media_id) {
        document.getElementById("quick_play_field_"+media_id).innerHTML = '<div id=quick_play_'+media_id+'></div>';
        document.getElementById("control_quick_play_"+media_id).innerHTML = '<a href="#" onclick="return QPlay(\''+media_id+'\');"><img src="img/quick_play.gif" border="0"></a>';
    return false;
}  
//Begin New Windows
function showImage(url)
{         
    image = new Image(); 
    image.src =(url);           
    width=image.width;
    height=image.height;
    return showDialog('viewimage.php?url=' + url,width+200,height+200);

}

function showDialog(url, width, height)
{
    return showWindow(url, false, true, true, false, false, false, true, true, width, height, 0, 0);
}

function showWindow(url, isStatus, isResizeable, isScrollbars, isToolbar, isLocation, isFullscreen, isTitlebar, isCentered, width, height, top, left)
{
    if (isCentered)
    {
        top = (screen.height - height) / 2;
        left = (screen.width - width) / 2;
    }

    open(url, '_blank', 'status=' + (isStatus ? 'yes' : 'no') + ','
    + 'resizable=' + (isResizeable ? 'yes' : 'no') + ','
    + 'scrollbars=' + (isScrollbars ? 'yes' : 'no') + ','
    + 'toolbar=' + (isToolbar ? 'yes' : 'no') + ','
    + 'location=' + (isLocation ? 'yes' : 'no') + ','
    + 'fullscreen=' + (isFullscreen ? 'yes' : 'no') + ','
    + 'titlebar=' + (isTitlebar ? 'yes' : 'no') + ','
    + 'height=' + height + ',' + 'width=' + width + ','
    + 'top=' + top + ',' + 'left=' + left);
}
//End  New Windows

