	var nDialogWidth1 = 300;
	var nDialogHeight1 = 400;
	var nLeft1 = (window.screen.availWidth-nDialogWidth1)/2;
	var nTop1 = (window.screen.availHeight-nDialogHeight1)/2;
	var sFeatures1 = "dialogLeft:"+nLeft1+"px;dialogTop:"+nTop1+"px;dialogHeight:"+nDialogHeight1+"px;dialogWidth:"+nDialogWidth1+"px;help:no;status:no";

	var nDialogWidth2 = 800;
	var nDialogHeight2 = 600;
	var nLeft2 = (window.screen.availWidth-nDialogWidth2)/2;
	var nTop2 = (window.screen.availHeight-nDialogHeight2)/2;
	var sFeatures2 = "dialogLeft:"+nLeft2+"px;dialogTop:"+nTop2+"px;dialogHeight:"+nDialogHeight2+"px;dialogWidth:"+nDialogWidth2+"px;help:no;status:no";


//select one position
function alertMsg(data){
	$('<div style="text-align:center">'+data+'</div>').dialog({
              title: '提示',
              autoOpen: true,
              width: 300,
              height: 50,
              modal: true,
	          resizable: false,
           buttons: {
			"确定": function() {
				$( this ).dialog( "close" );
			}
		}  
          }).width(300).height(50);
}

/**
*	弹出顶层窗口
*	data 为JSON串 其属性有：
*		src			弹出窗口链接
*		title		标题
*		width		弹出窗口的宽度
*		height		弹出窗口的高度
*		position	弹出位置
*		savefunc	点击保存时调用的方法，如果方法返回“success”则关闭
*		closefunc	点击关闭时调用的方法，如果方法返回“success”则关闭
*		ok			1保存 2确定 3注册
*	windowWork 调用该方法所在的window
*	params 参数数组，传入回调函数中
*	弹出窗口
*/
function opendailog(data,windowWork,params){
	var jsonObject = eval("("+data+")");
	var ok = jsonObject.ok;
	if(ok=="2"){
		top.calltopdailog2(data,windowWork,params);
	}else if(ok=="3"){
		top.calltopdailog3(data,windowWork,params);
	}else{
		top.calltopdailog(data,windowWork,params);
	}
}
/**
*	弹出顶层窗口
*	data 为JSON串 其属性有：
*		id			弹出窗口id
*		src			弹出窗口链接
*		title		标题
*		width		弹出窗口的宽度
*		height		弹出窗口的高度
*		position	弹出位置
*/
function opendailog1(data){
	top.calltopdailog1(data);
}
function closedailog1(id){
	top.closedailog1(id);
}

function countChecked(name){
	var all = document.getElementsByName(name);
	var count = 0;
    for(var i=0; i<all.length; i++)
    {
    	if(all[i].checked)
    	{
    		count++;
    	}
    }
    return count;
}

function checkOnlySel(){
	var count = countChecked("chk");
	
	if(count <=0)
	{
		alert("对不起您还没有选中一条记录");
		return false;
	}
	if(count >1)
	{
		alert("对不起，您只能对一条选中的记录进行编辑");
		return false;
	}
	if(count == 1)
	{	
		return true;
	}
}

function getCheckedObj(name){
	var all = document.getElementsByName(name);
	var chkedArray = new Array();
    for(var i=0; i<all.length; i++)
    {
    	if(all[i].checked)
    	{
    		chkedArray.push(all[i]);
    	}
    }
    return chkedArray;
}

Date.prototype.format = function(format){   
	 /*  
	  * eg:format="YYYY-MM-dd hh:mm:ss";  
	  */  
	 var o = {   
	  "M+" :  this.getMonth()+1,  //month   
	  "d+" :  this.getDate(),     //day   
	  "h+" :  this.getHours(),    //hour   
	      "m+" :  this.getMinutes(),  //minute   
	      "s+" :  this.getSeconds(), //second   
	      "q+" :  Math.floor((this.getMonth()+3)/3),  //quarter   
	      "S"  :  this.getMilliseconds() //millisecond   
	   }   
	    
	   if(/(y+)/.test(format)) {   
	    format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
	   }   
	    
	   for(var k in o) {   
	   if(new RegExp("("+ k +")").test(format)) {   
	     format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));   
	    }   
	   }   
	 return format;   
}

function nowTime(ev,type){   
    /*  
     * ev:显示时间的元素  
     * type:时间显示模式.若传入12则为12小时制,不传入则为24小时制  
     */  
    //年月日时分秒   
    var Y,M,D,W,H,I,S;   
    //月日时分秒为单位时前面补零   
    function fillZero(v){   
        if(v<10){v='0'+v;}   
        return v;   
    }   
    (function(){   
        var d=new Date();   
        var Week=['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];   
        Y=d.getFullYear();   
        M=fillZero(d.getMonth()+1);   
        D=fillZero(d.getDate());   
        W=Week[d.getDay()];   
        H=fillZero(d.getHours());   
        I=fillZero(d.getMinutes());   
        S=fillZero(d.getSeconds());   
        //12小时制显示模式   
        if(type && type==12){   
            //若要显示更多时间类型诸如中午凌晨可在下面添加判断   
            if(H<=12){   
                H='上午 '+H;   
            }else if(H>12 && H<24){   
                H-=12;   
                H='下午 '+fillZero(H);   
            }else if(H==24){   
                H='下午 00';   
            }   
        }   
        ev.innerHTML=Y+'年'+M+'月'+D+'日 '+' '+W+' '+H+':'+I+':'+S;   
        //每秒更新时间   
        setTimeout(arguments.callee,1000);   
    })();   
}  

