var oldObj;
function onClick(cmd){
  var temp=window.event.srcElement;
  if(temp.tagName=='TD'){
    if(oldObj){
    	oldObj.background="";
    }
    temp.background=path+"/img/corpinfo/img-016.jpg";
    oldObj=temp;
    document.getElementById("currCmd").value=cmd;
  }
}

function onOpen(cmd){
	onClick(cmd);
	var temp=document.all("8child");
	if(temp){
		if(temp.length){
			for(var i=0;i<temp.length;i++){
				temp[i].style.display=(temp[i].style.display=="")?"none":"";
			}
		}else{
			temp.style.display=(temp.style.display=="")?"none":"";
		}		
	}
}
function hasNoRight(right,cmd,args,flag){
  if(right==null || right==0){
  	if(confirm('本项为有偿服务内容，成为钻石、铂金、黄金或限量订阅会员才可浏览（会员权限对比）。如果您是拥有使用该项服务的会员，登陆系统后即能使用该项目服务。如果您是普通会员，可登陆后到“我的账户”中申请会员升级。如果您不是会员，请现在注册。')){
  		doLogin();
  		return false;
  	}else{
  		return false;
  	}
  }else if(right==-1){
    alert('请绑定座席！');
    var url
    if(flag && flag=='1'){//handle corp info first, the rest left to hqx 
    	url=path+"/jsp/corpinfo/bindseat.jsp?cmd=corpInfo&hasSeat="+hasSeat+"&url=%2FcorpReportDetail.do%3Fcmd%3d"+cmd+"&"+paramName+"="+args+"&flag1="+flag;
    }else if(flag && flag=='2'){
    	url=path+"/jsp/corpinfo/bindseat.jsp?cmd=corpInfo&hasSeat="+hasSeat+"&url=%2FcorpIncrementService.do%3Fcmd%3D"+cmd+"&"+paramName+"="+args+"&flag1="+flag;
    }else if(flag && flag=='3'){
    	url=path+"/jsp/corpinfo/bindseat.jsp?cmd="+cmd+"&hasSeat="+hasSeat+"&"+paramName+"="+args+"&flag1="+flag;
    }
    openWin(url);
    return false;
  }else if(right==-2){
    if(confirm('您确定要浏览该企业的付费信息吗？')){
    	var temp=document.getElementById(cmd);
    	if(flag && flag=='1'){//handle corp info first, the rest left to hqx 
    		temp.target = "_self";
    		temp.href=path+"/corpReportDetail.do?cmd=corpInfo&url=%2Fcorp%2FcorpReportDetail%2F"+cmd+"&"+paramName+"="+args;
    	}else if(flag && flag=='2'){
    		temp.target = "_self";
    		temp.href=path+"/corpIncrementService.do?cmd=corpInfo&url=%2Fcorp%2FcorpReportDetail%2F0"+"&"+paramName+"="+args+"&type=archivesDownload";
    	}else if(flag && flag=='3'){
    		temp.target = "_self";
    		temp.href=path+"/corpReportDetail.do?cmd=corpInfo&url=%2Fcorp%2FcorpReportDetail%2F0"+"&"+paramName+"="+args;
    	}
    }else{
    	return false;
    }    
  }else if(right==-3){
    if(confirm('要使用该项服务，您需要升级为更高级别的会员(会员权限对比)。您现在提交会员升级申请吗？')){
    	document.accountManager.submit();
    }else{
    	return false;
    }
  }else if(right==-4){
    alert('请转为时段会员或购买企业信用报告获得该企业信息！');
    return false;
  }else if(right==-5){
	alert('母账户没有企业档案权限！');
    return false;
  }else if(right==-6){
  	alert('您的母帐户没有给予您足够权限！');
  	return false;
  }
}

function hasDuplicate(bl,message,args){
	if(bl){
		alert(message);
		return false;
	}
	else{
		if(confirm(message)){
	    	url = path + "/corpIncrementService.do?cmd=deptcorpAchieve&state=2&"+paramName+"="+args+"&right=1";;
	    	document.addDetect.action=url;
	    	document.addDetect.submit();			
		}
		else{
			return false;
		}
	}
}

