/*
+---------------------------------------------------------------------------+
| baomeng.net                                                                 |
| ==========                                                                |
|                                                                           |
| Copyright (c) 2009-2011 baomeng.net Limited  alex.cheng                                   |
| For contact details, see: http://www.baomeng.net/                           |
|                                                                           |
+---------------------------------------------------------------------------+
*/
(function(){
	function s(b){return b!=null?'"'+b+'"':'""'}
	function e(b){
		if(typeof encodeURIComponent=="function"){
			return encodeURIComponent(b)
		}else{
			return encodeURI(b)
		}
	}
	function G(n,v){
		if(v){window.t_a_url+="&"+n+"="+v}
	}
	function D(w,t,d){
		var s=w.screen,j='0';
		tz=-t.getTimezoneOffset();
		if(navigator.javaEnabled())j='1';
		if(s){
			G("z_s_h",s.height);
			G("z_s_w",s.width);
			G("z_s_c",s.colorDepth)}
			G("z_c_u",w.union_code_url);
			G("z_r_u",w.union_ref_url);
			G("z_r_k",w.union_ref_k);
			G("z_r_s",w.union_ref_s);
			G("z_u_t",tz/60);
			G("z_u_h",history.length);
			G("z_u_j",j);
			G("z_u_f",F());
			G("z_u_c",Ck());
			G("z_u_l",Ln());
			if(navigator.plugins){
				G("z_u_p",navigator.plugins.length)
			}
			if(navigator.mimeTypes){
				G("z_u_m",navigator.mimeTypes.length)
			}
	}
	function B(w,d){
		return w.top.location==d.location;
	}
	function S(w,a,sr){
		var w=window;
		a.write('<iframe name="t_bm_iframe"+w.t_a_zones+" id="t_bm_iframe"+w.t_a_zones+" width='+s(w.t_a_width)+" height="+s(w.t_a_height)+" frameborder=0 src="+s(sr)+' marginwidth="0" marginheight="0" vspace="0" hspace="0" align="center,center" allowtransparency="true" scrolling="no" charset="gbk">');
		a.write("</iframe>");
	}
	function A(){
		var w=window,d=document,t=new Date;
		w.t_a_url="http://www.baomeng.net/clk/tc.asp?";
		w.t_a_url+="z_uid="+w.t_a_client;
		w.t_a_url+="&z_id="+w.t_a_zones;
		if(w.union_num_ads_zone){
			w.union_num_ads_zone=w.union_num_ads_zone+1;
		}	else{
			w.union_num_ads_zone=1
		}
		if(w.union_num_ads_zone>10){return}
		if(B(w,d)&&d.body){
			var j=d.body.scrollHeight,v=d.body.clientHeight;
			if(v&&j){G("z_uc_ks",Math.round(j))}
		}
		D(w,t,d);
		S(w,d,w.t_a_url)
	}
	function C(w,d){return true}
	function E(){
		DurationController.init();
		var w=window,d=document,e=null;
		g=d.referrer,w.onerror123=C;
		if(w.union_code_url==e){
			w.union_code_url=escape(w.location);
			if(!B(w,d)){
				w.union_code_url=g;
			}
		}
		w.union_ref_url='';
		if(B(w,d)&&g){
			w.union_ref_url=escape(g);
		}
		w.union_ref_k='';
		w.union_ref_s='';
		if(g){
			var ref_ks;
	    ref_ks=K(g);
	    if(ref_ks!="")
	    {
	    	var a;
	    	a=ref_ks.split("|");
	    	w.union_ref_k=a[0];
	    	w.union_ref_s=a[1];
	    }
		}
	}
	var Z={};
	function ya(b){
		if(b in Z)return Z[b];
		return Z[b]=navigator.userAgent.toLowerCase().indexOf(b)!=-1
	}
	function Ck(){
		return navigator.cookieEnabled?"1":"0"
	}
	function Ln(){
		var a=navigator;
		return (a.systemLanguage?a.systemLanguage:a.browserLanguage?a.browserLanguage:a.language?a.language:a.userLanguage?a.userLanguage:"-").toLowerCase()
	}
	function F(){
		if(navigator.plugins&&navigator.mimeTypes.length){
			var b=navigator.plugins["Shockwave Flash"];
			if(b&&b.description)return b.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s)+r/,".")
		}else if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){
			var a=3,c=1;
			while(c)
			try{
				c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+(a+1));
				a++
			}
			catch(e){c=null}
			return a.toString()
		}else if(ya("msie")&&!window.opera){
			var c=null;
			try{
				c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
			}
			catch(e){
				var a=0;
				try{
					c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					a=6;
					c.AllowScriptAccess="always";
				}
			catch(e){if(a==6)return a.toString()}
			try{c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}
			catch(e){}
			}
			if(c!=null){
				var a=c.GetVariable("$version").split(" ")[1];
				return a.replace(/,/g,".")
			}
		}
		return"0"
	}
	function utg(str1){
	        var substr = "";
	        var a = "";
	        var b = "";
	        var c = "";
	        var i = -1;
	        i = str1.indexOf("%");
	        if(i==-1){
	          return str1;
	        }
	        while(i!= -1){
	    if(i<3){
	                substr = substr + str1.substr(0,i-1);
	                str1 = str1.substr(i+1,str1.length-i);
	                a = str1.substr(0,2);
	                str1 = str1.substr(2,str1.length - 2);
	                if(parseInt("0x" + a) & 0x80 == 0){
	                  substr = substr + String.fromCharCode(parseInt("0x" + a));
	                }
	                else if(parseInt("0x" + a) & 0xE0 == 0xC0){ //two byte
	                        b = str1.substr(1,2);
	                        str1 = str1.substr(3,str1.length - 3);
	                        var widechar = (parseInt("0x" + a) & 0x1F) << 6;
	                        widechar = widechar | (parseInt("0x" + b) & 0x3F);
	                        substr = substr + String.fromCharCode(widechar);
	                }
	                else{
	                        b = str1.substr(1,2);
	                        str1 = str1.substr(3,str1.length - 3);
	                        c = str1.substr(1,2);
	                        str1 = str1.substr(3,str1.length - 3);
	                        var widechar = (parseInt("0x" + a) & 0x0F) << 12;
	                        widechar = widechar | ((parseInt("0x" + b) & 0x3F) << 6);
	                        widechar = widechar | (parseInt("0x" + c) & 0x3F);
	                        substr = substr + String.fromCharCode(widechar);
	                }
	     }
	     else {
	      substr = substr + str1.substring(0,i);
	      str1= str1.substring(i);
	     }
	              i = str1.indexOf("%");
	        }
	
		return substr+str1;
	}
	function getValue(a,b){
		var d=b.match(RegExp("(^|&|\\?)"+a+"=([^&]*)(&|$|#)"));
		return d?d[2]:""
	}
	function K(r){
		var sindex=[2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
	  var sengin=["baidu.com", "baidu.com", "google.com", "google.cn", "sogou.com", "zhongsou.com", "search.yahoo.com", "one.cn.yahoo.com", "soso.com", "118114.cn", "search.live.com", "youdao.com", "gougou.com", "bing.com"];
	  var sword=["word", "wd", "q", "q", "query", "w", "p", "p", "w", "kw", "q", "q", "search", "q"];
	  var swBlacklist=["www.baomeng.net"];
		var swtags;
		if(r!=""&&r!=null){
			for(var b=0,d=sengin.length;b<d;b++){
				var e=getValue(sword[b],r);
				if(r.indexOf(sengin[b])>-1&&e){
					if(sindex[b]==3||sindex[b]==4){
						swtags=utg(e)+"|"+sindex[b]
					}else
						{
					swtags=e+"|"+sindex[b]
				}
					b=0;
					for(d=swBlacklist.length;b<d;b++)r.indexOf(swBlacklist)>-1&&(swtags="");
					return swtags
				}
			}
		}
		return ""
	}
	function sendDurationHandler(){
		return function(){
			var cep=DurationController.getPageDuration()+","+DurationController.getFocusDuration();
			postData("3",cep)
		}
	}
	function postData(et,ep){
		var rcv="http://www.baomeng.net/clk/ev.asp";
		var w=window;
		var a=new Image(1,1);
		a.onload=function(){};
		a.src=rcv+"?url="+escape(w.location)+"&uid="+w.t_a_client+"&et="+et+"&ep="+ep;
	}
	var DurationController={
		pageBeginTime:0,currentFocusBeginTime:0,previousFocusDuration:0,hasFocus:!1,
		init:function(){
			this.handleEvents();
			this.currentFocusBeginTime=this.pageBeginTime=(new Date).getTime();
		},getPageDuration:function(){
			return(new Date).getTime()-this.pageBeginTime
		},getFocusDuration:function(){
			return(new Date).getTime()-this.currentFocusBeginTime+this.previousFocusDuration
		},eventsHandler:function(){
			var a=this;
			return function(b){
				var b=b||window.event,d=b.srcElement||b.target;if(b.type=="focus"&&d==window||b.type=="focusin")a.hasFocus=!0,a.currentFocusBeginTime=(new Date).getTime();else if(b.type=="blur"&&d==window||b.type=="focusout")a.hasFocus=!1,a.previousFocusDuration+=(new Date).getTime()-a.currentFocusBeginTime,a.currentFocusBeginTime=(new Date).getTime()
			}
		},handleEvents:function(){
			typeof document.onfocusin=="object"?(document.attachEvent("onfocusin",this.eventsHandler()),document.attachEvent("onfocusout",this.eventsHandler())):(window.addEventListener("focus",this.eventsHandler(),!1),window.addEventListener("blur",this.eventsHandler(),!1))
		}
	}
	function on(a,b,d){
		b=b.replace(/^on/i,"").toLowerCase();
		a.attachEvent?a.attachEvent("on"+b,function(b){d.call(a,b)}):a.addEventListener&&a.addEventListener(b,d,!1)
	}
	function adDocEvt(){
		var w=window;
		on(w,"beforeunload",sendDurationHandler())
	}
	E();
	A();
	adDocEvt();
	}
)();



