﻿// JScript File
function ToggleMe(psID){
	var loObj = document.getElementById(psID);
	if(!loObj)
		return;
	 if(loObj.className == '')
	  loObj.className = 'hide';
	 else
	  loObj.className = '';
}
function PlayMedia(psType,psCheck,psID){
	var lsDiv, lWidth, lHeight,lsContent;
	var lTop, lLeft;
	try{// && navigator.appName != 'Netscape'
		if(psType == 'clip'){
			lHeight = 0.7 * screen.availHeight;
			lWidth = 0.7 * screen.availWidth;
		}else{
			lHeight = screen.availHeight / 1.5;
			lWidth = screen.availWidth * 0.6;
			
		}
		lTop = (screen.availHeight - lHeight) / 2;
		lLeft = (screen.availWidth - lWidth) / 2;
		var handlename;
		handlename = window.open('../Play/MediaPlayer.aspx?type=' + psType + '&check=' + psCheck + '&id=' + psID,'player','resizable=yes,scrollbars=yes,menubar=0,status=yes,height=' + lHeight + ',width=' + lWidth + ',left=' + lLeft + ',top=' + lTop);
		handlename.moveTo(lLeft,lTop);
		handlename.resizeTo(lWidth,lHeight);
		handlename.focus();
	}catch(ex){}
}
function PlayMediaList(psType){
	var lsDiv, lWidth, lHeight,lsContent;
	var lTop, lLeft;
	try{
		if(psType == 'clip'){
			lHeight = 0.7 * screen.availHeight;
			lWidth = 0.7 * screen.availWidth;
		}else{
			lHeight = screen.availHeight / 1.5;
			lWidth = screen.availWidth * 0.6;
			
		}
		lTop = (screen.availHeight - lHeight) / 2;
		lLeft = (screen.availWidth - lWidth) / 2;
		var handlename;
		handlename = window.open('../Play/ListMediaPlayer.aspx?type=' + psType,'player','resizable=yes,scrollbars=yes,menubar=0,status=yes,height=' + lHeight + ',width=' + lWidth + ',left=' + lLeft + ',top=' + lTop);
		handlename.moveTo(lLeft,lTop);
		handlename.resizeTo(lWidth,420);
		handlename.focus();
	}catch(ex){}
}
function PlayArticleMedia(psID){
	var lsDiv, lWidth, lHeight,lsContent;
	try{
		lHeight = screen.availHeight / 2;
		lWidth = screen.availWidth / 2;
		var handlename;
		handlename = window.open('../Play/ArticlePlayer.aspx?id='+ psID,'player','scrollbars=yes,menubar=0,status=yes,height=' + lHeight + ',width=' + lWidth + ',left=' + lWidth/2 + ',top=' + lHeight/2);
		handlename.focus();
	}catch(ex){}
}
function ResizeMedia(psType){
	var lWidth, lHeight;
	try{
		if(psType == 'clip'){
			lHeight = 0.84 * 0.7 * screen.availHeight;
			lWidth = 0.7 * 0.7 * screen.availWidth;
		}else{
			lHeight =  0.84 * screen.availHeight / 2;
			lWidth =  0.55 * screen.availWidth / 2;
		}
		var handlename;
		handlename = document.getElementById('mpPlayer');
		if(handlename){
			handlename.width = lWidth;
			handlename.height = lHeight;
		}
		handlename = document.getElementById('embPlayer');
		if(handlename){//IE not found
			handlename.width = lWidth - 10;
			handlename.height = lHeight - 10;
		}
	}catch(ex){}
}
function DownloadSong(psSong){
	window.location = "../Info/Download.aspx?file=" + psSong;
}
function WriteArticle(psSong){
	try{
		var lsURL;
		lsURL = "../Article/Article.aspx?idsong=" + psSong;
		if(window.opener){
			window.opener.location = lsURL;
			window.opener.focus();
		}else{
			var handlename;
			handlename = window.open(lsURL,'article');
			handlename.focus();
		}
	}catch(ex){}
}
function ViewSingerInfo( url ){
	try{
		if(window.opener){
			window.opener.location = url;
			window.opener.focus();
		}else{
			var handlename;
			handlename = window.open(url,'singer');
			handlename.focus();
		}
	}catch(ex){}
}
function GoPage(psPage,psPara,iPage){
	var lsReq = '';
	if(psPage && psPara && iPage){
		aspnetForm.action = psPage + "?" + psPara + "=" + iPage;
		aspnetForm.submit();
	}
}
function GoPage2(psPage,psPara,iPage, sPara2, sValue2){
	//var lsReq = '';
	if(psPage && psPara && iPage && sPara2 && sValue2){
		aspnetForm.action = psPage + "?" + psPara + "=" + iPage + "&" + sPara2 + "=" + sValue2;
		aspnetForm.submit();
	}
}
function ToPage(iPage){
	var lsReq = '';
	if(iPage){
		frmSong.action = "Song.aspx?Page=" + iPage;
		frmSinger.submit();
	}
}
function ShowImg(psPath){
	var lsDiv, lWidth, lHeight,lsContent;
	try{
		lHeight = screen.availHeight / 2;
		lWidth = screen.availWidth / 2;
		var divShow, handlename;
		handlename = window.open('','img','scrollbars=yes,menubar=0,status=yes,height=' + lHeight + ',width=' + lWidth + ',left=' + lWidth/2 + ',top=' + lHeight/2);
		divShow = handlename.document.getElementById('divShow');
		lsDiv = "<img src='" + psPath + "' alt=''/>";
		if(divShow)
			divShow.innerHTML = lsDiv;
		else{
			lsDiv = "<div align='center' id='divShow'>" + lsDiv + '</div>';
			handlename.document.write(lsDiv);
		}
		handlename.focus();
	}catch(ex){}
}
//8888888888888888888888888888888888888888888888888888888888888888888//
function TopHit_AddToPlaylist( SongID, SongName )
{
    //if(!CheckEmailVote())
	//	return;
	var lForm, loMsg;
	var lsUrl = '../Ajax/AjaxRes.aspx';
	lForm = document.forms[0];
	//lForm.btnSend.disabled = true;
	document.getElementById('hdnSongID').value = SongID;
	document.getElementById('hdnSongName').value = SongName;
	var lRequest = new System.Net.Ajax.Request('POST', lsUrl, Result_AddToPlaylist, true);
	lRequest.AddParam('action','AddToPlaylist');
	lRequest.AddParam('SongID',trim(lForm.hdnSongID.value));
	lRequest.AddParam('SongName',trim(lForm.hdnSongName.value));
	var lPageReq = new System.Net.Ajax.PageRequests(lRequest);
	var lConnect = new System.Net.Ajax.Connection(lPageReq);
	lConnect.Open();
}
function Result_AddToPlaylist(pXMLHTTP){
	try{
		var lDivWait;
		//lDivWait = document.getElementById('divResult');
		if (pXMLHTTP.ReadyState == 1)
			lDivWait.className = '';
		else if(pXMLHTTP.ReadyState == 4 && pXMLHTTP.Status == 200){
			var answer = pXMLHTTP.ResponseText;
			//if(answer.indexOf('Error') == 0){
			//	document.getElementById('evEVote_lblMsg').innerHTML = answer.substr(7);
			//	document.getElementById('txtCode').value = '';
			//	document.getElementById('btnSend').disabled = false;
			//}else{
			//	document.getElementById('evEVote_lblMsg').innerHTML = answer;
			//	ClearData();
			//}
			//lDivWait.className = 'hide';
			alert(answer);
			document.getElementById("hdnSongID").value = "";
			document.getElementById("hdnSongName").value = "";
		}
	}catch(ex){}
}
function PlayMyList()
{
    var lsUrl = '../Ajax/AjaxRes.aspx';
	var lRequest = new System.Net.Ajax.Request('POST', lsUrl, Result_PlayMyList, true);
	lRequest.AddParam('action','PlayMyList');
	var lPageReq = new System.Net.Ajax.PageRequests(lRequest);
	var lConnect = new System.Net.Ajax.Connection(lPageReq);
	lConnect.Open();
}
function Result_PlayMyList(pXMLHTTP)
{
    try{
		var lDivWait;
		if (pXMLHTTP.ReadyState == 1)
			lDivWait.className = '';
		else if(pXMLHTTP.ReadyState == 4 && pXMLHTTP.Status == 200){
			var answer = pXMLHTTP.ResponseText;
			
			if ( answer.substring( 0, 1 ) == "0" )
			    alert(answer.substr( 1 ));
			else
			{
			    PlayMediaList('audio');
			}
		}
	}catch(ex){}
}
//8888888888888888888888888888888888888888888888888888888888888888888//

function trim(psValue)
{
	if(!psValue){ 
		psValue = "";
		return psValue;
	}
	return String(psValue).replace(/^\s*|\s*$/g,"");
}
function CheckEmail(psEmail){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(psEmail)){
		return true;
	}
	return false;
}
