
/*===================================*/
function go(url) {
	document.location.href = url;
}
function toback() {
	window.history.back();
}
function backlist() {
	document.location.href = top.listpage;
}
/*===================================*/
var highlightcolor = "#eafcd5";
//此处clickcolor只能用win系统颜色代码才能成功,如果用#xxxxxx的代码就不行,还没搞清楚为什么:(
var clickcolor = "#51b2f6";
function changeto() {
	source = event.srcElement;
	if (source.tagName == "TR" || source.tagName == "TABLE") {
		return;
	}
	while (source.tagName != "TD") {
		source = source.parentElement;
	}
	source = source.parentElement;
	cs = source.children;
//alert(cs.length);
	if (cs[1].style.backgroundColor != highlightcolor && source.id != "nc" && cs[1].style.backgroundColor != clickcolor) {
		for (i = 0; i < cs.length; i++) {
			cs[i].style.backgroundColor = highlightcolor;
		}
	}
}
function changeback() {
	if (event.fromElement.contains(event.toElement) || source.contains(event.toElement) || source.id == "nc") {
		return;
	}
	if (event.toElement != source && cs[1].style.backgroundColor != clickcolor) {
//source.style.backgroundColor=originalcolor
	}
	for (i = 0; i < cs.length; i++) {
		cs[i].style.backgroundColor = "";
	}
}
function clickto() {
	source = event.srcElement;
	if (source.tagName == "TR" || source.tagName == "TABLE") {
		return;
	}
	while (source.tagName != "TD") {
		source = source.parentElement;
	}
	source = source.parentElement;
	cs = source.children;
//alert(cs.length);
	if (cs[1].style.backgroundColor != clickcolor && source.id != "nc") {
		for (i = 0; i < cs.length; i++) {
			cs[i].style.backgroundColor = clickcolor;
		}
	} else {
		for (i = 0; i < cs.length; i++) {
			cs[i].style.backgroundColor = "";
		}
	}
}
/*===================================*/
function enCode(chineseStr) {
	return encodeURI(chineseStr, "utf-8");
}
function getForm() {
	return document.getElementsByTagName("form")[0];
}
function getManFrame() {
}
function getRadioValue(RadioName) {
	var obj;
	obj = document.getElementsByName(RadioName);
	if (obj != null) {
		var i;
		for (i = 0; i < obj.length; i++) {
			if (obj[i].checked) {
				return obj[i].value;
			}
		}
	}
	return null;
}
function getRadioValueByRadis(obj) {
	if (obj != null) {
		var i;
		for (i = 0; i < obj.length; i++) {
			if (obj[i].checked) {
				return obj[i].value;
			}
		}
	}
	return null;
}
function checkedBoxSongId() {
	var ids = document.getElementsByName("songid");
	for (var i = 0; i < ids.length; i++) {
		if (ids[i].name == "songid") {
			ids[i].checked = true;
		}
	}
	//alert("^!^ 全选/反选本功能需完善！");
}
function allBoxSongId(iselected) {
	var ids = document.getElementsByName("songid");
	for (var i = 0; i < ids.length; i++) {
		if (ids[i].name == "songid") {
			ids[i].checked = iselected;
		}
	}
}
function inverseBoxSongId(name) {
    var name_s='songid';
    if(name!=undefined){
	  name_s=name;
	}
	var ids = document.getElementsByName(name_s);
	
	for (var i = 0; i < ids.length; i++) {
		if (ids[i].name == name_s) {
			ids[i].checked = !ids[i].checked;
		}
	}
}
function getSongIdCheckBox() {
	var uid = "";
	var obj = document.getElementsByName(name);
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			uid += obj[i].value + ",";
		}
	}
	if (uid == "") {
		alert("\u8bf7\u9009\u62e9\u64cd\u4f5c\u7684\u6570\u636e");
	}
	return uid;
}
function getSongIdCheckBoxFirst() {
	var uid = "";
	var obj = document.getElementsByName("songid");
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			uid += obj[i].value;
			break;
		}
	}
	if (uid == "") {
		alert("\u8bf7\u9009\u62e9\u64cd\u4f5c\u7684\u6570\u636e");
	}
	return uid;
}
function getSelectCheckBox(WinCmsTable) {
	var selectebBox = new Array();
	var obj = WinCmsTable.document.getElementsByName("songid");
	var times = 0;
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			selectebBox[times++] = obj[i];
		          //if(obj[i].innerHTML==''){
		          //  alert('异常'+obj[i].innerHTML);
		          //  continue;
		          // }
		          // alert( selectebBox[i].value);
		}
	}
	if (selectebBox.length == 0) {
		alert("\u8bf7\u9009\u62e9\u64cd\u4f5c\u7684\u6570\u636e");
		return;
	}
	return selectebBox;
}
function getSongIdCheckBox(WinCmsTable) {
	var uid = "";
	if (WinCmsTable == undefined) {
		WinCmsTable = window;
	}
	var obj = WinCmsTable.document.getElementsByName("songid");
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			uid += obj[i].value + ",";
		}
	}
	if (uid == "") {
		alert("\u8bf7\u9009\u62e9\u64cd\u4f5c\u7684\u6570\u636e");
	}
	return uid;
}
function getTableSelectIdName(WinCmsTable) {
	var uid = "";
	var obj = WinCmsTable.document.getElementsByName("songid");
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			uid += obj[i].value;
			var parentN = obj[i].parentNode.parentNode.lastChild.childNodes[0];
			uid += "_" + parentN.innerHTML;
		}
	}
	if (uid == "") {
		alert("\u8bf7\u9009\u62e9\u64cd\u4f5c\u7684\u6570\u636e");
	}
	return uid;
}
function isDigit(s) {
	var patrn = /^[0-9]{1,20}$/;
	if (!patrn.exec(s)) {
		return false;
	}
	return true;
}
/*删除===================================*/
	
