﻿//coded by Ninja + Le Hoan, hie hie
var miniPlayer;

var isNS4 = (navigator.appName=="Netscape")?1:0;
//mainPlayer
var mainHeightLarge = 370;
var mainHeightSmallIe = 60;
var mainHeightSmallFf = 45;
var mainWidthLarge = 420;
var mainWidthSmall = 420;
//miniPlayer
var miniHeightLarge = 370;
var miniHeightSmallIe = 60;
var miniHeightSmallFf = 45;
var miniWidthLarge = 420;
var miniWidthSmall = 420;
//playList
var plHeightIe = 370;
var plHeightFf = 370;
var plWidth = 570;

function gotoshow(){
window.location=slidelinks[whichlink]
}



function ItemMinimize(Name) {
if (Name<=3) {
  for(i=1;i<4;i++) {
	var MItem=document.all('IDM_'.concat(i));	
    if (i==Name){
			if (MItem.style.display=='') {
				MItem.style.display='none';
			}
			else {
				MItem.style.display='';
			}
	}
	else {
		MItem.style.display='none';
	}
  }  
}
else {
	var MItem=document.all('IDM_'.concat(Name));	
    
			if (MItem.style.display=='') {
				MItem.style.display='none';			
			}
			else {
				MItem.style.display='';			
			} 
	}
}
function changeSource( strSource )
	{
		var s;
		
		s="<OBJECT id=Player ";
		s+="codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ";
		s+="type=application/x-oleobject height=370 ";
		s+="standby=\"Loading Microsoft Windows Media Player components...\" "; 
		s+="width=424 classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ";
		s+="name=winMediaPlayer>";
		
		s+="<PARAM NAME=\"URL\" VALUE=\""+strSource+"\"> ";
                             s+="<PARAM NAME=\"ShowControls\" VALUE=\"1\">";
                             s+="<PARAM NAME=\"Volume\" VALUE=\"100\">";
                             s+="<PARAM NAME=\"rate\" VALUE=\"1\">";
                             s+="<PARAM NAME=\"balance\" VALUE=\"0\">";
                             s+="<PARAM NAME=\"currentPosition\" VALUE=\"0\">";
                             s+=" <PARAM NAME=\"defaultFrame\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"currentMarker\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"invokeURLs\" VALUE=\"-1\">";
                              s+="<PARAM NAME=\"baseURL\" VALUE=\"\">";
                              s+="<PARAM NAME=\"mute\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"uiMode\" VALUE=\"full\">";
                              s+="<PARAM NAME=\"stretchToFit\" VALUE=\"-1\">";
                              s+="<PARAM NAME=\"windowlessVideo\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"enabled\" VALUE=\"-1\">";
                              s+="<PARAM NAME=\"enableContextMenu\" VALUE=\"0\">";
                                s+="<PARAM NAME=\"playCount\" VALUE=\"1\">";
                              s+="<PARAM NAME=\"CursorType\" VALUE=\"-1\">";
                             s+=" <PARAM NAME=\"autoStart\" VALUE=\"1\">";
                              s+="<PARAM NAME=\"fullScreen\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"SAMIStyle\" VALUE=\"\">";
                              s+="<PARAM NAME=\"SAMILang\" VALUE=\"\">";
                              s+="<PARAM NAME=\"SAMIFilename\" VALUE=\"\">";
                  	s+="<PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\"> \n";
		s+="<Embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' filename='"+strSource+"' src='"+strSource+"' Name='MediaPlayerTV' "; 
		s+="width='424' ";
		s+="height='370' ";
		s+="AutoSize='1' ";
		s+="AutoStart='1' ";
		s+="ClickToPlay='1' ";
		s+="DisplaySize='1' ";
		s+="EnableContextMenu='1' ";
		s+="EnableFullScreenControls='1' "; 
		s+="EnableTracker='1' ";
		s+="Mute='0' ";
		s+="PlayCount='1' "; 
		s+="ShowControls='1' "; 
		s+="ShowAudioControls='1' "; 
		s+="ShowDisplay='0' ";
		s+="ShowGotoBar='0' ";
		s+="ShowPositionControls='1' "; 
		s+="ShowStatusBar='1' ";
		s+="ShowTracker='1'> ";
		s+="</embed> ";
		s+="</OBJECT>";
		
		
		
		
		document.getElementById("MediaPlayer").innerHTML=s;
	}
	
