var upload_page1 = gaowj.WEB_APP_NAME+"/system/pages/frameEasyui/upload.jsp";
var up_maxsize = "10M";
var up_image_type = "gif,jpg,jpeg,bmp,png,tif,tiff";
var up_doc_type = "txt,doc,docx,xls,xlsx,ppt,pptx,pdf,cab";
var up_imagedoc_type = up_image_type+","+up_doc_type;
var up_act1 = "reportact_upload";
// 判断字符串是否只含中文
function isAllChinese(str) {
	return new RegExp(/^[\u4e00-\u9fa5]+$/).test(str);
}

// 空值处理
function nvl(info, showValue) {
	if (info == null) {// 若值为空则显示""
		if (showValue == null) {
			return "";
		} else {
			return showValue;
		}
	} else {
		return info;
	}
}
// 截取字符串
function CutString(str, length) {
	if (length == null) {
		length = 30;
	}
	if (str == null) {
		return "";
	} else if (str.length > length) {
		return str.substring(0, length) + "...";
	} else {
		return str;
	}
}
//去除HTML标签
function removeHtml(str){
	str = str || "";//防止空指针
	str = str.replace(/<(?!\/?p\b)[^>]+>|(<p)\b[^>]*(>)/ig, "$1$2");
	str = str.replace(/\s+/g,"");
	str = str.replace(new RegExp("&nbsp;","gm"),"");
	return str;
}
// 日期转换 如2011年06月22日 17:18
function formatDtoStr(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '年'
			+ pasTwo((currentDate.getMonth() + 1)) + '月'
			+ pasTwo(currentDate.getDate()) + "日 "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes());
	return currentDateStr;
}
// 日期转换 如2011-06-22 17:18
function formatDtoStr1(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate()) + " "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes());
	return currentDateStr;
}
// 日期转换 如2011-06-22 17:18:58
function formatDtoStrSec(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate()) + " "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes())  + ":"
			+ pasTwo(currentDate.getSeconds());
	return currentDateStr;
}
// 日期转换 如2011-06-22
function formatDtoStrDay(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate());
	return currentDateStr;
}
//日期转换 如22:22:22
function formatDtoStrTime(currentDate){
	currentDate = new Date(currentDate);
	var currentDateStr = pasTwo(currentDate.getHours()) + ":" +
	pasTwo(currentDate.getMinutes()) + ":" +
	pasTwo(currentDate.getSeconds());
	return currentDateStr;
}
//日期转换 如22:22
function formatDtoStrTime_by_hhmi(currentDate){
	currentDate = new Date(currentDate);
	var currentDateStr = pasTwo(currentDate.getHours()) + ":" +
	pasTwo(currentDate.getMinutes()) ;
	return currentDateStr;
}
function pasTwo(str){
	if(parseFloat(str)<10){
		return "0"+str;
	}else{
		return str;
	}
}

function getNowDateCN(){
	var myDate = new Date();
	return myDate.toLocaleDateString();
}


function getNowDateEN(is_date) {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = "";
    if(is_date=='date'){
    	currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    }else if(is_date=='datetime'){
    	currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + " " + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds();
    }
    return currentdate;
} 

var BASE64={ 
    /** 
     * 此变量为编码的key，每个字符的下标相对应于它所代表的编码。 
     */ 
    enKey: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', 
    /** 
     * 此变量为解码的key，是一个数组，BASE64的字符的ASCII值做下标，所对应的就是该字符所代表的编码值。 
     */ 
    deKey: new Array( 
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 
        52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, 
        -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
        15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, 
        -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 
        41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1 
    ), 
    /** 
     * 编码 
     */ 
    encode: function(src){ 
    	// 为null时转为空串;
    	src = src || "";
        //用一个数组来存放编码后的字符，效率比用字符串相加高很多。 
        var str=new Array(); 
        var ch1, ch2, ch3; 
        var pos=0; 
       //每三个字符进行编码。 
        while(pos+3<=src.length){ 
            ch1=src.charCodeAt(pos++); 
            ch2=src.charCodeAt(pos++); 
            ch3=src.charCodeAt(pos++); 
            str.push(this.enKey.charAt(ch1>>2), this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f));
            str.push(this.enKey.charAt(((ch2<<2)+(ch3>>6))&0x3f), this.enKey.charAt(ch3&0x3f));
         } 
        //给剩下的字符进行编码。 
        if(pos<src.length){ 
            ch1=src.charCodeAt(pos++); 
            str.push(this.enKey.charAt(ch1>>2)); 
            if(pos<src.length){ 
                ch2=src.charCodeAt(pos); 
                str.push(this.enKey.charAt(((ch1<<4)+(ch2>>4))&0x3f)); 
                str.push(this.enKey.charAt(ch2<<2&0x3f), '='); 
            }else{ 
                str.push(this.enKey.charAt(ch1<<4&0x3f), '=='); 
            } 
        } 
       //组合各编码后的字符，连成一个字符串。 
        return str.join(''); 
    }, 
    /** 
     * 解码。 
     */ 
    decode: function(src){ 
        //用一个数组来存放解码后的字符。 
        var str=new Array(); 
        var ch1, ch2, ch3, ch4; 
        var pos=0; 
       //过滤非法字符，并去掉'='。 
        src=src.replace(/[^A-Za-z0-9\+\/]/g, ''); 
        //decode the source string in partition of per four characters. 
        while(pos+4<=src.length){ 
            ch1=this.deKey[src.charCodeAt(pos++)]; 
            ch2=this.deKey[src.charCodeAt(pos++)]; 
            ch3=this.deKey[src.charCodeAt(pos++)]; 
            ch4=this.deKey[src.charCodeAt(pos++)]; 
            str.push(String.fromCharCode( 
                (ch1<<2&0xff)+(ch2>>4), (ch2<<4&0xff)+(ch3>>2), (ch3<<6&0xff)+ch4));
         } 
        //给剩下的字符进行解码。 
        if(pos+1<src.length){ 
            ch1=this.deKey[src.charCodeAt(pos++)]; 
            ch2=this.deKey[src.charCodeAt(pos++)]; 
            if(pos<src.length){ 
                ch3=this.deKey[src.charCodeAt(pos)]; 
                str.push(String.fromCharCode((ch1<<2&0xff)+(ch2>>4), (ch2<<4&0xff)+(ch3>>2)));
             }else{ 
                str.push(String.fromCharCode((ch1<<2&0xff)+(ch2>>4))); 
            } 
        } 
       //组合各解码后的字符，连成一个字符串。 
        return str.join(''); 
    } 
}; 


