// 打开Dialog对话框
function doDialog(url, name, width, height) {
	width = (typeof(width)=="undefined") ? '700' : width;
	height = (typeof(height)=="undefined") ? '500' : height;
	window.top.art.dialog({id:'doDialog'}).close();
	window.top.art.dialog({title:name,id:'doDialog',iframe:url,width:width,height:height,padding:0}, function(){var d = window.top.art.dialog({id:'doDialog'}).data.iframe;d.document.getElementById('submit').click();return false;}, function(){window.top.art.dialog({id:'doDialog'}).close()});
}
// 关闭Dialog对话框
function doDialogClose() {
	window.top.art.dialog({id:'doDialog'}).close();
}
// 对话框显示提示信息
function doTip(msg) {
	window.top.art.dialog({content:msg,lock:true,width:'250',height:'50'}, function(){this.close();});
}
// 切换每页显示记录数
function setPage(size) {
	document.getElementById("pagesize").value = size;
	document.frmsearch.submit();
}
// 批量操作提示
function batchctrl(){
	var sel = document.getElementById("batchaction");
	if (sel.value == '') {
		alert('请先在下拉列表里选择批量操作类型');
		return false;
	}
	if(confirm('确定要『'+sel.options[sel.selectedIndex].text+'』所有选中记录吗？')) {
		document.frmpost.submit();
	}
	return false;
}
// 对话框查看会员信息
function viewuser(uid){
	doDialog('/member/admin/view.php?uid='+uid,'查看会员','600','300')
}
function swapshow(obj){
	if (obj.className=='show_single') {
		obj.className='show_all';
	} else {
		obj.className='show_single';
	}
}
/**
 * 全选checkbox,注意：标识checkbox id固定为为check_all
 * @param string name 列表check名称,如 uid[]
 */
function checkall(name) {
	if ($("#check_all").attr("checked")) {
		$("input[name='"+name+"']").each(function() {
			this.checked=true;
		});
	} else {
		$("input[name='"+name+"']").each(function() {
			this.checked=false;
		});
	}
}
function checkAll(type, form, value, checkall) {
	var checkall = checkall ? checkall : 'chkall';
	for(var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if(type == 'option' && e.type == 'radio' && e.value == value && e.disabled != true) {
			e.checked = true;
		} else if(type == 'value' && e.type == 'checkbox' && e.getAttribute('chkvalue') == value) {
			e.checked = form.elements[checkall].checked;
		} else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) {
			if (e.type == 'text') {
				e.value = form.elements[checkall].value;
			} else {
				e.checked = form.elements[checkall].checked;
			}
		}
	}
}
//提交排序表单
function formSort(field, sort, order) {
	if( document.frmsearch ) {
		var form_search = document.frmsearch;
	} else {
		var form_search = document.createElement("form");
		document.body.appendChild(form_search);
	}
	if( form_search ){
		if( form_search.form_sort ) {
			obj_sort = form_search.form_sort;
		} else {
			obj_sort = formCreat( form_search, 'form_sort' );
		}
		if( form_search.form_order ) {
			obj_order = form_search.form_order;
		} else {
			obj_order = formCreat( form_search, 'form_order' );
		}
		obj_sort.value = field;
		if(field != sort) {
			obj_order.value = 'desc';
		} else if(order == 'asc') {
			obj_order.value = 'desc';
		} else if(order == 'desc') {
			obj_order.value = 'asc';
		}
		form_search.submit();
	} else {
		return false;
	}
}
//创建表单元素
function formCreat(form, ename) {
	var e = document.createElement("input");
	e.type = "hidden";
	e.name = ename;
	e.value = "";
	form.appendChild( e );
	return e;
}
// TAB显示参数设置
function swapTab(cnt,cur){
	for(i=1;i<=cnt;i++){
		if(i==cur){
			 $('#div_setting_'+i).show();
			 $('#tab_setting_'+i).attr('class','on');
		}else{
			 $('#div_setting_'+i).hide();
			 $('#tab_setting_'+i).attr('class','');
		}
	}
}
// 隐藏显示元素
function display(id) {
	var obj = document.getElementById(id);
	if(obj.style.visibility) {
		obj.style.visibility = obj.style.visibility == 'visible' ? 'hidden' : 'visible';
	} else {
		obj.style.display = obj.style.display == '' ? 'none' : '';
	}
}