function fixChannelUrl()
{
	var links = document.getElementsByTagName("a"); 
	var tagNum = links.length; 
	var hrefStr = "";
	
	for(i = 0; i < tagNum; i++)
	{                        
		hrefStr = links[i].href;		
		if ( hrefStr == '' )
		{
			links[i].href = ''; 
		} 
	} 
}
	
function MediaPlayer(fixChannelUrl)
	{
		var s;
		
		s="<OBJECT id=Player ";
		s+="codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ";
		s+="type=application/x-oleobject height=370 ";
		s+="standby=\"Loading Microsoft Windows Media Player components...\" "; 
		s+="width=424 classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 ";
		s+="name=winMediaPlayer>";
		
		s+="<PARAM NAME=\"URL\" VALUE=\"nghe.asp\"> ";
                             s+="<PARAM NAME=\"ShowControls\" VALUE=\"1\">";
                             s+="<PARAM NAME=\"Volume\" VALUE=\"100\">";
                             s+="<PARAM NAME=\"rate\" VALUE=\"1\">";
                             s+="<PARAM NAME=\"balance\" VALUE=\"0\">";
                             s+="<PARAM NAME=\"currentPosition\" VALUE=\"0\">";
                             s+=" <PARAM NAME=\"defaultFrame\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"currentMarker\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"invokeURLs\" VALUE=\"-1\">";
                              s+="<PARAM NAME=\"baseURL\" VALUE=\"\">";
                              s+="<PARAM NAME=\"mute\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"uiMode\" VALUE=\"full\">";
                              s+="<PARAM NAME=\"stretchToFit\" VALUE=\"-1\">";
                              s+="<PARAM NAME=\"windowlessVideo\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"enabled\" VALUE=\"-1\">";
                              s+="<PARAM NAME=\"enableContextMenu\" VALUE=\"0\">";
                                s+="<PARAM NAME=\"playCount\" VALUE=\"1\">";
                              s+="<PARAM NAME=\"CursorType\" VALUE=\"-1\">";
                             s+=" <PARAM NAME=\"autoStart\" VALUE=\"1\">";
                              s+="<PARAM NAME=\"fullScreen\" VALUE=\"0\">";
                              s+="<PARAM NAME=\"SAMIStyle\" VALUE=\"\">";
                              s+="<PARAM NAME=\"SAMILang\" VALUE=\"\">";
                              s+="<PARAM NAME=\"SAMIFilename\" VALUE=\"\">";
                  	s+="<PARAM NAME=\"enableErrorDialogs\" VALUE=\"0\"> \n";
		s+="<Embed type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/windowsmedia/download/' filename='nghe.asp' src='nghe.asp' Name='MediaPlayerTV' "; 
		s+="width='424' ";
		s+="height='370' ";
		s+="AutoSize='1' ";
		s+="AutoStart='1' ";
		s+="ClickToPlay='1' ";
		s+="DisplaySize='1' ";
		s+="EnableContextMenu='1' ";
		s+="EnableFullScreenControls='1' "; 
		s+="EnableTracker='1' ";
		s+="Mute='0' ";
		s+="PlayCount='1' "; 
		s+="ShowControls='1' "; 
		s+="ShowAudioControls='1' "; 
		s+="ShowDisplay='0' ";
		s+="ShowGotoBar='0' ";
		s+="ShowPositionControls='1' "; 
		s+="ShowStatusBar='1' ";
		s+="ShowTracker='1'> ";
		s+="</embed> ";
		s+="</OBJECT>";
		
		
		
		document.getElementById("MediaPlayer").innerHTML=s;
	}	



///************** mini player js ******************///
function openMiniPlayer(){	
		var miniPlayer;
		if (navigator.appName.indexOf('Microsoft') != -1) 
		{
			height = miniHeightSmallIe;
		}
		else 
		{
			height = miniHeightSmallFf;
		}
		
		width = miniWidthLarge;		
		winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,dependent=yes,titlebar=yes,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
		winDef = winDef.concat('top=').concat((screen.height - height)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - width)/2);
		window.name="mainPage";
		miniPlayer = open('miniplayer.htm', '_blank', winDef);
		miniPlayer.focus();
}

