	function myjs(){}
	
   
   myjs.prototype.randomNumber = new Date().getTime(); // 随机数
   myjs.prototype.SUCCESS = 'success'; //成功字符串 标记用
   myjs.prototype.FAILED = 'failed'; //失败字符串
   	
	/**F
	* 选中所有的复选框
	* @param boxId 按钮Id
	* @param ids 复选框的name属性
	*/
   myjs.prototype.checkboxByAll = function(boxId,ids) {
   		try {
			var box = $("#" +boxId);
			if(box.attr("checked")==true) {
				$("[name="+ids+"]:checkbox").each(function() { 
					$(this).attr("checked", "true"); 
				}) 
			} else {
				$("[name="+ids+"]:checkbox").each(function() { 
					$(this).attr("checked", ""); 
				})
			}
			return false;
		}catch(e) {
		}
   }
   
   /**
	* 根据值选中对应的复选框
	* @param boxId 按钮Id
	* @param nodeId 复选框ID
	* @param vlaue 值
	*/
   myjs.prototype.checkboxCheckedByValueOther = function(nodeId,value) {
   		try{
   			if(value != null && value !='' && value != undefined){
   				var valueList = value.split(",");
	   			$("[name="+nodeId+"]:checkbox").each(function() { 
	   				for(j=0;j<valueList.length;j++){
						if(valueList[j] == $(this).val()){
							$(this).attr("checked", "true");
						}
					}
				}) 
			}
   		}catch(e) {
   			alert(e);
		}
   }
   
   /**
	* 根据值选中对应的复选框
	* @param boxId 按钮Id
	* @param nodeId 复选框ID
	* @param vlaue 值
	*/
   myjs.prototype.checkboxCheckedByValue = function(boxId,nodeId,value) {
   		try{
   			var box = $("#"+boxId);
   			if(value != null && value !='' && value != undefined){
   				var valueList = value.split(",");
	   			$("[name="+nodeId+"]:checkbox").each(function() { 
	   				for(j=0;j<valueList.length;j++){
						if(valueList[j] == $(this).val()){
							if(boxId == 'not'){
								$(this).attr("checked", "true");
							}else if(box.attr("checked")==true){
								$(this).attr("checked", "true");
							}else{
								$(this).attr("checked", "");
							} 
						}
					}
				}) 
			}
   		}catch(e) {
		}
   }
   
   /**
 	* 选中单选按钮
 	* @param radioName 单选按钮组的名称
 	* @param value 目标value
 	*/
   myjs.prototype.radioCheckedByValue = function(radioName, value) {
   		try {
   			
			if(radioName != undefined && value != undefined && value != '' && radioName != '') {
				$("[name="+radioName+"]:radio").each(function() { 
					if(value == $(this).val()){
						$(this).attr("checked", "true");
					}else{
						$(this).attr("checked", "");
					}
				}) 
			}
			
			
		}catch(e) {
		}
   }
  	
   /**
	* 选中当前下拉框的值
	* @param nodeId 下拉w框Id
	* @param ids 要选中的当前值
	*/
   myjs.prototype.selectBySingle = function(nodeId,value){
   		try{
   			if(nodeId != undefined && value != undefined && value != ''){
   				$("#"+nodeId).val(value); 
   			}
		}catch(e){
		}
	}
	
	/**
	* 批量提交
	* @param str 文字说明
	* @param method 提交action
	* @param ids 选中对像 checkbox
	* @param target 移动到的栏目
	*/
	myjs.prototype.batchSubmit = function(str,method,ids,target){
		try{
		    var url;
			var idsNode = $("input[name='"+ids+"']:checked");
			var idsValue = "";
			idsNode.each(function(){
			 	idsValue += this.value +",";
			}); 
			
			if(idsValue == '' || idsValue == undefined){
				alert('请选择需要批量操作的记录');
				return ;
			}
			
			var targetValue ;
			if(target != '' && target != undefined){
				var targetNode = $("#"+target);
				targetValue = targetNode.val();
			}
			
			if(method != '' && method != undefined){
				if(targetValue != '' && targetValue != undefined){
					url = "targetId="+targetValue+"&ids="+idsValue;
				}else{
					url = 'ids='+idsValue;
				}
				$.ajax({
					type:'POST',
					dataType:'text',
					url:method,
					data:url+'&t='+myjs.randomNumber,
					success:function(data){
						if(myjs.SUCCESS == data) {
							alert(str+'成功');
							window.location.reload();
						} else {
							alert(str+'失败，请重试');
							return ;
						}
					}
				});
			}
		}catch(e){
		}
	}
	
	/**
	* 批量审核、首页、热门、推荐提交 
	* @param str 文字说明
	* @param method 提交action
	* @param ids 选中对像 checkbox
	* @param is  是设置/取消
	*/
	myjs.prototype.isallSubmit = function(str,method,ids,is){
		try{
		    var url;
			var idsNode = $("input[name='"+ids+"']:checked");
			var idsValue = "";
			idsNode.each(function(){
			 	idsValue += this.value +",";
			}); 
			
			if(idsValue == '' || idsValue == undefined){
				alert('请选择需要批量操作的记录');
				return ;
			}
			
			var isAll = $(":radio[name="+is+"]:checked").val();
			if(isAll == '' || isAll == undefined){
				alert('请选择需要批量:取消/设置');
				return ;
			}
			if(method != '' && method != undefined){
				url = 'ids='+idsValue+'&isAll='+isAll;
				$.ajax({
					type:'POST',
					dataType:'text',
					url:method,
					data:url+'&t='+myjs.randomNumber,
					success:function(data){
						if(myjs.SUCCESS == data) {
							alert(str+'成功');
							window.location.reload();
						} else {
							alert(str+'失败，请重试');
							return ;
						}
					}
				});
			}
		}catch(e){
		}
	}
	
	/**
	* 回复提交
	* @param str 文字说明
	* @param method 提交action
	* @param id 评论ID
	* @param node 表单原素 textarea
	*/
	myjs.prototype.replySubmit = function(str,method,parameter,node){
		try{
			
			var txtNode = $("#"+node);
			var nodeValue = txtNode.val();
			if(parameter == '' || parameter == undefined){
				alert('请选择需要回复的记录');
				return ;
			}
			if(nodeValue == '' && nodeValue == undefined){
				alert('请添加回复的内容');
				return ;
			}
			
			if(method != '' && method != undefined){
				var url = method+'?'+parameter+'&replyText='+myjs.encodeByValue(nodeValue)+'&t='+myjs.randomNumber;
				window.location.href = url;
			}
		}catch(e){
		}
	}
	
	/**
	* 后台通用搜索
	* @param str 	 文字说明
	* @param keyword 搜索关键词
	* @param field  搜索字段
	* @param method 提交action
	* @param parameter 传递参数
	* @param nodeId 导航下拉框id
	*/
	myjs.prototype.adminSearch = function(str,method,keyword,field,parameter,nodeId,propertyId){
		try{
			var url ;
			var nodeValue = $("#"+nodeId).val();
			var keywordValue = $("#"+keyword).val();
			var propertyValue = $("#"+propertyId).val();
			if(nodeValue == '' && nodeValue == undefined){
				if(keywordValue == '' || keywordValue == undefined){
					alert('请输入搜索关键词!');
					return ;
				}
			}
			if(method != '' && method != undefined){
			    url = method+'?'+parameter+'&keyword='+myjs.encodeByValue(keywordValue)+'&field='+field
			    if(nodeValue != '' && nodeValue != undefined){
			    	url += "&newsclassId="+nodeValue;
			    }
			    if(propertyValue != '' && propertyValue != undefined){
			    	url += "&propertyId="+propertyValue;
			    }
			}
			window.location.href=url;
		}catch(e){
		}
	}
	
	/**
	* 后台通用修改排序值 ordersValue
	* @param str 	 文字说明
	* @param nodeId  input对象
	* @param parameter  传递参数
	* @param method 提交action
	*/
	myjs.prototype.moveCustom = function(method,nodeId,parameter,oldValue){
		try{
			 var node = $("#ordersValue"+nodeId);
		  	 var value = node.val();
		  	  if(value == ""){
					alert('请输入要修改的数值!');
					node.focus();	
				} else if(isNaN(value)) {
				    alert('排序值必须为数字,请重新输入!');
				    node.attr("value", oldValue);
				    node.focus();
				} else{									//调用Ajax
					$.ajax({
	 				type: "POST",
	 					url: method,
	 					data:parameter+"&ordersValue="+value+"&time="+new Date().getTime(),
	 						success: function(data){ 						
	 							if(myjs.SUCCESS == data) {
									alert('排序值修改成功');
									window.location.reload();
								} else {
									alert('排序值修改失败，请重试');
									return ;
								}
	 					 } 
					});
			}
		}catch(e){
		}
	}
	
	/**
	 * 对JQuery的encode方法进行二次封装 根据jquery对象
	 */
	myjs.prototype.encodeByObject = function(value) {
		try {
			var value = $(value);
			return encodeURI(encodeURI(value.val()));
		}catch(e){}
	}

	/**
	 * 对JQuery的encode方法进行二次封装 根据value值
	 */
	myjs.prototype.encodeByValue = function(value) {
		try {
			return encodeURI(encodeURI(value));
		}catch(e){}
	}
	
	
	/**
	 * 验证指定的jQuery对象里面的value是否为空
	 * @param value 要验证的jQuery对象
	 * @result 如果结果为空,则返回true , 如果不为空,则返回false
	 */
	myjs.prototype.isNullByJQuery = function(value) {
		try {
			var value = $(value);
			if($.trim(value.val()) == null || $.trim(value.val()) == "") {
				return true;
			} else {
				return false;
			}
		}catch(e){}
	}
	
	/**
	 * 验证指定的字符串是否为email格式的
	 * 
	 * @param email
	 *            要验证的字符串
	 * @result 如果验证合法则返回true, 否则返回false
	 */
	myjs.prototype.isEmail = function(email) {
		try {
			var myReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;
			if (myReg.test(email)) {
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	}
	
	/**
	 * 判断指定字符串是否为空或者全部都是空格,null,undefined
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是空格则返回true, 否则返回false
	 */
	myjs.prototype.isNull = function(value) {
		try {
			if (value == "" || value == null || value == undefined) {
				return true;
			}
			return new RegExp("^[ ]+$").test(value);
		} catch (e) {
			return false;
		}
	}
	
	/**
	 * 判断指定字符串是否为为合法的IP地址
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是IP则返回true, 否则返回false
	 */
	myjs.prototype.isIP = function(value) {
		try {
			if (this.isNull(value)) {
				return false;
			}
			var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g
			if (re.test(value)) {
				if (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256
						&& RegExp.$4 < 256) {
					return true;
				}
			}
			return false;
		} catch (e) {
			return false;
		}
	}
	
	/**
	 * 判断指定字符串是否为int类型
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是整数类型则返回true, 否则返回false
	 */
	myjs.prototype.isInteger = function(value) {
		try {
			var regu = /^[-]{0,1}[0-9]{1,}$/;
			return regu.test(value);
		} catch (e) {
			return false;
		}
	}
	
	/**
	 * 判断指定字符串是否为手机号码
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	myjs.prototype.isMobile = function(value) {
		try {
			var regu = /^([1][3]|[1][5])[0-9]{9}$/;
			var re = new RegExp(regu);
			if (re.test(value)) {
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	}
	
	   
    var myjs = new myjs();
   
   
