if(typeof filter_a == 'undefined') {
    var filter_a='-1';
}
if(typeof filter_b == 'undefined') {
    var filter_b=new Array();
}
if(typeof filter_c == 'undefined') { 
    var filter_c = 0;
}else{
    filter_c++;
}
var js_domain="http://node3.redu.com";
var cl_domain="http://www.redu-click.com/iclk/";
if(typeof filter_d == 'undefined') {
    var filter_d=0;
	var rei=0;
	var frsh=0;
	var tmp_cookie_r=0;
}
if(typeof filter_e == 'undefined') {
    var filter_e='-1';
}
window.redu_a_url='';
function load_redu_js(){
var oHead = document.getElementsByTagName('HEAD').item(0); 

    var oScript= document.createElement("script"); 

    oScript.type = "text/javascript"; 
    oScript.src=filter_b[filter_d]+"&rand="+Math.random(); 
    //alert(window.redu_a_url);
    oHead.appendChild( oScript); 
}
function load_redu_tongji(js_url){
    var oHead = document.getElementsByTagName('HEAD').item(0); 
    var oScript= document.createElement("script"); 
    oScript.type = "text/javascript"; 
    oScript.src=js_url; 
    oHead.appendChild( oScript); 
}
function ReduWriteCookie(name, value, seconds){var expire = "";if(seconds != null){expire = new Date((new Date()).getTime() + seconds * 1000);expire = "; expires=" + expire.toGMTString();}document.cookie = name + "=" + escape(value) + expire;}

function ReduReadCookie(name){var cookieValue = "";var search = name + "=";if(document.cookie.length > 0){offset = document.cookie.indexOf(search);if (offset != -1){offset += search.length;end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;cookieValue = unescape(document.cookie.substring(offset, end))}}return cookieValue;}

if(typeof cccc01=="undefined"){(function(){
var tmp_cookie=ReduReadCookie("myCookierhhi");
if(tmp_cookie==""){
	ReduWriteCookie("myCookierhhi", window.location+"|"+rei+"|"+tmp_cookie_r,10);
}else{
	tmp_cookie_var=tmp_cookie.split("|");
	var current_url=tmp_cookie_var[0];
	if(current_url!=window.location){ReduWriteCookie("myCookierhhi", window.location+"|"+rei+"|0",10);};//
	var planids=tmp_cookie_var[1];
	tmp_cookie_r=Number(tmp_cookie_var[2])+1;
	if(tmp_cookie_r>2){frsh=100;rei=planids}
    
}
})();}