//**** Playlist js************ //
var playlist;
function openPlaylist(page){
		if (navigator.appName.indexOf('Microsoft') != -1) 
		{
			height = plHeightIe;
		}
		else 
		{
			height = plHeightFf;
		}
		
		width = plWidth;		
		winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,dependent=yes,titlebar=no,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
		winDef = winDef.concat('top=').concat((screen.height - height)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - width)/2);
		window.name="mainPage";
		playlist = open(page, 'PlayList', winDef);
		playlist.focus();
		return false;
}
function jumpToThisSong(stt){
	try{
		if (navigator.appName.indexOf('Microsoft') != -1){
		Player = document.all.Player;		
		if(Player.currentPlaylist.item(stt-1) != Player.controls.currentItem)
			Player.controls.currentItem = Player.currentPlaylist.item(stt-1);
			Player.controls.Play();	
		}else{
			alert("Trình duyệt của bạn không hổ trợ tính năng này. Mong bạn thông cảm!");
		}
	}catch(ex){
			alert(ex);
	}
}

function randomPlaylistMode(){
	try{
		if (navigator.appName.indexOf('Microsoft') != -1){
			Player = document.all.Player;		
			if(document.all.check3.checked)
				Player.settings.setMode('shuffle', true);
			else
				Player.settings.setMode('shuffle', false);
		}else{
			document.all.check3.checked = false;
			alert("Trình duyệt của bạn không hổ trợ tính năng này. Mong bạn thông cảm!!");
		}
	}catch(ex){
			alert(ex);
	}
}

// ****************** detail **************///
//khai bao
function miniPlayerOpen(){
	if(navigator.appName.indexOf('Microsoft') != -1)
		openForIe();
	else
		openForFf();
}
function miniPlayerClose(){	
	if(navigator.appName.indexOf('Microsoft') != -1)
		closeForIe();
	else
		closeForFf();
}
function repeatMode(){
	if(navigator.appName.indexOf('Microsoft') != -1)
		repeatForIe();
	else
		repeatForFf();
}

function repeatModeMain(){
	if(navigator.appName.indexOf('Microsoft') != -1)
		repeatForIeMain();
	else
		repeatForFfMain();
}
function changeSize(){
	if(navigator.appName.indexOf('Microsoft') != -1)
		changeSizeForIe();
	else
		changeSizeForFf();		
}

function changeSizeMain(){
	if(navigator.appName.indexOf('Microsoft') != -1)
		changeSizeForIeMain();
	else
		changeSizeForFfMain();		
}

function mainOpenSetting(){
	if(navigator.appName.indexOf('Microsoft') != -1)
		document.all.Player.height = mainHeightSmallIe;	
	else
		document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMainPlayer').innerHTML.replace('height="'+mainHeightLarge+'"', 'height="'+mainHeightSmallFf+'"');		
}
	

