﻿// JScript 文件
    function AllSelect(cid)
    {
        for(var i = 0; i < document.form1.elements.length; i++)
        {
            var id;
            if(i < 10)
            {
                id = cid.replace("{0}", i);
            }else
            {
                id = cid.replace("0{0}", i);
            }
            if(document.getElementById(id) == null)
            {
                break;
            }
            document.getElementById(id).checked = true;
        }
    }
    function AllCancel(cid)
    {
        for(var i = 0; i < document.form1.elements.length; i++)
        {
            var id;
            if(i < 10)
            {
                id = cid.replace("{0}", i);
            }else
            {
                id = cid.replace("0{0}", i);;
            }
            if(document.getElementById(id) == null)
            {
                break;
            }
            if(document.getElementById(id).checked == true)
            {
                document.getElementById(id).checked = false;
            }else
            {
                document.getElementById(id).checked = true;
            }
        }
    }
function loadPlay()
{
  try{
    setColor(0); 
    var url = document.getElementById("MusicList").options[0].value.split("|")[0];
    document.WMP.URL="http://www.zhhart.com/Admin/UpLoadPic/UpLoadVideo/"+url; //指定(播放)列表中的第一首歌曲
    document.WMP.controls.play(); //播放
  }catch(e){}

  //try{}catch(e){}表示忽略程序运行中出现的错误
}

//function getCurrPos()
//{
//    if(document.getElementById("WMP").controls.currentPosition > 0)
//    {
//        document.getElementById("hidValue").value = document.getElementById("WMP").controls.currentPosition.toString();
//        document.getElementById("Text1").value = document.getElementById("WMP").controls.currentPosition.toString();
//    }
//}

function getWMATime()
{
//    var cu = ;
//    var du = document.WMP.currentMedia.duration;
    if(document.WMP.controls.currentPosition == 0)
    {
        playNext();
    }
//    if(document.getElementById("WMP").currentMedia.duration.toString() == document.getElementById("hidValue").value)
//    {
//        playNext();
//    }
}

//以下函数获取当前播放歌曲在列表中的索引
function getMusicIndex()
{
  try{
    var MusicIndex=0; //存储当前播放歌曲的位置
    /*
     遍历整个播放列表.
     获取当前播放歌曲在列表中的下标位置
     用document.WMP.URL来和列表项的值比较
    */
    for(i=0;i<document.getElementById("MusicList").length;i++)
    {
      var murl = "http://www.zhhart.com/Admin/UpLoadPic/UpLoadVideo/"+document.all.MusicList.options[i].value.split("|")[0];
      if(document.WMP.URL==murl)
      {      
        MusicIndex=i; //记录下当前播放歌曲的位置
        break;
      }    
    }
    return MusicIndex; //整个函数返回当前播放歌曲的下标位置
  }catch(e){}
//  setTimeout('getMusicIndex()',1000); //每隔1秒就检测一下当前播放歌曲的位置
}
getMusicIndex(); //调用getMusicIndex()函数

//设置当前播放与不播放的歌曲的颜色
function setColor(me)
{
  for(i=0;i<document.getElementById("MusicList").length;i++)
  {
    document.getElementById("MusicList").options[i].style.color="purple";
    if(i==me)
    {      
      document.getElementById("MusicList").options[i].style.color="green";  
      document.getElementById("MusicList").options[i].selected = true;
      continue;
    }    
  }
}
//播放上一曲
function playPrevious()
{
   try{
    var PlayIndex=getMusicIndex(); //将当前播放歌曲的位置存储到PlayIndex变量中
    PlayIndex--; //当前播放歌曲的位置-1就表示起上一曲的位置
    setColor(PlayIndex);
    var url = document.getElementById("MusicList").options[PlayIndex].value.split("|")[0];
    document.WMP.URL="http://www.zhhart.com/Admin/UpLoadPic/UpLoadVideo/"+url;
    document.WMP.controls.play();    
  }catch(e){}
}
//播放下一曲
function playNext()
{
   try{
    var PlayIndex=getMusicIndex(); //将当前播放歌曲的位置存储到PlayIndex变量中
    PlayIndex++; //当前播放歌曲的位置+1就表示起下一曲的位置
    setColor(PlayIndex);
       var url = document.getElementById("MusicList").options[PlayIndex].value.split("|")[0];
    document.WMP.URL="http://www.zhhart.com/Admin/UpLoadPic/UpLoadVideo/"+url;;
    document.WMP.controls.currentPosition = 1;
    document.WMP.controls.play();
    getMusicInfo();
  }catch(e){}
}
function getMusicInfo()
{
    var info = new Array();
    var PlayIndex=getMusicIndex();
    info = document.getElementById("MusicList").options[PlayIndex].value.split("|");
    var text = document.getElementById("MusicList").options[PlayIndex].text;
    document.getElementById("lblMusicNM").innerHTML = "歌曲名称："+text;
    document.getElementById("lblMusic_Nm").innerHTML = text;
    document.getElementById("geci").innerHTML = "<strong>"+ text + "歌词</strong>";
    document.getElementById("lblCompany").innerHTML = "唱片公司："+info[1];
    document.getElementById("lblWriteComposer").innerHTML = info[2];
    document.getElementById("lblWriteLyrics").innerHTML = info[3];
    document.getElementById("lblSinger").innerHTML = info[4];
    document.getElementById("txtSongIntroduction").innerHTML = info[5];
    document.getElementById("txtLyrics").innerHTML = info[6];
    document.getElementById("down").innerHTML = "<a href=DownLoads.aspx?FNO="+ info[0] +">下载</a>";
    
}
function palyCurrent(obj)
{
    var url = obj.options[obj.selectedIndex].value.split("|")[0];
    setColor(obj.selectedIndex);
    document.WMP.URL="http://www.zhhart.com/Admin/UpLoadPic/UpLoadVideo/"+url;
    document.WMP.controls.currentPosition = 1;
    document.WMP.controls.play();
    getMusicInfo();
}