(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.u_a_url+="&"+n+"="+v;
		}
	}
	function G3(n,v){
		if(v){
			window.redu_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_sh",s.height);
			G("z_sw",s.width);
			G("z_scd",s.colorDepth);
			G3("screen",s.height+'x'+s.width+'x'+s.colorDepth);
		}	
		G("z_c_url",w.union_code_url);
		G3("siteurl",escape(window.location));
		G("z_uref",w.union_ref_url);
		G3("referer",w.union_ref_url);
		G("z_urefk",w.union_ref_k);
		G3("keyword",w.union_ref_k);
		G("z_utz",tz/60);
		G3("timezone",tz/60);
		G("z_uhis",history.length);
		G3("history",history.length);
		G("z_ujava",j);
		G3("java",j);
		G("z_ufv",F());
		G3("flash",F());
		if(navigator.plugins){
			G("z_unplug",navigator.plugins.length);
			G3("plugins",navigator.plugins.length);
		}
		if(navigator.mimeTypes){
			G("z_unmime",navigator.mimeTypes.length);
			G3("mimetypes",navigator.mimeTypes.length);
		}
		G3("viewtime", parseInt(new Date().getTime()/1000));
	}
	function B(w,d){
		return w.top.location==d.location
	}

	function S(w,a,sr){
		filter_b[filter_c]=sr;
		if(filter_c>4){     
			document.write('<div>热度推广: 保护环境，珍惜地球！</div>');
			filter_c=5;
			return;
		}
		document.write('<iframe name="u_a_iframe'+filter_c+'" id="u_a_iframe'+filter_c+'" width='+s(w.u_a_width)+' height='+s(w.u_a_height)+' frameborder=0 src="about:blank"  marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no"></iframe>');  
		if(filter_c==0){
		  setTimeout(load_redu_js,10);
		  document.write("<div id='51js_tongji' style='display:none'></div>");
		  setTimeout(function(){load_redu_tongji('http://img.redu.com/tongji/'+getRootDomain()+'.js');},2000); 
               //document.write('<script type="text/javascript" src="http://img.redu.com/tongji/'+getRootDomain()+'.js"><\/script>');
		}
		if(filter_c==1){
		  var int1 = setInterval(function (){if(filter_d==1){loadjs_0();clearInterval(int1);}},10);
		}
		if(filter_c==2){
		  var int2 = setInterval(function (){if(filter_d==2){loadjs_1();clearInterval(int2);}},10);
		}
		if(filter_c==3){
		  var int3 = setInterval(function (){if(filter_d==3){loadjs_2();clearInterval(int3);}},10);
		}
		if(filter_c==4){
		  var int4 = setInterval(function (){if(filter_d==4){loadjs_3();clearInterval(int4);}},10);
		}
		if(filter_c==5){
		  var int5 = setInterval(function (){if(filter_d==5){loadjs_4();clearInterval(int5);}},10);
		}
		/*if(w.u_a_type=="1"){
			a.write('<script language="JavaScript1.1" src='+s(sr)+" charset=gbk><\/script>")
		}else{
			a.write('<iframe name="u_a_iframe'+filter_c+'" width='+s(w.u_a_width)+" height="+s(w.u_a_height)+" frameborder=0 src="+s(sr)+'  marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no">');
			a.write("</iframe>")			
		}*/
	}

	function A(){
		var w=window,d=document,t=new Date;
             	if(getRootDomain()=="27dy.cn"||getRootDomain()=="27.cn"||getRootDomain()=="algj-27dy.cn"){
                 js_domain=getJSSrv();//"http://node1.redu.com";                
		}
		w.u_a_url= js_domain+'/cache/js/'+w.u_a_client+'/'+w.u_a_zones+'.js?'; 
		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)) ;
				G3("scrollheight",Math.round(j));				
			}
		}
		D(w,t,d);
		S(w,d,w.u_a_url);
	}
						
	function C(w,d){
		return true
	}
	function E(){
		var w=window,d=document,e=null;g=d.referrer,w.onerror=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=g;
			w.union_ref_k=K(g);
		}		
	}
	var Z={};
	function ya(b)
	{
		if(b in Z)return Z[b];
		return Z[b]=navigator.userAgent.toLowerCase().indexOf(b)!=-1
	}
	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 K(r){
		var s=["wd","p","q","keyword","kw","w","key","word","query","q1","name"];
		if(r!=""&&r!=null){	
			for(var i=0;i<s.length;i++){
				var re=new RegExp("[^1-9a-zA-Z]"+s[i]+"=\([^&]*\)");
				var kk=r.match(re);
				if(kk!=null){
					return kk[1];
				}
			}
		}return "";
	}
	E();
	A();
})();

function getRootDomain(){
	var urls=window.location;
	urls=urls.toString();
	try{
		return urls.match(/([a-zA-Z0-9\-]+\.(?:com|cn|net|com\.cn|info|net\.cn|org|org\.cn|gov|gov\.cn|cc|la|edu|biz|name))(?:\/|$)/)[1];
	}catch(e){
		return urls;
	}
   
}

if(typeof filter_f == 'undefined') {
    var filter_f=new Array();
	var filter_f_i=0;
	var not_Enough_ad=false;
}
if(typeof filter_g == 'undefined') {
    var filter_g=new Array();
}
if(typeof filter_h == 'undefined') {
    var filter_h='';
var X2={} //
X2.Eval=function(code){
if(!!(window.attachEvent && !window.opera)){  
//ie
execScript(code); 
}else{
//not ie
window.eval(code);
}
}
var inArray = function (arr,value) 
// Returns true if the passed value is found in the 
// array.  Returns false if it is not. 
{ 
    var i; 
    for (i=0; i < arr.length; i++) { 
        // Matches identical (===), not just similar (==). 
        if (arr[i] === value) { 
            return true; 
        } 
    } 
    return false; 
}; 
}

