<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import = "cn.com.dekn.common.util.*" %>

   var getMyID="";
   var url = location.search; //获取url中"?"符后的字串

   if (url.indexOf("?") != -1) {    //判断是否有参数

      var str = url.substr(1); //从第一个字符开始 因为第0个是?号 获取所有除问号的所有符串

      strs = str.split("=");   //用等号进行分隔 （因为知道只有一个参数 所以直接用等号进分隔 如果有多个参数 要用&号分隔 再用等号进行分隔）
      
      getMyID=strs[1];
      
      //alert(strs[1]);          //直接弹出第一个参数 （如果有多个参数 还要进行循环的）

   }

//博客统计类
var urlID='<%=request.getContextPath()%>';
var Counter = {
	nodeID : null, //博客id，必须提供，否则统计不会进行统计
	engineURL : [[".google.","谷歌","q"],[".baidu.","百度","wd"],[".soso.","搜搜","w"]], //搜索引擎的URL
	countType : "site", 
	counterURL : "../../counter", //统计servlet的url
	ajax : null,
	url : null,
	
	id : null,
	
	source : null, //浏览器地址栏的上一个地址
	clientScreen : null,//显示器分辨率
	clientColor : null,//显示器颜色
	clientAgent : null,//浏览器信息
	clientOS : null,//操作系统
	clientLanguage : null,//操作系统语言
	engineSource : null, //搜索引擎	
	engineKey : null, //搜索的关键字
	
	//设置blogID
	setNodeID:function(id){
						Counter.nodeID = id;
					},
					
	setType:function(type){
						Counter.countType = type;
					},
					
	setCounterURL:function(url){
						Counter.counterURL = url;
					},
					
	//若统计文章或相册需要指定相应的id
	setId:function(id){
						Counter.id = id;
					},				
	
	
	//增加搜索引擎网址
	appendEngine:function(URL){
							Counter.engineURL = Counter.engineURL + "," + URL;
						},
	
	init:function(){
	              // alert("初始化");
					Counter.clientScreen = window.screen.width+"*"+window.screen.height; 
					Counter.clientColor = window.screen.colorDepth + "bit"; 
					/*Counter.clientAgent = navigator.appName;　
					Counter.clientOS = navigator.platform; */
					Counter.clientAgent = "";//浏览器　
					Counter.clientOS = "";//操作系统
					Counter.clientLanguage = navigator.systemLanguage?navigator.systemLanguage:navigator.language; 
					
					//计算客户端操作系统以及浏览器信息
					var userAgent = navigator.userAgent;
					if(userAgent.indexOf("NT 5.0")>0){
						Counter.clientOS = "WindowsServer2000";
					}else if(userAgent.indexOf("NT 5.1")>0){
						Counter.clientOS = "WindowsXP";					
					}else if(userAgent.indexOf("NT 5.2")>0){
						Counter.clientOS = "WindowsServer2003";
					}else if(userAgent.indexOf("NT 6.0")>0){
						Counter.clientOS = "WindowsVista";
					}
					if(navigator.appName.indexOf("Microsoft")>-1){
						Counter.clientAgent = userAgent.split(";")[1];
					}else{
						Counter.clientAgent = userAgent.split(";")[4].split(" ")[3];
					}
					
					//Counter.engineSource = "";
					//Counter.engineKey = "";
					
					//Counter.ajax = new AJAXRequest;
					Counter.url = Counter.counterURL + "?type=" + Counter.countType + "&cluster_node_id=" + Counter.nodeID + "&source=" + Counter.source + "&clientScreen=" + Counter.clientScreen + "&clientColor=" + Counter.clientColor + "&clientAgent=" + Counter.clientAgent + "&clientOS=" + Counter.clientOS + "&clientLanguage=" + Counter.clientLanguage.toLowerCase() + "&id=" + Counter.id;
				},
				
	count:function(){ //统计
					//alert("function()  "+Counter.url);
					var iframe = document.createElement("iframe");
					iframe.setAttribute("frameborder","0");
					iframe.setAttribute("hspace","0");
					iframe.setAttribute("marginheight","0");
					iframe.setAttribute("marginwidth","0");
					iframe.setAttribute("scrolling","no");
					iframe.setAttribute("vspace","0");
					iframe.setAttribute("src",Counter.url);
					
					iframe.style.display = "none";
					
					document.body.appendChild(iframe);
				}
}

//alert("1");
<%	
	//统计sevlet所在路径
	String COUNTER_URL = StrUtil.getNotNullStringValue(request.getParameter("COUNTER_URL"),"../../counter");
	
	//站点ID
	String NODE_ID = StrUtil.getNotNullStringValue(request.getParameter("cluster_node_id"));
	if(StrUtil.isNull(NODE_ID)){
		NODE_ID = StrUtil.getNotNullStringValue(request.getParameter("node_id"),"root");
	}
	
	//统计类型 article:文章点击统计 download:下载次数统计 albumphoto:相册中的照片点击 multimedia:多媒体资源的访问量 site:网站的访问量
	String TYPE = StrUtil.getNotNullStringValue(request.getParameter("type"),"site");
	
	//若为文章、相册、多媒体的统计请提供相应的id
	String ID = StrUtil.getNotNullStringValue(request.getParameter("id"),"cms4j");
	System.out.println("ID----------------"+ID);
%>

	Counter.setCounterURL("<%=COUNTER_URL%>"); //统计程序对应的路径
	Counter.setNodeID("<%=NODE_ID%>"); 
	Counter.setType("<%=TYPE%>"); 
	
	<%if(ID.equals("cms4j")==false){%>
		Counter.setId("<%=ID%>"); 
	<%}%>

	Counter.init();
	Counter.count(); //若使用iframe进行统计请不要调用此方法
