//打开模式窗口
function openModalDialog(url, width, height)
{
	var features = 'dialogWidth:'+width+'px;'+'dialogHeight:'+height+'px;'+'edge: Raised; center: Yes; help: No; resizable: No; status: No;';
	var handle = window.showModalDialog(url, window, features);
}

//全部选择
function selectall()
{
	if(document.msgform){
		if(document.msgform.checkallmsg.checked==true){
			var total = document.msgform.page_intLineNum.value*1+1;
			for(var i = 1; i < total; i++){
				var thisCtrl = eval("document.msgform.checkmsg" + i);
				if(thisCtrl){
					thisCtrl.checked = true;
					thisCtrl.disabled = false;
				}
			}
		}else{
			var total = document.msgform.page_intLineNum.value*1+1;
			for(var i = 1; i < total; i++){
				var thisCtrl = eval("document.msgform.checkmsg" + i);
				if(thisCtrl){
					thisCtrl.checked = false;
					thisCtrl.disabled = false;
				}
			}
		}
	}
}
//全部选择
function checkall()
{
	if(document.msgform){
		var total = document.msgform.page_intLineNum.value*1+1;
		for( var i = 1; i < total; i++ ){	
			var thisCtrl = eval("document.msgform.checkmsg" + i);
			if( thisCtrl && thisCtrl.checked == true ){
				return true;
				break;
			}
		}
	}
	return false;;
}

//去除首尾空格
function killSpace(x)
{
	while((x.length>0) && (x.charAt(0)==' '))
		x = x.substring(1,x.length)
	while((x.length>0) && (x.charAt(x.length-1)==' '))
		x = x.substring(0,x.length-1)
	return x
}

function opendate(obj,e,s,url)
{
	var iurl = ( url ) ? url : "../";
	var width = 375;
	var height = 280;
	s = ( s ) ? s : 0;
	e = ( e ) ? e : 19;
	
	var left = window.screenLeft + obj.offsetLeft + 2;
	var top = window.screenTop + obj.offsetTop + obj.offsetHeight;
	if (parseInt((left + width),10) > parseInt(screen.availWidth,10)) left = left - width + obj.offsetWidth - 2;
	if ((top + height) > screen.availHeight) top = top - height - obj.offsetHeight + 2;	
	
	retval = window.showModalDialog(iurl+"com/calendar.php?sindex="+s+"&eindex="+e, "日期/时间 属性", "dialogWidth:"+width+"px; dialogHeight:"+height+"px; dialogLeft:"+left+"px; dialogTop:"+top+"px; status:no; directories:yes;scrollbars:no;Resizable=no;");

	if( retval != null ) {
		obj.value = retval;
	}
}


//编辑记录
function editmsg(id,url){
	document.msgform.func.value="E";
	document.msgform.post_i_id.value=id;
	document.msgform.action = url;
	document.msgform.submit();
}
//新增
function addmsg(url){
	document.msgform.func.value="N";
	document.msgform.action = url;
	document.msgform.submit();
}
//gengxin
function updmsg(url){
	document.msgform.func.value="H";
	document.msgform.action = url;
	document.msgform.submit();
}
//gengxin
function updmsg1(url){
	document.msgform.func.value="O";
	document.msgform.action = url;
	document.msgform.submit();
}
//shanchu
function delmsg(url){
	if( checkall() ){
		if( confirm("确定删除？") ){
			document.msgform.func.value="D";
			document.msgform.action = url;
			document.msgform.submit();
		}
	}else{
		alert("请至少选择一条记录！");
	}
	
}

function audmsg(url,f){
	if( checkall() ){
		if( confirm("确定授权操作吗？") ){
			document.msgform.func.value=f;
			document.msgform.action = url;
			document.msgform.submit();
		}
	}else{
		alert("请至少选择一条记录！");
	}
	
}

function chktr(id){
	var o = document.getElementById('tr_'+id);
	if( o.style.display == "none" ){
		o.style.display = 'block';
	}else{
		o.style.display = 'none';
	}
}