//校验开始
;
(function($){
    $.fn.checker = function(){
        return $.checker(this);
    };
    $.checker = function(Obj){
        var oc = {
            act:function(eventType){
                var _this = this;
                for(var i=0;i<arguments.length;i++){
                    this.bind(arguments[i],function(){_this.exc()});
                }
                return _this;
            },
            reg:function(){
                var queue = (this.data("checkqueue")&&this.data("checkqueue").constructor==Array) ?this.data("checkqueue"):[];
                for(var i=0;i<arguments.length;i++){
                    queue.push(arguments[i]);
                }
                this.data("checkqueue",queue);
                return this;
            },
            exc:function(){
                var queue = this.data("checkqueue");
                for(var i=0;queue&&i<queue.length;i++){
                    if(!(queue[i].call(this))){
                        return false;
                    }
                }
                return true;
            }
        };
        $.extend(Obj?Obj:$({}),oc);
        return Obj;
    };
    $.fn.checkwrite = function(msg){
        $.checkwrite(this,msg);
    };
    $.checkwrite = function(obj,msg){
        var jobj = $(obj),
            top = jobj.position().top, 
		    left = jobj.position().left,	 
	        width = jobj.outerWidth(),
	        height = jobj.outerHeight(),
	        newleft = left,
	        newtop = top+height;
	        //alert("top:"+top+"left:"+left+"width:"+width+"height:"+height+"newleft:"+newleft+"newtop:"+newtop);
	    if(msg){
	        if(jobj.next().is("p[name='msgbox']")){
	            jobj.next().html(msg);
	        }else{
	        	if($.browser.msie){
	        		jobj.after($("<p name='msgbox'/>")
	    	                .css("clear","both")
	    	                .css("position","absolute")
	    	                .css("width","auth")
	    	                .css("text-align","left")
	    	                .css("border","2px outset white")
	    	                .css("background-color","#FFFFCC")
	    	                .css("color","red")
	    	                .html(msg));
	        	}else{
	        		jobj.after($("<p name='msgbox'/>")
	    	                .css("clear","both")
	    	                .css("position","absolute")
	    	                .css("width","auth")
	    	                .css("text-align","left")
	    	                .css("border","2px outset white")
	    	                .css("background-color","#FFFFCC")
	    	                .css("color","red")
	    	                .css("top",newtop)
	    	                .css("left",newleft)
	    	                .html(msg));
	        	}
	        }
	    }else{
	        jobj.next("p[name='msgbox']").remove();
	    }
    };
    
  //文本框只能输入数字，并屏蔽输入法和粘贴  
    $.fn.numeral = function() {     
               $(this).css("ime-mode", "disabled");     
               this.bind("keypress",function(e) {     
               var code = (e.keyCode ? e.keyCode : e.which);  //兼容火狐 IE      
                   if(!$.browser.msie&&(e.keyCode==0x8))  //火狐下不能使用退格键     
                   {     
                        return ;     
                       }     
                       return code >= 48 && code<= 57;     
               });     
               this.bind("blur", function() {     
                   if (this.value.lastIndexOf(".") == (this.value.length - 1)) {     
                       this.value = this.value.substr(0, this.value.length - 1);     
                   } else if (isNaN(this.value)) {     
                       this.value = "";     
                   }     
               });     
               this.bind("paste", function() {     
                   var s = clipboardData.getData('text');     
                   if (!/\D/.test(s));     
                   value = s.replace(/^0*/, '');     
                   return false;     
               });     
               this.bind("dragenter", function() {     
                   return false;     
               });     
               this.bind("keyup", function() {     
               if (/(^0+)/.test(this.value)) {     
                   this.value = this.value.replace(/^0*/, '');     
                   }     
               });     
    };

    //tipWrap:  提示消息的容器
    //maxNumber:  最大输入字符
    $.fn.artTxtCount = function(tipWrap,tipWrap_warn,maxNumber){
        var disabledClass = 'disabled';
        
        //统计字数
        var count = function(){
          var btn = $(this).closest('form').find(':submit'),text_this = $(this),
          //是否禁用提交按钮
          disabled = {
             on: function(){
                 btn.removeAttr('disabled').removeClass(disabledClass);
             },
             off: function(){
                 btn.attr('disabled', 'disabled').addClass(disabledClass);
                 var textarea_val = text_this.val().replace(/[\r\n]/g, "");
             	 var curLength = textarea_val.length;
             	 if (curLength > maxNumber) {
             		text_this.val(textarea_val.substr(0, maxNumber));
             		if (tipWrap_warn.css("display") == "none") {
             			tipWrap_warn.fadeIn();
             			tipWrap_warn.fadeOut(4000);
             		}
             	}
             }
          };
          if (text_this.val().length == 0) disabled.off();
          if(text_this.val().length <= maxNumber){
             if (text_this.val().length > 0) disabled.on();
             tipWrap.html('<span>\u8FD8\u80FD\u8F93\u5165 <strong>' + (maxNumber - text_this.val().length) + '/'+maxNumber+'</strong> \u4E2A\u5B57</span>');
          }else{
             disabled.off();
          };
        };
        $(this).bind('keyup change', count);
        return this;
    };
    
 // json对象比较
	$.compareJsonObj = function(o1, o2) {
		if (typeof arguments[0] != typeof arguments[1])
			return false;
		if (arguments[0] instanceof Array) {
			if (arguments[0].length != arguments[1].length)
				return false;
			var allElementsEqual = true;
			for (var i = 0; i < arguments[0].length; ++i) {
				if (typeof arguments[0][i] != typeof arguments[1][i])
					return false;
				if (typeof arguments[0][i] == 'number'
						&& typeof arguments[1][i] == 'number')
					allElementsEqual = (arguments[0][i] == arguments[1][i]);
				else
					allElementsEqual = arguments.callee(arguments[0][i],
							arguments[1][i]); // 递归判断对象是否相等
			}
			return allElementsEqual;
		}
		if (arguments[0] instanceof Object && arguments[1] instanceof Object) {
			var result = true;
			var attributeLengthA = 0, attributeLengthB = 0;
			for (var o in arguments[0]) {
				// 判断两个对象的同名属性是否相同（数字或字符串）
				if (typeof arguments[0][o] == 'number'
						|| typeof arguments[0][o] == 'string')
					result = eval("arguments[0]['" + o + "'] == arguments[1]['"
							+ o + "']");
				else {
					// 如果对象的属性也是对象，则递归判断两个对象的同名属性
					// if (!arguments.callee(arguments[0][o], arguments[1][o]))
					if (!arguments.callee(eval("arguments[0]['" + o + "']"),
							eval("arguments[1]['" + o + "']"))) {
						result = false;
						return result;
					}
				}
				++attributeLengthA;
			}
			for (var o in arguments[1]) {
				++attributeLengthB;
			}
			// 如果两个对象的属性数目不等，则两个对象也不等
			if (attributeLengthA != attributeLengthB)
				result = false;
			return result;
		}
		return arguments[0] == arguments[1];
	}
})(jQuery);

//点击到区域事件方法
function shiftMoveEnd(obj){
    if (obj.createTextRange) {//IE浏览器
       var range = obj.createTextRange();
       range.move("textedit");
       range.collapse(true);
       range.select();
    } else {//非IE浏览器
       obj.setSelectionRange(obj.value.length, obj.value.length);
       obj.focus();
    }
}
//修改名称显示
function changeNameDisplay(str,length){
    var l = str.length;
    if(l<length){
        return str;
    }else{
        return str.substring(0,length)+"..."
    }
}
//区分浏览器来判断输入框的字符长度
function fixLength_publish(obj,objtext_length,objtext_warn){
var element = document.getElementById("mytext");
if("\v"=="v") {
obj.attachEvent("onpropertychange",webChange);
}else{
obj.addEventListener("input",webChange,false);
}
function webChange(){
	if(obj.value){
	 var textarea_val=obj.value.replace(/[\r\n]/g,"") ;
     var curLength=textarea_val.length; 
     if(curLength>120){
         objtext_length.css("color","#ff0000");
         var num = textarea_val.substr(0, 120);//截取120输入内容
			obj.value = num;
			if (objtext_warn.css("display") == "none") {
				$("span[name='publishNull']").hide();
				objtext_warn.fadeIn();
				objtext_warn.fadeOut(4000);
			}
     }
     else{
         objtext_length.css("color","#999");
         objtext_length.text(curLength);
     }
         return false;
	}
	}
}