function Perform(url){
	new Ajax.Request(url,{
			onSuccess: function(transport) {
				alert(transport.responseText);
				//refresh();
			    document.location.reload();
			},
			onFailure : function(){ alert('操作失败！'); }
  		});
 }
function PerformNotRefresh(url){
	new Ajax.Request(url,{
			onSuccess: function(transport) {
				alert(transport.responseText);
				document.location.reload();
			},
			onFailure : function(){ alert('操作失败！'); }
  		});
 }
function batchDel(para) {
//alert(para);return;
	var path = document.location.pathname + "?action=del&ids=";
	if (getSongIdCheckBox() != "") {
		url = path + getSongIdCheckBox();
		if(para!=undefined){
		  url+='&'+para;
		}
		Perform(url);
	}
}
function actionIds(action,para) {
	var path = document.location.pathname + '?action='+action+'&ids=';
	if (getSongIdCheckBox() != "") {
		url = path + getSongIdCheckBox();
		if(para!=undefined){
		  url+='&'+para;
		}
		Perform(url);
	}
}
function delBean(id,para){
    var url=document.location.pathname + '?action=del&ids='+id;
    if(para!=undefined){
		  url+='&'+para;
	}
	new Ajax.Request(url,{
			onSuccess: function(transport) {
				alert(transport.responseText);
				document.location.reload();
			},
			onFailure : function(){ alert('操作失败！'); }
  		});
}
function PerformNotRefresh(url) {
	new Ajax.Request(url, {onSuccess:function (transport) {
		alert(transport.responseText);
	}, onFailure:function () {
		alert("\u64cd\u4f5c\u5931\u8d25\uff01");
	}});
}
/*表单验证===================================*/
function notnull(name,msg){
	if(document.getElementById(name).value=='')
	{
	  alert(msg);
	  document.getElementById(name).focus();
	  return false;
	}
	return true;
}

/*ajax 方式提交===================================*/
function ajaxCms(url,isalert,isreload){
	new Ajax.Request(url,{
			onSuccess: function(transport) {
			    if(isalert)
				alert(transport.responseText);
				if(isreload)
				document.location.reload();
			},
			onFailure : function(){ alert('操作失败！'); }
  		});
 }
/*===================================*/
/*===================================*/