//mo ta
function openForIe(){
	document.getElementById('boxMiniPlayer').innerHTML = window.opener.document.getElementById('boxMainPlayer').innerHTML;	
	window.opener.document.all.Player.controls.stop();
	window.opener.document.all.Player.enabled = false;		
	Player.height = miniHeightSmallIe;
}
function openForFf(){
	document.getElementById('boxMiniPlayer').innerHTML = window.opener.document.getElementById('boxMainPlayer').innerHTML;	
	window.opener.document.getElementById('boxMainPlayer').innerHTML = "";
	document.getElementById('boxMiniPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML.replace('height="'+miniHeightLarge+'"', 'height="'+miniHeightSmallFf+'"');
	//document.getElementById('cellPlayer').height = 60;	
}

function repeatForIe(){
	if(Player.settings.playCount == 1)
		Player.settings.playCount = 9999;
	else
		Player.settings.playCount = 1;
}

function repeatForFf(){
	//alert(document.getElementById('boxMiniPlayer').innerHTML);
	if(document.all.check1.checked == true)
		document.getElementById('boxMiniPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML.replace('playcount="1"', 'playcount="9999"');
	else
		document.getElementById('boxMiniPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML.replace('playcount="9999"', 'playcount="1"');
}
//main

function repeatForIeMain(){
	if(document.all.check1.checked == true)
		document.getElementById('Player').settings.playCount = 9999;
	else
		document.getElementById('Player').settings.playCount = 1;
}

function repeatForFfMain(){
	//alert(document.getElementById('boxMiniPlayer').innerHTML);
	if(document.all.check1.checked == true)
		document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMainPlayer').innerHTML.replace('playcount="1"', 'playcount="9999"');
	else
		document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMainPlayer').innerHTML.replace('playcount="9999"', 'playcount="1"');
}


function changeSizeForIe(){
	if(Player.height == miniHeightSmallIe){		
		window.moveBy(0, -189);
		window.resizeTo(440,460);
		Player.height = miniHeightLarge;		
	}
	else{		
		window.resizeTo(440,200);
		window.moveBy(0, 189);
		Player.height = miniHeightSmallIe;		
	}
}

function changeSizeForFf(){
	if(document.all.check2.checked == true){
		window.moveBy(0, -200);
		window.resizeTo(300,340);
		document.getElementById('boxMiniPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML.replace('height="'+miniHeightSmallFf+'"','height="'+miniHeightLarge+'"');
	}
	else{
		window.resizeTo(300,240);		
		window.moveBy(0, 200);		
		document.getElementById('boxMiniPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML.replace('height="'+miniHeightLarge+'"', 'height="'+miniHeightSmallFf+'"');
	}
}
//main
function changeSizeForIeMain(){
	if(document.all.check2.checked == true){		
		document.getElementById('Player').height = mainHeightLarge;		
	}
	else{		
		document.getElementById('Player').height = mainHeightSmallIe;		
	}
}

function changeSizeForFfMain(){
	if(document.all.check2.checked == true){
		document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMainPlayer').innerHTML.replace('height="'+mainHeightSmallFf+'"', 'height="'+mainHeightLarge+'"');
	}
	else{
		document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMainPlayer').innerHTML.replace('height="'+mainHeightLarge+'"', 'height="'+mainHeightSmallFf+'"');
	}
}



function closeForIe(){
try{
	Player.height = miniHeightLarge;
	Player.controls.pause();	
	window.opener.document.all.Player.enabled = true;
	if(window.opener.document.getElementById('boxMainPlayer')){
		if(window.opener.document.getElementById('ctrlMusicPlaying_imgFormat').alt == "Audio")
			Player.height = miniHeightSmallIe;
		window.opener.document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML;
				//if(window.opener.document.all.check2.checked == true){		
				//window.opener.document.getElementById('Player').height = 250;		
			/*}
			//else{	*/	
				//window.opener.document.getElementById('Player').height = 60;		
			//}*/
		}
}
catch(ex){

	this.close();
}
		
}

function closeForFf(){
try{
	if(document.all.check2.checked == false)
		document.getElementById('boxMiniPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML.replace('height="'+miniHeightSmallFf+'"', 'height="'+miniHeightLarge+'"');
	if(window.opener.document.getElementById('boxMainPlayer')){
		window.opener.document.getElementById('boxMainPlayer').innerHTML = document.getElementById('boxMiniPlayer').innerHTML;
		if(window.opener.document.getElementById('ctrlMusicPlaying_imgFormat').alt == "Audio")
			window.opener.document.getElementById('boxMainPlayer').innerHTML = window.opener.document.getElementById('boxMainPlayer').innerHTML.replace('height="'+mainHeightLarge+'"', 'height="'+mainHeightSmallFf+'"');
		}
}
catch(ex){

	this.close();
}
}
function radio(){
document.writeln("                <Div dir=\"ltr\"><b><A href=\"javascript:changeSource('nghequocte.asp')\">QT!Radio<\/a> |  <A href=\"javascript:changeSource('nghedance.asp')\">Dance!Radio<\/a> | <A href=\"javascript:changeSource('ngheviet.asp')\">VN!Radio<\/a> <\/b><\/Div>");
}
//filter key

function filterKey(suk){
	if(navigator.appName.indexOf('Microsoft') != -1){
		if(event.keyCode == 85 || event.keyCode == 117)
			return false;
		else
			return true;
	}
	else{
		
		if(suk == 85 || suk == 117)
			return false;
		else
			return true;}

}