//判断textarea长度
function changeLen(obj, objtext_length, objtext_warn,objtext_length_number) {
	var textarea_val = obj.value.replace(/[\r\n]/g, "");
	var curLength = textarea_val.length;
	if (curLength > objtext_length_number) {
		var num = textarea_val.substr(0, objtext_length_number);
		obj.value = num;
		objtext_length.text(""+objtext_length_number);
		if (objtext_warn.css("display") == "none") {
			objtext_warn.fadeIn();
			objtext_warn.fadeOut(4000);
		}
	return false;
	} else {
		objtext_length.text(curLength);
	}
}


// 日期转换
function formatDtoStr3(currentDate){
	currentDate=new Date(currentDate);
	var today = new Array("周日","周一","周二","周三","周四","周五","周六");
	var currentYear = ( currentDate.getYear() < 1900 ) ? ( 1900 + currentDate.getYear() ) : currentDate.getYear();
	var currentDateStr = currentYear + '年' + pasTwo((currentDate.getMonth() + 1)) + '月' + pasTwo(currentDate.getDate())+"日"+" "+today[currentDate.getDay()]+" "+pasTwo(currentDate.getHours())+":"+pasTwo(currentDate.getMinutes()); 
	return currentDateStr; 
}
//剩余时间
function lastTime(currentDate){
	var endDate = new Date(currentDate);
	var ss = 1000;
	var mi = ss*60;
	var hh = mi*60;
	var dd = hh*24;
	
	
	var now = new Date();
	if(endDate <= now){
		return "00小时00分钟";
	}
	if(endDate > now){
		var ms = endDate-now;
		var day = Math.floor(ms/dd);
		var hour = Math.floor((ms-day*dd)/hh);
		var minute = Math.ceil((ms-day*dd-hour*hh)/mi);
		
		if(hour < 10){
			hour = "0" + hour;
		}
		if(minute < 10){
			minute = "0" + minute;
		}
		if(day == 0){
			return hour + "小时" + minute + "分钟";
		}else {
			return day + "天" + hour + "小时" + minute + "分钟";
		}
	}
}

//将String转义
function displayHtml(str){   
	if(str != null){
    //将字符串转换成数组   
    var strArr = str.split('');   
   //HTML页面特殊字符显示，空格本质不是，但多个空格时浏览器默认只显示一个，所以替换   
    var htmlChar="&<>";   
    for(var i = 0; i< str.length;i++){   
       //查找是否含有特殊的HTML字符   
        if(htmlChar.indexOf(str.charAt(i)) !=-1){   
            //如果存在，则将它们转换成对应的HTML实体   
           switch (str.charAt(i)) {                           
                case '<':   
                    strArr.splice(i,1,'&#60;');   
                    break;   
              case '>':   
                    strArr.splice(i,1,'&#62;');   
                    break;   
               case '&':   
                    strArr.splice(i,1,'&#38;');   
           }   
        }   
   }   
    return strArr.join('');   
    }
}

//去掉html标签
function removeHtmlTab(tab) {
	if(tab==null){
		return "";
	}else{
		return tab.replace(/<[^<>]+?>/g,'');//删除所有HTML标签
	}
	
}
//普通字符转换成转意符
function html2Escape(sHtml) {
	return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
}
// &nbsp;转成空格
function nbsp2Space(str) {
	var arrEntities = {'nbsp' : ' '};
	return str.replace(/&(nbsp);/ig, function(all, t){return arrEntities[t]})
}

//空格符转换成&nbsp;
function space2Nbsp(str) {
	return str.replace(/\s/ig, '&nbsp;');
}

//转意符换成普通字符
function escape2Html(str) {
	var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
	return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
}

//回车转为br标签
function return2Br(str) {
	return str.replace(/\r?\n/g,"<br/>");
}

//去除开头结尾换行,并将连续3次以上换行转换成2次换行
function trimBr(str) {
	str=str.replace(/((\s|&nbsp;)*\r?\n){3,}/g,"\r\n\r\n");//限制最多2次换行
	str=str.replace(/^((\s|&nbsp;)*\r?\n)+/g,'');//清除开头换行
	str=str.replace(/((\s|&nbsp;)*\r?\n)+$/g,'');//清除结尾换行
	return str;
}

// 将多个连续空格合并成一个空格
function mergeSpace(str) {
	str=str.replace(/(\s|&nbsp;)+/g,' ');
	return str;
}

