﻿var http = createRequestObject();
var lastUrl = '';
var current_url = '';
var field = '';
var interval = '';
var loading=0;

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;
}

var loadingText = "<center><img src='skins/img/loading.gif'> <b>Đang tải dữ liệu ...</b></center>";

function do_search() {
	var frm = document.frm_search;
	kw = frm.keyword.value;
	if (kw == "")
		alert('Bạn chưa nhập từ khóa');
	else {
		kw = encodeURIComponent(kw);		
		for(var i = 0; i < frm.elements.length; i++) {
			if(frm.elements[i].type == 'radio' && frm.elements[i].checked == true) {
				type = frm.elements[i].value ;
				last_url = '';
				window.location.href = '?o=/'+type+'/Search/'+kw+'';		
			}		
		}
	}
	return false;
}


function do_search_2() {
	var frm = document.frm_search;
	kw = frm.keyword.value;
	if (kw == "")
		alert('Bạn chưa nhập từ khóa');
	else {
		kw = encodeURIComponent(kw);		
		for(var i = 0; i < frm.elements.length; i++) {
			if(frm.elements[i].type == 'radio' && frm.elements[i].checked == true) {
				type = frm.elements[i].value ;
				last_url = '';
				window.location.href = '?o=/'+type+'/Search/'+kw+'';
						
			}		
		}
	}
	return false;
}


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

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',  'index.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=# title="close" onclick="return CQPlay(\''+media_id+'\');"><img src="skins/img/icon/unquick_play.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="#"  title="quick_play" onclick="return QPlay(\''+media_id+'\');"><img src="skins/img/icon/quick_play.gif" border="0"></a>';  
   return false;
}  


function mediaNext(type)
{
	if(document.getElementById("current_id"))
	$idnext = document.getElementById("current_id").value;
  	s=$idnext;
	window.location='./?o=/'+type+'/Play/'+s;
}


function test_user_add()
	{	
		var USER_NAME
		USER_NAME=register.user.value
		if (USER_NAME=="")
		{
			alert("Bạn chưa nhập Tên Đăng Nhập !")						
			register.user.focus()
			return false
		}
		var USER_PASS
		USER_PASS=register.pass.value
		if (USER_PASS=="" || USER_PASS.length<6)
		{
			alert("Bạn chưa nhập Mật Khẩu, hoặc Mật Khẩu bạn nhập nhỏ hơn 6 kí tự !")						
			register.pass.focus()
			return false
		}
		return true
}

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);}


