// JavaScript Document
function textFormat(content){
    var value = searchform.searchtext.value;
    if(value == null || value == "") {
	    document.searchform.searchtext.value = content;
		document.searchform.searchtext.style.color = "#999";
	}
	if(value == "\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0" || value == "\u8bf7\u8f93\u5165\u6b4c\u624b\u540d\u79f0" ){
	    document.searchform.searchtext.value = content;
		document.searchform.searchtext.style.color = "#999";
	}
	
}
function searchImg(imgId){
	for(var i = 1; i < 3;i++){
		if(imgId == i){
			switchImageName("search_menu_"+i, "/user/_/images/title/search_menu_2_"+i+".jpg");
		}
		else{
			switchImageName("search_menu_"+i, "/user/_/images/title/search_menu_"+i+".jpg");
		}
	}
	if(imgId == 1){
		searchform.field.value = "tonename";
		textFormat("\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0");
	}
	else if(imgId == 2){
		searchform.field.value = "singer";
		textFormat("\u8bf7\u8f93\u5165\u6b4c\u624b\u540d\u79f0");
	}
}
function setFont(value){
    if(value == "\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0" || value == "\u8bf7\u8f93\u5165\u6b4c\u624b\u540d\u79f0"){
	    searchform.searchtext.value = "";
		searchform.searchtext.style.color = "#000000";
	}
}

//\u589e\u52a0trim\u51fd\u6570
String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
function searchSubmit(){
	var IllegalString = "\`~!#$%^&*()+{}|\\:\"<>?-_=/,\'";
	var val = document.searchform.searchtext.value.trim();
	if(val == "\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0" || val == "\u8bf7\u8f93\u5165\u6b4c\u624b\u540d\u79f0" || val=="")
    {
		alert("\u5bf9\u4e0d\u8d77\uff0c\u641c\u7d22\u5173\u952e\u5b57\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\u5173\u952e\u5b57\u3002");
		document.searchform.searchtext.focus();
		return false;
    }
    for (var j=0;j<=val.length-1;j++) {
	    if (IllegalString.indexOf(val.charAt(j))>=0) {
            alert("\u5173\u952e\u5b57\u5305\u542b\u4ee5\u4e0b\u65e0\u6548\u5b57\u7b26\uff1a"+IllegalString);
            document.searchform.searchtext.focus();
	  	    return false;
	    }
    }	
	document.searchform.action="/user/querytonebytype.do";
	document.searchform.searchType.value = "1";
	document.searchform.condition.value=val;
	document.searchform.submit();
}
function changeMcard(obj){
	var url=obj.value;
	obj.value="0";
	if("0"!=url) window.open(url,"_blank");
}

//Added by jinweida in 2009-05-12 at version SP89
//全选
function od_SelectAll(checkboxname)
{
	var hotmusic = document.getElementsByName(checkboxname);
	for(var i=0;i<hotmusic.length;i++)
	{
		if(!hotmusic[i].disabled)
		{
			hotmusic[i].checked=true;
		}
	}
}

//反选
function od_UnSelectAll(checkboxname)
{
	var hotmusic = document.getElementsByName(checkboxname);
	for(var i=0;i<hotmusic.length;i++)
	{
		if(hotmusic[i].checked)
		{
			if(!hotmusic[i].disabled)
			{
				hotmusic[i].checked=false;
			}
		}
		else
		{
			if(!hotmusic[i].disabled)
			{
				hotmusic[i].checked=true;
			}
		}
	}
}

//试听多首铃音打开播放器
function listentone(checkboxname)
{
	  var hotmusic = document.getElementsByName(checkboxname);
	  var toneChannelCodeArray = new Array();
	  var toneChannelCode = "";
    var n=0;
	  for(var i=0;i<hotmusic.length;i++)
	  {
	      if(hotmusic[i].checked)
		    {
		  	    toneChannelCodeArray[n] = hotmusic[i].value;
		  	    toneChannelCode = toneChannelCode + hotmusic[i].value + "#";
		  	    n=n+1;
		    } 
	  }
	  toneChannelCode = toneChannelCode.substring(0,toneChannelCode.length-1);
	  var maxNum = mytoneform.maxnumlistentone.value;
	  if(n>maxNum)
    {
  	    var j= n-maxNum;
  	    toneChannelCode = "";
  	    for(;j<n;j++)
  	    {
  	 	      toneChannelCode = toneChannelCode + toneChannelCodeArray[j] + "#";
  	    } 
  	    toneChannelCode = toneChannelCode.substring(0,toneChannelCode.length-1);
    }
	  if(toneChannelCode=="")
	  {
	      alert("\u8BF7\u5148\u9009\u62E9\u6B4C\u66F2\u518D\u64AD\u653E\uFF01");
	      return;
	  }
	  var playURL = "/user/listen/player.screen";
	  //防止二次采集用户试听音乐时用户访问行为数据，将ajaxPlayURL设为统计类  add by wuxiaolu in sp112
	  var ajaxPlayURL = "/user/listen/ajaxplayer.screen";
	  var param = "toneinfo="+toneChannelCode;
	  ajaxUtil.isExec=false;
	  ajaxUtil.isAsynch=false;
	  //ajaxUtil.doPost(playURL,param);
	  ajaxUtil.doPost(ajaxPlayURL,param);
	  var m_win_player = window.open(playURL,"mwlisten","width=850,height=650,top=100,left=100");
	  m_win_player.focus();
}

//试听单首铃音打开播放器
function playmusic(toneChannelCode)
{
	  if(toneChannelCode!=="")
	  {
          var playURL = "/user/listen/player.screen";
    	  var ajaxPlayURL = "/user/listen/ajaxplayer.screen";
	      var param = "toneinfo="+toneChannelCode;
	      ajaxUtil.isExec=false;
	      ajaxUtil.isAsynch=false;
	      ajaxUtil.doPost(ajaxPlayURL,param);
        var m_win_player = window.open(playURL,"mwlisten","width=850,height=650,top=100,left=100");
        m_win_player.focus();
    }
}
//Ended by jinweida in 2009-05-12 at version SP89