// 截取长度为length个字的字符串,多于length的字会截成length-1个字和"...", 
//没有中文和全角符号会截取length*1.6(取整)个字符
var subStringForDepart = function(str, length) {
	str = str || "";
	var enReg = /^[a-z0-9\`\-\=\[\]\;\s\'\,\.\/\~\\!\@\#\$\%\^\&\*\(\)\_\+\{\}\|\:\"\<\>\?]*$/;
	if(enReg.test(str)){
		length=Math.floor(length*1.6);
	}
	var newStr = str.substring(0, length);
	if (str.length > length) {
		newStr = str.substring(0,length-1);
		newStr += "......";
	}
	return newStr;
};

//按字节截取字符串，结尾添加"..."
function subStringByByte(str, len, ifAddEtc) {
    if (!str || !len) {
        return '';
    }
    str = str || "";
    // 预期计数：中文2字节，英文1字节
    var a = 0;
    // 循环计数
    var i = 0;
    // 临时字串
    var temp = '';
    for (i = 0; i < str.length; i++) {
    	if (str.charCodeAt(i) > 255 ) {
            // 按照预期计数增加2
        	if(str.charCodeAt(i) != 65279)
            a += 2;
        } else {
        	if(str.charCodeAt(i) != 65279)
            a++;
        }
        // 如果增加计数后长度大于限定长度，就直接返回临时字符串
        if (a > len) {
        	if(ifAddEtc==true || ifAddEtc=="true")
        		return temp+"...";
        	else
        		return temp;
        }
        // 将当前内容加到临时字符串
        temp += str.charAt(i);
    }
    return str;
}

// 将用户的标题转换成可html显示的标题
function transformTitle(inStr){
	var str = inStr || "";
	// 普通字符转换成转义符
	str = html2Escape(str);
	// 合并多个空格
	str = mergeSpace(str);
	return str;
}

// 将用户输入的文本转换成可显示的文本
function transformText(inStr) {
	var str = inStr || "";
	// 普通字符转换成转义符
	str = html2Escape(str);
	//去除开头结尾换行,并将连续3次以上换行转换成2次换行
	str = trimBr(str);
	// 回车换行转换成<br />标签
	str = return2Br(str);
	// 空格符转换成&nbsp;
	str = space2Nbsp(str);
	return str;
} 
// 将毫秒数转化为日期
function formatDataStr(currentDate) {
	currentDate = new Date(currentDate);
	var currentYear = (currentDate.getYear() < 1900) ? (1900 + currentDate
			.getYear()) : currentDate.getYear();
	var currentDateStr = currentYear + '-'
			+ pasTwo((currentDate.getMonth() + 1)) + '-'
			+ pasTwo(currentDate.getDate()) + " "
			+ pasTwo(currentDate.getHours()) + ":"
			+ pasTwo(currentDate.getMinutes());
	return currentDateStr;
}

//截取参数方法，hash：截取的字符串，name：截取的参数名，nvl：该参数不存在时的返回值
function getParameter(hash,name,nvl) {
	if(!nvl){
		nvl = "";
	}
	var svalue = hash.match(new RegExp("[\?\&]?" + name + "=([^\&]*)(\&?)", "i"));
	if(svalue == null){
		return nvl;
	}else{
		return svalue ? svalue[1] : svalue;
	}
}


//获取焦点
function setFocus(obj) {
	if (obj.setSelectionRange) {
		obj.setSelectionRange(0, 0);
		obj.focus();
	} else {
		if (obj.createTextRange) {
			var range = obj.createTextRange();
			range.collapse(true);
			range.moveEnd("character", 0);
			range.moveStart("character", 0);
			range.select();
		}
		try {
			obj.focus();
		} catch (e) {
		}
	}
} 

//手机号码验证,不符合规则返回false，否则返回true
function validationOfMobilePhoneNum(mobilePhoneNum) {
	var patrn = /^\d{11}$/;
	if(mobilePhoneNum != undefined && mobilePhoneNum!="" && !patrn.exec(mobilePhoneNum))
		return false;
	else
		return true;
}

/*******************
 * 搜索框叉叉整合
 */
function clean_search_value(){
	var searchinputbox =$("div[searchbox='search_box']").find("input[searchinput='searchinput']");
	if(searchinputbox!=null){
		searchinputbox.val("");
		searchinputbox.focus();
	}
}
//页面置顶
function goTop(){
	var nScrollTop = $(window).scrollTop();
	if (nScrollTop > 0) {
	$(window).scrollTop(0,0);
	}
}



;(function($){
	$.fn.extend({
		"appendWithUrl" : function(options){
			var opt = {
					url : ""
			};
			opt = $.extend(opt, options);
			this.each(function(){
				$(this).append(function(){
					var d = "";
					 $.ajax({
					 url:opt.url,
					 async:false,
					 success:function(data, status){
					    d = data;
					 }
					 });
					 return d;
				}); 
			});
		}
	});
}(jQuery));

//加载loading图片，页面全部加载完后再显示页面内容
function loadingPicFun(){
	//隐藏显示内容
	$("#container").hide();
	//loading图标
	var insert_html = "<div id = \"loading_div\" style = \"width: 100%; margin-top: 240px;\">"+
			"<img id='loadingImg' src='"+path+"/portal/images/loading_img.gif' style=\"height:150px;width:150px;\"/>"+
		"</div>";
	//<body>标签后加代码显示Loading图标
	$("body").prepend(insert_html);
	
	loadingProccess();
}
//页面全部加载完后显示页面，loading隐藏
function loadingProccess(){
	sh = setInterval('proccess();',100); 
}
//loading状态函数
function proccess(){
	//页面元素全部加载完成
    if(document.readyState == "complete"){
    	//loading图标隐藏
    	$("#loading_div").hide();
    	//页面内容显示
    	$("#container").show();
   		clearInterval(sh); 
    }
}

/*
 * 2014-11-25
 * 高伟杰
 * 文本框、表单校验
 *
*/
;(function($){
	var validator = {
		is_legal : true,
		"required" : function(value,$this){
			if($.trim(value).length!=0){
				$this.checkwrite(null);
				return true;
			} else {
				$this.checkwrite("不能为空!");
				setFocus($this);
				return false;
			}
		},
		"maxlength" : function(value,$this){
			var v_maxlength = $this.attr("maxlengthvalue");
			if(value.length<=v_maxlength){
				$this.checkwrite(null);
				return true;
			} else {
				$this.checkwrite("超出最大值("+v_maxlength+")!");
				setFocus($this);
				return false;
			}
		},
		"minlength" : function(value,$this){
			var v_minlength = $this.attr("minlengthvalue");
			if(value.length>=v_minlength){
				$this.checkwrite(null);
				return true;
			} else {
				$this.checkwrite("未达最小值("+v_minlength+")!");
				setFocus($this);
				return false;
			}
		},
		"isdate" : function(strDate,$this){
			if(strDate==""||strDate==null){
				$this.checkwrite(null);
				return true;
			}else{
				if(CheckDate(strDate)){
					$this.checkwrite(null);
					return true;
				}else{
					$this.checkwrite("输入正确的日期(yyyy-mm-dd)!");
					setFocus($this);
					return false;
				}
			}
			return CheckDate(strDate);
		},
		"isnumber" : function(value,$this){
			var reCheck = /^[1-9]+.?[0-9]*$/ ;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/  
		    if (!reCheck.test(value)){
		    	$this.checkwrite("输入数字!");
		    	setFocus($this);
		        return false;
		    }else{
		    	$this.checkwrite(null);
		    	return true;
		    }
		},
		"validate_field" : function($this, rules){
			var value = "";
			if($this.is("input")){
				//<inupt type="radio">
				if($this.is(":radio")){
					var field_id = $this.attr("name");
					value = $("[name="+field_id+"]:checked").val();
				}
				//<inupt type="checkbox">
				else if($this.is(":checkbox")){
					//var field_id = $this.attr("name");
					value = $this.is(":checked")?"1":"0";
				}
				//<inupt type="text" t="date">
				else if($this.is("[t='date']")){
					value = $this.val();
				} 
				//<inupt type="text">
				else if ($this.is(":text")){
					value = $this.val();
				}
			}
			else if($this.is("select")){
				value = $this.find("option:selected").val();
			}
			else if($this.is("textarea")){
				value = ($this.val());
			}
			if(rules.validate == 'undefined')return true;
			for(var o=0;o<rules.validate.split(',').length;o++){
				if(!validator[rules.validate.split(',')[o]](value,$this)){
					this.is_legal = false;
					return false;
				}else{
					this.is_legal = true;
				}
			}
			return this.is_legal;
		}
	};
	$.fn.extend({
		"loadMy97DateTime" : function(fitValue){
				if($(this).is("input")){
					//<inupt type="text" t="date" class="Wdate">
					if($(this).is("[t='date']")){
						$(this).attr("onClick",function(){
							$(this).click(function() {
				        		WdatePicker({
				        			dateFmt : 'yyyy-MM-dd HH:mm:ss',
				        			isShowWeek:true
				        		});
				        	});
			        	});
					$(this).attr("class","Wdate");
					if(fitValue)$(this).val(formatDtoStrSec(new Date()));
					}
				}
		},
		"loadMy97Date" : function(fitValue){
			if($(this).is("input")){
				//<inupt type="text" t="date" class="Wdate">
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
						$(this).click(function() {
			        		WdatePicker({
			        			dateFmt : 'yyyy-MM-dd',
			        			isShowWeek:true
			        		});
			        	});
		        	});
				$(this).attr("class","Wdate");
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateMinMax" : function(fitValue,isMin,isMax){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datepicker({
								changeMonth : true,
								changeYear : true,
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTimeMinMax" : function(fitValue,isMin,isMax){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss',
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "loadJqueryDateMinMaxLimit" : function(fitValue,isMin,isMax,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datepicker({
								changeMonth : true,
								changeYear : true,
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								},
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTimeMinMaxLimit" : function(fitValue,isMin,isMax,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $("#"+isMin+", #"+isMax+"").datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss',
								onSelect : function(selectedDate) {
									var option = this.id == isMin ? "minDate" : "maxDate", 
											instance = $(this).data("datepicker"), 
											date = $.datepicker.parseDate(
											instance.settings.dateFormat
													|| $.datepicker._defaults.dateFormat, selectedDate,
											instance.settings);
									dates.not(this).datepicker("option", option, date);
								},
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "loadJqueryDate" : function(fitValue){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datepicker({
								changeMonth : true,
								changeYear : true
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTime" : function(fitValue){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss'
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "loadJqueryDateLimit" : function(fitValue,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datepicker({
								changeMonth : true,
								changeYear : true,
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrDay(new Date()));
				}
			}
	    },
	    "loadJqueryDateTimeLimit" : function(fitValue,WeekStart,WeekEnd){
			if($(this).is("input")){
				if($(this).is("[t='date']")){
					$(this).attr("onClick",function(){
							var dates = $(this).datetimepicker({
								changeMonth : true,
								changeYear : true,
								controlType: 'select',
								timeFormat: 'HH:mm:ss',
								beforeShowDay:function(e){var t=e.getDay();return[t>WeekStart&&t<WeekEnd,""]}
							});
		        	});
				if(fitValue)$(this).val(formatDtoStrSec(new Date()));
				}
			}
	    },
	    "readonly" : function(){
			if($(this).is("input")){
				//<inupt type="text" readonly ="readonly">
				$(this).attr("readonly","'readonly'");
				$(this).css("background-color","#cccccc");
			}
	    },
		"validateBlur" : function(){
			this.each(function(options){
				var $this = $(this);
				var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
				$(this).blur(function(){
					setTimeout(function(){
					  return validator.validate_field($this,rules);
					}, 200);
				});
			});
		},
		"validateFormBlur" : function(){
			this.find("input, select, textarea").each(function(){
				var $this = $(this);
				var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
				if($this.is(":checkbox[single='true']")){
					var field_name = $this.attr("name");
					$(":checkbox[name="+field_name+"][single='true']").each(function(){ 
						$(this).click(function(){ 
						   $("[name="+field_name+"][single='true']").attr("checked",false);
						   $(this).attr('checked',true); 
						}); 
					});
				}else{
					$this.attr("onBlur",function(){
						$(this).blur(function(){
							setTimeout(function(){
								validator.validate_field($this,rules);
							}, 200);
						});
					});
				}
			});
		},
		"validateSubmit" : function(){
			var check=true;
			this.find("input, select, textarea").each(function(){
				//input 标签
				if($(this).is("input")){
					//<inupt type="radio">
					if($(this).is(":radio")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					}
					//<inupt type="checkbox">
					else if($(this).is(":checkbox")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					}
					//<inupt type="text" t="date">
					else if($(this).is("[t='date']")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					} 
					//<inupt type="text">
					else if ($(this).is(":text")){
						var $this = $(this);
						var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
						check = validator.validate_field($this,rules);
						if(!check) return false;
					}
				}
				else if($(this).is("select")){
					var $this = $(this);
					var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
					check = validator.validate_field($this,rules);
					if(!check) return false;
				}
				else if($(this).is("textarea")){
					var $this = $(this);
					var rules = eval("({'validate':'"+$(this).attr("validate")+"'})");
					check = validator.validate_field($this,rules);
					if(!check) return false;
				}
			});
			return check;
		}
	});
}(jQuery));


function CheckDate(strDate){
	//结束时间不输入时，check通过
	if (strDate == null || strDate==""){
		return true;
	}
    var r=/\d{4}(?:-\d{1,2}){0,2}/;
    //正则表达式，判断是否为yyyy-mm-dd,yyyy-mm,yyyy格式
    if(strDate.match(r)==strDate){

    }else{
	 return false;
    }
    var ss=strDate.split("-");
    if (ss.length==3){
    	
    }else{
    	return false;
    }
    
    var year=ss[0];
    var month=ss[1];
    var date=ss[2];
    if(!checkYear(year)){return false;}
    if(!checkMonth(month)){return false;}
    if(!checkDate(year,month,date)){return false;}
    return true;
}
function checkYear(year){
    if(isNaN(parseInt(year)))
    {
         return false;
    }
    return true;
}
function checkMonth(month){
	if(isNaN(parseInt(month,10))){
		 return false;
	} else if(parseInt(month,10)<1 || parseInt(month,10) >12)
	{ 
		return false;
	}  else return true;
}
function checkDate(year,month,date){
	var daysOfMonth=CalDays(parseInt(year),parseInt(month));
	if(isNaN(parseInt(date,10)))
	{
		 return false;
	}  else if(parseInt(date,10)<1||parseInt(date,10)>daysOfMonth){
		return false;
	}
	    else return true;
}
function CalDays(year,month){
	var date= new Date(year,month,0);
	return date.getDate();
}
function isLeapYear(year){
		if((year %4==0 && year %100!=0) || (year %400==0)) return true;
		else return false;
}


//
function strToDateObj(str){
	var regEx = new RegExp("\\-","gi");
	dependedVal = str.replace(regEx,"/");
	var millionseconds = Date.parse(dependedVal);
	millionseconds = "DATE_"+millionseconds;
	if(millionseconds == "DATE_NaN")millionseconds="";
	return millionseconds;
}

;(function($){
	$.fn.extend({
		getFormVal : function(){
			var data = {};
			this.find("input, select, textarea").each(function(){
				//input 标签
				if($(this).is("input")){
					//<inupt type="radio">
					if($(this).is(":radio")){
						var field_id = $(this).attr("name");
						data[field_id] = $("[name="+field_id+"]:checked").val();
					}
					//<inupt type="checkbox">
					else if($(this).is(":checkbox")){
						var field_id = $(this).attr("name");
						var str="";
						$("[name="+field_id+"]:checked").each(function(){ 
					        if($(this).attr("checked")){
					           str += $(this).val()+",";
					        }
					     });
					     if(str.length>1){
					    	 str = str.substring(0, str.length - 1);
					     }
					     data[field_id] = str;
					}
					//<inupt type="text" t="date">
					else if($(this).is("[t='date']")){
						var field_id = $(this).attr("name");
						data[field_id] = strToDateObj($(this).val());
					} 
					//<inupt type="text">
					else if ($(this).is(":text")){
						var field_id = $(this).attr("name");
						data[field_id] = $(this).val();
					}
					//<inupt type="hidden">
					else if ($(this).is(":hidden") || $(this).is(":password")){
						var field_id = $(this).attr("name");
						data[field_id] = $(this).val();
					}
				}
				else if($(this).is("select")){
					var field_id = $(this).attr("name");
					data[field_id] = $(this).find("option:selected").val();
				}
				else if($(this).is("textarea")){
					var field_id = $(this).attr("name");
					data[field_id] = ($(this).val());
				}
			});
			return data;
		}
	});
}(jQuery));

function get_FIELD(data){
	if(data == null){
		return;
	}
	var ret_data = {};
    $.each(data,function(i,n){
    	ret_data["FIELD_"+i]=n;
   });
   return ret_data;
}


/**
 * 文件上传
 * @returns {Boolean}
 */
//上传页面打开1
function openUpload_page1(up_type,up_act,uuid){
	openUpload(upload_page1,up_type,up_act,uuid);
}
//上传页面打开2
function openUpload_page2(up_act,uuid){
	openUpload(upload_page1,up_imagedoc_type,up_act,uuid);
}
//上传页面打开3
function openUpload_page3(up_act,uuid,is_width,is_height,is_left,is_top){
	openUploadWidth(upload_page1,up_imagedoc_type,up_act,uuid,is_width,is_height,is_left,is_top);
}
//上传页面打开(图片)
function openUpload_image(uuid){
	openUpload(upload_page1,up_image_type,up_act1,uuid);
}
//上传页面打开(常用公文)
function openUpload_doc(uuid){
	openUpload(upload_page1,up_doc_type,up_act1,uuid);
}
//上传页面打开(常用公文加图片)
function openUpload_imagedoc(uuid){
	openUpload(upload_page1,up_imagedoc_type,up_act1,uuid);
}
//打开上传页面
function openUpload(url,up_type,up_act,uuid){
	$('#upload').dialog( {
		title : '文件上传',
		iconCls : $.getJwWindowPic(),
		width : ls_width * 0.45,
		height :ls_height * 0.35,
		closed : false,
		cache : false,
		maximizable:false,
		left:160,
		top:0,
		href : url,
		modal : true,
		buttons : [ {
			text : '上传',
			iconCls : 'icon-ok',
			handler : function() {
				return ajaxFileUpload(up_type,up_act,uuid);
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('upload');
			}
		} ],
		onLoad:function() {
			$('#notice').html("只上传"+up_type+"类型的图片,目前最大上传支持"+up_maxsize+"!");
		}
	});
}


//打开上传页面
function openUploadWidth(url,up_type,up_act,uuid,is_width,is_height,is_left,is_top){
	$('#upload').dialog( {
		title : '文件上传',
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:false,
		left:is_left,
		top:is_top,
		href : url,
		modal : true,
		buttons : [ {
			text : '上传',
			iconCls : 'icon-ok',
			handler : function() {
				return ajaxFileUpload(up_type,up_act,uuid);
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('upload');
			}
		} ],
		onLoad:function() {
			$('#notice').html("只上传"+up_type+"类型的图片,目前最大上传支持"+up_maxsize+"!");
		}
	});
}

//单个文件上传
function ajaxFileUpload(up_type,up_act,uuid)
{ 
    $("#loading")
    .ajaxStart(function(){
        $(this).show();
    })//开始上传文件时显示一个图片
    .ajaxComplete(function(){
        $(this).hide();
    });//文件上传完成将图片隐藏起来
    if($.trim($("#userFile").val()).length==0)
    	return false;
    
    if((up_type).indexOf($("#userFile").val().substring($("#userFile").val().lastIndexOf('.')+1))==-1){
    	$.messager.alert('提示',"只上传"+up_type+"类型的文件,目前最大上传支持"+up_maxsize+"!",'info');
    	return false;
    }
    $.ajaxFileUpload({
        url:up_act,//用于文件上传的服务器端请求地址
        secureuri:false,//一般设置为false
        fileElementId:'userFile',//文件上传空间的id属性  <input type="file" id="file" name="file" />
        dataType: 'json',//返回值类型 一般设置为json
        success: function (data, status){//服务器成功响应处理函数
	        if(data.message.file!='undefined'){
	        	if(data.message.file == '-1'){
	        		$.messager.alert('提示',"文件上传失败,大小超出"+up_maxsize+"!",'error');
	        		return false;
	        	}
	        	var view_name = data.message.file.split(",")[1];
	        	var store_name = data.message.file.split(",")[0];
	        	uploadCallback(view_name,store_name,uuid);
	        	$('#upload').dialog('close');
	        }            
        },error: function(data, status, e){//服务器响应失败处理函数
           alert(e);
        }
      });
    
    return false;

}
/****/

/**
 * 文件下载
 * @returns {Boolean}
 */
function fileDownload(uploadnew,uploadpath,uploadold,uuid){
   var form=$("<form>");//定义一个form表单
   form.attr("style","display:none");
   form.attr("target","");
   form.attr("method","post");
   form.attr("action","reportact_download");
   var input1=$("<input>");
   input1.attr("type","hidden");
   input1.attr("name","uploadnew");
   input1.attr("value",uploadnew);
   var input2=$("<input>");
   input2.attr("type","hidden");
   input2.attr("name","uploadpath");
   input2.attr("value",uploadpath);
   var input3=$("<input>");
   input3.attr("type","hidden");
   input3.attr("name","uploadold");
   input3.attr("value",uploadold);
   var input4=$("<input>");
   input4.attr("type","hidden");
   input4.attr("name","uuid");
   input4.attr("value",uuid);
   $("#upload").append(form);
   form.append(input1);
   form.append(input2);
   form.append(input3);
   form.append(input4);
   form.submit();//表单提交 
}
/****/

/**
 * 文件下载
 * @returns {Boolean}
 */
function fileDownloadURL(uploadnew,uploadpath,uploadold,uuid,downloadURL){
   if(downloadURL == '' || downloadURL == null || downloadURL == 'undefined'){
	   fileDownload(uploadnew,uploadpath,uploadold,uuid);
   }else{
	   var form=$("<form>");//定义一个form表单
	   form.attr("style","display:none");
	   form.attr("target","");
	   form.attr("method","post");
	   form.attr("action",downloadURL);
	   var input1=$("<input>");
	   input1.attr("type","hidden");
	   input1.attr("name","uploadnew");
	   input1.attr("value",uploadnew);
	   var input2=$("<input>");
	   input2.attr("type","hidden");
	   input2.attr("name","uploadpath");
	   input2.attr("value",uploadpath);
	   var input3=$("<input>");
	   input3.attr("type","hidden");
	   input3.attr("name","uploadold");
	   input3.attr("value",uploadold);
	   var input4=$("<input>");
	   input4.attr("type","hidden");
	   input4.attr("name","uuid");
	   input4.attr("value",uuid);
	   $("#upload").append(form);
	   form.append(input1);
	   form.append(input2);
	   form.append(input3);
	   form.append(input4);
	   form.submit();//表单提交 
   }
}
/****/

/**
 * ztree树初始化(新版)
 * @returns {Boolean}
 */
function setInitTree(is_title,is_name,idkey,pidkey){
	//定义ztree参数
	var setting = {
		view: {
			  dblClickExpand: false,
			  showLine: true,
			  selectedMulti: false
			},
		data: {
			  key: {
			    title:is_title,
			    name:is_name
			  },
			  simpleData: {
			    enable: true,
			    idKey: idkey,
			    pIdKey: pidkey,
			    rootPId: ""
			 }
			},
		edit: {
				drag:{
					autoExpandTrigger:true,
					isCopy:false,
					isMove:true
				},
				enable:true,
				showRemoveBtn: false,
				showRenameBtn: false
			},	
		callback: {
				beforeClick: beforeClick,
				onClick: onClick,
				beforeDrag: beforeDrag,
				beforeDrop: beforeDrop,
                onDrop: onDrop
			}
		};
	return setting;
}

/**
 * ztree树初始化
 * @returns {Boolean}
 */
function setInitTreeGroup(is_title,is_name,idkey,pidkey){
	//定义ztree参数
	var setting = {
		view: {
			  dblClickExpand: false,
			  showLine: true,
			  selectedMulti: false
			},
		data: {
			  key: {
			    title:is_title,
			    name:is_name
			  },
			  simpleData: {
			    enable: true,
			    idKey: idkey,
			    pIdKey: pidkey,
			    rootPId: ""
			  }
			},
        check: {
        	autoCheckTrigger: true,
        	enable: true,
        	chkboxType: { "Y": "s", "N": "s" }
        },
		callback: {
				beforeClick: beforeClick,
				onClick: onClick,
				onCheck:onCheck
			}
		};
	return setting;
}
function beforeClick(treeId, treeNode) {
	  return (treeNode.click != false);
}
function onClick(event, treeId, treeNode) { 
	   modifyNode(treeNode);
}
function onCheck(e,treeId,treeNode){
	   var zTree = $.fn.zTree.getZTreeObj(treeId);
	   var nodes = zTree.getCheckedNodes(true); 
	   v="";
       for(var i=0;i<nodes.length;i++){
       v+=nodes[i].UUID + ",";
       }
       getTreeNode(v);
    }
function beforeDrag(treeId, treeNodes){
	for(var i=0,l=treeNodes.length; i<l; i++){
		if (treeNodes[i].drag === false) {
			return false;
		}
	}
	return true;
}
function beforeDrop(treeId, treeNodes, targetNode, moveType) {
	return targetNode ? targetNode.drop !== false : true;
}
function onDrop(event, treeId, treeNodes, targetNode, moveType, isCopy){
	isCopy = false;
	var node = treeNodes[0];
	updateParentId(node, targetNode);
}
function loadTree(dataUrl,viewNode,expandKey,expandVal){
	//展现左边机构树
	$.sendPost (dataUrl, {}, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, data.rowSet);
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	zTree.expandNode(treeNode,null,null,null,null);
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
function loadTreeImage(dataUrl,viewNode,expandKey,expandVal){
	//展现左边机构树
	$.sendPost (dataUrl, {}, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, getDataAddNode(data.rowSet,"icon",gaowj.WEB_APP_NAME + "/images/main/bumen.gif"));
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	zTree.expandNode(treeNode,null,null,null,null);
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
function loadTreeGroup(dataUrl,viewNode,expandKey,expandVal){
	//展现左边机构树根据权限选择数据是否被勾选中
	$.sendPost (dataUrl, {}, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, getDataUnitOrUser(data.rowSet, gaowj.WEB_APP_NAME));
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	var treeNode2 = zTree.getNodesByParam("AUTH",1,null);
	zTree.expandNode(treeNode,null,null,null,null);
	for(var i=0, l=treeNode2.length; i < l; i++){
		zTree.checkNode(treeNode2[i],true,true,false);
	}
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
function loadTreeQuery(dataUrl,viewNode,v_query,expandKey,expandVal){
	//展现左边机构树
	$.sendPost (dataUrl, v_query, function(data){
	var zTree = $.fn.zTree.init($("#"+viewNode), setting, data.rowSet);
	var treeNode = zTree.getNodeByParam(expandKey,expandVal, null);
	zTree.expandNode(treeNode,null,null,null,null);
	defautClick(zTree,treeNode);
	}, function(data){
	alert("失败");
	}, "json");
}
/****/

/**
 * 上浮横向菜单
 * @returns {Boolean}
 */
//菜单更多上浮横向菜单集(无需更改)
function createOptionMenuTooltip(menuWidth) {
	$('#list').datagrid('getPanel').find('.easyui-tooltip').each(
		function() {
			var index = parseInt($(this).attr('data-p1'));
			$(this).tooltip({
				content : $('<div></div>'),
				onUpdate : function(cc) {
					var row = $('#list').datagrid('getRows')[index];
					var content = getOptionMenu(row,index);
					var mCount = getOptionMenuCount();
					cc.css("border","0").panel({
						width : (menuWidth * mCount),
						content : content
					});
				},
				position : 'right',
				deltaX : -20,
				onShow : function() {
					var t = $(this);
					t.tooltip('tip').css( {
						backgroundColor : '#ffffff'
							}).unbind().bind('mouseenter', function() {
						t.tooltip('show');
					}).bind('mouseleave', function() {
						t.tooltip('hide');
					});
				}
			});
	    });
}
/****/
function createOptionMenuTooltipTree(menuWidth) {
	$('#list').treegrid('getPanel').find('.easyui-tooltip').each(
		function() {
			var index = $(this).attr('data-p1');
			$(this).tooltip({
				content : $('<div></div>'),
				onUpdate : function(cc) {
					$('#list').treegrid('select',index);
					var row = $('#list').treegrid('getSelected');
					$('#list').treegrid('unselectAll');
					var content = getOptionMenu(row,index);
					var mCount = getOptionMenuCount();
					cc.css("border","0").panel({
						width : (menuWidth * mCount),
						content : content
					});
				},
				position : 'right',
				deltaX : -20,
				onShow : function() {
					var t = $(this);
					t.tooltip('tip').css( {
						backgroundColor : '#ffffff'
							}).unbind().bind('mouseenter', function() {
						t.tooltip('show');
					}).bind('mouseleave', function() {
						t.tooltip('hide');
					});
				}
			});
	    });
}
/****/
/**
 * 弹出ifram页面
 * @returns {Boolean}
 */
function openViewIframRow(opendiv,editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#'+opendiv).dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		content : '<iframe scrolling="yes" frameborder="0"  src="'+ editUrl+ '" style="width:100%;height:98%;"></iframe><span id="return_text"></span>',
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [{
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox(opendiv);
			}
		} ],
		onClose: function () {
			closeCallback(is_row);
		}
	});
}
/**
 * 弹出ifram页面(授权)
 * @returns {Boolean}
 */
function openViewIframGroup(opendiv,editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#'+opendiv).dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		content : '<iframe scrolling="yes" frameborder="0"  src="'+ editUrl+ '" style="width:100%;height:98%;"></iframe><span style="display:none" id="return_text"></span>',
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '确定',
			iconCls : 'icon-ok',
			handler : function() {
				groupBox(is_row, opendiv,'list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox(opendiv);
			}
		} ]
	});
}
//弹出层权限选择按扭
function groupBox(is_row,Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id= opendiv;
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
		var v_result;
		v_result = addToGroup(is_row,Box_id);
		if (v_result != null && v_result != undefined) {
			$.messager.alert('提示', v_result.VALUE);
		}
}
/****/

/**
 * 弹出页面
 * @returns {Boolean}
 */
function openViewRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [{
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ]
	});
}
/**
 * 推送页面
 * @returns {Boolean}
 */
function openEditPush(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		//queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '推送',
			iconCls : 'icon-ok',
			handler : function() {
				pushBox(is_row,'detail','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ],
		onLoad:function pushUrlOnload(){
			pushUrlOnloadCallback(is_row);
		}
	});
}
/**
 * 推送页面
 * @returns {Boolean}
 */
function openEditPushAdd(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		//queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '添加',
			iconCls : 'icon-add',
			handler : function() {
				AddBox(is_row,'detail','list');
			}
		}, {
			text : '推送',
			iconCls : 'icon-ok',
			handler : function() {
				pushBox(is_row,'detail','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ],
		onLoad:function pushUrlOnload(){
			pushUrlOnloadCallback(is_row);
		}
	});
}
//弹出层保存按扭
function pushBox(is_row,Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
		var v_result;
		v_result = addToPush(is_row);
		if (v_result != null && v_result != undefined) {
			closeBox(Box_id);
			$.messager.alert('提示', v_result.VALUE);
		}
}
/****/
//添加要推送的人员或者部门数据
function AddBox(is_row,Box_id,List_id){
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
		var v_result;
		v_result = addToTree(is_row);
		if (v_result != null && v_result != undefined) {
			closeBox(Box_id);
			$.messager.alert('提示', v_result.VALUE);
		}
}

/**
 * 编辑页面
 * @returns {Boolean}
 */
function openEditRow(editUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#detail').dialog( {
		title : is_title,
		iconCls : $.getJwWindowPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : editUrl,
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '保存',
			iconCls : 'icon-ok',
			handler : function() {
				saveBox('detail','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('detail');
			}
		} ],
		onLoad:function editUrlOnload(){
			if(is_row.OPETYPE=='insert'){
				addUrlOnloadCallback(is_row);
			}else{
				updateUrlOnloadCallback(is_row);
			}
		}
	});
}
/****/

/**
 * 编辑页面的动作
 * @returns {Boolean}
 */
//弹出层返回按扭
function closeBox(Box_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	$('#'+Box_id).dialog('close');
}

//弹出层保存按扭
function saveBox(Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='detail';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
	var returnIsValid = $('#inputForm').form('validate');
	if (returnIsValid) {
		//$("#inputForm").submit();
		var query = $("#inputForm").getFormVal();
		var v_result;
		if ($('#OPETYPE').val() == null || $('#OPETYPE').val() == undefined
				|| $('#OPETYPE').val() == '' || $('#OPETYPE').val()=='insert'){
			v_result = insertData(query);
		}
		else{
			v_result = updateData(query);
		}
		if (v_result != null && v_result != undefined) {
			closeBox(Box_id);
			$.messager.alert('提示', v_result.VALUE);	
		}
	}
}
/****/

/**
 * 高级查询页面
 * @returns {Boolean}
 */
function openAdvsearchRow(advsearchUrl,is_row,is_title,is_max,is_width,is_height,is_left,is_top){
	$('#advsearch').dialog( {
		title : is_title,
		iconCls : $.getJwAdvsearchPic(),
		width : ls_width * is_width,
		height :ls_height * is_height,
		closed : false,
		cache : false,
		maximizable:is_max,
		left:is_left,
		top:is_top,
		href : advsearchUrl,
		queryParams:get_FIELD(is_row),
		modal : true,
		buttons : [ {
			text : '查询',
			iconCls : 'icon-search',
			handler : function() {
				advsearchBox('advsearch','list');
			}
		}, {
			text : '关闭',
			iconCls : 'icon-back',
			handler : function() {
				closeBox('advsearch');
			}
		} ],
		onLoad:function editUrlOnload(){
		    addAdvsearchCallback(is_row);	
		}
	});
}
/****/

/**
 * 编辑页面的动作
 * @returns {Boolean}
 */
//弹出层保存按扭
function advsearchBox(Box_id,List_id) {
	if(Box_id==null||Box_id==''||Box_id==undefined)
		Box_id='advsearch';
	if(List_id==null||List_id==''||List_id==undefined)
		List_id='list';
	var returnIsValid = $('#adv_inputForm').form('validate');
	if (returnIsValid) {
		//$("#inputForm").submit();
		var query = $("#adv_inputForm").getFormVal();
		advsearchData(query);
		closeBox(Box_id);
		
	}
}
/****/


/**
 * 数据窗口
 * 2016-12-01
 * 高伟杰
**/
function datagrid(is_view,is_title,is_url,is_query,is_column,is_opetipmenuwidth){
	$('#'+is_view).datagrid({
		title:is_title,
	    iconCls:$.getJwWindowPic(),
	    url:is_url,
	    queryParams : is_query,//查询参数
		rownumbers : true,//显示索引号
		singleSelect : false,//是否多选
		fitColumns : false,//是否撑满
		autoRowHeight : false,//设定高度
		rowStyler :function(index,row){return rowstyler(index,row);},
		pagination : true,//分页显示
		pageSize : rows,//显示行数
		pageList : listPageSize,//条数选择
		striped : true, //是否隔行显示
		remoteSort : false,//是否从服务器排序
		frozenColumns : [[
				{
					field : 'ck',
					checkbox : true
				},
				{
					field : 'option',
					title : '操作',
					width : 120,
					align : 'center',
					formatter : formatMenu
				}
				       ]],
		columns : is_column,
		toolbar : '#tb',
		onLoadSuccess : function() {
			if(is_opetipmenuwidth==null){
				is_opetipmenuwidth = 60;
			}
			createOptionMenuTooltip(is_opetipmenuwidth);
			dataOnLoadSuccess();
		},
		onDrop:function(targetRow, sourceRow, point) {
			dataOnDrop(targetRow, sourceRow, point);
		}
	});
}

/**
 * 报表窗口
 * 2016-12-01
 * 高伟杰
**/
function reportgrid(is_view,is_title,is_url,is_query,is_column){
	$('#'+is_view).datagrid({
		title:is_title,
	    iconCls:$.getJwWindowPic(),
	    url:is_url,
	    queryParams : is_query,//查询参数
		rownumbers : true,//显示索引号
		singleSelect : false,//是否多选
		fitColumns : false,//是否撑满
		autoRowHeight : false,//设定高度
		rowStyler :function(index,row){return rowstyler(index,row);},
//		pagination : true,//分页显示
//		pageSize : rows,//显示行数
//		pageList : listPageSize,//条数选择
		striped : true, //是否隔行显示
		remoteSort : false,//是否从服务器排序
		frozenColumns : [[
				{
					field : 'ck',
					checkbox : true
				}
				       ]],
		columns : is_column,
		toolbar : '#tb',
		onLoadSuccess : function() {
			reportrollback();
		}
	});
}

/**
 * 禁止使用右键、复制
 * 2016-12-01
 * 高伟杰
**/
function disabledRightMenu(){
	$(document).bind("contextmenu",function(){return false;});
	$(document).bind("selectstart",function(){return false;});
}
