/**author lisheng
* 	date 2009-07-01
*/   
  function flashChecker(){
	var hasFlash=0;         //是否安装了flash
	var flashVersion=0; 	//flash版本
	var isIE=/*@cc_on!@*/0; //是否IE浏览噄17

	if(isIE){
	var swf;

	try{
		 swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); 
		
		}catch(e){}
		
		if(swf) {
		
		hasFlash=1;
		VSwf=swf.GetVariable("$version");
		flashVersion=parseInt(VSwf.split(" ")[1].split(",")[0]); 
	   }
	 
	}else{

		if (navigator.plugins && navigator.plugins.length > 0){
			var swf=navigator.plugins["Shockwave Flash"];
        if (swf){
		hasFlash=1;
        var words = swf.description.split(" ");
        for (var i = 0; i < words.length; ++i){
            if (isNaN(parseInt(words[i]))) continue;
            flashVersion = parseInt(words[i]);
		  }
        }
      }
   }

  return {f:hasFlash,v:flashVersion};
 }
   
   
   function getOsVersion(info){  
   	  var resultValue;
        if(info.indexOf("Windows NT 5.1")>-1){
         	   resultValue = "WindowsXP";
         }else if(info.indexOf("Windows NT 5.2")>-1){
          	   resultValue = "Windows2003";
         }else if(info.indexOf("Windows NT 6.0")>-1){
          	   resultValue = "WindowsVista";
         }else{
         	   resultValue = "其他";
         }
   	     return resultValue;
   }

/*操作系统 - 弄17姄17*/
		function OS(){
			if(isWin95())return"7";
			if(isWin98())return"6";
			if(isWinMe())return"5";
			if(isWin2000())return"4";
			if(isWinXP())return"2";
			if(isWin2003())return"3";
			if(isWinVista())return"1";
			if(isWinOT())return"8";
			if(isMac())return"13";
			if(isMacPPC())return"14";
			if(isUnix())return"11";
			if(isLinux())return"12";
			else return"0"
		}
   		function isWindows(){
			return(au.indexOf("win")!=-1)
		}
		function isWinOT(){
			return(isWindows()&&!isWin2000()&&!isWinXP()&&!isWin2003()&&!isWinVista()&&!isWin95()&&!isWin98()&&!isWinMe())
		}
		function isWin95(){
			return(isWindows()&&(au.indexOf("win95")>-1||au.indexOf("windows 95")>-1))
		}
		function isWin98(){
			return(isWindows()&&(au.indexOf("win98")>-1||au.indexOf("windows 98")>-1))
		}
		function isWinMe(){return(isWindows()&&(au.indexOf("win 94.90")>-1||au.indexOf("windowsme")>-1))
		}
		function isWin2000(){
			return(isWindows()&&(au.indexOf("windows nt 5.0")!=-1||au.indexOf("windows 2000")>-1))
		}
		function isWinXP(){
			return(isWindows()&&(au.indexOf("windows nt 5.1")!=-1||au.indexOf("windows xp")>-1))
		}
		function isWin2003(){
			return(isWindows()&&(au.indexOf("windows nt 5.2")!=-1||au.indexOf("windows 2003")>-1))
		}
		function isWinVista(){
			return(isWindows()&&(au.indexOf("windows nt 6.0")!=-1||au.indexOf("windows vista")>-1))
		}
		function isMac(){
			return(au.indexOf("mac")!=-1||au.indexOf("68k")>-1)
		}
		function isMacPPC(){
			return(isMac()&&(au.indexOf("ppc")!=-1||au.indexOf("powerpc")!=-1))
		}
		function isUnix(){
			return(au.indexOf("unix")!=-1||au.indexOf("sunos")!=-1||au.indexOf("bsd")!=-1||au.indexOf("x11")!=-1)
		}
		function isLinux(){
			return(au.indexOf("linux")!=-1)
		}
