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

function Alert_Upload() {
	alert("Bạn chưa đăng nhập. Vui lòng đăng nhập để Upload nhạc.");
}
function Alert_Add_Playlist() {
	alert("Bạn chưa đăng nhập. Vui lòng đăng nhập để thêm vào Playlist.");
}
function Alert_Download() {
	alert("Hiện tại Server đang quá tải do số lượng download nhiều. Để đảm bảo server hoạt động tốt, trong thời gian tới các bạn phải đăng nhập mới có thể Download nhạc từ GTTM. Mong các bạn thông cảm. Vào http://www.giaitrithuongmai.com/Register.html để đăng ký Username và Mật khẩu.");
}

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 do_search(folder) {
	kw = document.getElementById("keyword").value;
	if (!kw) alert('Bạn chưa nhập từ khóa');
	else {
		kw = encodeURIComponent(kw);
		type = document.getElementById("t").value;
		/*s_type = document.getElementById("searchType");
		type = s_type.options[s_type.selectedIndex].value;
		switch (type) {
			case 'song' : type = 'song'; break;
			case 'singer' : type = 'singer'; break;
			case 'album' : type = 'album'; break;
		}*/
		last_url = '';
		if (type==1)
		window.location.href = '/search/'+kw+'/'+'song'+'.html';
        else 
        if (type==2)                
		window.location.href = '/search/'+kw+'/'+'singer'+'.html';
        else
		if (type==3) 
		window.location.href = '/search/'+kw+'/'+'album'+'.html';
		//window.location.href = '/search/'+kw+'/'+type+'.html';
	}
	return false;
}
function do_templates(folder) {
	temp_id = document.getElementById("template").value;
	window.location.href = '/index.php?template='+temp_id;
	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;
			window.parent.location= nowURL;
		}
  	}
	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 
			alert("Đăng nhập thành công");
			window.location.href = mainURL;
		}
  	}
	catch(e){}
	finally{}
}

function login(form) {
name = encodeURIComponent(document.getElementById("name").value);
pwd = encodeURIComponent(document.getElementById("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',  mainURL);
			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 {
				alert("Bạn đã đăng kí thành công");
				window.location.href = mainURL;
			}
		}
  	}
	catch(e){}
	finally{}
}

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);	
	sec_num = encodeURIComponent(document.getElementById("sec_num").value);
	agree = document.getElementById("agree").checked;

	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(sec_num) == "" ||	trim(pwd2) == "" ||	trim(email) == "" )
		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',  mainURL);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = reg_handleResponse;
				http.send('reg=1&name='+name+'&pwd='+pwd+'&email='+email+'&sec_num='+sec_num+'&sex='+sex);
				
			}
			catch(e){}
			finally{}
		}
	return ok;
}


// + ----------------------------- +
// |        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',  mainURL);
			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(folder,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 broken(id,folder,width,height) {
	popup('/brokenlink.php?id='+id,'broken',width,height);
}
function receive_gift(id) {
	window.location.href = '/index.php?go=gift_receive&id='+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;
}

if (!document.all) 

document.captureEvents(Event.MOUSEMOVE) 

// On the move of the mouse, it will call the function getPosition 

document.onmousemove = getPosition;  

// These varibles will be used to store the position of the mouse 

var X = 0 

var Y = 0  

// This is the function that will set the position in the above varibles 

function getPosition(args) 

{ 

  // Gets IE browser position 

  if (document.all) 

  { 

    X = event.clientX + document.body.scrollLeft 

    Y = event.clientY + document.body.scrollTop 

  } 

  // Gets position for other browsers 

  else 

  {  

    X = args.pageX 

    Y = args.pageY 

  }  

}
  

 // To enable/disable the background:  

function backgroundFilter() 

{ 

    var div; 

    if(document.getElementById) 

    // Standard way to get element 

    div = document.getElementById('backgroundFilter'); 

    else if(document.all) 

    // Get the element in old IE's 

    div = document.all['backgroundFilter'];    

    // if the style.display value is blank we try to check it out here 

    if(div.style.display== '' && div.offsetWidth != undefined&&div.offsetHeight != undefined) 

    { 

        div.style.display = (div.offsetWidth!=0 && div.offsetHeight!=0)?'block':'none'; 

    } 

    // If the background is hidden ('none') then it will display it ('block'). 

    // If the background is displayed ('block') then it will hide it ('none'). 

    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block'; 

} 

 // To display/hide the popup:  

function popUp() 

{ 

    var div; 

    if(document.getElementById) 

    // Standard way to get element 

    div = document.getElementById('popupWindow'); 

    else if(document.all) 

    // Get the element in old IE's 

    div = document.all['popupWindow'];    

    // if the style.display value is blank we try to check it out here 

    if(div.style.display== '' && div.offsetWidth != undefined && div.offsetHeight != undefined) 

    { 

        div.style.display = (div.offsetWidth!=0 && elem.offsetHeight!=0)?'block':'none'; 

    } 

    // If the PopUp is hidden ('none') then it will display it ('block'). 

    // If the PopUp is displayed ('block') then it will hide it ('none'). 

    div.style.display = (div.style.display==''||div.style.display=='block')?'none':'block'; 

    // Off-sets the X position by 15px 

    X = X + 5;    

    // Sets the position of the DIV 

    div.style.left = X+'px'; 

    div.style.top = Y+'px'; 

} 
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}

