﻿var pdString;
var typeID;
var wishlistMsg = "如果您想以后再购买该音乐，您可以把喜欢的音乐先放进您的愿望列表，而且愿望列表是可以和朋友，家人一起分享的，让他们准备一份音乐的礼物给您，不是很棒的事情吗！！";
var libraryName = "/audition/js/cookie.js";
 document.write('<script type="text/javascript" src="'+libraryName+'"></script>');

		function switchAll(mainCtrl) 
		{
			for (var j = 1; j <= boxNUM; j++) 
			{
			box = document.getElementById("Song" + j);
			if (mainCtrl.checked == true)
			{
				box.checked = true;
			}
			else
			{
				box.checked = false;
			}
			
   			}
		}
		function audtionAll(mainCtrl)
		{
		mainCtrl.checked = true;
		switchAll(mainCtrl);
		AuditionSelect();
		}
		
		function AddToPlayList()
		{
			var list = GetSelectSong();
			
			if(list == "")
				{
					alert("请选择!");
					return false;
				}
			else
				{
					list = "N"+list;
					
					addCollection(list);
				}
		}
		
		
		function AddToWishList(IsSpecial)
		{
			var wishlist;
			var type ;

			if(IsSpecial)
			{	type = "2";
				wishlist = SpecialID;
			}
			else
			{
				type = "1";
				wishlist = GetSongIDList();
			}
			
			AddWishList(type,wishlist);
		}
		var selectCount = 0;
		function AddToCartSelect()
		{
			AddToCartMsg = "";
			var productids="";
			for(var j = 1;j<= boxNUM;j++)
			{
					box = document.getElementById("Song" + j);
					if(box.checked == true)
					{
						selectCount++;
						if(productids=="")
						productids+=box.value
						else
						productids+=","+box.value
						//AddSelectToCart(box.value);
					}
					
			}
			if(productids!="")
			window.open("http://www.top100.cn/payment/Cart.aspx?Productid="+productids);
				
			if(selectCount == 0)
			{
				alert("请选择!");
			}
		}
		function AddSongToCart(songID)
		{
				AddToCartMsg = "";
				AddToCart(songID);
		}
		function ShowAddToCartMsg(msg)
		{
			alert(msg);
		}
		function AuditionSelect()
		{
			//typeID = 4;//试听
			if(SetPdString())
			{
				/*window.location.href = "../PageRedirect.aspx?type="+typeID+"&ProductID="+pdString;
				if(pdString.length > 240)
				{ 
					alert("选择的歌曲太多!^_^");
				}
				else
				{*/
					SetCookie("AuditionTrackList","");
					//window.open("/Audition/Play.aspx?PM=1","Top100_Audition_Play");
					//play("http://www.top100.cn/Audition/Play.htm?PM=1");
					play("http://www.top100.cn/Audition/flplayer.html?song="+pdString);
					//flplayer.html?song=M
				//}
			}
			else
			{
				alert("请选择!");
			}
		}
		function AddWidgetSelect()
		{
			//typeID = 4;//试听
			if(SetPdString())
			{
				/*window.location.href = "../PageRedirect.aspx?type="+typeID+"&ProductID="+pdString;
				if(pdString.length > 240)
				{ 
					alert("选择的歌曲太多!^_^");
				}
				else
				{*/
					SetCookie("AuditionTrackList",pdString);
					//window.open("/Audition/Play.aspx?PM=1","Top100_Audition_Play");
					//play("http://www.top100.cn/Audition/Play.htm?PM=1");
					window.open("http://widget.top100.cn/interface/IWidget.aspx?Type=Song&ProductId="+pdString,"_blank");  
					//flplayer.html?song=M
				//}
			}
			else
			{
				alert("请选择!");
			}
		}
		function MonthlyAudition()
		{
			//typeID = 5;
			if(SetPdString())
			{
				/*
				window.open("../PageRedirect.aspx?usemonth=1&type="+typeID+"&ProductID="+pdString);
				window.open("/Payment/Period/PeriodLogin.aspx?ServiceID=602902&usemonth=1&type="+typeID+"&ProductID="+pdString);
				if(pdString.length > 240)
				{ 
					alert("选择的歌曲太多!^_^");
				}
				else
				{
				*/
					//SetCookie("AuditionTrackList",pdString);
					//window.open("/Audition/Play.aspx?PM=1","Top100_Audition_Play");
					SetCookie("AuditionTrackList",pdString);
					//window.open("/Audition/Play.aspx?PM=1","Top100_Audition_Play");
					play("http://www.top100.cn/Audition/Play.htm?PM=1");

				//}
				//Payment/Period/PeriodLogin.aspx
			}
			else
			{
				alert("请选择!");
			}
		
		}
		function SetPdString()
		{
			pdString = GetSelectSong();
			if(pdString == "")
			{
				return false;
			}
			pdString = pdString.replace(/\|/g,",");
			return true;
		}
		
		function GetSongNameList()
		{
			var retSongList = "";
			
			for(var j = 1;j<= boxNUM;j++)
			{
				box = document.getElementById("Song" + j);
				
				if(box.checked == true)
				{
					retSongList = retSongList + box.SongName + ',';
				}
			}
			
			return retSongList;
		}
		function GetSelectSong()
		{
			var selectSong = "";
			for(var j = 1;j<= boxNUM;j++)
				{
					box = document.getElementById("Song" + j);
					
					if(box.checked == true)
					{
						selectSong =selectSong + box.value+"|";
					}
				}
				
			return selectSong.substr(0,selectSong.length - 1);
		}
		function GetSongIDList()
		{
			
			var retSongList = "";
			
			for(var j = 1;j<= boxNUM;j++)
			{
				box = document.getElementById("Song" + j);
				
				if(box.checked == true)
				{
					retSongList = retSongList + box.SongID + ',';
				}
			}
			
			return retSongList;
		}
		function GetSpecialName()
		{
			var songSpan = document.getElementById("songName");
			
			return songSpan?songSpan.innerText:"";
			
			
		}
		function GetSingerName()
		{
			var name = document.getElementById("SingerName");
			if(name)			
			{
			    return name.innerText;
			}
			else
			{
				name=document.getElementById("lblSingerName");
				return name?name.innerText:"";
			}   
		}