function hasDetectNum(message,ifcontain,right,args,flag){
	var url;

	if(ifcontain==1 || ifcontain ==0){	    
	    url = path + "/corpIncrementService.do?cmd=deptcorpAchieve&state="+ifcontain+"&flag="+flag+"&"+paramName+"="+args+"&right="+right;;
	    document.addDetect.action=url;
	    document.addDetect.submit();
	}else if(ifcontain==2){
		if(confirm(message)){
	    	url = path + "/corpIncrementService.do?cmd=deptcorpAchieve&state=2&"+paramName+"="+args+"&right="+right;;
	    	document.addDetect.action=url;
	    	document.addDetect.submit();			
		}
		else{
			return false;
		}
	}else if(ifcontain==-3){
		if(confirm(message)){
	    	url = path + "/accountManagerAction.do?select=24&url="+path+"/accountServiceAction.do%3fcmd%3dsubscribeKEMPre%26flag%3dkem&right="+right;;
	    	document.addDetect.action=url;
	    	document.addDetect.submit();
		}
		else{
			return;
		}
	}else if(ifcontain==-2){
	   alert(message);
	   return;	
	}else if(ifcontain==-1){
		if(confirm(message)){
	    	url = path + "/accountManagerAction.do?select=24&url="+path+"/accountServiceAction.do%3fcmd%3dsubscribeKEMPre%26flag%3dkem&right="+right;;
	    	document.addDetect.action=url;
	    	document.addDetect.submit();
		}
		else{
			return;
		}	
	}
}

function hasNoDetectRight(right,cmd,args,flag){
  if(right==0){
  	if(confirm('本项为有偿服务内容，成为钻石、铂金、黄金或限量订阅会员才可浏览（会员权限对比）。如果您是拥有使用该项服务的会员，登陆系统后即能使用该项目服务。如果您是普通会员，可登陆后到“我的账户”中申请会员升级。如果您不是会员，请现在注册。')){
  		doLogin();
  		return ;
  	}else{
  		return ;
  	}
  }else if(right==-1){
    alert('请绑定座席！');
    var url
    if(flag && flag=='1'){//handle corp info first, the rest left to hqx 
    	url=path+"/jsp/corpinfo/bindseat.jsp?cmd=corpInfo&hasSeat="+hasSeat+"&url=%2FcorpReportDetail.do%3Fcmd%3d"+cmd+"&"+paramName+"="+args+"&flag1="+flag+"&right="+right;
    }else if(flag && flag=='2'){
    	url=path+"/jsp/corpinfo/bindseat.jsp?cmd=corpInfo&hasSeat="+hasSeat+"&url=%2FcorpIncrementService.do%3Fcmd%3D"+cmd+"&"+paramName+"="+args+"&flag1="+flag+"&right="+right;
    }
    openWin(url);
    return ;
  }else if(right==-3){
    if(confirm('要使用该项服务，您需要升级为更高级别的会员(会员权限对比)。您现在提交会员升级申请吗？')){
    	document.accountManager.submit();
    }else{
    	return;
    }
  }else if(right==-4){
    alert('请升级为时段会员！');
    return ;
  }else if(right==-6){
  	alert('您的母帐户没有给予您足够权限！');
  	return ;
  }
}
function openWin(url){
	var win_width = 500;
	var win_height = 350;
	var win_top = (screen.availHeight - win_height) /2;
	var win_left = (screen.availWidth -win_width)/2;
	var win_dimensions = "top =" +win_top+ ",left = " +win_left+ ",height=" + win_height + ",width=" + win_width + ",scrollbars=no" + ",resizable=1";
	window.open(url,"loginWin",win_dimensions);
}
function onFastSearch(){
	var cmd = document.fastSearch.cmd.value;
  if(document.fastSearch.keyword.value == null || document.fastSearch.keyword.value == ""){
      alert("请输入关键词！");
      document.fastSearch.keyword.focus();
      return false;
  }else{
     if(document.fastSearch.cmd.value == "stock"){
        var partrn=/^[A-Za-z0-9]+$/;
        if (!partrn.test(document.fastSearch.keyword.value)) {
            alert("股票代码必须由数字和字母组成");
            document.fastSearch.keyword.focus();
            return false;
        }
     }else if(document.fastSearch.cmd.value == "corpname" ){
         if(!inputError(document.fastSearch.keyword.value)){
     	    	 return false;
     	    }      	       	  
     }  
      document.fastSearch.action=path+"/fastSearch.do?cmd="+cmd;  
  }
}
function isContain(szSrc)
{
    var bResult = false;
    if(szSrc == "有限责任公司"
    || szSrc == "有限"
    || szSrc == "有限责"
    || szSrc == "有限责任"
    || szSrc == "责任"
    || szSrc == "限责任"
    || szSrc == "任公司"
    || szSrc == "责任公司"
    || szSrc == "公司"
    || szSrc == "有限公"
    || szSrc == "有限公司")
    {
        bResult = true;
    }
    return bResult;
}
function reportdo(name){
	document.report.report_name.value=name;
	document.report.submit();
}
function toCreditLink(){
	var ajax = new AJAX(path+"/ajax.do",false);
	ajax.remoteCall("/login.toCreditLink",null, doForward);
}
function doForward(obj){
	var params=obj.split("_");
	document.creditlink.visitor.value=params[0];
	document.creditlink.cipher.value=params[1];
	document.creditlink.submit();
}
function inputError(inputValue){
	if(isContain(inputValue)){
		alert("不能仅输入"+inputValue+"！");
		return false;
	}
	return true;
}