function tabview_aux(TabViewId, id)
{
  var TabView = document.getElementById(TabViewId);

  var Tabs = TabView.firstChild;
  while (Tabs.className != "Tabs" ) Tabs = Tabs.nextSibling;

  var Tab = Tabs.firstChild;
  var i   = 0;

  do
  {
    if (Tab.tagName == "A")
    {
      i++;
      Tab.href      = "javascript:tabview_switch('"+TabViewId+"', "+i+");";
      Tab.className = (i == id) ? "Active" : "";
      Tab.blur();
    }
  }
  while (Tab = Tab.nextSibling);

  var Pages = TabView.firstChild;
  while (Pages.className != 'Pages') Pages = Pages.nextSibling;

  var Page = Pages.firstChild;
  var i    = 0;

  do
  {
    if (Page.className == 'Page')
    {
      i++;
      if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px";
      Page.style.overflow = "auto";
      Page.style.display  = (i == id) ? 'block' : 'none';
    }
  }
  while (Page = Page.nextSibling);
}

function tabview_switch(TabViewId, id) { tabview_aux(TabViewId, id); }

function tabview_initialize(TabViewId) { tabview_aux(TabViewId,  1); }



//////////////////////
//					//
// USER POST MUSIC	//
//					//
//////////////////////

function user_post_handleResponse() {
	try {
		if((http.readyState == 4)&&(http.status == 200)){
			document.getElementById("upload_music_loading").style.display = "none";
			var response = http.responseText;
			if (response) {
				document.getElementById("upload_music_loading").innerHTML = response;
				document.getElementById("upload_music_loading").style.display = "block";
			}
			else {
				alert("Bài hát đã được đăng thành công");
				window.location.href = mainURL;
			}
		}
  	}
	catch(e){}
	finally{}
}

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_img_link_post = encodeURIComponent(document.getElementById("singer_img_link_post").value);
    singer_type_post = encodeURIComponent(document.getElementById("singer_type_post").value);
    new_album_post = encodeURIComponent(document.getElementById("new_album_post").value);
	album_img_link_post = encodeURIComponent(document.getElementById("album_img_link_post").value);
	//file_post_name = encodeURIComponent(document.getElementById("file_post_name").value);
	
	
	if(	trim(title_post) == "" || trim(link_post) =="" && trim(file_post_name) =="" ){
		alert("Bạn chưa nhập đầy đủ thông tin");
	}			
	else {
			try{
				document.getElementById("upload_music_loading").innerHTML = loadingText;
				document.getElementById("upload_music_loading").style.display = "block";
				http.open('POST', mainURL);
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http.onreadystatechange = user_post_handleResponse;
				http.send('post_music=1&title_post='+title_post+'&link_post='+link_post+'&new_album_post='+new_album_post+'&album_img_link_post='+album_img_link_post+'&new_singer_post='+new_singer_post+'&singer_img_link_post='+singer_img_link_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;
}


// FLASH PLAYER //

function changeplayer(type,id,s) {
	document.getElementById("old_player_field").innerHTML = '';
	document.getElementById("new_player_field").innerHTML = loadingText;
    document.getElementById("new_player_field").style.display = "block";
	var player = '<OBJECT id="Mediaplayer" name="Mediaplayer" width="500" height="65" CLASSID="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">';
	player += '<param name="url" VALUE="/asx.php?type='+type+'&id='+id+'">';
	player += '<param name="EnableContextMenu" value="false">';
	player += '<param name="volume" value="100">';
	player += '<param name="ShowStatusBar" value="true">';
	player += '<param name="ShowDisplay" value="false">';
	player += '<embed type="application/x-mplayer2" quality="high" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" file="/asx.php?type='+type+'&id='+id+'" src="/asx.php?type='+type+'&id='+id+'" width="500" height="65" AutoStart="1" EnableContextMenu="0" Mute="0" ShowStatusBar="1" loop="true" ShowDisplay="0" />';
	player += '</OBJECT>';
	player += '<div align=center style="padding-top: 5px;"><a style="cursor:pointer" onclick="return returnplayer('+type+','+id+','+s+')"><font color="#0b83ca"><b>Nhấn vào đây để nghe bằng Flash player nếu bạn muốn đẹp mắt hơn!</b></font></a></div>';
	document.getElementById("new_player_field").innerHTML = player;
}

function returnplayer(type,id,s) {
document.getElementById("new_player_field").innerHTML = '';
document.getElementById("old_player_field").innerHTML = loadingText;
document.getElementById("old_player_field").style.display = "block";
var player = '<embed type="application/x-shockwave-flash" src="/mediaplayer.swf" wmode="transparent" id="player" name="player" quality="high" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=/flash.php?id='+id+'&displayheight=100&abouttxt=GiaiTriThuongMai.Com&aboutlnk=http://www.giaitrithuongmai.com&lightcolor=66FFFF&showdigits=true&showeq=true&showfsbutton=true&logo=/img/flash_background1.gif&autostart=true&shuffle=true&repeat=true;volume=100;width=380&height=120" height="120" width="380">';
player += '<div class="space"></div>';
player += '<div align=center style="padding-top: 5px"><a style="cursor:pointer" onclick="return changeplayer('+type+','+id+','+s+')"><font color="#0b83ca"><b>Nếu Flash Player không tự play nhạc hoặc không có biểu tượng load, có thể là do File nhạc có định dạng WMA. Bạn hãy click vào đây để nghe bằng Windows Media nhé.</b></font></a></div>';
document.getElementById("old_player_field").innerHTML = player;
}




// FLASH SINGER PLAYER //

function changeplayersinger(type,id,sg) {
	document.getElementById("old_player_field").innerHTML = '';
	document.getElementById("new_player_field").innerHTML = loadingText;
    document.getElementById("new_player_field").style.display = "block";
	var player = '<OBJECT id="Mediaplayer" name="Mediaplayer" width="500" height="65" CLASSID="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">';
	player += '<param name="url" VALUE="/asx.php?type='+type+'&id='+id+'">';
	player += '<param name="EnableContextMenu" value="false">';
	player += '<param name="volume" value="100">';
	player += '<param name="ShowStatusBar" value="true">';
	player += '<param name="ShowDisplay" value="false">';
	player += '<embed type="application/x-mplayer2" quality="high" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" file="/asx.php?type='+type+'&id='+id+'" src="/asx.php?type='+type+'&id='+id+'" width="500" height="65" AutoStart="1" EnableContextMenu="0" Mute="0" ShowStatusBar="1" loop="true" ShowDisplay="0" />';
	player += '</OBJECT>';
	player += '<div align=center style="padding-top: 5px;"><a style="cursor:pointer" onclick="return returnplayersinger('+type+','+id+','+sg+')"><font color="#0b83ca"><b>Nhấn vào đây để nghe bằng Flash player nếu bạn muốn đẹp mắt hơn!</b></font></a></div>';
	document.getElementById("new_player_field").innerHTML = player;
}

function returnplayersinger(type,id,sg) {
document.getElementById("new_player_field").innerHTML = '';
document.getElementById("old_player_field").innerHTML = loadingText;
document.getElementById("old_player_field").style.display = "block";
var player = '<embed type="application/x-shockwave-flash" src="/mediaplayer.swf" wmode="transparent" id="player" name="player" quality="high" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=/flash-playsinger.php?id='+id+'&displayheight=100&abouttxt=GiaiTriThuongMai.Com&aboutlnk=http://www.giaitrithuongmai.com&lightcolor=66FFFF&showdigits=true&showeq=true&showfsbutton=true&autostart=true&shuffle=true&repeat=true;volume=100;width=380&height=300" height="300" width="380">';
player += '<div class="space"></div>';
player += '<div align=center style="padding-top: 5px"><a style="cursor:pointer" onclick="return changeplayersinger('+type+','+id+','+sg+')"><font color="#0b83ca"><b>Nếu Flash Player không tự play nhạc hoặc không có biểu tượng load, có thể là do File nhạc có định dạng WMA. Bạn hãy click vào đây để nghe bằng Windows Media nhé.</b></font></a></div>';
document.getElementById("old_player_field").innerHTML = player;
}



// FLASH ALBUM PLAYER //

function changeplayeralbum(type,id,ab) {
	document.getElementById("old_player_field").innerHTML = '';
	document.getElementById("new_player_field").innerHTML = loadingText;
    document.getElementById("new_player_field").style.display = "block";
	var player = '<OBJECT id="Mediaplayer" name="Mediaplayer" width="500" height="65" CLASSID="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">';
	player += '<param name="url" VALUE="/asx.php?type='+type+'&id='+id+'">';
	player += '<param name="EnableContextMenu" value="false">';
	player += '<param name="volume" value="100">';
	player += '<param name="ShowStatusBar" value="true">';
	player += '<param name="ShowDisplay" value="false">';
	player += '<embed type="application/x-mplayer2" quality="high" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" file="/asx.php?type='+type+'&id='+id+'" src="/asx.php?type='+type+'&id='+id+'" width="500" height="65" AutoStart="1" EnableContextMenu="0" Mute="0" ShowStatusBar="1" loop="true" ShowDisplay="0" />';
	player += '</OBJECT>';
	player += '<div align=center style="padding-top: 5px;"><a style="cursor:pointer" onclick="return returnplayeralbum('+type+','+id+','+ab+')"><font color="#0b83ca"><b>Nhấn vào đây để nghe bằng Flash player nếu bạn muốn đẹp mắt hơn!</b></font></a></div>';
	document.getElementById("new_player_field").innerHTML = player;
}

function returnplayeralbum(type,id,ab) {
document.getElementById("new_player_field").innerHTML = '';
document.getElementById("old_player_field").innerHTML = loadingText;
document.getElementById("old_player_field").style.display = "block";
var player = '<embed type="application/x-shockwave-flash" src="/mediaplayer.swf" wmode="transparent" id="player" name="player" quality="high" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=/flash-album.php?id='+id+'&displayheight=100&abouttxt=GiaiTriThuongMai.Com&aboutlnk=http://www.giaitrithuongmai.com&lightcolor=66FFFF&showdigits=true&showeq=true&showfsbutton=true&autostart=true&shuffle=true&repeat=true;volume=100;width=380&height=300" height="300" width="380">';
player += '<div class="space"></div>';
player += '<div align=center style="padding-top: 5px"><a style="cursor:pointer" onclick="return changeplayeralbum('+type+','+id+','+ab+')"><font color="#0b83ca"><b>Nếu Flash Player không tự play nhạc hoặc không có biểu tượng load, có thể là do File nhạc có định dạng WMA. Bạn hãy click vào đây để nghe bằng Windows Media nhé.</b></font></a></div>';
document.getElementById("old_player_field").innerHTML = player;
}



// FLASH PLAYLIST PLAYER //

function changeplayerplaylist(type,id,pl) {
	document.getElementById("old_player_field").innerHTML = '';
	document.getElementById("new_player_field").innerHTML = loadingText;
    document.getElementById("new_player_field").style.display = "block";
	var player = '<OBJECT id="Mediaplayer" name="Mediaplayer" width="500" height="65" CLASSID="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701">';
	player += '<param name="url" VALUE="/asx.php?type='+type+'&id='+id+'">';
	player += '<param name="EnableContextMenu" value="false">';
	player += '<param name="volume" value="100">';
	player += '<param name="ShowStatusBar" value="true">';
	player += '<param name="ShowDisplay" value="false">';
	player += '<embed type="application/x-mplayer2" quality="high" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" file="/asx.php?type='+type+'&id='+id+'" src="/asx.php?type='+type+'&id='+id+'" width="500" height="65" AutoStart="1" EnableContextMenu="0" Mute="0" ShowStatusBar="1" loop="true" ShowDisplay="0" />';
	player += '</OBJECT>';
	player += '<div align=center style="padding-top: 5px;"><a style="cursor:pointer" onclick="return returnplayerplaylist('+type+','+id+','+pl+')"><font color="#0b83ca"><b>Nhấn vào đây để nghe bằng Flash player nếu bạn muốn đẹp mắt hơn!</b></font></a></div>';
	document.getElementById("new_player_field").innerHTML = player;
}

function returnplayerplaylist(type,id,pl) {
document.getElementById("new_player_field").innerHTML = '';
document.getElementById("old_player_field").innerHTML = loadingText;
document.getElementById("old_player_field").style.display = "block";
var player = '<embed type="application/x-shockwave-flash" src="/mediaplayer.swf" wmode="transparent" id="player" name="player" quality="high" allowfullscreen="true" allowscriptaccess="always" flashvars="&file=/flash-playlist.php?id='+id+'&displayheight=100&abouttxt=GiaiTriThuongMai.Com&aboutlnk=http://www.giaitrithuongmai.com&lightcolor=66FFFF&showdigits=true&showeq=true&showfsbutton=true&autostart=true&shuffle=true&repeat=true;volume=100;width=380&height=300" height="300" width="380">';
player += '<div class="space"></div>';
player += '<div align=center style="padding-top: 5px"><a style="cursor:pointer" onclick="return changeplayerplaylist('+type+','+id+','+pl+')"><font color="#0b83ca"><b>Nếu Flash Player không tự play nhạc hoặc không có biểu tượng load, có thể là do File nhạc có định dạng WMA. Bạn hãy click vào đây để nghe bằng Windows Media nhé.</b></font></a></div>';
document.getElementById("old_player_field").innerHTML = player;
}