
function textFormat(content){
    var value = document.searchform.searchtext.value;
    if(value == null || value == "") {
	    document.searchform.searchtext.value = content;
		document.searchform.searchtext.className = "null_txt";
	}
	if(value == "\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0" || value == "\u8bf7\u8f93\u5165\u6b4c\u624b\u540d\u79f0" || value == "\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0\u6216\u6b4c\u624b\u540d\u79f0" ){
	    document.searchform.searchtext.value = content;
		document.searchform.searchtext.className = "null_txt";
	}
	
}
function searchImg(obj,id){
	mouseoverSearch(obj);
	document.getElementById("d_search_menu").className = "bg_img_" + id;
	if(id == 1){
		textFormat("\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0\u6216\u6b4c\u624b\u540d\u79f0");
	}
	else if(id == 2){
		document.searchform.field.value = "tonename";
		textFormat("\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0");
	}
	else if(id == 3){
		document.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" || value == "\u8bf7\u8f93\u5165\u6b4c\u66f2\u540d\u79f0\u6216\u6b4c\u624b\u540d\u79f0"){
	    document.searchform.searchtext.value = "";
		document.searchform.searchtext.className = "notnull_txt";
	}else{
		document.searchform.searchtext.select();
	}
}


String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
function searchSubmit(){
if(isCanSearchSubmit()){
	document.searchform.submit();
}
}

function isCanSearchSubmit(){
	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;
	return true;
}

function changeMcard(obj){
	var url=obj.value;
	obj.value="0";
	if("0"!=url) window.open(url,"_blank");
}



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";
	  
	  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();
}


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();
    }
}


function mouseSearch(obj,id){
	var vfield;
	if(id==2){vfield="tonename"}
	else if(id==3){vfield="singer"}
	if(vfield != document.searchform.field.value)
	{
		obj.className = "s_border_1";
	}
}
function mouseoverSearch(obj){
	obj.className = "s_border_0";
}
var isSearchSubmit = true;
function searchClick(obj){
if(isSearchSubmit && isCanSearchSubmit()){
    isSearchSubmit = false;
    document.searchform.submit();
    obj.className = "notcans_img";
    obj.disabled="disabled";
}
}
function onSearchSubmit(){ 
if(isSearchSubmit && isCanSearchSubmit()){
    isSearchSubmit = false;
    document.getElementById("in_searchbutton").className = "notcans_img";
    document.getElementById("in_searchbutton").disabled = "disabled";
}else{
	return false;
}
}
