// choose： checkbox name名称  对checkbox统一选中和不选中
function checkboxAll(the,choose){
	var arr=document.getElementsByName(choose);
	for(i=0;i<arr.length;i++){
		arr[i].checked=the.checked;
	}
}

// choose： checkbox name名称  检查有没有选中项
function isChoose(choose){
	var arr=document.getElementsByName(choose);
	var j=0;
	for(i=0;i<arr.length;i++){
		if(arr[i].checked){
			j++;
			break;
		}
	}
	if(j==0){
		alert("请选择至少一项数据才可以继续下一步操作！！");
		return false;
	}else{
		if(!confirm("您确定要提交吗？")){
			return false;
		}
	}
	return true;
}
function openDivWindow(id,url,isRefresh,paramTitle,paramWidth,paramHeight){
	openDivWindow(id,url,isRefresh,paramTitle,paramWidth,paramHeight,null)
}
		//浮动窗口
function openDivWindow(id,url,isRefresh,paramTitle,paramWidth,paramHeight,quertyString){
   if(paramWidth==''){
      paramWidth=600;
   }
   if(paramHeight==''){
      paramHeight=250;
   }
    
   var obj=document.getElementById(id);
   
	if($(obj).html() == ""){
	   $(obj).window({
	      title:paramTitle,
	      width:paramWidth,
	      height:paramHeight,
	      iconCls:'icon-search',
	      minimizable:false,
          collapsible:false,
          maximizable:false,
          resizable:false,
          modal:true,
          href:url,
          val:quertyString
	   });
	}else{
	     $(obj).html("");
	     $(obj).window({href:url,val:quertyString});
	     $(obj).window("refresh");
         $(obj).window("open");
	}
}
var website="/";
var url="";
var target="";
function ajaxVerify(obj,e,str){

    if(obj!='form'){
	    doane(e);//禁止click元素的子事件触发
	    url = $(obj).attr("href");//jquery获取href属性
	    target = $(obj).attr("target"); 
    }
     $.ajax({
		     url:website+'sessionVerify.html',
		     type : "post", 
		     dataType: 'json',
		     error: function () {//请求失败时调用函数。 
				alert("请求失败!");  
			}, 
	        success: function(data){
				if(data){
					if(obj!='form'){
						openUrl();
						//alert("ddd");
						//window.location.href="<%=request.getContextPath()%>/manager/login.html";
					}else{
						if(str == null){
							document.getElementById(e).submit();
						} else {
							//在调用页面实现的方法
							execFun();
						}
					}
				}else{
                     var url = website+"ajaxLogin.html";
				     if(str != null && str != "" ){
				        url +="?type="+str;
				     }
					 openDivWindow("showLoginWindow",url,'','会员登录',415,320);
					return false;
				}
             }  
		 }); 
     return false;
}

function openUrl(){
  if(url!=""){
  	 if(url=='reload'){
  	 	window.location.reload();
  	 }else{
	     if(target=='rightMain'){
		 	document.getElementById("rightMain").src=url;
		 }else{
		 	window.location.href=url;
		 } 
	 }
 }
}

function doane(event)
{
  e = event ? event : window.event;
  if(window.event)
  {
    e.returnValue = false;
    e.cancelBubble = true;
  }else{
    e.stopPropagation();
    e.preventDefault();
  }
} 

