﻿var domainnums;
var rands;
theDomain = new Array();

domainnums=1;
theDomain[0] = "c.baidu.com.cnxad.com";
theDomain[1] = "c.baidu.com.cnxad.com";

if (domainnums>1)
{
  rands = Math.round(Math.random()*domainnums);
  while (rands >(domainnums-1)) {
   rands = Math.round(Math.random()*domainnums);
  }
}else{rands=0;}

if (rands==""){rands=0}
var codedomain=theDomain[rands];

var cnxad_location = window.location.href;
var cnxad_from_url = document.referrer;
cnxad_location=encodeURIComponent(cnxad_location);
cnxad_from_url=encodeURIComponent(cnxad_from_url);
var cnxad_width=0;
var cnxad_height=0;

  if(self!=top)
    {
	var cnxadkeshibody;
	cnxadkeshibody=document.documentElement;
	if (eval(cnxadkeshibody.clientWidth)<=0)
	{
	document.writeln("<body></body>");
	cnxadkeshibody=document.body;
	}	
	if ((cnxadkeshibody.clientWidth<=(parseInt(cnxad_width)+100))||(cnxadkeshibody.clientHeight<=(parseInt(cnxad_height)+100)))
	top.location=self.location; 
    }

function setCookie(name,value) {
    var mini = cnxad_t;
    if (mini>60){mini=1};
    var exp  = new Date();   
        exp.setTime(exp.getTime() + mini*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";
}

function ReadCookie(name) 
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}


if (cnxad_userid!='0')
{
 if ((ReadCookie("cnxad_popm") == "")||(ReadCookie("cnxad_popm") == null))
  {
	document.writeln("<script type='text/javascript' language='javascript' src=\"http:\/\/"+codedomain+"\/p1.ashx?w="+cnxad_userid+"&sid="+cnxad_subid+"&e="+cnxad_encode+"&furl="+cnxad_location+"&ffurl="+cnxad_from_url+"\"><\/script>");
	if (cnxad_t!="0"){setCookie("cnxad_popm","yes");}
  }
}
else
{alert('请将代码放入网页中观看效果');}