/*操作系统 - 结束*/
/*浏览噄17 - 弄17姄17*/
		function isNav(){
			return(ap=="Netscape"&&!isOpera()&&!isKHTML()&&!isFirefox())
		}
		function isIE(){
			return(ap=="Microsoft Internet Explorer"&&!isOpera())
		}
		function isOpera(){
			return(au.indexOf("opera")!=-1)
		}
		function isKHTML(){
			var A=au.indexOf("khtml")>-1||au.indexOf("konqueror")>-1||au.indexOf("applewebkit")>-1;
			return A
		}
		function isFirefox(){
			return(au.indexOf("firefox")!=-1)
		}
		function BW(){
			var B=parseFloat(navigator.appVersion);
			if(isNav()){
				B="40"+B;return B
			}
			if(isIE()){
				var D=new RegExp("msie (\\d+\\.\\d+);");
				D.test(au);
				B=parseFloat(RegExp["$1"]);
				if(au.indexOf("maxthon")>-1)B="11"+B;
				else if(au.indexOf("avant")>-1)B="12"+B;
				else if(au.indexOf("tencent")>-1)B="13"+B;
				else B="10"+B;
				return B
			}
			if(isOpera()){
				B="30"+parseFloat(au.substring(au.indexOf("opera")+6)); 
				return B
			}
			if(isKHTML()){
				var A=au.indexOf("applewebkit")>-1,
					C=au.indexOf("konqueror")>-1;
					D=au.indexOf("chrome")>-1;
				if(A&&D)B="70"+parseFloat(au.substring(au.lastIndexOf("konqueror/")+10));
				else if(A)B="50"+parseFloat(au.substring(au.lastIndexOf("applewebkit/")+12));
				else if(C)B="60"+parseFloat(au.substring(au.lastIndexOf("konqueror/")+10));
				return B
			}
			if(isFirefox()){
				B=parseFloat(au.substring(au.indexOf("/",au.indexOf("firefox/")+6)+1));
				if(au.indexOf("flock")>-1)B="21"+B;
				else B="20"+B;
				return B
			}
			else return "0"
		}
/*浏览噄17 - 结束*/
   //////////设置cookies////////////////////////////////////////
   
   function SetCookie(sName, sValue, timeKeep)
	{
	var now=new Date();
	var expireTime= new Date(now.valueOf()+timeKeep*60000*60);
	document.cookie = sName + "=" + escape(sValue) + "; path=/; expires=" + expireTime.toGMTString() + ";";
	}

	function GetCookie(sName)
	{
		var aCookie = document.cookie.split("; ");
		for (var i=0; i < aCookie.length; i++)
		{
			var aCrumb = aCookie[i].split("=");
			if (sName == aCrumb[0]) 
				return unescape(aCrumb[1]);
		}
		return null;
	}

	function GetCurrentDateTime()
	{
	    var date = new Date();
	    var current=new String("");
	    current += date.getFullYear()+"-";
	    current += date.getMonth() + 1+"-";
	    current += date.getDate()+" ";
	    current += date.getHours()+":";
	    current += date.getMinutes()+":";
	    current += date.getSeconds();
	    return current;
	}

   
   
   
   //扄17属搜素引擄17
   var issearch;
   
   if(document.referrer!=''){
      issearch = document.referrer;
    }else{
      issearch = 0;
    }
    
    //浏览器分辨率
    var screenValueWidth;
    var screenValueHeight;
       screenValueWidth = screen.width ;
       screenValueHeight = screen.height;
       
    //浏览器属怄17
//     var userAgentValue = navigator.userAgent;
//     var appNameValue = navigator.appName;
	   var au = navigator.userAgent;
	   var ap = navigator.appName;
     
     var explorerVersion;
     var osVersion;
     
//     if(appNameValue=="Microsoft Internet Explorer"){
//         if(userAgentValue.indexOf("MSIE 7.0")>-1){
//             explorerVersion = "IE7";
//         }else if(userAgentValue.indexOf("MSIE 6.0")>-1){
//             explorerVersion = "IE6";
//         }else{
//         	 explorerVersion = "IE";
//         }
         //系统版本