function getReduA(){
	var ads_id=new Array();
	var cur_hours=new Date().getHours();
	var allWeight=0;
	var ads_id_i=0;
	for(var m=0;m<myArray.length;m++){
		if(inArray(filter_f,myArray[m][0])==false&&inArray(filter_g,myArray[m][2])==false
			&&inArray(myArray[m][3],cur_hours)==true){
			ads_id[ads_id_i]=myArray[m];
			ads_id_i++;
			allWeight=allWeight+myArray[m][1];
		}
	}
	var randKey=Math.floor(Math.random()*(allWeight)+1);
	//alert(randKey);
	var radix=0;
	var redu_i;
	for(redu_i=0;redu_i<ads_id.length;redu_i++){
		radix+=ads_id[redu_i][1];
		if(randKey<=radix){
			break;
		}
	}
	if(ads_id.length==1)not_Enough_ad=true;
	if(ads_id.length>0){
		filter_f[filter_f_i]=ads_id[redu_i][0];//qu chong fu
		filter_g[filter_f_i]=ads_id[redu_i][2];
		filter_f_i++;
		redu_plandids[redu_plandids_i]=ads_id[redu_i][2];//save zoneid info
		redu_adids[redu_adids_i]=ads_id[redu_i][0];
		redu_adids_i++;
		redu_plandids_i++;
		load_redu_tongji(js_domain+'/cache/uad_js/'+ads_id[redu_i][0]+'.js');
	}else{
		 default_redu();	
	}
}
function default_redu(){
       var   ifram   =   document.getElementById("u_a_iframe"+filter_d).contentWindow;
		ifram.document.open();
		ifram.document.write('<a id="ua" target="_blank" href="http://www.redu.com/bar.php"><img src="http://img.redu.com/domain_limit/'+redu_zoneinfo_2.width+'x'+redu_zoneinfo_2.height+'.gif" border="0" alt="&#27491;&#22312;&#20026;&#24744;&#25361;&#36873;&#24191;&#21578;" title="&#27491;&#22312;&#20026;&#24744;&#25361;&#36873;&#24191;&#21578;"></a><a href="http://www.redu.com/bar.php" target="_blank" ><span style="position:absolute; z-index: 70; bottom:0px; right: 0px;FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale,src=http://img.redu.com/images/copy-e.png);width:88px;height:18px;cursor:pointer;background: url(http://img.redu.com/images/copy-e.png) no-repeat;_background: none;"></span></a>');
		ifram.document.close();	
		X2.Eval("function loadjs_"+filter_d+"(){load_redu_js()}");
		filter_d++;
}
function getJSSrv(){
	var ads_id=new Array(["http://node3.redu.com",40],["http://node1.redu.com",30],["http://node2.redu.com",30]);
	var allWeight=100;
	var randKey=Math.floor(Math.random()*(allWeight)+1);
	var radix=0;
	var i;
	for(i=0;i<ads_id.length;i++){
		radix+=ads_id[i][1];
		if(randKey<=radix){
			break;
		}
	}
	return ads_id[i][0];
}
function limit_redu(){
       var   ifram   =   document.getElementById("u_a_iframe"+filter_d).contentWindow;
		ifram.document.open();
		ifram.document.write('<a id="ua" target="_blank" href="http://www.redu.com/bar.php"><img src="http://img.redu.com/domain_limit/'+redu_zoneinfo_2.width+'x'+redu_zoneinfo_2.height+'.gif" border="0" alt="&#22495;&#21517;&#21463;&#38480;&#21046;" title="&#22495;&#21517;&#21463;&#38480;&#21046;"></a><a href="http://www.redu.com/bar.php" target="_blank" ><span style="position:absolute; z-index: 70; bottom:0px; right: 0px;FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale,src=http://img.redu.com/images/copy-e.png);width:88px;height:18px;cursor:pointer;background: url(http://img.redu.com/images/copy-e.png) no-repeat;_background: none;"></span></a>');
		ifram.document.close();	
		X2.Eval("function loadjs_"+filter_d+"(){load_redu_js()}");
		filter_d++;
}
   var keyStr = "ABCDEFGHIJKLMNOP" +
                "QRSTUVWXYZabcdef" +
                "ghijklmnopqrstuv" +
                "wxyz0123456789+/" +
                "=";

   function encode64(input) {
      //input = escape(input);
      var output = "";
      var chr1, chr2, chr3 = "";
      var enc1, enc2, enc3, enc4 = "";
      var i = 0;

      do {
         chr1 = input.charCodeAt(i++);
         chr2 = input.charCodeAt(i++);
         chr3 = input.charCodeAt(i++);

         enc1 = chr1 >> 2;
         enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
         enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
         enc4 = chr3 & 63;

         if (isNaN(chr2)) {
            enc3 = enc4 = 64;
         } else if (isNaN(chr3)) {
            enc4 = 64;
         }

         output = output + 
            keyStr.charAt(enc1) + 
            keyStr.charAt(enc2) + 
            keyStr.charAt(enc3) + 
            keyStr.charAt(enc4);
         chr1 = chr2 = chr3 = "";
         enc1 = enc2 = enc3 = enc4 = "";
      } while (i < input.length);

      return output;
   }