//        osVersion = getOsVersion(userAgentValue.toLowerCase());

//     }else if(userAgentValue.indexOf("Firefox")>-1){
//          explorerVersion = "Firefox";
     	  //系统版本
//          osVersion = getOsVersion(userAgentValue); 
//     }else if(appNameValue.indexOf("Opera")>-1){     
//          explorerVersion = "Opera";
     	  //系统版本
//          osVersion = getOsVersion(userAgentValue);   
//     }else{
//     explorerVersion = "0";
//     osVersion ="0";
//     }
	explorerVersion = BW();/**************************************************************/
	osVersion = OS();/**************************************************************/
     //Flash版本
     var flashVersion;
     var fls=flashChecker();  
     
      if(fls.f) flashVersion = fls.v;
	  else flashVersion = "0";
	  
	  //是否支持Cookies
	  var isCookies;
	  if(navigator.cookieEnabled){
	     isCookies="1";
	   }else{
	     isCookies="0";
	   }
     //浏览器语訄17
	   var exporerLanguage;
        if(null==navigator.browserLanguage){
		   exporerLanguage = navigator.language;
		   }else{
		   exporerLanguage = navigator.browserLanguage;
		  }
	 //当前页面URL	  
		var locationhref = location.href;
		
      /////////////////////////////////////////////////////////////////////////////////////
		

		
		//	Cookie名称
		var w_cookie_unique="w_total_cookie_"+website_id;
		var w_cookie_all_uniquee="w_total_cookie_parent_"+locationhref;
		var w_cookie_datetime="w_total_cookie_datetime_"+website_id;		
		
		// 是否唯一用户＄17小时算一欄17
		var w_unique_user="1";//是否是UV
		var w_all_unique_user="1";
		
	if (GetCookie(w_cookie_unique)==null)//UV
		{
			w_unique_user="1";
			SetCookie(w_cookie_unique,"1",24);
		}
		else
			w_unique_user="0";
			
		if (GetCookie(w_cookie_all_uniquee)==null)//PV
		{
			w_all_unique_user="1";
			SetCookie(w_cookie_all_uniquee,"1",24);
		}
		else
			w_all_unique_user="0";
			
			
		// 访问时间
		var m_tc_datetime=GetCookie(w_cookie_datetime);
		
		SetCookie(w_cookie_datetime,GetCurrentDateTime(),365*24);
		if (m_tc_datetime==null){
			m_tc_datetime="0";
		}else{
		    m_tc_datetime="1";
		}
		if(w_unique_user=="1"||w_all_unique_user=="1"){
		
		   document.write("<iframe src=\"http://"+w_server+"/webstats.html?website_id="+escape(website_id)+"&w_unique_user="+escape(w_unique_user)+"&m_tc_datetime="+m_tc_datetime+"&locationhref="+escape(locationhref)+"&exporerLanguage="+escape(exporerLanguage)+"&flashVersion="+escape(flashVersion)+"&osVersion="+escape(osVersion)+"&explorerVersion="+escape(explorerVersion)+"&screenValueWidth="+escape(screenValueWidth)+"&screenValueHeight="+escape(screenValueHeight)+"&issearch="+escape(issearch)+"&isCookies="+escape(isCookies)+"\" style=\"display:none;width:0;height:0;\"></iframe>");
     
		}
     
     
     
  // 图标
	if(w_style!=0){
	  document.write("<a href=\"http://"+w_server+"/?website_id="+website_id+"\" target=_blank title=\"网站流量统计\"><img src=\"http://"+w_server+"/resources/images/0"+w_style+".gif\" align=absmiddle border=0></a>");
	}else{
	 document.write("<a href=\"http://"+w_server+"/?website_id="+website_id+"\" target=_blank>[本站统计]</a>");
	}
     
     
     
     
     
     
     